Make COM_ParseWarning report starting line number of multi-line tokens

COM_ParseWarning use to show last line number of multi-line string tokens, now shows starting line number.
This commit is contained in:
Zack Middleton 2013-06-03 22:35:57 -05:00
parent d4f785c465
commit 1315d62491

View file

@ -286,15 +286,22 @@ PARSING
static char com_token[MAX_TOKEN_CHARS]; static char com_token[MAX_TOKEN_CHARS];
static char com_parsename[MAX_TOKEN_CHARS]; static char com_parsename[MAX_TOKEN_CHARS];
static int com_lines; static int com_lines;
static int com_tokenline;
void COM_BeginParseSession( const char *name ) void COM_BeginParseSession( const char *name )
{ {
com_lines = 1; com_lines = 1;
com_tokenline = 0;
Com_sprintf(com_parsename, sizeof(com_parsename), "%s", name); Com_sprintf(com_parsename, sizeof(com_parsename), "%s", name);
} }
int COM_GetCurrentParseLine( void ) int COM_GetCurrentParseLine( void )
{ {
if ( com_tokenline )
{
return com_tokenline;
}
return com_lines; return com_lines;
} }
@ -312,7 +319,7 @@ void COM_ParseError( char *format, ... )
Q_vsnprintf (string, sizeof(string), format, argptr); Q_vsnprintf (string, sizeof(string), format, argptr);
va_end (argptr); va_end (argptr);
Com_Printf("ERROR: %s, line %d: %s\n", com_parsename, com_lines, string); Com_Printf("ERROR: %s, line %d: %s\n", com_parsename, COM_GetCurrentParseLine(), string);
} }
void COM_ParseWarning( char *format, ... ) void COM_ParseWarning( char *format, ... )
@ -324,7 +331,7 @@ void COM_ParseWarning( char *format, ... )
Q_vsnprintf (string, sizeof(string), format, argptr); Q_vsnprintf (string, sizeof(string), format, argptr);
va_end (argptr); va_end (argptr);
Com_Printf("WARNING: %s, line %d: %s\n", com_parsename, com_lines, string); Com_Printf("WARNING: %s, line %d: %s\n", com_parsename, COM_GetCurrentParseLine(), string);
} }
/* /*
@ -434,6 +441,7 @@ char *COM_ParseExt( char **data_p, qboolean allowLineBreaks )
data = *data_p; data = *data_p;
len = 0; len = 0;
com_token[0] = 0; com_token[0] = 0;
com_tokenline = 0;
// make sure incoming data is valid // make sure incoming data is valid
if ( !data ) if ( !data )
@ -490,6 +498,9 @@ char *COM_ParseExt( char **data_p, qboolean allowLineBreaks )
} }
} }
// token starts on this line
com_tokenline = com_lines;
// handle quoted strings // handle quoted strings
if (c == '\"') if (c == '\"')
{ {