From 762008f504791e19684c1fb8a09cc100a0b31978 Mon Sep 17 00:00:00 2001 From: Zack Middleton Date: Mon, 3 Jun 2013 22:35:57 -0500 Subject: 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. --- src/qcommon/q_shared.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/qcommon/q_shared.c b/src/qcommon/q_shared.c index ea365b55..e70cd398 100644 --- a/src/qcommon/q_shared.c +++ b/src/qcommon/q_shared.c @@ -287,15 +287,22 @@ PARSING static char com_token[MAX_TOKEN_CHARS]; static char com_parsename[MAX_TOKEN_CHARS]; static int com_lines; +static int com_tokenline; void COM_BeginParseSession( const char *name ) { com_lines = 1; + com_tokenline = 0; Com_sprintf(com_parsename, sizeof(com_parsename), "%s", name); } int COM_GetCurrentParseLine( void ) { + if ( com_tokenline ) + { + return com_tokenline; + } + return com_lines; } @@ -313,7 +320,7 @@ void COM_ParseError( char *format, ... ) Q_vsnprintf (string, sizeof(string), format, 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, ... ) @@ -325,7 +332,7 @@ void COM_ParseWarning( char *format, ... ) Q_vsnprintf (string, sizeof(string), format, 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); } /* @@ -435,6 +442,7 @@ char *COM_ParseExt( char **data_p, qboolean allowLineBreaks ) data = *data_p; len = 0; com_token[0] = 0; + com_tokenline = 0; // make sure incoming data is valid if ( !data ) @@ -491,6 +499,9 @@ char *COM_ParseExt( char **data_p, qboolean allowLineBreaks ) } } + // token starts on this line + com_tokenline = com_lines; + // handle quoted strings if (c == '\"') { -- cgit