dvidelabs / flatcc

FlatBuffers Compiler and Library in C for C
Apache License 2.0
631 stars 180 forks source link

parse fbs file failed when comment with utf8 characters >= 0x80 #283

Closed jerrrykong closed 1 month ago

jerrrykong commented 1 month ago

I debug the program flatcc. found in: external/lex/luthor.c

#ifndef lex_isctrl
#include <ctype.h>
#define lex_isctrl(c) ((c) < 0x20 || (unsigned char)(c) == 0x7f)
#endif

When the character c is utf8, it will be a negative number. This will result in being judged as a control character. Control characters are not allowed in the syntax, resulting in compilation failure.

Fix it:

#ifndef lex_isctrl
#include <ctype.h>
#define lex_isctrl(c) ((unsigned char)(c) < 0x20 || (unsigned char)(c) == 0x7f)
#endif
jerrrykong commented 1 month ago

I found that is fixed. ;)

mikkelfj commented 1 month ago

Yes, it should be fixed here: https://github.com/dvidelabs/flatcc/issues/267