dvidelabs / flatcc

FlatBuffers Compiler and Library in C for C
Apache License 2.0
653 stars 189 forks source link

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

Closed jerrrykong closed 6 months ago

jerrrykong commented 6 months 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 6 months ago

I found that is fixed. ;)

mikkelfj commented 6 months ago

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