Fix crash of bgLex on linux. No idea why this worked on Windows it should have crashed as well.

This commit is contained in:
Walter Hennecke 2013-10-10 23:36:08 +02:00
parent aee36d9ad1
commit 216a871ff8
3 changed files with 11 additions and 1653 deletions

View file

@ -95,6 +95,7 @@ typedef enum {
} bgLexSymbol;
typedef enum {
LMT_EOF,
LMT_STRING = 1,
LMT_INT,
LMT_DOUBLE,
@ -135,4 +136,4 @@ int bgLex_lex(bgLex* lex);
bgLexSymbol bgLex_textToSymbol(char* text);
void bgLexFatalError(const char* msg, void* lex);
#endif /* BG_LEX_H */
#endif /* BG_LEX_H */

View file

@ -706,6 +706,10 @@ KEYWORD [a-zA-Z]+[a-zA-Z0-9]*
yyextra->type = LMT_IGNORE;
return LMT_IGNORE;
}
<<EOF>> {
yyextra->type = LMT_EOF;
return LMT_EOF;
}
. {
yyextra->column++;
yyextra->type = LMT_IGNORE;
@ -737,6 +741,10 @@ int main(int argc, char* argv[]) {
bgLex* bgLex_create(char* data) {
bgLex* l = malloc(sizeof(bgLex));
/* HACK: prevent compiler warnings */
UNUSED(yyunput);
UNUSED(input);
if(l != NULL) {
l->morphem.line = 0;
l->morphem.column = 0;
@ -767,10 +775,6 @@ void bgLex_destroy(bgLex* lex) {
int bgLex_lex(bgLex* lex) {
int res;
if(lex->morphem.data.str != NULL) {
free(lex->morphem.data.str);
}
/* skip LMT_IGNORE */
while(1) {
res = yylex(lex->lex);
@ -884,7 +888,7 @@ bgLexSymbol bgLex_textToSymbol(char* text) {
}
if(strcmp("WP_COFFEE", text) == 0) {
return LSYM_WP_COFFEE;
return LSYM_WP_COFFEE;
}
if(strcmp("WP_PHASER", text) == 0) {

File diff suppressed because it is too large Load diff