if (!allowmodel && (!strcasecmp(key, "pmodel") || !strcasecmp(key, "emodel")))
fail = true;
for (i = 0;key[i];i++)
- if (key[i] <= ' ' || key[i] == '\"')
+ if (ISWHITESPACE(key[i]) || key[i] == '\"')
fail = true;
for (i = 0;value[i];i++)
if (value[i] == '\r' || value[i] == '\n' || value[i] == '\"')
if (text < textend)
text++;
// trim trailing whitespace
- while (lineend > linestart && lineend[-1] <= ' ')
+ while (lineend > linestart && ISWHITESPACE(lineend[-1]))
lineend--;
// trim leading whitespace
- while (linestart < lineend && *linestart <= ' ')
+ while (linestart < lineend && ISWHITESPACE(*linestart))
linestart++;
// check if this is a comment
if (linestart + 2 <= lineend && !strncmp(linestart, "//", 2))
else
maxs[i - 3] = atof(linetext);
// now advance past the number
- while (linetext < lineend && *linetext > ' ' && *linetext != ',')
+ while (linetext < lineend && !ISWHITESPACE(*linetext) && *linetext != ',')
linetext++;
// advance through whitespace
if (linetext < lineend)
limit = 6;
// note: comma can be followed by whitespace
}
- if (*linetext <= ' ')
+ if (ISWHITESPACE(*linetext))
{
// skip whitespace
- while (linetext < lineend && *linetext <= ' ')
+ while (linetext < lineend && ISWHITESPACE(*linetext))
linetext++;
}
}
text++;
if (line[0] == '/' && line[1] == '/')
continue; // skip comments if anyone happens to add them
- for (i = 0;i < len && line[i] > ' ';i++)
+ for (i = 0;i < len && !ISWHITESPACE(line[i]);i++)
address[i] = line[i];
address[i] = 0;
// skip exactly one space character
*is_multiple = true;
// kill pre-argument whitespace
- for (;*p && *p <= ' ';p++)
+ for (;*p && ISWHITESPACE(*p);p++)
;
return p;
while (1)
{
// skip whitespace up to a /n
- while (*text && *text <= ' ' && *text != '\r' && *text != '\n')
+ while (*text && ISWHITESPACE(*text) && *text != '\r' && *text != '\n')
text++;
// line endings:
*cur++ = STRING_COLOR_TAG;
*cur++ = STRING_COLOR_TAG;
}
- else if (d[j] >= ' ')
+ else if (d[j] >= (unsigned char) ' ')
*cur++ = d[j];
else
*cur++ = '.';
// UNIX: \n
// Mac: \r
// Windows: \r\n
- for (;*data <= ' ' && ((*data != '\n' && *data != '\r') || !returnnewline);data++)
+ for (;ISWHITESPACE(*data) && ((*data != '\n' && *data != '\r') || !returnnewline);data++)
{
if (*data == 0)
{
else
{
// regular word
- for (;*data > ' ';data++)
+ for (;!ISWHITESPACE(*data);data++)
if (len < (int)sizeof(com_token) - 1)
com_token[len++] = *data;
com_token[len] = 0;
// UNIX: \n
// Mac: \r
// Windows: \r\n
- for (;*data <= ' ' && ((*data != '\n' && *data != '\r') || !returnnewline);data++)
+ for (;ISWHITESPACE(*data) && ((*data != '\n' && *data != '\r') || !returnnewline);data++)
{
if (*data == 0)
{
else
{
// regular word
- for (;*data > ' ' && *data != '{' && *data != '}' && *data != ')' && *data != '(' && *data != ']' && *data != '[' && *data != ':' && *data != ',' && *data != ';';data++)
+ for (;!ISWHITESPACE(*data) && *data != '{' && *data != '}' && *data != ')' && *data != '(' && *data != ']' && *data != '[' && *data != ':' && *data != ',' && *data != ';';data++)
if (len < (int)sizeof(com_token) - 1)
com_token[len++] = *data;
com_token[len] = 0;
// UNIX: \n
// Mac: \r
// Windows: \r\n
- for (;*data <= ' ' && ((*data != '\n' && *data != '\r') || !returnnewline);data++)
+ for (;ISWHITESPACE(*data) && ((*data != '\n' && *data != '\r') || !returnnewline);data++)
{
if (*data == 0)
{
else
{
// regular word
- for (;*data > ' ' && *data != ',' && *data != ';' && *data != '{' && *data != '}' && *data != ')' && *data != '(' && *data != ']' && *data != '[' && *data != ':' && *data != ',' && *data != ';';data++)
+ for (;!ISWHITESPACE(*data) && *data != ',' && *data != ';' && *data != '{' && *data != '}' && *data != ')' && *data != '(' && *data != ']' && *data != '[' && *data != ':' && *data != ',' && *data != ';';data++)
if (len < (int)sizeof(com_token) - 1)
com_token[len++] = *data;
com_token[len] = 0;
// skip whitespace
skipwhite:
- for (;*data <= ' ';data++)
+ for (;ISWHITESPACE(*data);data++)
{
if (*data == 0)
{
else
{
// regular word
- for (;*data > ' ';data++)
+ for (;!ISWHITESPACE(*data);data++)
if (len < (int)sizeof(com_token) - 1)
com_token[len++] = *data;
com_token[len] = 0;
commentprefixlength = (int)strlen(commentprefix);
while (*l && *l != '\n' && *l != '\r')
{
- if (*l > ' ')
+ if (!ISWHITESPACE(*l))
{
if (commentprefixlength && !strncmp(l, commentprefix, commentprefixlength))
{
}
else
{
- while (*l > ' ')
+ while (!ISWHITESPACE(*l))
{
if (tokenbuf >= tokenbufend)
return -1;
if (com_token[0] == '}')
break;
// skip leading whitespace
- for (k = 0;com_token[k] && com_token[k] <= ' ';k++);
- for (l = 0;l < (int)sizeof(keyname) - 1 && com_token[k+l] && com_token[k+l] > ' ';l++)
+ for (k = 0;com_token[k] && ISWHITESPACE(com_token[k]);k++);
+ for (l = 0;l < (int)sizeof(keyname) - 1 && com_token[k+l] && !ISWHITESPACE(com_token[k+l]);l++)
keyname[l] = com_token[k+l];
keyname[l] = 0;
if (!COM_ParseToken_Simple(&data, false, false))
// convert space to _ to make stdio happy
// LordHavoc: convert control characters to _ as well
for (i=0 ; i<SAVEGAME_COMMENT_LENGTH ; i++)
- if (comment[i] <= ' ')
+ if (ISWHITESPACEORCONTROL(comment[i]))
comment[i] = '_';
comment[SAVEGAME_COMMENT_LENGTH] = '\0';
for (i = 0;rcon_password.string[i];i++)
{
- if (rcon_password.string[i] <= ' ')
+ if (ISWHITESPACE(rcon_password.string[i]))
{
Con_Printf("rcon_password is not allowed to have any whitespace.\n");
return;
return NULL;
for(text = s; text != endpos; ++text)
- if(*text > 0 && (*text < ' ' || *text == ';'))
+ if((signed char) *text > 0 && ((signed char) *text < (signed char) ' ' || *text == ';'))
return NULL; // block possible exploits against the parser/alias expansion
while(s != endpos)
char *s = string + 5;
char *endpos = string + length + 1; // one behind the NUL, so adding strlen+1 will eventually reach it
char password[64];
- for (i = 0;*s > ' ';s++)
+ for (i = 0;!ISWHITESPACE(*s);s++)
if (i < (int)sizeof(password) - 1)
password[i++] = *s;
- if(*s <= ' ' && s != endpos) // skip leading ugly space
+ if(ISWHITESPACE(*s) && s != endpos) // skip leading ugly space
++s;
password[i] = 0;
- if (password[0] > ' ')
+ if (!ISWHITESPACE(password[0]))
{
const char *userlevel = RCon_Authenticate(password, s, endpos);
if(userlevel)
void VM_CheckEmptyString (const char *s)
{
- if (s[0] <= ' ')
+ if (ISWHITESPACE(s[0]))
PRVM_ERROR ("%s: Bad string", PRVM_NAME);
}
break;
// skip whitespace here to find token start pos
- while(*p && (unsigned char) *p <= ' ')
+ while(*p && ISWHITESPACE(*p))
++p;
tokens_startpos[num_tokens] = p - string;
break;
// skip whitespace here to find token start pos
- while(*p && (unsigned char) *p <= ' ')
+ while(*p && ISWHITESPACE(*p))
++p;
tokens_startpos[num_tokens] = p - string;
break;
case ev_float:
- while (*s && *s <= ' ')
+ while (*s && ISWHITESPACE(*s))
s++;
val->_float = atof(s);
break;
case ev_vector:
for (i = 0;i < 3;i++)
{
- while (*s && *s <= ' ')
+ while (*s && ISWHITESPACE(*s))
s++;
if (!*s)
break;
val->vector[i] = atof(s);
- while (*s > ' ')
+ while (!ISWHITESPACE(*s))
s++;
if (!*s)
break;
break;
case ev_entity:
- while (*s && *s <= ' ')
+ while (*s && ISWHITESPACE(*s))
s++;
i = atoi(s);
if (i >= prog->limit_edicts)
// debug protocol exploits.
#define DEMOMSG_CLIENT_TO_SERVER 0x80000000
+// In Quake, any char in 0..32 counts as whitespace
+//#define ISWHITESPACE(ch) ((unsigned char) ch <= (unsigned char) ' ')
+#define ISWHITESPACE(ch) (!(ch) || (ch) == ' ' || (ch) == '\t' || (ch) == '\r' || (ch) == '\n')
+
+// This also includes extended characters, and ALL control chars
+#define ISWHITESPACEORCONTROL(ch) ((signed char) (ch) <= (signed char) ' ')
+
#endif
#endif
while(*text)
{
- int written = (int)write(1, text, (int)strlen(text));
+ ssize_t written = write(1, text, strlen(text));
if(written <= 0)
break; // sorry, I cannot do anything about this error - without an output
text += written;
if(sys_usenoclockbutbenchmark.integer)
{
benchmark_time += 1;
- return benchmark_time / 1e6;
+ return ((double) benchmark_time) / 1e6;
}
#ifdef WIN32
#include <mmsystem.h>
break;
default:
- if (ch >= ' ')
+ if (ch >= (int) (unsigned char) ' ')
{
WriteFile(houtput, &ch, 1, &dummy, NULL);
text[len] = ch;
// FIXME: this tokenizer is rather redundent, call a more general one
while (*lpCmdLine && (com_argc < MAX_NUM_ARGVS))
{
- while (*lpCmdLine && *lpCmdLine <= ' ')
+ while (*lpCmdLine && ISWHITESPACE(*lpCmdLine))
lpCmdLine++;
if (!*lpCmdLine)
// unquoted word
argv[com_argc] = lpCmdLine;
com_argc++;
- while (*lpCmdLine && *lpCmdLine > ' ')
+ while (*lpCmdLine && !ISWHITESPACE(*lpCmdLine))
lpCmdLine++;
}