mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2025-02-14 16:01:44 +00:00
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: http://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@795 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
b6b05dba3d
commit
4fed8b4dc8
2 changed files with 39 additions and 29 deletions
|
@ -718,7 +718,7 @@ int MSG_ReadShort (void)
|
|||
}
|
||||
|
||||
c = (short)(net_message.data[msg_readcount]
|
||||
+ (net_message.data[msg_readcount+1]<<8));
|
||||
+ (net_message.data[msg_readcount+1]<<8));
|
||||
|
||||
msg_readcount += 2;
|
||||
|
||||
|
@ -736,9 +736,9 @@ int MSG_ReadLong (void)
|
|||
}
|
||||
|
||||
c = net_message.data[msg_readcount]
|
||||
+ (net_message.data[msg_readcount+1]<<8)
|
||||
+ (net_message.data[msg_readcount+2]<<16)
|
||||
+ (net_message.data[msg_readcount+3]<<24);
|
||||
+ (net_message.data[msg_readcount+1]<<8)
|
||||
+ (net_message.data[msg_readcount+2]<<16)
|
||||
+ (net_message.data[msg_readcount+3]<<24);
|
||||
|
||||
msg_readcount += 4;
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1059,21 +1060,31 @@ const char *COM_Parse (const char *data)
|
|||
|
||||
// skip whitespace
|
||||
skipwhite:
|
||||
while ( (c = *data) <= ' ')
|
||||
while ((c = *data) <= ' ')
|
||||
{
|
||||
if (c == 0)
|
||||
return NULL; // end of file;
|
||||
return NULL; // end of file
|
||||
data++;
|
||||
}
|
||||
|
||||
// skip // comments
|
||||
if (c=='/' && data[1] == '/')
|
||||
if (c == '/' && data[1] == '/')
|
||||
{
|
||||
while (*data && *data != '\n')
|
||||
data++;
|
||||
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,8 +1092,9 @@ skipwhite:
|
|||
data++;
|
||||
while (1)
|
||||
{
|
||||
c = *data++;
|
||||
if (c=='\"' || !c)
|
||||
if ((c = *data) != 0)
|
||||
++data;
|
||||
if (c == '\"' || !c)
|
||||
{
|
||||
com_token[len] = 0;
|
||||
return data;
|
||||
|
@ -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);
|
||||
|
||||
|
|
|
@ -189,10 +189,10 @@ static void Con_Dump_f (void)
|
|||
}
|
||||
|
||||
// skip initial empty lines
|
||||
for (l = con_current - con_totallines + 1 ; l <= con_current ; l++)
|
||||
for (l = con_current - con_totallines + 1; l <= con_current; l++)
|
||||
{
|
||||
line = con_text + (l%con_totallines)*con_linewidth;
|
||||
for (x=0 ; x<con_linewidth ; x++)
|
||||
line = con_text + (l % con_totallines)*con_linewidth;
|
||||
for (x = 0; x < con_linewidth; x++)
|
||||
if (line[x] != ' ')
|
||||
break;
|
||||
if (x != con_linewidth)
|
||||
|
@ -201,18 +201,18 @@ static void Con_Dump_f (void)
|
|||
|
||||
// write the remaining lines
|
||||
buffer[con_linewidth] = 0;
|
||||
for ( ; l <= con_current ; l++)
|
||||
for ( ; l <= con_current; l++)
|
||||
{
|
||||
line = con_text + (l%con_totallines)*con_linewidth;
|
||||
strncpy (buffer, line, con_linewidth);
|
||||
for (x=con_linewidth-1 ; x>=0 ; x--)
|
||||
for (x = con_linewidth - 1; x >= 0; x--)
|
||||
{
|
||||
if (buffer[x] == ' ')
|
||||
buffer[x] = 0;
|
||||
else
|
||||
break;
|
||||
}
|
||||
for (x=0; buffer[x]; x++)
|
||||
for (x = 0; buffer[x]; x++)
|
||||
buffer[x] &= 0x7f;
|
||||
|
||||
fprintf (f, "%s\n", buffer);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -881,7 +879,7 @@ void BuildTabList (const char *partial)
|
|||
cmdalias_t *alias;
|
||||
cvar_t *cvar;
|
||||
cmd_function_t *cmd;
|
||||
int len;
|
||||
int len;
|
||||
|
||||
tablist = NULL;
|
||||
len = strlen(partial);
|
||||
|
@ -910,11 +908,11 @@ Con_TabComplete -- johnfitz
|
|||
*/
|
||||
void Con_TabComplete (void)
|
||||
{
|
||||
char partial[MAXCMDLINE];
|
||||
char partial[MAXCMDLINE];
|
||||
const char *match;
|
||||
static char *c;
|
||||
tab_t *t;
|
||||
int mark, i;
|
||||
int mark, i;
|
||||
|
||||
// if editline is empty, return
|
||||
if (key_lines[edit_line][1] == 0)
|
||||
|
@ -1246,7 +1244,7 @@ void Con_NotifyBox (const char *text)
|
|||
Con_Printf ("\n");
|
||||
IN_Activate();
|
||||
key_dest = key_game;
|
||||
realtime = 0; // put the cursor back to invisible
|
||||
realtime = 0; // put the cursor back to invisible
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue