* Use yytext instead of strres_text
* Get rid of lexer function strresGetErrorData and use strres_get_lineno() and strres_get_text() instead * Don't call abort() in function strres_error as the parser will return an error anyway (causing strresLoad to return false) git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5084 4a71c877-e1ca-e34f-864e-861f7616d084master
parent
fdc48bfc94
commit
dfaf3cea17
|
@ -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;
|
||||
|
|
|
@ -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()
|
|||
<QUOTE>\" { BEGIN 0; }
|
||||
<QUOTE>\n { strres_error("Unexpected end of line in string"); }
|
||||
<QUOTE>[^\"\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()
|
|||
<SLCOMMENT>[^\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)
|
||||
*/
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
%}
|
||||
|
@ -73,8 +70,4 @@ line: TEXT_T QTEXT_T
|
|||
YYABORT;
|
||||
}
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
%%
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue