diff --git a/lib/framework/strres.c b/lib/framework/strres.c index 281ce830c..f86194ba7 100644 --- a/lib/framework/strres.c +++ b/lib/framework/strres.c @@ -360,7 +360,7 @@ char *strresGetString(STR_RES *psRes, UDWORD id) /* Load a string resource file */ BOOL strresLoad(STR_RES* psRes, const char* fileName) { - bool retval = true; + bool retval; lexerinput_t input; input.type = LEXINPUT_PHYSFS; diff --git a/lib/framework/strres_lexer.l b/lib/framework/strres_lexer.l index 4edc19dab..7a7a49bce 100644 --- a/lib/framework/strres_lexer.l +++ b/lib/framework/strres_lexer.l @@ -86,7 +86,7 @@ char* yyget_text() /* Match text values */ [a-zA-Z][-0-9_a-zA-Z]* { - strlcpy(aText[currText], strres_text, sizeof(aText[currText])); + strlcpy(aText[currText], yytext, sizeof(aText[currText])); strres_lval.sval = aText[currText]; currText = (currText + 1) % TEXT_BUFFERS; return TEXT_T; @@ -97,7 +97,7 @@ char* yyget_text() \" { BEGIN 0; } \n { strres_error("Unexpected end of line in string"); } [^\"\n]* { - strlcpy(aText[currText], strres_text, sizeof(aText[currText])); + strlcpy(aText[currText], yytext, sizeof(aText[currText])); strres_lval.sval = aText[currText]; currText = (currText + 1) % TEXT_BUFFERS; return QTEXT_T; @@ -119,7 +119,7 @@ char* yyget_text() [^\n]* ; /* Match anything that's been missed and pass it as a char */ -. return strres_text[0]; +. return yytext[0]; %% @@ -135,12 +135,6 @@ YY_EXTRA_TYPE yyget_extra() return pBuffer; } -void strresGetErrorData(int *pLine, char **ppText) -{ - *pLine = strres_lineno; - *ppText = strres_text; -} - /* Older GNU Flex versions don't define yylex_destroy() * (and neither define a subminor version) */ diff --git a/lib/framework/strres_parser.y b/lib/framework/strres_parser.y index b8b65644a..8025100ef 100644 --- a/lib/framework/strres_parser.y +++ b/lib/framework/strres_parser.y @@ -27,16 +27,13 @@ #include "lib/framework/strres.h" #include "lib/framework/strresly.h" -extern int strres_lex (void); +extern int strres_lex(void); +extern int strres_get_lineno(void); +extern char* strres_get_text(void); void yyerror(const char* msg) { - int line; - char *pText; - - strresGetErrorData(&line, &pText); - debug(LOG_ERROR, "STRRES file parse error:\n%s at line %d\nText: '%s'", msg, line, pText); - abort(); + debug(LOG_ERROR, "STRRES file parse error:\n%s at line %d\nText: '%s'", msg, strres_get_lineno(), strres_get_text()); } %} @@ -58,23 +55,19 @@ file: line ; line: TEXT_T QTEXT_T - { - /* Pass the text string to the string manager */ - if (!strresStoreString(psCurrRes, $1, $2)) - { - YYABORT; - } - } + { + /* Pass the text string to the string manager */ + if (!strresStoreString(psCurrRes, $1, $2)) + { + YYABORT; + } + } | TEXT_T '_' '(' QTEXT_T ')' - { - /* Pass the text string to the string manager */ - if (!strresStoreString(psCurrRes, $1, gettext($4))) - { - YYABORT; - } - } - + { + /* Pass the text string to the string manager */ + if (!strresStoreString(psCurrRes, $1, gettext($4))) + { + YYABORT; + } + } ; - -%% - diff --git a/lib/framework/strresly.h b/lib/framework/strresly.h index 6c37fbf47..feba44c9b 100644 --- a/lib/framework/strresly.h +++ b/lib/framework/strresly.h @@ -34,9 +34,6 @@ extern STR_RES *psCurrRes; /* Set the current input buffer for the lexer - used by strresLoad */ extern void strres_set_extra(YY_EXTRA_TYPE user_defined); -/* Give access to the line number and current text for error messages */ -extern void strresGetErrorData(int *pLine, char **ppText); - /* Call the yacc parser */ extern int strres_parse(void);