mirror of
https://github.com/UberGames/ioef.git
synced 2025-01-19 15:40:52 +00:00
Bug 5075 - Fix comments in quake3 configs, patch by q3urt.undead@gmail.com
This commit is contained in:
parent
e6ba500164
commit
ac054c198d
1 changed files with 28 additions and 4 deletions
|
@ -176,6 +176,11 @@ void Cbuf_Execute (void)
|
||||||
char line[MAX_CMD_LINE];
|
char line[MAX_CMD_LINE];
|
||||||
int quotes;
|
int quotes;
|
||||||
|
|
||||||
|
// This will keep // style comments all on one line by not breaking on
|
||||||
|
// a semicolon. It will keep /* ... */ style comments all on one line by not
|
||||||
|
// breaking it for semicolon or newline.
|
||||||
|
qboolean in_star_comment = qfalse;
|
||||||
|
qboolean in_slash_comment = qfalse;
|
||||||
while (cmd_text.cursize)
|
while (cmd_text.cursize)
|
||||||
{
|
{
|
||||||
if ( cmd_wait > 0 ) {
|
if ( cmd_wait > 0 ) {
|
||||||
|
@ -185,7 +190,7 @@ void Cbuf_Execute (void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// find a \n or ; line break
|
// find a \n or ; line break or comment: // or /* */
|
||||||
text = (char *)cmd_text.data;
|
text = (char *)cmd_text.data;
|
||||||
|
|
||||||
quotes = 0;
|
quotes = 0;
|
||||||
|
@ -193,10 +198,29 @@ void Cbuf_Execute (void)
|
||||||
{
|
{
|
||||||
if (text[i] == '"')
|
if (text[i] == '"')
|
||||||
quotes++;
|
quotes++;
|
||||||
if ( !(quotes&1) && text[i] == ';')
|
|
||||||
break; // don't break if inside a quoted string
|
if ( !(quotes&1)) {
|
||||||
if (text[i] == '\n' || text[i] == '\r' )
|
if (i < cmd_text.cursize - 1) {
|
||||||
|
if (! in_star_comment && text[i] == '/' && text[i+1] == '/')
|
||||||
|
in_slash_comment = qtrue;
|
||||||
|
else if (! in_slash_comment && text[i] == '/' && text[i+1] == '*')
|
||||||
|
in_star_comment = qtrue;
|
||||||
|
else if (in_star_comment && text[i] == '*' && text[i+1] == '/') {
|
||||||
|
in_star_comment = qfalse;
|
||||||
|
// If we are in a star comment, then the part after it is valid
|
||||||
|
// Note: This will cause it to NUL out the terminating '/'
|
||||||
|
// but ExecuteString doesn't require it anyway.
|
||||||
|
i++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (! in_slash_comment && ! in_star_comment && text[i] == ';')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (! in_star_comment && (text[i] == '\n' || text[i] == '\r')) {
|
||||||
|
in_slash_comment = qfalse;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( i >= (MAX_CMD_LINE - 1)) {
|
if( i >= (MAX_CMD_LINE - 1)) {
|
||||||
|
|
Loading…
Reference in a new issue