mirror of
https://github.com/ioquake/ioq3.git
synced 2024-11-10 07:11:46 +00:00
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.
This commit is contained in:
parent
6c4d010f29
commit
c0a21d0898
1 changed files with 9 additions and 3 deletions
|
@ -289,7 +289,7 @@ static int com_lines;
|
||||||
|
|
||||||
void COM_BeginParseSession( const char *name )
|
void COM_BeginParseSession( const char *name )
|
||||||
{
|
{
|
||||||
com_lines = 0;
|
com_lines = 1;
|
||||||
Com_sprintf(com_parsename, sizeof(com_parsename), "%s", name);
|
Com_sprintf(com_parsename, sizeof(com_parsename), "%s", name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -473,6 +473,10 @@ char *COM_ParseExt( char **data_p, qboolean allowLineBreaks )
|
||||||
data += 2;
|
data += 2;
|
||||||
while ( *data && ( *data != '*' || data[1] != '/' ) )
|
while ( *data && ( *data != '*' || data[1] != '/' ) )
|
||||||
{
|
{
|
||||||
|
if ( *data == '\n' )
|
||||||
|
{
|
||||||
|
com_lines++;
|
||||||
|
}
|
||||||
data++;
|
data++;
|
||||||
}
|
}
|
||||||
if ( *data )
|
if ( *data )
|
||||||
|
@ -499,6 +503,10 @@ char *COM_ParseExt( char **data_p, qboolean allowLineBreaks )
|
||||||
*data_p = ( char * ) data;
|
*data_p = ( char * ) data;
|
||||||
return com_token;
|
return com_token;
|
||||||
}
|
}
|
||||||
|
if ( c == '\n' )
|
||||||
|
{
|
||||||
|
com_lines++;
|
||||||
|
}
|
||||||
if (len < MAX_TOKEN_CHARS - 1)
|
if (len < MAX_TOKEN_CHARS - 1)
|
||||||
{
|
{
|
||||||
com_token[len] = c;
|
com_token[len] = c;
|
||||||
|
@ -517,8 +525,6 @@ char *COM_ParseExt( char **data_p, qboolean allowLineBreaks )
|
||||||
}
|
}
|
||||||
data++;
|
data++;
|
||||||
c = *data;
|
c = *data;
|
||||||
if ( c == '\n' )
|
|
||||||
com_lines++;
|
|
||||||
} while (c>32);
|
} while (c>32);
|
||||||
|
|
||||||
com_token[len] = 0;
|
com_token[len] = 0;
|
||||||
|
|
Loading…
Reference in a new issue