Skip to content
Myr

sprintf warnings

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 · parent 498bd3e · Browse files · 2 files+5 added−5 removed
This commit

State

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

Diff stats

2 files+5 added−5 removed

  • tests:+4 added−4 removed
  • other:+1 added−1 removed

2 files+5 added−5 removed

modified:tests/test_sprintf.c+4 added-4 removed
109 unmodified lines
110111#if __STDC_VERSION__ >= 199901L112#if USE_STB113 CHECK4("Inf Inf NaN", "%g %G %f", INFINITY, INFINITY, NAN);114 CHECK1("N", "%.1g", NAN);114 CHECK2("N", "%.1g", NAN);115#else116 CHECK4("inf INF nan", "%g %G %f", INFINITY, INFINITY, NAN);117 CHECK1("nan", "%.1g", NAN);117 CHECK2("nan", "%.1g", NAN);118#endif119#endif120121 // %n
27 unmodified lines
149 assert(SNPRINTF(buf, 100, "%f", pow_2_75) == 30);150 assert(strncmp(buf, "37778931862957161709568.000000", 17) == 0);151 n = SNPRINTF(buf, 10, "number %f", 123.456789);152 assert(strcmp(buf, "number 12") == 0);153 assert(n == (USE_STB ? 9 : 17)); // written vs would-be written bytes153 assert(n == 17); // written vs would-be written bytes154 n = SNPRINTF(buf, 0, "7 chars");155 assert(n == (USE_STB ? 0 : 7));155 assert(n == 7);156 // stb_sprintf uses internal buffer of 512 chars - test longer string157 assert(SPRINTF(buf, "%d %600s", 3, "abc") == 603);158 assert(strlen(buf) == 603);159 SNPRINTF(buf, 550, "%d %600s", 3, "abc");
44 unmodified lines
modified:stb_sprintf.h+1 added-1 removed
180 unmodified lines
181182#ifndef STB_SPRINTF_MIN183#define STB_SPRINTF_MIN 512 // how many characters per callback184#endif185typedef char *STBSP_SPRINTFCB(char *buf, void *user, int len);185typedef char *STBSP_SPRINTFCB(const char *buf, void *user, int len);186187#ifndef STB_SPRINTF_DECORATE188#define STB_SPRINTF_DECORATE(name) stbsp_##name // define this before including if you want to change the names189#endif
1688 unmodified lines