summaryrefslogtreecommitdiff
path: root/src/qcommon/q_shared.c
diff options
context:
space:
mode:
authorZack Middleton <zturtleman@gmail.com>2013-06-02 21:21:45 -0500
committerTim Angus <tim@ngus.net>2014-06-17 17:43:32 +0100
commitf454aeaa8376d36e373eab69b877b67e8f9a661d (patch)
treec105fd39843ca04aba11c3f803dc0ddc844e324e /src/qcommon/q_shared.c
parentd23343534d84fba2f4c8733726a9772f75c0aa37 (diff)
Fix setting COM_Parse current line number
Fix initial off-by-one error. Count lines in /* */ comments and multi-line strings. Fix counting some lines twice if text has Unix newlines.
Diffstat (limited to 'src/qcommon/q_shared.c')
-rw-r--r--src/qcommon/q_shared.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/qcommon/q_shared.c b/src/qcommon/q_shared.c
index 897bdae4..9cea9bda 100644
--- a/src/qcommon/q_shared.c
+++ b/src/qcommon/q_shared.c
@@ -290,7 +290,7 @@ static int com_lines;
void COM_BeginParseSession( const char *name )
{
- com_lines = 0;
+ com_lines = 1;
Com_sprintf(com_parsename, sizeof(com_parsename), "%s", name);
}
@@ -474,6 +474,10 @@ char *COM_ParseExt( char **data_p, qboolean allowLineBreaks )
data += 2;
while ( *data && ( *data != '*' || data[1] != '/' ) )
{
+ if ( *data == '\n' )
+ {
+ com_lines++;
+ }
data++;
}
if ( *data )
@@ -500,6 +504,10 @@ char *COM_ParseExt( char **data_p, qboolean allowLineBreaks )
*data_p = ( char * ) data;
return com_token;
}
+ if ( c == '\n' )
+ {
+ com_lines++;
+ }
if (len < MAX_TOKEN_CHARS - 1)
{
com_token[len] = c;
@@ -518,8 +526,6 @@ char *COM_ParseExt( char **data_p, qboolean allowLineBreaks )
}
data++;
c = *data;
- if ( c == '\n' )
- com_lines++;
} while (c>32);
com_token[len] = 0;