mirror of
https://github.com/libretro/libretro-prboom.git
synced 2024-11-23 16:09:41 +00:00
Show name on scanner errors for context
This commit is contained in:
parent
80ac8aa94d
commit
25f0f7b278
@ -332,7 +332,7 @@ static int ParseMapEntry(u_scanner_t *s, mapentry_t *val)
|
||||
int U_ParseMapInfo(const char *buffer, size_t length)
|
||||
{
|
||||
unsigned int i;
|
||||
u_scanner_t scanner = U_ScanOpen(buffer, length);
|
||||
u_scanner_t scanner = U_ScanOpen(buffer, length, "UMAPINFO");
|
||||
|
||||
while (U_HasTokensLeft(&scanner))
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ void U_ParseMusInfo(const char *mapid)
|
||||
int lumpnum;
|
||||
int inMap = false;
|
||||
|
||||
u_scanner_t s = U_ScanOpen(data, datalength);
|
||||
u_scanner_t s = U_ScanOpen(data, datalength, "MUSINFO");
|
||||
while (U_HasTokensLeft(&s))
|
||||
{
|
||||
if (inMap || U_CheckToken(&s, TK_Identifier))
|
||||
|
@ -54,7 +54,7 @@ void U_ExpandState(u_scanner_t* scanner);
|
||||
void U_Unescape(char *str);
|
||||
void U_SetString(char **ptr, const char *start, int length);
|
||||
|
||||
u_scanner_t U_ScanOpen(const char* data, int length)
|
||||
u_scanner_t U_ScanOpen(const char* data, int length, const char* name)
|
||||
{
|
||||
u_scanner_t scanner;
|
||||
scanner.lineStart = scanner.logicalPosition = scanner.scanPos = scanner.tokenLinePosition = 0;
|
||||
@ -62,6 +62,7 @@ u_scanner_t U_ScanOpen(const char* data, int length)
|
||||
scanner.needNext = TRUE;
|
||||
scanner.string = NULL;
|
||||
scanner.nextState.string = NULL;
|
||||
scanner.name = name;
|
||||
|
||||
if(length == -1)
|
||||
length = strlen(data);
|
||||
@ -470,7 +471,7 @@ void U_Error(u_scanner_t* s, const char *msg, ...)
|
||||
va_start(ap, msg);
|
||||
vsnprintf(buffer, 1024, msg, ap);
|
||||
va_end(ap);
|
||||
I_Error("%d:%d:%s.", s->tokenLine, s->tokenLinePosition, buffer);
|
||||
I_Error("%s:%d:%d:%s.", s->name, s->tokenLine, s->tokenLinePosition, buffer);
|
||||
}
|
||||
|
||||
boolean U_MustGetToken(u_scanner_t* s, char token)
|
||||
|
@ -63,6 +63,8 @@ typedef struct
|
||||
|
||||
typedef struct
|
||||
{
|
||||
const char* name;
|
||||
|
||||
u_parserstate_t nextState;
|
||||
|
||||
char* data;
|
||||
@ -86,7 +88,7 @@ typedef struct
|
||||
} u_scanner_t;
|
||||
|
||||
|
||||
u_scanner_t U_ScanOpen(const char* data, int length);
|
||||
u_scanner_t U_ScanOpen(const char* data, int length, const char *name);
|
||||
void U_ScanClose(u_scanner_t* scanner);
|
||||
boolean U_GetNextToken(u_scanner_t* scanner, boolean expandState);
|
||||
boolean U_HasTokensLeft(u_scanner_t* scanner);
|
||||
|
Loading…
Reference in New Issue
Block a user