stb_c_lexer.h: Compile fixes when not using CRT
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Alan Hickman · committed by fahickman · parent e713a69 · Browse files · 1 file·+9 added−8 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+9 added−8 removed
- other:+9 added−8 removed
Provenance
- Commit
c6b6239- Tree
748355c- Author
Alan Hickman <f.alan.hickman@gmail.com>- Committer
fahickman <f.alan.hickman@gmail.com>- Parent
e713a69
1 file changed+9 added−8 removed
modified:stb_c_lexer.h+9 added-8 removed
371 unmodified lines372 if (*p == '.') {373 double powten=1, addend = 0;374 ++p;375 while (*p >= '0' && *p <= '9') {376- addend = addend + 10*(*p++ - '0');376+ addend = addend*10 + (*p++ - '0');377 powten *= 10;378 }379 value += addend / powten;380 }267 unmodified lines648 else649 break;650 ++q;651 }652- lexer->int_field = n; // int_field is macro that expands to real_number/int_number depending on type of n652+ lexer->int_number = n;653 #endif654 if (q == p+2)655 return stb__clex_token(lexer, CLEX_parse_error, p-2,p-1);656 return stb__clex_parse_suffixes(lexer, CLEX_intlit, p,q, STB_C_LEX_HEX_SUFFIXES);34 unmodified lines691 #else692 stb__clex_int n=0;693 while (q != lexer->eof) {694 if (*q >= '0' && *q <= '7')695- n = n*8 + (q - '0');695+ n = n*8 + (*q - '0');696 else697 break;698 ++q;699 }700 if (q != lexer->eof && (*q == '8' || *q=='9'))701- return stb__clex_token(tok, CLEX_parse_error, p, q);702- lexer->int_field = n;701+ return stb__clex_token(lexer, CLEX_parse_error, p, q);702+ lexer->int_number = n;703 #endif704 return stb__clex_parse_suffixes(lexer, CLEX_intlit, p,q, STB_C_LEX_OCTAL_SUFFIXES);705 }706 #endif // STB__clex_octal_ints6 unmodified lines713 #else714 stb__clex_int n=0;715 while (q != lexer->eof) {716 if (*q >= '0' && *q <= '9')717- n = n*10 + (q - '0');717+ n = n*10 + (*q - '0');718 else719 break;720 ++q;721 }722- lexer->int_field = n;722+ lexer->int_number = n;723 #endif724 return stb__clex_parse_suffixes(lexer, CLEX_intlit, p,q, STB_C_LEX_OCTAL_SUFFIXES);725 }726 #endif // STB__clex_decimal_ints4 unmodified lines731 732 #ifdef STB_C_LEXER_SELF_TEST733 734 #include <stdio.h>735+#include <stdlib.h>736 737 static void print_token(stb_lexer *lexer)738 {739 switch (lexer->token) {47 unmodified lines787 /**/ extern /**/788 789 void dummy(void)790 {790- printf("test",1); // https://github.com/nothings/stb/issues/13791+ printf("test %d",1); // https://github.com/nothings/stb/issues/13792 }793 794 int main(int argc, char **argv)795 {22 unmodified lines