Commit 8a7b7308 authored by Rob Swindell's avatar Rob Swindell 💬
Browse files

Replace ctype.h function calls with new MSVC-safe XPDEV macros

I'm fed-up with MSVC assertions in ctype functions (e.g. isdigit, isprint, isspace, etc.) when called with out-of-range (e.g. negative) values.

This problem only affects MSVC debug builds, but if you run them (like I do), these things are like little time bombs that can drive you crazy (knocking your board out of service).

The new macros names are bit more descriptive as well.
parent 3706559b
Pipeline #525 passed with stage
in 13 minutes and 56 seconds
......@@ -11,6 +11,9 @@ When submitting merge requests to existing files, unless you have prior agreemen
In general, if it's a large set of changes, your best bet of getting it accepted and merged into the repo would be to discuss the concept of the change with the developers in the [Synchronet Programming conference](http://web.synchro.net/?page=001-forum.ssjs&sub=syncprog) **first**.
If you were intereseted in contributing money, not code, then paypal to rob at synchro dot net.
When modifying the C/C++ source files:
* Do not call functions from `ctype.h` (e.g. `isprint`, `isspace`, `isdigit`, etc.) - use the `gen_defs.h IS_*` macros instead.
If you were interested in contributing money, not code, then paypal to rob at synchro dot net.
Thank you for contributing!
\ No newline at end of file
......@@ -91,7 +91,7 @@ void prep_desc(char *str)
tmp[j++]=str[i];
else if(j && str[i]<=' ' && str[i] > 0&& tmp[j-1]==' ')
continue;
else if(i && !isalnum((uchar)str[i]) && str[i]==str[i-1])
else if(i && !IS_ALPHANUMERIC(str[i]) && str[i]==str[i-1])
continue;
else if(str[i]>=' ' || str[i]<0)
tmp[j++]=str[i];
......@@ -248,7 +248,7 @@ bool get_file_diz(file_t* f, const char* filepath, char* ext)
sprintf(tmpext,"%.256s",ext);
prep_desc(tmpext);
for(i=0;tmpext[i];i++)
if(isalpha((uchar)tmpext[i]))
if(IS_ALPHA(tmpext[i]))
break;
sprintf(f->desc,"%.*s",LEN_FDESC,tmpext+i);
for(i=0;(f->desc[i]>=' ' || f->desc[i]<0) && i<LEN_FDESC;i++)
......@@ -411,7 +411,7 @@ void addlist(char *inpath, file_t f, uint dskip, uint sskip)
else /* no space after filename? */
continue;
#endif
if(!isalnum(*fname)) { // filename doesn't begin with an alpha-numeric char?
if(!IS_ALPHANUMERIC(*fname)) { // filename doesn't begin with an alpha-numeric char?
continue;
}
SAFEPRINTF2(filepath,"%s%s",cur_altpath ? scfg.altpath[cur_altpath-1]
......@@ -756,7 +756,7 @@ int main(int argc, char **argv)
mode|=AUTO_ADD;
i=0;
} else {
if(!isalnum((uchar)argv[1][0]) && argc==2) {
if(!IS_ALPHANUMERIC(argv[1][0]) && argc==2) {
puts(usage);
return(1);
}
......@@ -862,7 +862,7 @@ int main(int argc, char **argv)
return(1);
}
}
else if(isdigit((uchar)argv[j][0])) {
else if(IS_DIGIT(argv[j][0])) {
if(desc_offset==0)
desc_offset=atoi(argv[j]);
else
......@@ -872,9 +872,9 @@ int main(int argc, char **argv)
else if(argv[j][0]=='+') { /* filelist - FILES.BBS */
listgiven=1;
if(argc > j+1
&& isdigit((uchar)argv[j+1][0])) { /* skip x characters before description */
&& IS_DIGIT(argv[j+1][0])) { /* skip x characters before description */
if(argc > j+2
&& isdigit((uchar)argv[j+2][0])) { /* skip x characters before size */
&& IS_DIGIT(argv[j+2][0])) { /* skip x characters before size */
addlist(argv[j]+1,f,atoi(argv[j+1]),atoi(argv[j+2]));
j+=2;
}
......
......@@ -182,22 +182,22 @@ int main(int argc, char **argv)
case 'F': /* Set required flags */
j=3;
set=1;
if(isdigit(argv[i][2]))
if(IS_DIGIT(argv[i][2]))
set=argv[i][2]&0xf;
else
j=2;
for(;argv[i][j];j++)
if(isalpha(argv[i][j]))
if(IS_ALPHA(argv[i][j]))
reqflags[set-1]|=FLAG(toupper(argv[i][j]));
break;
case 'R': /* Set required restrictions */
for(j=2;argv[i][j];j++)
if(isalpha(argv[i][j]))
if(IS_ALPHA(argv[i][j]))
reqrest|=FLAG(toupper(argv[i][j]));
break;
case 'E': /* Set required exemptions */
for(j=2;argv[i][j];j++)
if(isalpha(argv[i][j]))
if(IS_ALPHA(argv[i][j]))
reqexempt|=FLAG(toupper(argv[i][j]));
break;
default: /* Unrecognized include */
......@@ -210,7 +210,7 @@ int main(int argc, char **argv)
case 'F': /* flags */
j=3;
set=1;
if(isdigit(argv[i][2]))
if(IS_DIGIT(argv[i][2]))
set=argv[i][2]&0xf;
else
j=2;
......@@ -221,7 +221,7 @@ int main(int argc, char **argv)
sub=1;
}
for(;argv[i][j];j++)
if(isalpha(argv[i][j]))
if(IS_ALPHA(argv[i][j]))
flags|=FLAG(toupper(argv[i][j]));
SAFEPRINTF(str,"%suser.dat",dir);
if(!fexistcase(str) || (file=sopen(str,O_RDWR|O_BINARY,SH_DENYNO))==-1) {
......@@ -285,7 +285,7 @@ int main(int argc, char **argv)
sub=1;
}
for(;argv[i][j];j++)
if(isalpha(argv[i][j]))
if(IS_ALPHA(argv[i][j]))
flags|=FLAG(toupper(argv[i][j]));
SAFEPRINTF(str,"%suser.dat",dir);
if(!fexistcase(str) || (file=sopen(str,O_RDWR|O_BINARY,SH_DENYNO))==-1) {
......
......@@ -243,7 +243,7 @@ bool sbbs_t::ansi_getxy(int* x, int* y)
rsp++;
start=time(NULL);
}
else if(isdigit(ch) && rsp==2) {
else if(IS_DIGIT(ch) && rsp==2) {
if(y!=NULL) {
(*y)*=10;
(*y)+=(ch&0xf);
......@@ -254,7 +254,7 @@ bool sbbs_t::ansi_getxy(int* x, int* y)
rsp++;
start=time(NULL);
}
else if(isdigit(ch) && rsp==3) {
else if(IS_DIGIT(ch) && rsp==3) {
if(x!=NULL) {
(*x)*=10;
(*x)+=(ch&0xf);
......
......@@ -102,7 +102,7 @@ uchar* arstr(ushort* count, const char* str, scfg_t* cfg, uchar* ar_buf)
if(str[i]=='&')
continue;
if(isalpha(str[i])) {
if(IS_ALPHA(str[i])) {
p=np=str+i;
SKIP_ALPHA(np);
n=np-p;
......@@ -248,7 +248,7 @@ uchar* arstr(ushort* count, const char* str, scfg_t* cfg, uchar* ar_buf)
continue;
}
if(!arg_expected && isalpha(str[i])) {
if(!arg_expected && IS_ALPHA(str[i])) {
n=i;
if(!strnicmp(str+i,"AGE",3)) {
artype=AR_AGE;
......@@ -550,7 +550,7 @@ uchar* arstr(ushort* count, const char* str, scfg_t* cfg, uchar* ar_buf)
ar[j++]=AR_EQUAL;
not=equal=0;
if(artype==AR_FLAG1 && isdigit(str[i])) { /* flag set specified */
if(artype==AR_FLAG1 && IS_DIGIT(str[i])) { /* flag set specified */
switch(str[i]) {
case '2':
artype=AR_FLAG2;
......@@ -567,15 +567,15 @@ uchar* arstr(ushort* count, const char* str, scfg_t* cfg, uchar* ar_buf)
arg_expected=FALSE;
if(artype==AR_SUB && !isdigit(str[i]))
if(artype==AR_SUB && !IS_DIGIT(str[i]))
artype=AR_SUBCODE;
if(artype==AR_DIR && !isdigit(str[i]))
if(artype==AR_DIR && !IS_DIGIT(str[i]))
artype=AR_DIRCODE;
if(artype==AR_INVALID)
artype=AR_LEVEL;
ar[j++]=artype;
if(isdigit(str[i]) && !ar_string_arg(artype)) {
if(IS_DIGIT(str[i]) && !ar_string_arg(artype)) {
if(artype==AR_TIME) {
n=atoi(str+i)*60;
p=strchr(str+i,':');
......@@ -583,7 +583,7 @@ uchar* arstr(ushort* count, const char* str, scfg_t* cfg, uchar* ar_buf)
n+=atoi(p+1);
*((short *)(ar+j))=n;
j+=2;
while(isdigit(str[i+1]) || str[i+1]==':') i++;
while(IS_DIGIT(str[i+1]) || str[i+1]==':') i++;
continue;
}
n=atoi(str+i);
......@@ -635,7 +635,7 @@ uchar* arstr(ushort* count, const char* str, scfg_t* cfg, uchar* ar_buf)
j--;
break;
}
while(isdigit(str[i+1])) i++;
while(IS_DIGIT(str[i+1])) i++;
continue;
}
maxlen=128;
......@@ -681,7 +681,7 @@ uchar* arstr(ushort* count, const char* str, scfg_t* cfg, uchar* ar_buf)
}
else /* Unknown sub-board */
j--;
while(isalpha(str[i+1])) i++;
while(IS_ALPHA(str[i+1])) i++;
break;
case AR_DIR:
for(n=0;n<(uint)cfg->total_dirs;n++)
......@@ -693,7 +693,7 @@ uchar* arstr(ushort* count, const char* str, scfg_t* cfg, uchar* ar_buf)
}
else /* Unknown directory */
j--;
while(isalpha(str[i+1])) i++;
while(IS_ALPHA(str[i+1])) i++;
break;
case AR_DAY:
if(toupper(str[i])=='S'
......@@ -712,7 +712,7 @@ uchar* arstr(ushort* count, const char* str, scfg_t* cfg, uchar* ar_buf)
else if(toupper(str[i])=='F') /* Friday */
ar[j++]=5;
else ar[j++]=6; /* Saturday */
while(isalpha(str[i+1])) i++;
while(IS_ALPHA(str[i+1])) i++;
break;
default: /* Badly formed ARS, digit expected */
j--;
......
......@@ -52,7 +52,7 @@ static char* separate_thousands(const char* src, char *dest, size_t maxlen, char
if(strlen(src) * 1.3 > maxlen)
return (char*)src;
const char* tail = src;
while(*tail && isdigit(*tail))
while(*tail && IS_DIGIT(*tail))
tail++;
if(tail == src)
return (char*)src;
......@@ -174,13 +174,13 @@ int sbbs_t::show_atcode(const char *instr, JSObject* obj)
if(p!=NULL) {
char* lp = p;
lp++; // skip the '|' or '-'
while(*lp == '>'|| isalpha((uchar)*lp))
while(*lp == '>'|| IS_ALPHA(*lp))
lp++;
if(*lp)
width_specified = true;
while(*lp && !isdigit((uchar)*lp))
while(*lp && !IS_DIGIT(*lp))
lp++;
if(*lp && isdigit((uchar)*lp)) {
if(*lp && IS_DIGIT(*lp)) {
disp_len=atoi(lp);
width_specified = true;
}
......
......@@ -148,7 +148,7 @@ int32_t val(char *src, char *p)
static int inside;
int32_t l;
if(isdigit((uchar)*p) || *p=='-') /* Dec, Hex, or Oct */
if(IS_DIGIT(*p) || *p=='-') /* Dec, Hex, or Oct */
l=strtol(p,&p,0);
else if(*p=='\'') { /* Char */
p++;
......@@ -230,11 +230,11 @@ void writecstr(char *p)
continue; }
if(*p=='\\') { /* escape */
p++;
if(isdigit((uchar)*p)) {
if(IS_DIGIT(*p)) {
sprintf(tmp,"%.3s",p);
str[j]=atoi(tmp); /* decimal, NOT octal */
if(isdigit((uchar)*(++p))) /* skip up to 3 digits */
if(isdigit((uchar)*(++p)))
if(IS_DIGIT(*(++p))) /* skip up to 3 digits */
if(IS_DIGIT(*(++p)))
p++;
j++;
continue; }
......@@ -311,7 +311,7 @@ void newvar(char* src, char *in)
char name[128];
int32_t i,l;
if(isdigit((uchar)*in)) {
if(IS_DIGIT(*in)) {
printf("!SYNTAX ERROR (illegal variable name):\n");
printf(linestr,src,line,(char*)in);
bail(1);
......@@ -377,7 +377,7 @@ int32_t isvar(char *arg)
char name[128],*p;
int32_t i,l;
if(!arg || !(*arg) || isdigit((uchar)*arg))
if(!arg || !(*arg) || IS_DIGIT(*arg))
return(0);
sprintf(name,"%.80s",arg);
......@@ -426,7 +426,7 @@ void expdefs(char *line)
continue; }
for(sp=p;*sp;sp++)
if(!isalnum((uchar)*sp) && *sp!='_')
if(!IS_ALPHANUMERIC(*sp) && *sp!='_')
break;
sav[0]=*sp; /* Save delimiter */
sav[1]=0;
......@@ -1185,7 +1185,7 @@ void compile(char *src)
if(!stricmp(p,"COMPARE_INT_VAR") ||
(!stricmp(p,"COMPARE")
&& (isdigit((uchar)*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
&& (IS_DIGIT(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
if(!(*arg)) break;
fputc(CS_VAR_INSTRUCTION,out);
......@@ -1290,7 +1290,7 @@ void compile(char *src)
if(!stricmp(p,"ADD_INT_VAR")
|| (!stricmp(p,"ADD")
&& (isdigit((uchar)*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
&& (IS_DIGIT(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
if(!(*arg)) break;
fputc(CS_VAR_INSTRUCTION,out);
fputc(ADD_INT_VAR,out);
......@@ -1318,7 +1318,7 @@ void compile(char *src)
if(!stricmp(p,"SUB_INT_VAR")
|| (!stricmp(p,"SUB")
&& (isdigit((uchar)*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
&& (IS_DIGIT(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
if(!(*arg)) break;
fputc(CS_VAR_INSTRUCTION,out);
fputc(SUB_INT_VAR,out);
......@@ -1346,7 +1346,7 @@ void compile(char *src)
if(!stricmp(p,"MUL_INT_VAR")
|| (!stricmp(p,"MUL")
&& (isdigit((uchar)*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
&& (IS_DIGIT(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
if(!(*arg)) break;
fputc(CS_VAR_INSTRUCTION,out);
fputc(MUL_INT_VAR,out);
......@@ -1374,7 +1374,7 @@ void compile(char *src)
if(!stricmp(p,"DIV_INT_VAR")
|| (!stricmp(p,"DIV")
&& (isdigit((uchar)*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
&& (IS_DIGIT(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
if(!(*arg)) break;
fputc(CS_VAR_INSTRUCTION,out);
fputc(DIV_INT_VAR,out);
......@@ -1402,7 +1402,7 @@ void compile(char *src)
if(!stricmp(p,"MOD_INT_VAR")
|| (!stricmp(p,"MOD")
&& (isdigit((uchar)*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
&& (IS_DIGIT(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
if(!(*arg)) break;
fputc(CS_VAR_INSTRUCTION,out);
fputc(MOD_INT_VAR,out);
......@@ -1430,7 +1430,7 @@ void compile(char *src)
if(!stricmp(p,"AND_INT_VAR")
|| (!stricmp(p,"AND")
&& (isdigit((uchar)*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
&& (IS_DIGIT(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
if(!(*arg)) break;
fputc(CS_VAR_INSTRUCTION,out);
fputc(AND_INT_VAR,out);
......@@ -1474,7 +1474,7 @@ void compile(char *src)
if(!stricmp(p,"OR_INT_VAR")
|| (!stricmp(p,"OR")
&& (isdigit((uchar)*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
&& (IS_DIGIT(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
if(!(*arg)) break;
fputc(CS_VAR_INSTRUCTION,out);
fputc(OR_INT_VAR,out);
......@@ -1500,7 +1500,7 @@ void compile(char *src)
if(!stricmp(p,"NOT_INT_VAR")
|| (!stricmp(p,"NOT")
&& (isdigit((uchar)*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
&& (IS_DIGIT(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
if(!(*arg)) break;
fputc(CS_VAR_INSTRUCTION,out);
fputc(NOT_INT_VAR,out);
......@@ -1526,7 +1526,7 @@ void compile(char *src)
if(!stricmp(p,"XOR_INT_VAR")
|| (!stricmp(p,"XOR")
&& (isdigit((uchar)*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
&& (IS_DIGIT(*arg2) || atol(arg2) || *arg2=='\'' || *arg2=='.'))) {
if(!(*arg)) break;
fputc(CS_VAR_INSTRUCTION,out);
fputc(XOR_INT_VAR,out);
......@@ -1678,7 +1678,7 @@ void compile(char *src)
if(!(*arg)) break;
fputc(CS_FIO_FUNCTION,out);
if(!(*arg3) || isdigit((uchar)*arg3) || atoi(arg3))
if(!(*arg3) || IS_DIGIT(*arg3) || atoi(arg3))
fputc(FIO_READ,out);
else
fputc(FIO_READ_VAR,out);
......@@ -1691,7 +1691,7 @@ void compile(char *src)
if(p)
*p=0;
writecrc(src,arg2); /* Variable */
if(isdigit((uchar)*arg3))
if(IS_DIGIT(*arg3))
i=val(src,arg3); /* Length */
else
i=0;
......@@ -1703,7 +1703,7 @@ void compile(char *src)
if(!stricmp(p,"FWRITE")) {
if(!(*arg)) break;
fputc(CS_FIO_FUNCTION,out);
if(!(*arg3) || isdigit((uchar)*arg3) || atoi(arg3))
if(!(*arg3) || IS_DIGIT(*arg3) || atoi(arg3))
fputc(FIO_WRITE,out);
else
fputc(FIO_WRITE_VAR,out);
......@@ -1716,7 +1716,7 @@ void compile(char *src)
if(p)
*p=0;
writecrc(src,arg2); /* Variable */
if(isdigit((uchar)*arg3))
if(IS_DIGIT(*arg3))
i=val(src,arg3); /* Length */
else
i=0;
......@@ -1769,7 +1769,7 @@ void compile(char *src)
if(!stricmp(p,"FSET_POS") || !stricmp(p,"FSEEK")) {
if(!(*arg)) break;
fputc(CS_FIO_FUNCTION,out);
if(isdigit((uchar)*arg2) || atol(arg2))
if(IS_DIGIT(*arg2) || atol(arg2))
fputc(FIO_SEEK,out);
else
fputc(FIO_SEEK_VAR,out);
......@@ -1781,7 +1781,7 @@ void compile(char *src)
p=strchr(arg2,' ');
if(p)
*p=0;
if(atol(arg2) || isdigit((uchar)*arg2)) {
if(atol(arg2) || IS_DIGIT(*arg2)) {
l=val(src,arg2);
fwrite(&l,4,1,out); }
else
......@@ -1800,7 +1800,7 @@ void compile(char *src)
if(!stricmp(p,"FLOCK")) {
if(!(*arg)) break;
fputc(CS_FIO_FUNCTION,out);
if(isdigit((uchar)*arg2) || atol(arg2))
if(IS_DIGIT(*arg2) || atol(arg2))
fputc(FIO_LOCK,out);
else
fputc(FIO_LOCK_VAR,out);
......@@ -1809,7 +1809,7 @@ void compile(char *src)
break;
*p=0;
writecrc(src,arg); /* File handle */
if(atol(arg2) || isdigit((uchar)*arg2)) {
if(atol(arg2) || IS_DIGIT(*arg2)) {
l=val(src,arg2);
if(!l)
break;
......@@ -1820,7 +1820,7 @@ void compile(char *src)
if(!stricmp(p,"FUNLOCK")) {
if(!(*arg)) break;
fputc(CS_FIO_FUNCTION,out);
if(isdigit((uchar)*arg2) || atol(arg2))
if(IS_DIGIT(*arg2) || atol(arg2))
fputc(FIO_UNLOCK,out);
else
fputc(FIO_UNLOCK_VAR,out);
......@@ -1829,7 +1829,7 @@ void compile(char *src)
break;
*p=0;
writecrc(src,arg); /* File handle */
if(atol(arg2) || isdigit((uchar)*arg2)) {
if(atol(arg2) || IS_DIGIT(*arg2)) {
l=val(src,arg2);
if(!l)
break;
......@@ -1840,7 +1840,7 @@ void compile(char *src)
if(!stricmp(p,"FSET_LENGTH")) {
if(!(*arg)) break;
fputc(CS_FIO_FUNCTION,out);
if(isdigit((uchar)*arg2) || atol(arg2))
if(IS_DIGIT(*arg2) || atol(arg2))
fputc(FIO_SET_LENGTH,out);
else
fputc(FIO_SET_LENGTH_VAR,out);
......@@ -1849,7 +1849,7 @@ void compile(char *src)
break;
*p=0;
writecrc(src,arg); /* File handle */
if(atol(arg2) || isdigit((uchar)*arg2)) {
if(atol(arg2) || IS_DIGIT(*arg2)) {
l=val(src,arg2);
fwrite(&l,4,1,out); }
else
......@@ -2548,7 +2548,7 @@ void compile(char *src)
if(!stricmp(p,"GETSTR")) {
p=strchr(arg,' ');
if(p) *p=0;
if((!(*arg) || isdigit((uchar)*arg) || !stricmp(arg,"STR")) && !(*arg3))
if((!(*arg) || IS_DIGIT(*arg) || !stricmp(arg,"STR")) && !(*arg3))
fprintf(out,"%c%c",CS_GETSTR,atoi(arg) ? atoi(arg)
: *arg2 ? atoi(arg2) : 128);
else {
......@@ -2577,7 +2577,7 @@ void compile(char *src)
if(!(*arg)) break;
p=strchr(arg,' ');
if(p) *p=0;
if(isdigit((uchar)*arg)) {
if(IS_DIGIT(*arg)) {
i=val(src,arg);
fprintf(out,"%c",CS_GETNUM);
fwrite(&i,2,1,out); }
......@@ -2612,7 +2612,7 @@ void compile(char *src)
if(!stricmp(p,"GETLINE")) {
p=strchr(arg,' ');
if(p) *p=0;
if(!(*arg) || isdigit((uchar)*arg))
if(!(*arg) || IS_DIGIT(*arg))
fprintf(out,"%c%c",CS_GETLINE,*arg ? atoi(arg) :128);
else {
if((l=isvar(arg2))!=0) {
......@@ -2632,7 +2632,7 @@ void compile(char *src)
if(!stricmp(p,"GETSTRUPR")) {
p=strchr(arg,' ');
if(p) *p=0;
if(!(*arg) || isdigit((uchar)*arg))
if(!(*arg) || IS_DIGIT(*arg))
fprintf(out,"%c%c",CS_GETSTRUPR,*arg ? atoi(arg) :128);
else {
if((l=isvar(arg2))!=0) {
......@@ -2652,7 +2652,7 @@ void compile(char *src)
if(!stricmp(p,"GETNAME")) {
p=strchr(arg,' ');
if(p) *p=0;
if(!(*arg) || isdigit((uchar)*arg))
if(!(*arg) || IS_DIGIT(*arg))
fprintf(out,"%c%c",CS_GETNAME,*arg ? atoi(arg) :25);
else {
if((l=isvar(arg2))!=0) {
......@@ -2673,7 +2673,7 @@ void compile(char *src)
if(!(*arg)) break;
p=strchr(arg,' ');
if(p) *p=0;
if(isdigit((uchar)*arg))
if(IS_DIGIT(*arg))
fprintf(out,"%c%c",CS_SHIFT_STR,atoi(arg));
else {
if((l=isvar(arg2))!=0) {
......
......@@ -1571,7 +1571,7 @@ void sbbs_t::guruchat(char* line, char* gurubuf, int gurunum, char* last_answer)
j=strlen(line);
k=0;
for(i=0;i<j;i++) {
if(line[i]<0 || !isalnum((uchar)line[i])) {
if(line[i]<0 || !IS_ALPHANUMERIC(line[i])) {
if(!k) /* beginning non-alphanumeric */
continue;
if(line[i]==line[i+1]) /* redundant non-alnum */
......@@ -1584,7 +1584,7 @@ void sbbs_t::guruchat(char* line, char* gurubuf, int gurunum, char* last_answer)
cstr[k]=0;
while(k) {
k--;
if(!isalnum((uchar)cstr[k]))
if(!IS_ALPHANUMERIC(cstr[k]))
continue;
break;
}
......@@ -1786,8 +1786,8 @@ void sbbs_t::guruchat(char* line, char* gurubuf, int gurunum, char* last_answer)
if(action!=NODE_MCHT) {
for(i=0;i<k;i++) {
if(i && mistakes && theanswer[i]!=theanswer[i-1] &&
((!isalnum((uchar)theanswer[i]) && !sbbs_random(100))
|| (isalnum((uchar)theanswer[i]) && !sbbs_random(30)))) {
((!IS_ALPHANUMERIC(theanswer[i]) && !sbbs_random(100))
|| (IS_ALPHANUMERIC(theanswer[i]) && !sbbs_random(30)))) {
c=j=((uint)sbbs_random(3)+1); /* 1 to 3 chars */
if(c<strcspn(theanswer+(i+1),"\0., "))
c=j=1;
......@@ -1909,7 +1909,7 @@ bool sbbs_t::guruexp(char **ptrptr, char *line)
if((**ptrptr)==')')
break;
c=0;
while((**ptrptr) && isspace(**ptrptr))
while((**ptrptr) && IS_WHITESPACE(**ptrptr))
(*ptrptr)++;
while((**ptrptr)!='|' && (**ptrptr)!='&' && (**ptrptr)!=')' &&(**ptrptr)) {
str[c++]=(**ptrptr);
......@@ -1948,13 +1948,13 @@ bool sbbs_t::guruexp(char **ptrptr, char *line)
else {
cp=strstr(line,str);
if(cp && c) {
if(cp!=line || isalnum((uchar)*(cp+strlen(str))))
if(cp!=line || IS_ALPHANUMERIC(*(cp+strlen(str))))
cp=0;
}
else { /* must be isolated word */
while(cp)
if((cp!=line && isalnum((uchar)*(cp-1)))
|| isalnum((uchar)*(cp+strlen(str))))
if((cp!=line && IS_ALPHANUMERIC(*(cp-1)))
|| IS_ALPHANUMERIC(*(cp+strlen(str))))
cp=strstr(cp+strlen(str),str);
else