mirror of
https://github.com/UberGames/rpgxEF.git
synced 2024-11-14 00:40:34 +00:00
Changed morphem string data to a fixed size of 1024.
This commit is contained in:
parent
9a7adfab67
commit
b2250734e0
2 changed files with 13 additions and 10 deletions
|
@ -96,12 +96,13 @@ typedef enum {
|
|||
LMT_VECTOR3,
|
||||
LMT_VECTOR4,
|
||||
LMT_SYMBOL,
|
||||
LMT_IGNORE
|
||||
LMT_IGNORE,
|
||||
LMT_STRERROR
|
||||
} bgLexMorphemType;
|
||||
|
||||
typedef struct bgLexMorphemData_s bgLexMorphemData;
|
||||
struct bgLexMorphemData_s {
|
||||
char* str;
|
||||
char str[1024];
|
||||
bgLexSymbol symbol;
|
||||
int numInteger;
|
||||
double numDouble;
|
||||
|
@ -130,4 +131,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 */
|
||||
|
|
|
@ -19,9 +19,11 @@ KEYWORD [a-zA-Z]+[a-zA-Z0-9]*
|
|||
\"[^\"]*\" {
|
||||
char *s = yytext; s++;
|
||||
yyextra->type = LMT_STRING;
|
||||
yyextra->data.str = malloc(strlen(yytext) - 1);
|
||||
memset(yyextra->data.str, 0, strlen(yytext) - 1);
|
||||
strncpy(yyextra->data.str, s, strlen(yytext) - 2);
|
||||
if(strlen(yytext) > 1023) {
|
||||
return LMT_STRERROR;
|
||||
}
|
||||
memset(yyextra->data.str, 0, 1024);
|
||||
strcpy(yyextra->data.str, yytext);
|
||||
yyextra->column += strlen(yytext);
|
||||
return LMT_STRING;
|
||||
}
|
||||
|
@ -782,10 +784,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);
|
||||
|
@ -794,6 +792,10 @@ int bgLex_lex(bgLex* lex) {
|
|||
}
|
||||
}
|
||||
|
||||
if(res != LMT_STRING) {
|
||||
memset(lex->morphem->data.str, 0, 1024);
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue