* Get rid of global variable *psCurrRes, which is used by the strres_parser to operate on

* Instead pass the current STR_RES* pointer to work on to the parser function

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5654 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2008-07-24 14:16:27 +00:00
parent d9baa8d8b7
commit e8efe132f8
3 changed files with 8 additions and 12 deletions

View File

@ -68,9 +68,6 @@ typedef struct STR_RES
/* Static forward declarations */ /* Static forward declarations */
static void strresReleaseIDStrings(STR_RES *psRes); static void strresReleaseIDStrings(STR_RES *psRes);
/* The string resource currently being loaded */
STR_RES *psCurrRes;
/* Allocate a string block */ /* Allocate a string block */
static STR_BLOCK* strresAllocBlock(const size_t size) static STR_BLOCK* strresAllocBlock(const size_t size)
{ {
@ -380,11 +377,8 @@ BOOL strresLoad(STR_RES* psRes, const char* fileName)
return false; return false;
} }
// Set string resource to operate on
psCurrRes = psRes;
strres_set_extra(&input); strres_set_extra(&input);
retval = (strres_parse() == 0); retval = (strres_parse(psRes) == 0);
strres_lex_destroy(); strres_lex_destroy();
PHYSFS_close(input.input.physfsfile); PHYSFS_close(input.input.physfsfile);

View File

@ -36,6 +36,11 @@ void yyerror(const char* msg)
debug(LOG_ERROR, "STRRES file parse error:\n%s at line %d\nText: '%s'", msg, strres_get_lineno(), strres_get_text()); debug(LOG_ERROR, "STRRES file parse error:\n%s at line %d\nText: '%s'", msg, strres_get_lineno(), strres_get_text());
} }
// Forward declaration to allow pointers to this type
struct STR_RES;
#define YYPARSE_PARAM psStrRes
%} %}
%name-prefix="strres_" %name-prefix="strres_"
@ -70,7 +75,7 @@ file: line
line: TEXT_T string line: TEXT_T string
{ {
/* Pass the text string to the string manager */ /* Pass the text string to the string manager */
const bool success = strresStoreString(psCurrRes, $1, $2); const bool success = strresStoreString((struct STR_RES*)psStrRes, $1, $2);
// Clean up our tokens // Clean up our tokens
free($1); free($1);

View File

@ -25,14 +25,11 @@
#include "lib/framework/lexer_input.h" #include "lib/framework/lexer_input.h"
/* The string resource currently being loaded */
extern struct STR_RES* psCurrRes;
/* Set the current input buffer for the lexer - used by strresLoad */ /* Set the current input buffer for the lexer - used by strresLoad */
extern void strres_set_extra(YY_EXTRA_TYPE user_defined); extern void strres_set_extra(YY_EXTRA_TYPE user_defined);
/* Call the yacc parser */ /* Call the yacc parser */
extern int strres_parse(void); extern int strres_parse(void* psStrRes);
/* Destroy the lexer */ /* Destroy the lexer */
extern int strres_lex_destroy(void); extern int strres_lex_destroy(void);