diff options
author | Zack Middleton <zturtleman@gmail.com> | 2013-06-03 22:35:57 -0500 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2014-06-17 17:43:32 +0100 |
commit | 762008f504791e19684c1fb8a09cc100a0b31978 (patch) | |
tree | 436b9018fe210cd4de176a0cde2219f0ff2a9c76 /src/qcommon/q_shared.c | |
parent | f2566c01933d14fee5c2c252e7c47b993e79b81c (diff) |
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.
Diffstat (limited to 'src/qcommon/q_shared.c')
-rw-r--r-- | src/qcommon/q_shared.c | 15 |
1 files 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 == '\"') { |