Skip to content
Myr

fix bug in string parsing that was ignoring next character after the string

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 44c37c5 · Browse files · 1 file+16 added−14 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−14 removed

  • other:+16 added−14 removed

1 file+16 added−14 removed

modified:stb_c_lexer.h+16 added-14 removed
1// stb_c_lexer.h - v0.05 - public domain Sean Barrett 20131// stb_c_lexer.h - v0.06 - public domain Sean Barrett 20132// lexer for making little C-like languages with recursive-descent parsers3//4// This file provides both the interface and the implementation.5// To instantiate the implementation,
3 unmodified lines
9// The default configuration is fairly close to a C lexer, although10// suffixes on integer constants are not handled (you can override this).11//12// History:13// 0.0514// refixed get_location because github version had lost the fix15// 0.0416// fix octal parsing bug17// 0.0318// added STB_C_LEX_DISCARD_PREPROCESSOR option19// refactor API to simplify (only one struct instead of two)20// change literal enum names to have 'lit' at the end21// 0.0222// first public release13// 0.06 fix missing next character after ending quote mark (Andreas Fredriksson)14// 0.05 refixed get_location because github version had lost the fix15// 0.04 fix octal parsing bug16// 0.03 added STB_C_LEX_DISCARD_PREPROCESSOR option17// refactor API to simplify (only one struct instead of two)18// change literal enum names to have 'lit' at the end19// 0.02 first public release20//21// Status:22// - haven't tested compiling as C++23// - haven't tested the float parsing path
131 unmodified lines
155156#ifdef STB_C_LEXER_IMPLEMENTATION157158 #if defined(Y) || defined(N)162 #error "Can only use stb_c_lex in contexts where the preprocessor symbols 'Y' and 'N' are not defined"159 #error "Can only use stb_c_lexer in contexts where the preprocessor symbols 'Y' and 'N' are not defined"160 #endif161162163// Hacky definitions so we can easily #if on them
273 unmodified lines
437 }438 *out = 0;439 lexer->string = lexer->string_storage;440 lexer->string_len = out - lexer->string_storage;444 return stb__clex_token(lexer, type, start, p+1);441 return stb__clex_token(lexer, type, start, p);442}443444int stb_c_lexer_get_token(stb_lexer *lexer)445{
331 unmodified lines
777778/*/ comment /*/779/**/ extern /**/780781void dummy(void)782{783 printf("test",1); // https://github.com/nothings/stb/issues/13784}785786int main(int argc, char **argv)787{786 FILE *f = fopen("stb_c_lexer.h", "rb");788 FILE *f = fopen("stb_c_lexer.h","rb");789 char *text = (char *) malloc(1 << 20);790 int len = f ? fread(text, 1, 1<<20, f) : -1;791 stb_lexer lex;792 if (len < 0) {
17 unmodified lines