Skip to content
Myr

Merge branch 'lead_sign' of https://github.com/rohit-n/stb into working

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Sean Barrett · committed by Sean Barrett · parents 324be64, 13927ac · Browse files · 1 file+16 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+16 added−7 removed

  • other:+16 added−7 removed

1 file+16 added−7 removed

modified:stb_sprintf.h+16 added-7 removed
257 unmodified lines
258 #define stbsp__chk_cb_bufL(bytes) { int len = (int)(bf-buf); if ((len+(bytes))>=STB_SPRINTF_MIN) { tlen+=len; if (0==(bf=buf=callback(buf,user,len))) goto done; } }259 #define stbsp__chk_cb_buf(bytes) { if ( callback ) { stbsp__chk_cb_bufL(bytes); } }260 #define stbsp__flush_cb() { stbsp__chk_cb_bufL(STB_SPRINTF_MIN-1); } //flush if there is even one byte in the buffer261 #define stbsp__cb_buf_clamp(cl,v) cl = v; if ( callback ) { int lg = STB_SPRINTF_MIN-(int)(bf-buf); if (cl>lg) cl=lg; }262 #define stbsp__lead_sign(fl, lead) \263 lead[0] = 0;\264 if (fl&STBSP__NEGATIVE) {\265 lead[0]=1;\266 lead[1]='-';\267 } else if (fl&STBSP__LEADINGSPACE) {\268 lead[0]=1;\269 lead[1]=' ';\270 } else if (fl&STBSP__LEADINGPLUS) {\271 lead[0]=1;\272 lead[1]='+';\273 }274275 // fast copy everything up to the next % (or end of string)276 for(;;)277 {
174 unmodified lines
452 fl |= STBSP__NEGATIVE;453 454 s = num+64;455444 // sign445 lead[0]=0; if (fl&STBSP__NEGATIVE) { lead[0]=1; lead[1]='-'; } else if (fl&STBSP__LEADINGSPACE) { lead[0]=1; lead[1]=' '; } else if (fl&STBSP__LEADINGPLUS) { lead[0]=1; lead[1]='+'; };456 stbsp__lead_sign(fl, lead);457458 if (dp==-1023) dp=(n64)?-1022:0; else n64|=(((stbsp__uint64)1)<<52);459 n64<<=(64-56);460 if (pr<15) n64+=((((stbsp__uint64)8)<<56)>>(pr*4));
65 unmodified lines
526 if ( stbsp__real_to_str( &sn, &l, num, &dp, fv, pr|0x80000000 ) )527 fl |= STBSP__NEGATIVE;528 doexpfromg: 529 tail[0]=0; 519 lead[0]=0; if (fl&STBSP__NEGATIVE) { lead[0]=1; lead[1]='-'; } else if (fl&STBSP__LEADINGSPACE) { lead[0]=1; lead[1]=' '; } else if (fl&STBSP__LEADINGPLUS) { lead[0]=1; lead[1]='+'; };530 stbsp__lead_sign(fl, lead);531 if ( dp == STBSP__SPECIAL ) { s=(char*)sn; cs=0; pr=0; goto scopy; }532 s=num+64; 533 // handle leading chars534 *s++=sn[0];
35 unmodified lines
570 if ( stbsp__real_to_str( &sn, &l, num, &dp, fv, pr ) )571 fl |= STBSP__NEGATIVE;572 dofloatfromg:573 tail[0]=0;563 // sign564 lead[0]=0; if (fl&STBSP__NEGATIVE) { lead[0]=1; lead[1]='-'; } else if (fl&STBSP__LEADINGSPACE) { lead[0]=1; lead[1]=' '; } else if (fl&STBSP__LEADINGPLUS) { lead[0]=1; lead[1]='+'; };574 stbsp__lead_sign(fl, lead);575 if ( dp == STBSP__SPECIAL ) { s=(char*)sn; cs=0; pr=0; goto scopy; }576 s=num+64; 577578 // handle the three decimal varieties
155 unmodified lines
734 while (s!=o) if ( ( fl&STBSP__TRIPLET_COMMA) && (l++==3) ) { l=0; *--s=stbsp__comma; --o; } else { *--s='0'; }735 }736737 tail[0]=0;728 // sign729 lead[0]=0; if (fl&STBSP__NEGATIVE) { lead[0]=1; lead[1]='-'; } else if (fl&STBSP__LEADINGSPACE) { lead[0]=1; lead[1]=' '; } else if (fl&STBSP__LEADINGPLUS) { lead[0]=1; lead[1]='+'; };738 stbsp__lead_sign(fl, lead);739740 // get the length that we copied741 l = (stbsp__uint32) ( (num+STBSP__NUMSZ) - s ); if ( l == 0 ) { *--s='0'; l = 1; }742 cs = l + (3<<24);
457 unmodified lines