fix quoted strings when EOF is reached before the closing '\"' and

support for C-style /*..*/ comments in COM_Parse(). some whitespace
tidy-up.

git-svn-id: svn+ssh://svn.code.sf.net/p/quakespasm/code/trunk@795 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
sezero 2013-01-16 19:02:23 +00:00
parent ab2e7e16af
commit 73c85d3b38
2 changed files with 39 additions and 29 deletions

View file

@ -876,15 +876,16 @@ void SZ_Write (sizebuf_t *buf, const void *data, int length)
void SZ_Print (sizebuf_t *buf, const char *data)
{
int len;
int len = Q_strlen(data) + 1;
len = Q_strlen(data) + 1;
// byte * cast to keep VC++ happy
if (buf->data[buf->cursize-1])
Q_memcpy ((byte *)SZ_GetSpace(buf, len),data,len); // no trailing 0
{ /* no trailing 0 */
Q_memcpy ((byte *)SZ_GetSpace(buf, len ) , data, len);
}
else
Q_memcpy ((byte *)SZ_GetSpace(buf, len-1)-1,data,len); // write over trailing 0
{ /* write over trailing 0 */
Q_memcpy ((byte *)SZ_GetSpace(buf, len-1)-1, data, len);
}
}
@ -1062,7 +1063,7 @@ skipwhite:
while ((c = *data) <= ' ')
{
if (c == 0)
return NULL; // end of file;
return NULL; // end of file
data++;
}
@ -1074,6 +1075,16 @@ skipwhite:
goto skipwhite;
}
// skip /*..*/ comments
if (c == '/' && data[1] == '*')
{
data += 2;
while (*data && !(*data == '*' && data[1] == '/'))
data++;
if (*data)
data += 2;
goto skipwhite;
}
// handle quoted strings specially
if (c == '\"')
@ -1081,7 +1092,8 @@ skipwhite:
data++;
while (1)
{
c = *data++;
if ((c = *data) != 0)
++data;
if (c == '\"' || !c)
{
com_token[len] = 0;
@ -1093,7 +1105,7 @@ skipwhite:
}
// parse single characters
if (c=='{' || c=='}'|| c==')'|| c=='(' || c=='\'' || c==':')
if (c == '{' || c == '}'|| c == '('|| c == ')' || c == '\'' || c == ':')
{
com_token[len] = c;
len++;
@ -1109,7 +1121,7 @@ skipwhite:
len++;
c = *data;
/* commented out the check for ':' so that ip:port works */
if (c == '{' || c == '}'|| c == ')'|| c == '(' || c == '\'' /* || c == ':' */)
if (c == '{' || c == '}'|| c == '('|| c == ')' || c == '\''/* || c == ':' */)
break;
} while (c > 32);

View file

@ -443,7 +443,6 @@ static void Con_Print (const char *txt)
cr = false;
}
if (!con_x)
{
Con_Linefeed ();
@ -471,7 +470,6 @@ static void Con_Print (const char *txt)
con_x = 0;
break;
}
}
}