...
 
Commits (1)
  • Rob Swindell's avatar
    Replace ctype.h function calls with new MSVC-safe XPDEV macros · 8a7b7308
    Rob Swindell authored
    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.
    8a7b7308
......@@ -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
break;
......
......@@ -178,7 +178,7 @@ size_t sbbs_t::bstrlen(const char *str, long mode)
/* Perform PETSCII terminal output translation (from ASCII/CP437) */
unsigned char cp437_to_petscii(unsigned char ch)
{
if(isalpha(ch))
if(IS_ALPHA(ch))
return ch ^ 0x20; /* swap upper/lower case */
switch(ch) {
case '\1': return '@';
......@@ -260,7 +260,7 @@ int sbbs_t::petscii_to_ansibbs(unsigned char ch)
{
if((ch&0xe0) == 0xc0) /* "Codes $60-$7F are, actually, copies of codes $C0-$DF" */
ch = 0x60 | (ch&0x1f);
if(isalpha(ch))
if(IS_ALPHA(ch))
return outchar(ch ^ 0x20); /* swap upper/lower case */
switch(ch) {
case '\r': newline(); break;
......@@ -1038,7 +1038,7 @@ void sbbs_t::ctrl_a(char x)
cursor_right((uchar)x-0x7f);
return;
}
if(isdigit(x)) { /* background color */
if(IS_DIGIT(x)) { /* background color */
atr &= (BG_BRIGHT|BLINK|0x0f);
}
switch(toupper(x)) {
......
......@@ -54,18 +54,18 @@ time32_t DLLCALL dstrtounix(scfg_t* cfg, const char *instr)
if(!instr[0] || !strncmp(instr,"00/00/00",8))
return(0);
if(isdigit(instr[0]) && isdigit(instr[1])
&& isdigit(instr[3]) && isdigit(instr[4])
&& isdigit(instr[6]) && isdigit(instr[7]))
if(IS_DIGIT(instr[0]) && IS_DIGIT(instr[1])
&& IS_DIGIT(instr[3]) && IS_DIGIT(instr[4])
&& IS_DIGIT(instr[6]) && IS_DIGIT(instr[7]))
p=instr; /* correctly formatted */
else {
p=instr; /* incorrectly formatted */
while(*p && isdigit(*p)) p++;
while(*p && IS_DIGIT(*p)) p++;
if(*p==0)
return(0);
p++;
day=p;
while(*p && isdigit(*p)) p++;
while(*p && IS_DIGIT(*p)) p++;
if(*p==0)
return(0);
p++;
......
......@@ -1521,9 +1521,9 @@ int sbbs_t::exec(csi_t *csi)
csi->logic=*csi->ip++;
return(0);
case CS_CMDKEY:
if( ((*csi->ip)==CS_DIGIT && isdigit(csi->cmd))
if( ((*csi->ip)==CS_DIGIT && IS_DIGIT(csi->cmd))
|| ((*csi->ip)==CS_EDIGIT && csi->cmd&0x80
&& isdigit(csi->cmd&0x7f))) {
&& IS_DIGIT(csi->cmd&0x7f))) {
csi->ip++;
return(0);
}
......@@ -1597,9 +1597,9 @@ int sbbs_t::exec(csi_t *csi)
memmove(csi->str,csi->str+i,j+1);
return(0);
case CS_COMPARE_KEY:
if( ((*csi->ip)==CS_DIGIT && isdigit(csi->cmd))
if( ((*csi->ip)==CS_DIGIT && IS_DIGIT(csi->cmd))
|| ((*csi->ip)==CS_EDIGIT && csi->cmd&0x80
&& isdigit(csi->cmd&0x7f))) {
&& IS_DIGIT(csi->cmd&0x7f))) {
csi->ip++;
csi->logic=LOGIC_TRUE;
}
......@@ -1628,7 +1628,7 @@ int sbbs_t::exec(csi_t *csi)
}
switch(*(csi->ip++)) {
case USER_STRING_ALIAS:
if(!isalpha(csi->str[0]) || trashcan(csi->str,"name"))
if(!IS_ALPHA(csi->str[0]) || trashcan(csi->str,"name"))
break;
i=matchuser(&cfg,csi->str,TRUE /*sysop_alias*/);
if(i && i!=useron.number)
......
......@@ -127,7 +127,7 @@ int sbbs_t::exec_file(csi_t *csi)
if((ch&0xf)*10U<=usrdirs[curlib] && (ch&0xf) && usrlibs) {
i=(ch&0xf)*10;
ch=getkey(K_UPPER);
if(!isdigit(ch) && ch!=CR) {
if(!IS_DIGIT(ch) && ch!=CR) {
ungetkey(ch);
curdir[curlib]=(i/10)-1;
return(0);
......@@ -142,7 +142,7 @@ int sbbs_t::exec_file(csi_t *csi)
if(i*10<=usrdirs[curlib]) { /* 100+ dirs */
i*=10;
ch=getkey(K_UPPER);
if(!isdigit(ch) && ch!=CR) {
if(!IS_DIGIT(ch) && ch!=CR) {
ungetkey(ch);
curdir[curlib]=(i/10)-1;
return(0);
......@@ -179,7 +179,7 @@ int sbbs_t::exec_file(csi_t *csi)
if((ch&0xf)*10U<=usrlibs && (ch&0xf)) {
i=(ch&0xf)*10;
ch=getkey(K_UPPER);
if(!isdigit(ch) && ch!=CR) {
if(!IS_DIGIT(ch) && ch!=CR) {
ungetkey(ch);
curlib=(i/10)-1;
return(0);
......
......@@ -123,7 +123,7 @@ int sbbs_t::exec_msg(csi_t *csi)
if(usrgrps && (ch&0xf)*10U<=usrsubs[curgrp] && (ch&0xf)) {
i=(ch&0xf)*10;
ch=getkey(K_UPPER);
if(!isdigit((uchar)ch) && ch!=CR) {
if(!IS_DIGIT(ch) && ch!=CR) {
ungetkey(ch);
cursub[curgrp]=(i/10)-1;
return(0);
......@@ -138,7 +138,7 @@ int sbbs_t::exec_msg(csi_t *csi)
if(i*10<=usrsubs[curgrp]) { /* 100+ subs */
i*=10;
ch=getkey(K_UPPER);
if(!isdigit((uchar)ch) && ch!=CR) {
if(!IS_DIGIT(ch) && ch!=CR) {
ungetkey(ch);
cursub[curgrp]=(i/10)-1;
return(0);
......@@ -175,7 +175,7 @@ int sbbs_t::exec_msg(csi_t *csi)
if((ch&0xf)*10U<=usrgrps && (ch&0xf)) {
i=(ch&0xf)*10;
ch=getkey(K_UPPER);
if(!isdigit((uchar)ch) && ch!=CR) {
if(!IS_DIGIT(ch) && ch!=CR) {
ungetkey(ch);
curgrp=(i/10)-1;
return(0);
......
......@@ -1887,8 +1887,8 @@ static void receive_thread(void* arg)
SAFECOPY(desc,ext);
strip_exascii(desc, desc); /* strip extended ASCII chars */
prep_file_desc(desc, desc); /* strip control chars and dupe chars */
for(i=0;desc[i];i++) /* find approprate first char */
if(isalnum(desc[i]))
for(i=0;desc[i];i++) /* find appropriate first char */
if(IS_ALPHANUMERIC(desc[i]))
break;
SAFECOPY(f.desc,desc+i);
}
......
......@@ -91,9 +91,9 @@ char sbbs_t::getkey(long mode)
return(0);
now=time(NULL);
if(ch) {
if(mode&K_NUMBER && isprint(ch) && !isdigit(ch))
if(mode&K_NUMBER && IS_PRINTABLE(ch) && !IS_DIGIT(ch))
continue;
if(mode&K_ALPHA && isprint(ch) && !isalpha(ch))
if(mode&K_ALPHA && IS_PRINTABLE(ch) && !IS_ALPHA(ch))
continue;
if(mode&K_NOEXASC && ch&0x80)
continue;
......@@ -365,7 +365,7 @@ long sbbs_t::getkeys(const char *keys, ulong max, long mode)
lncntr=0;
return(-1);
}
if(ch && !n && ((keys == NULL && !isdigit(ch)) || (strchr(str,ch)))) { /* return character if in string */
if(ch && !n && ((keys == NULL && !IS_DIGIT(ch)) || (strchr(str,ch)))) { /* return character if in string */
if(ch > ' ') {
if(!(mode&K_NOECHO))
outchar(ch);
......@@ -411,7 +411,7 @@ long sbbs_t::getkeys(const char *keys, ulong max, long mode)
i/=10;
n--;
}
else if(max && isdigit(ch) && (i*10)+(ch&0xf)<=max && (ch!='0' || n)) {
else if(max && IS_DIGIT(ch) && (i*10)+(ch&0xf)<=max && (ch!='0' || n)) {
i*=10;
n++;
i+=ch&0xf;
......
......@@ -99,7 +99,7 @@ size_t sbbs_t::getstr(char *strout, size_t maxlen, long mode, const str_list_t h
if(mode&K_AUTODEL && str1[0] && !(mode&K_NOECHO)) {
ch=getkey(mode|K_GETSTR);
attr(atr);
if(isprint(ch) || ch==DEL) {
if(IS_PRINTABLE(ch) || ch==DEL) {
for(i=0;i<l;i++)
backspace();
i=l=0;
......@@ -689,7 +689,7 @@ long sbbs_t::getnum(ulong max, ulong dflt)
i/=10;
n--;
}
else if(isdigit(ch) && (i*10UL)+(ch&0xf)<=max && (dflt || ch!='0' || n)) {
else if(IS_DIGIT(ch) && (i*10UL)+(ch&0xf)<=max && (dflt || ch!='0' || n)) {
i*=10L;
n++;
i+=ch&0xf;
......
......@@ -74,7 +74,7 @@ int kbincom(sbbs_t* sbbs, unsigned long timeout)
}
if((ch&0xe0) == 0xc0) /* "Codes $60-$7F are, actually, copies of codes $C0-$DF" */
ch = 0x60 | (ch&0x1f);
if(isalpha((unsigned char)ch))
if(IS_ALPHA(ch))
ch ^= 0x20; /* Swap upper/lower case */
}
......@@ -416,7 +416,7 @@ char sbbs_t::handle_ctrlkey(char ch, long mode)
return 0;
}
str[i++] = byte;
if(isalpha(byte))
if(IS_ALPHA(byte))
break;
}
str[i] = 0;
......@@ -487,7 +487,7 @@ char sbbs_t::handle_ctrlkey(char ch, long mode)
#endif
return 0;
}
if(ch!=';' && !isdigit((uchar)ch) && ch!='R') { /* other ANSI */
if(ch!=';' && !IS_DIGIT(ch) && ch!='R') { /* other ANSI */
str[i]=0;
switch(ch) {
case 'A':
......
......@@ -1662,7 +1662,7 @@ js_atcode(JSContext *cx, uintN argc, jsval *arglist)
else if((p=strstr(instr,"-R"))!=NULL)
padded_right=true;
if(p!=NULL) {
if(*(p+2) && isdigit(*(p+2)))
if(*(p+2) && IS_DIGIT(*(p+2)))
disp_len=atoi(p+2);
*p=0;
}
......
......@@ -714,7 +714,7 @@ static jsval get_value(JSContext *cx, char* value)
for(p=value;*p;p++) {
if(*p=='.' && !f)
f=TRUE;
else if(!isdigit((uchar)*p))
else if(!IS_DIGIT(*p))
break;
}
if(*p==0) {
......
......@@ -1886,7 +1886,7 @@ js_html_encode(JSContext *cx, uintN argc, jsval *arglist)
ansi_seq[MAX_ANSI_SEQ]=0;
for(lastparam=ansi_seq;*lastparam;lastparam++)
{
if(isalpha(*lastparam))
if(IS_ALPHA(*lastparam))
{
*(++lastparam)=0;
break;
......@@ -1896,16 +1896,16 @@ js_html_encode(JSContext *cx, uintN argc, jsval *arglist)
param=ansi_seq;
if(*param=='?') /* This is to fix ESC[?7 whatever that is */
param++;
if(isdigit(*param))
if(IS_DIGIT(*param))
ansi_param[k++]=atoi(ansi_seq);
while(isspace(*param) || isdigit(*param))
while(IS_WHITESPACE(*param) || IS_DIGIT(*param))
param++;
lastparam=param;
while((param=strchr(param,';'))!=NULL)
{
param++;
ansi_param[k++]=atoi(param);
while(isspace(*param) || isdigit(*param))
while(IS_WHITESPACE(*param) || IS_DIGIT(*param))
param++;
lastparam=param;
}
......
......@@ -150,7 +150,7 @@ static void remove_port_part(char *host)
{
char *p=strchr(host, 0)-1;
if (isdigit(*p)) {
if (IS_DIGIT(*p)) {
/*
* If the first and last : are not the same, and it doesn't
* start with '[', there's no port part.
......@@ -164,7 +164,7 @@ static void remove_port_part(char *host)
*p = 0;
break;
}
if (!isdigit(*p))
if (!IS_DIGIT(*p))
break;
}
}
......
......@@ -458,7 +458,7 @@ static ushort js_port(JSContext* cx, jsval val, int type)
if(JSVAL_IS_STRING(val)) {
str = JS_ValueToString(cx,val);
JSSTRING_TO_ASTRING(cx, str, cp, 16, NULL);
if(isdigit(*cp))
if(IS_DIGIT(*cp))
return((ushort)strtol(cp,NULL,0));
rc=JS_SUSPENDREQUEST(cx);
serv = getservbyname(cp,type==SOCK_STREAM ? "tcp":"udp");
......
......@@ -1111,7 +1111,7 @@ int parseLogLevel(const char* p)
str_list_t logLevelStringList=iniLogLevelStringList();
int i;
if(isdigit(*p))
if(IS_DIGIT(*p))
return strtol(p,NULL,0);
/* Exact match */
......
......@@ -474,7 +474,7 @@ char* prep_code(char *str, const char* prefix)
strcpy(str,tmp);
if(j>LEN_CODE) { /* Extra chars? Strip symbolic chars */
for(i=j=0;str[i];i++)
if(isalnum(str[i]))
if(IS_ALPHANUMERIC(str[i]))
tmp[j++]=str[i];
tmp[j]=0;
strcpy(str,tmp);
......
......@@ -61,7 +61,7 @@ int sbbs_t::login(char *username, char *pw_prompt, const char* user_pw, const ch
useron.number=0;
username = parse_login(username);
if(!(cfg.node_misc&NM_NO_NUM) && isdigit((uchar)username[0])) {
if(!(cfg.node_misc&NM_NO_NUM) && IS_DIGIT(username[0])) {
useron.number=atoi(username);
getuserdat(&cfg,&useron);
if(useron.number && useron.misc&(DELETED|INACTIVE))
......@@ -71,7 +71,7 @@ int sbbs_t::login(char *username, char *pw_prompt, const char* user_pw, const ch
if(!useron.number) {
useron.number=matchuser(&cfg,username,FALSE);
if(!useron.number && (uchar)username[0]<0x7f && username[1]
&& isalpha(username[0]) && strchr(username,' ') && cfg.node_misc&NM_LOGON_R)
&& IS_ALPHA(username[0]) && strchr(username,' ') && cfg.node_misc&NM_LOGON_R)
useron.number=userdatdupe(0,U_NAME,LEN_NAME,username);
if(useron.number) {
getuserdat(&cfg,&useron);
......
......@@ -243,7 +243,7 @@ bool sbbs_t::logon()
c=0;
while(c < RAND_PASS_LEN) { /* Create random password */
str[c]=sbbs_random(43)+'0';
if(isalnum(str[c]))
if(IS_ALPHANUMERIC(str[c]))
c++;
}
str[c]=0;
......
......@@ -40,7 +40,6 @@
#include <stdlib.h> /* ltoa in GNU C lib */
#include <stdarg.h> /* va_list */
#include <string.h> /* strrchr */
#include <ctype.h> /* isdigit */
#include <fcntl.h> /* Open flags */
#include <errno.h> /* errno */
......@@ -946,7 +945,7 @@ static u_long resolve_ip(const char *inaddr)
return((u_long)INADDR_NONE);
for(p=addr;*p;p++)
if(*p!='.' && !isdigit((uchar)*p))
if(*p!='.' && !IS_DIGIT(*p))
break;
if(!(*p))
return(inet_addr(addr));
......@@ -1478,7 +1477,7 @@ static void pop3_thread(void* arg)
if(!strnicmp(buf, "LIST",4) || !strnicmp(buf,"UIDL",4)) {
p=buf+4;
SKIP_WHITESPACE(p);
if(isdigit((uchar)*p)) {
if(IS_DIGIT(*p)) {
msgnum=strtoul(p, NULL, 10);
if(msgnum<1 || msgnum>msgs) {
lprintf(LOG_NOTICE,"%04d %s <%s> !INVALID message #%" PRIu32
......@@ -2428,7 +2427,7 @@ char* mimehdr_q_decode(char* buf)
for(;*p != 0; p++) {
if(*p == '=') {
p++;
if(isxdigit(*p) && isxdigit(*(p + 1))) {
if(IS_HEXDIGIT(*p) && IS_HEXDIGIT(*(p + 1))) {
uchar ch = HEX_CHAR_TO_INT(*p) << 4;
p++;
ch |= HEX_CHAR_TO_INT(*p);
......@@ -2655,7 +2654,7 @@ static int chk_received_hdr(SOCKET socket,const char* prot,const char *buf,IN_AD
if(*p==0)
break;
p2=host_name;
for(;*p && !isspace((unsigned char)*p) && p2<host_name+126;p++) {
for(;*p && !IS_WHITESPACE(*p) && p2<host_name+126;p++) {
*p2++=*p;
}
*p2=0;
......@@ -2754,7 +2753,7 @@ static char* qp_decode(char* buf)
p++;
if(*p==0) /* soft link break */
break;
if(isxdigit(*p) && isxdigit(*(p+1))) {
if(IS_HEXDIGIT(*p) && IS_HEXDIGIT(*(p+1))) {
char hex[3];
hex[0]=*p;
hex[1]=*(p+1);
......@@ -4836,7 +4835,7 @@ static void smtp_thread(void* arg)
}
if((p==alias_buf || p==name_alias_buf || startup->options&MAIL_OPT_ALLOW_RX_BY_NUMBER)
&& isdigit((uchar)*p)) {
&& IS_DIGIT(*p)) {
usernum=atoi(p); /* RX by user number */
/* verify usernum */
username(&scfg,usernum,str);
......@@ -5247,7 +5246,7 @@ void get_dns_server(char* dns_server, size_t len)
size_t count;
sprintf(dns_server,"%.*s",(int)len-1,startup->dns_server);
if(!isalnum(dns_server[0])) {
if(!IS_ALPHANUMERIC(dns_server[0])) {
if((list=getNameServerList())!=NULL) {
if((count=strListCount(list))>0) {
sprintf(dns_server,"%.*s",(int)len,list[xp_random(count)]);
......
......@@ -370,7 +370,7 @@ u_long resolve_ip(char *addr)
return((u_long)INADDR_NONE);
for(p=addr;*p;p++)
if(*p!='.' && !isdigit((uchar)*p))
if(*p!='.' && !IS_DIGIT(*p))
break;
if(!(*p))
return(inet_addr(addr));
......
......@@ -86,10 +86,10 @@ when_t DLLCALL rfc822date(char* date)
memset(&when,0,sizeof(when));
while(*p && *p<=' ') p++;
while(*p && !isdigit(*p)) p++;
while(*p && !IS_DIGIT(*p)) p++;
/* DAY */
tm.tm_mday=atoi(p);
while(*p && isdigit(*p)) p++;
while(*p && IS_DIGIT(*p)) p++;
/* MONTH */
while(*p && *p<=' ') p++;
sprintf(month,"%3.3s",p);
......@@ -125,23 +125,23 @@ when_t DLLCALL rfc822date(char* date)
else if(tm.tm_year>1900)
tm.tm_year-=1900;
while(*p && isdigit(*p)) p++;
while(*p && IS_DIGIT(*p)) p++;
/* HOUR */
while(*p && *p<=' ') p++;
tm.tm_hour=atoi(p);
while(*p && isdigit(*p)) p++;
while(*p && IS_DIGIT(*p)) p++;
/* MINUTE */
if(*p) p++;
tm.tm_min=atoi(p);
while(*p && isdigit(*p)) p++;
while(*p && IS_DIGIT(*p)) p++;
/* SECONDS */
if(*p) p++;
tm.tm_sec=atoi(p);
while(*p && isdigit(*p)) p++;
while(*p && IS_DIGIT(*p)) p++;
/* TIME ZONE */
while(*p && *p<=' ') p++;
if(*p) {
if(isdigit(*p) || *p=='-' || *p=='+') { /* [+|-]HHMM format */
if(IS_DIGIT(*p) || *p=='-' || *p=='+') { /* [+|-]HHMM format */
if(*p=='+') p++;
sprintf(str,"%.*s",*p=='-'? 3:2,p);
when.zone=atoi(str)*60;
......
......@@ -428,11 +428,11 @@ void sbbs_t::qwktonetmail(FILE *rep, char *block, char *into, uchar fromhub)
p=strrchr(to,'@'); /* Find '@' in name@addr */
if(p && !isdigit(*(p+1)) && !strchr(p,'.') && !strchr(p,':')) { /* QWKnet */
if(p && !IS_DIGIT(*(p+1)) && !strchr(p,'.') && !strchr(p,':')) { /* QWKnet */
qnet=1;
*p=0;
}
else if(p==NULL || !isdigit(*(p+1)) || !cfg.total_faddrs) {
else if(p==NULL || !IS_DIGIT(*(p+1)) || !cfg.total_faddrs) {
if(cfg.inetmail_misc&NMAIL_ALLOW) { /* Internet */
inet=1;
} else {
......
......@@ -383,7 +383,7 @@ BOOL sbbs_t::newuser()
c=0;
while(c < RAND_PASS_LEN) { /* Create random password */
useron.pass[c]=sbbs_random(43)+'0';
if(isalnum(useron.pass[c]))
if(IS_ALPHANUMERIC(useron.pass[c]))
c++;
}
useron.pass[c]=0;
......
......@@ -712,7 +712,7 @@ bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack)
for(i=0;i<(uint)g.gl_pathc;i++) { /* Copy BLT-*.* files */
fname=getfname(g.gl_pathv[i]);
padfname(fname,str);
if(isdigit(str[4]) && isdigit(str[9])) {
if(IS_DIGIT(str[4]) && IS_DIGIT(str[9])) {
SAFEPRINTF2(str,"%sQWK/%s",cfg.text_dir,fname);
SAFEPRINTF2(tmp2,"%s%s",cfg.temp_dir,fname);
mv(str,tmp2,/* copy: */TRUE);
......
......@@ -165,8 +165,8 @@ char sbbs_t::putmsgfrag(const char* buf, long* mode, long org_cols, JSObject* ob
if(mark == 0)
next = strchr(str + l + 1, str[l]);
char *blank = strstr(str + l + 1, "\n\r");
if(((l < 1 || isspace(str[l - 1]) || ispunct(str[l - 1]))
&& isalnum(str[l + 1]) && mark == 0 && next != NULL && (*(next + 1) == '\0' || isspace(*(next + 1)) || ispunct(*(next+1)))
if(((l < 1 || IS_WHITESPACE(str[l - 1]) || IS_PUNCTUATION(str[l - 1]))
&& IS_ALPHANUMERIC(str[l + 1]) && mark == 0 && next != NULL && (*(next + 1) == '\0' || IS_WHITESPACE(*(next + 1)) || IS_PUNCTUATION(*(next+1)))
&& (blank == NULL || next < blank))
|| str[l] == mark) {
if(mark == 0)
......@@ -201,7 +201,7 @@ char sbbs_t::putmsgfrag(const char* buf, long* mode, long org_cols, JSObject* ob
if(str[l+1]=='"' && !(sys_status&SS_NEST_PF) && !((*mode)&P_NOATCODES)) { /* Quote a file */
l+=2;
i=0;
while(i<(int)sizeof(tmp2)-1 && isprint((unsigned char)str[l]) && str[l]!='\\' && str[l]!='/')
while(i<(int)sizeof(tmp2)-1 && IS_PRINTABLE(str[l]) && str[l]!='\\' && str[l]!='/')
tmp2[i++]=str[l++];
if(i > 0) {
tmp2[i]=0;
......@@ -234,7 +234,7 @@ char sbbs_t::putmsgfrag(const char* buf, long* mode, long org_cols, JSObject* ob
}
else if(!((*mode)&P_NOXATTRS)
&& (cfg.sys_misc&SM_PCBOARD) && str[l]=='@' && str[l+1]=='X'
&& isxdigit((unsigned char)str[l+2]) && isxdigit((unsigned char)str[l+3])) {
&& IS_HEXDIGIT(str[l+2]) && IS_HEXDIGIT(str[l+3])) {
sprintf(tmp2,"%.2s",str+l+2);
ulong val = ahtoul(tmp2);
// @X00 saves the current color and @XFF restores that saved color
......@@ -255,15 +255,15 @@ char sbbs_t::putmsgfrag(const char* buf, long* mode, long org_cols, JSObject* ob
}
else if(!((*mode)&P_NOXATTRS)
&& (cfg.sys_misc&SM_WILDCAT) && str[l]=='@' && str[l+3]=='@'
&& isxdigit((unsigned char)str[l+1]) && isxdigit((unsigned char)str[l+2])) {
&& IS_HEXDIGIT(str[l+1]) && IS_HEXDIGIT(str[l+2])) {
sprintf(tmp2,"%.2s",str+l+1);
attr(ahtoul(tmp2));
// exatr=1;
l+=4;
}
else if(!((*mode)&P_NOXATTRS)
&& (cfg.sys_misc&SM_RENEGADE) && str[l]=='|' && isdigit((unsigned char)str[l+1])
&& isdigit((unsigned char)str[l+2]) && !(useron.misc&RIP)) {
&& (cfg.sys_misc&SM_RENEGADE) && str[l]=='|' && IS_DIGIT(str[l+1])
&& IS_DIGIT(str[l+2]) && !(useron.misc&RIP)) {
sprintf(tmp2,"%.2s",str+l+1);
i=atoi(tmp2);
if(i>=16) { /* setting background */
......@@ -278,7 +278,7 @@ char sbbs_t::putmsgfrag(const char* buf, long* mode, long org_cols, JSObject* ob
l+=3; /* Skip |xx */
}
else if(!((*mode)&P_NOXATTRS)
&& (cfg.sys_misc&SM_CELERITY) && str[l]=='|' && isalpha((unsigned char)str[l+1])
&& (cfg.sys_misc&SM_CELERITY) && str[l]=='|' && IS_ALPHA(str[l+1])
&& !(useron.misc&RIP)) {
switch(str[l+1]) {
case 'k':
......@@ -337,7 +337,7 @@ char sbbs_t::putmsgfrag(const char* buf, long* mode, long org_cols, JSObject* ob
l+=2; /* Skip |x */
} /* Skip second digit if it exists */
else if(!((*mode)&P_NOXATTRS)
&& (cfg.sys_misc&SM_WWIV) && str[l]==CTRL_C && isdigit((unsigned char)str[l+1])) {
&& (cfg.sys_misc&SM_WWIV) && str[l]==CTRL_C && IS_DIGIT(str[l+1])) {
exatr=1;
switch(str[l+1]) {
default:
......
......@@ -802,7 +802,7 @@ int sbbs_t::scanposts(uint subnum, long mode, const char *find)
domsg = true;
continue;
}
if(thread_mode && (isalpha(l) || l=='?')) {
if(thread_mode && (IS_ALPHA(l) || l=='?')) {
thread_mode = false;
domsg = true;
}
......
......@@ -50,10 +50,10 @@ char *readtext(long *line,FILE *stream,long dflt)
for(i=1,j=0;i<k && j<sizeof(str)-1;j++) {
if(buf[i]=='\\') { /* escape */
i++;
if(isdigit(buf[i])) {
if(IS_DIGIT(buf[i])) {
str[j]=atoi(buf+i); /* decimal, NOT octal */
if(isdigit(buf[++i])) /* skip up to 3 digits */
if(isdigit(buf[++i]))
if(IS_DIGIT(buf[++i])) /* skip up to 3 digits */
if(IS_DIGIT(buf[++i]))
i++;
continue;
}
......
......@@ -1723,7 +1723,7 @@ int main(int argc, char** argv)
mail_startup.options=strtoul(arg,NULL,0);
break;
case 'S': /* SMTP/SendMail */
if(isdigit(*arg)) {
if(IS_DIGIT(*arg)) {
mail_startup.smtp_port=atoi(arg);
break;
}
......@@ -1737,7 +1737,7 @@ int main(int argc, char** argv)
}
break;
case 'P': /* POP3 */
if(isdigit(*arg)) {
if(IS_DIGIT(*arg)) {
mail_startup.pop3_port=atoi(arg);
break;
}
......
......@@ -849,7 +849,7 @@ int write_flofile(const char *infile, fidoaddr_t dest, bool bundle, bool use_out
infile++;
#ifdef __unix__
if(isalpha(infile[0]) && infile[1] == ':') // Ignore "C:" prefix
if(IS_ALPHA(infile[0]) && infile[1] == ':') // Ignore "C:" prefix
infile += 2;
#endif
SAFECOPY(attachment, infile);
......@@ -2317,7 +2317,7 @@ char* process_areafix(fidoaddr_t addr, char* inbuf, const char* password, const
add_area=strListInit();
del_area=strListInit();
for(l=0;l<m;l++) {
while(*(p+l) && isspace((uchar)*(p+l))) l++;
while(*(p+l) && IS_WHITESPACE(*(p+l))) l++;
while(*(p+l)==CTRL_A) { /* Ignore kludge lines June-13-2004 */
while(*(p+l) && *(p+l)!='\r') l++;
continue;
......@@ -3107,7 +3107,7 @@ time32_t fmsgtime(const char *str)
memset(&tm,0,sizeof(tm));
tm.tm_isdst=-1; /* Do not adjust for DST */
if(isdigit((uchar)str[1])) { /* Regular format: "01 Jan 86 02:34:56" */
if(IS_DIGIT(str[1])) { /* Regular format: "01 Jan 86 02:34:56" */
tm.tm_mday=atoi(str);
sprintf(month,"%3.3s",str+3);
if(!stricmp(month,"jan"))
......@@ -6208,7 +6208,7 @@ int main(int argc, char **argv)
else {
if(strchr(argv[i],'.')!=NULL && fexist(argv[i]))
SAFECOPY(cfg.cfgfile,argv[i]);
else if(isdigit((uchar)argv[i][0]))
else if(IS_DIGIT(argv[i][0]))
nodeaddr = atofaddr(argv[i]);
else
sub_code = argv[i];
......@@ -6400,7 +6400,7 @@ int main(int argc, char **argv)
SKIP_WHITESPACE(p); /* Skip white space */
while(*p && *p!=';') {
if(!isdigit(*p)) {
if(!IS_DIGIT(*p)) {