vincent - try this on windows.

SVN revision: 76293
This commit is contained in:
Carsten Haitzler 2012-09-07 10:12:50 +00:00
parent 74f1f5eed1
commit e26ae30eb8
5 changed files with 49 additions and 43 deletions

View File

@ -664,4 +664,10 @@ extern FILE *outf; /* file written to */
extern jmp_buf errbuf; /* target of longjmp() on a fatal error */ extern jmp_buf errbuf; /* target of longjmp() on a fatal error */
#define sc_isspace(x) isspace ((int)((unsigned char)x))
#define sc_isalpha(x) isalpha ((int)((unsigned char)x))
#define sc_isdigit(x) isdigit ((int)((unsigned char)x))
#define sc_isupper(x) isupper ((int)((unsigned char)x))
#define sc_isxdigit(x) isxdigit((int)((unsigned char)x))
#endif #endif

View File

@ -489,7 +489,7 @@ sc_addtag(char *name)
/* tagname currently unknown, add it */ /* tagname currently unknown, add it */
tag = last + 1; /* guaranteed not to exist already */ tag = last + 1; /* guaranteed not to exist already */
if (isupper(*name)) if (sc_isupper(*name))
tag |= (int)FIXEDTAG; tag |= (int)FIXEDTAG;
append_constval(&tagname_tab, name, (cell) tag, 0); append_constval(&tagname_tab, name, (cell) tag, 0);
return tag; return tag;
@ -1949,7 +1949,7 @@ tag2str(char *dest, int tag)
tag &= TAGMASK; tag &= TAGMASK;
assert(tag >= 0); assert(tag >= 0);
sprintf(dest, "0%x", tag); sprintf(dest, "0%x", tag);
return isdigit(dest[1]) ? &dest[1] : dest; return sc_isdigit(dest[1]) ? &dest[1] : dest;
} }
char * char *
@ -1995,7 +1995,7 @@ parse_funcname(char *fname, int *tag1, int *tag2, char *opname)
} /* if */ } /* if */
assert(!unary || *tag1 == 0); assert(!unary || *tag1 == 0);
assert(*ptr != '\0'); assert(*ptr != '\0');
for (name = opname; !isdigit(*ptr);) for (name = opname; !sc_isdigit(*ptr);)
*name++ = *ptr++; *name++ = *ptr++;
*name = '\0'; *name = '\0';
*tag2 = (int)strtol(ptr, NULL, 16); *tag2 = (int)strtol(ptr, NULL, 16);
@ -2010,7 +2010,7 @@ funcdisplayname(char *dest, char *funcname)
constvalue *tagsym[2]; constvalue *tagsym[2];
int unary; int unary;
if (isalpha(*funcname) || *funcname == '_' || *funcname == PUBLIC_CHAR if (sc_isalpha(*funcname) || *funcname == '_' || *funcname == PUBLIC_CHAR
|| *funcname == '\0') || *funcname == '\0')
{ {
if (dest != funcname) if (dest != funcname)

View File

@ -443,9 +443,9 @@ dtoi(cell * val, char *curptr)
*val = 0; *val = 0;
ptr = curptr; ptr = curptr;
if (!isdigit(*ptr)) /* should start with digit */ if (!sc_isdigit(*ptr)) /* should start with digit */
return 0; return 0;
while (isdigit(*ptr) || *ptr == '_') while (sc_isdigit(*ptr) || *ptr == '_')
{ {
if (*ptr != '_') if (*ptr != '_')
*val = (*val * 10) + (*ptr - '0'); *val = (*val * 10) + (*ptr - '0');
@ -453,7 +453,7 @@ dtoi(cell * val, char *curptr)
} /* while */ } /* while */
if (alphanum(*ptr)) /* number must be delimited by non-alphanumerical */ if (alphanum(*ptr)) /* number must be delimited by non-alphanumerical */
return 0; return 0;
if (*ptr == '.' && isdigit(*(ptr + 1))) if (*ptr == '.' && sc_isdigit(*(ptr + 1)))
return 0; /* but a fractional part must not be present */ return 0; /* but a fractional part must not be present */
return (int)(ptr - curptr); return (int)(ptr - curptr);
} }
@ -471,18 +471,18 @@ htoi(cell * val, char *curptr)
*val = 0; *val = 0;
ptr = curptr; ptr = curptr;
if (!isdigit(*ptr)) /* should start with digit */ if (!sc_isdigit(*ptr)) /* should start with digit */
return 0; return 0;
if (*ptr == '0' && *(ptr + 1) == 'x') if (*ptr == '0' && *(ptr + 1) == 'x')
{ /* C style hexadecimal notation */ { /* C style hexadecimal notation */
ptr += 2; ptr += 2;
while (isxdigit(*ptr) || *ptr == '_') while (sc_isxdigit(*ptr) || *ptr == '_')
{ {
if (*ptr != '_') if (*ptr != '_')
{ {
assert(isxdigit(*ptr)); assert(sc_isxdigit(*ptr));
*val = *val << 4; *val = *val << 4;
if (isdigit(*ptr)) if (sc_isdigit(*ptr))
*val += (*ptr - '0'); *val += (*ptr - '0');
else else
*val += (tolower(*ptr) - 'a' + 10); *val += (tolower(*ptr) - 'a' + 10);
@ -554,9 +554,9 @@ ftoi(cell * val, char *curptr)
fnum = 0.0; fnum = 0.0;
dnum = 0L; dnum = 0L;
ptr = curptr; ptr = curptr;
if (!isdigit(*ptr)) /* should start with digit */ if (!sc_isdigit(*ptr)) /* should start with digit */
return 0; return 0;
while (isdigit(*ptr) || *ptr == '_') while (sc_isdigit(*ptr) || *ptr == '_')
{ {
if (*ptr != '_') if (*ptr != '_')
{ {
@ -568,12 +568,12 @@ ftoi(cell * val, char *curptr)
if (*ptr != '.') if (*ptr != '.')
return 0; /* there must be a period */ return 0; /* there must be a period */
ptr++; ptr++;
if (!isdigit(*ptr)) /* there must be at least one digit after the dot */ if (!sc_isdigit(*ptr)) /* there must be at least one digit after the dot */
return 0; return 0;
ffrac = 0.0; ffrac = 0.0;
fmult = 1.0; fmult = 1.0;
ignore = FALSE; ignore = FALSE;
while (isdigit(*ptr) || *ptr == '_') while (sc_isdigit(*ptr) || *ptr == '_')
{ {
if (*ptr != '_') if (*ptr != '_')
{ {
@ -605,10 +605,10 @@ ftoi(cell * val, char *curptr)
{ {
sign = 1; sign = 1;
} /* if */ } /* if */
if (!isdigit(*ptr)) /* 'e' should be followed by a digit */ if (!sc_isdigit(*ptr)) /* 'e' should be followed by a digit */
return 0; return 0;
exp = 0; exp = 0;
while (isdigit(*ptr)) while (sc_isdigit(*ptr))
{ {
exp = (exp * 10) + (*ptr - '0'); exp = (exp * 10) + (*ptr - '0');
ptr++; ptr++;
@ -1109,7 +1109,7 @@ command(void)
lptr++; lptr++;
for (i = 0; for (i = 0;
(i < (int)(sizeof(name))) && (i < (int)(sizeof(name))) &&
(isalpha(*lptr)); (sc_isalpha(*lptr));
i++, lptr++) i++, lptr++)
name[i] = *lptr; name[i] = *lptr;
name[i] = '\0'; name[i] = '\0';
@ -1171,7 +1171,7 @@ command(void)
while (*lptr <= ' ' && *lptr != '\0') while (*lptr <= ' ' && *lptr != '\0')
lptr++; lptr++;
for (i = 0; i < 40 && (isalpha(*lptr) || *lptr == '.'); i++, lptr++) for (i = 0; i < 40 && (sc_isalpha(*lptr) || *lptr == '.'); i++, lptr++)
name[i] = (char)tolower(*lptr); name[i] = (char)tolower(*lptr);
name[i] = '\0'; name[i] = '\0';
stgwrite("\t"); stgwrite("\t");
@ -1253,7 +1253,7 @@ command(void)
} /* while */ } /* while */
end = lptr; end = lptr;
/* check pattern to match */ /* check pattern to match */
if (!isalpha(*start) && *start != '_') if (!sc_isalpha(*start) && *start != '_')
{ {
error(74); /* pattern must start with an alphabetic character */ error(74); /* pattern must start with an alphabetic character */
break; break;
@ -1272,7 +1272,7 @@ command(void)
} /* while */ } /* while */
pattern[count] = '\0'; pattern[count] = '\0';
/* special case, erase trailing variable, because it could match anything */ /* special case, erase trailing variable, because it could match anything */
if (count >= 2 && isdigit(pattern[count - 1]) if (count >= 2 && sc_isdigit(pattern[count - 1])
&& pattern[count - 2] == '%') && pattern[count - 2] == '%')
pattern[count - 2] = '\0'; pattern[count - 2] = '\0';
/* find substitution string */ /* find substitution string */
@ -1313,7 +1313,7 @@ command(void)
substitution[count] = '\0'; substitution[count] = '\0';
/* check whether the definition already exists */ /* check whether the definition already exists */
for (prefixlen = 0, start = pattern; for (prefixlen = 0, start = pattern;
isalpha(*start) || isdigit(*start) || *start == '_'; sc_isalpha(*start) || sc_isdigit(*start) || *start == '_';
prefixlen++, start++) prefixlen++, start++)
/* nothing */ ; /* nothing */ ;
assert(prefixlen > 0); assert(prefixlen > 0);
@ -1484,7 +1484,7 @@ substpattern(char *line, size_t buffersize, char *pattern, char *substitution)
memset(args, 0, sizeof args); memset(args, 0, sizeof args);
/* check the length of the prefix */ /* check the length of the prefix */
for (prefixlen = 0, s = pattern; isalpha(*s) || isdigit(*s) || *s == '_'; for (prefixlen = 0, s = pattern; sc_isalpha(*s) || sc_isdigit(*s) || *s == '_';
prefixlen++, s++) prefixlen++, s++)
/* nothing */ ; /* nothing */ ;
assert(prefixlen > 0); assert(prefixlen > 0);
@ -1501,7 +1501,7 @@ substpattern(char *line, size_t buffersize, char *pattern, char *substitution)
if (*p == '%') if (*p == '%')
{ {
p++; /* skip '%' */ p++; /* skip '%' */
if (isdigit(*p)) if (sc_isdigit(*p))
{ {
arg = *p - '0'; arg = *p - '0';
assert(arg >= 0 && arg <= 9); assert(arg >= 0 && arg <= 9);
@ -1596,7 +1596,7 @@ substpattern(char *line, size_t buffersize, char *pattern, char *substitution)
/* calculate the length of the substituted string */ /* calculate the length of the substituted string */
for (e = substitution, len = 0; *e != '\0'; e++) for (e = substitution, len = 0; *e != '\0'; e++)
{ {
if (*e == '%' && isdigit(*(e + 1))) if (*e == '%' && sc_isdigit(*(e + 1)))
{ {
arg = *(e + 1) - '0'; arg = *(e + 1) - '0';
assert(arg >= 0 && arg <= 9); assert(arg >= 0 && arg <= 9);
@ -1620,7 +1620,7 @@ substpattern(char *line, size_t buffersize, char *pattern, char *substitution)
strdel(line, (int)(s - line)); strdel(line, (int)(s - line));
for (e = substitution, s = line; *e != '\0'; e++) for (e = substitution, s = line; *e != '\0'; e++)
{ {
if (*e == '%' && isdigit(*(e + 1))) if (*e == '%' && sc_isdigit(*(e + 1)))
{ {
arg = *(e + 1) - '0'; arg = *(e + 1) - '0';
assert(arg >= 0 && arg <= 9); assert(arg >= 0 && arg <= 9);
@ -1660,7 +1660,7 @@ substallpatterns(char *line, int buffersize)
/* find the start of a prefix (skip all non-alphabetic characters), /* find the start of a prefix (skip all non-alphabetic characters),
* also skip strings * also skip strings
*/ */
while (!isalpha(*start) && *start != '_' && *start != '\0') while (!sc_isalpha(*start) && *start != '_' && *start != '\0')
{ {
/* skip strings */ /* skip strings */
if (is_startstring(start)) if (is_startstring(start))
@ -1676,7 +1676,7 @@ substallpatterns(char *line, int buffersize)
/* get the prefix (length), look for a matching definition */ /* get the prefix (length), look for a matching definition */
prefixlen = 0; prefixlen = 0;
end = start; end = start;
while (isalpha(*end) || isdigit(*end) || *end == '_') while (sc_isalpha(*end) || sc_isdigit(*end) || *end == '_')
{ {
prefixlen++; prefixlen++;
end++; end++;
@ -2318,7 +2318,7 @@ litchar(char **lptr, int rawmode)
cptr += 1; cptr += 1;
break; break;
default: default:
if (isdigit(*cptr)) if (sc_isdigit(*cptr))
{ /* \ddd */ { /* \ddd */
c = 0; c = 0;
while (*cptr >= '0' && *cptr <= '9') /* decimal! */ while (*cptr >= '0' && *cptr <= '9') /* decimal! */
@ -2346,7 +2346,7 @@ litchar(char **lptr, int rawmode)
static int static int
alpha(char c) alpha(char c)
{ {
return (isalpha(c) || c == '_' || c == PUBLIC_CHAR); return (sc_isalpha(c) || c == '_' || c == PUBLIC_CHAR);
} }
/* alphanum /* alphanum
@ -2356,7 +2356,7 @@ alpha(char c)
int int
alphanum(char c) alphanum(char c)
{ {
return (alpha(c) || isdigit(c)); return (alpha(c) || sc_isdigit(c));
} }
/* The local variable table must be searched backwards, so that the deepest /* The local variable table must be searched backwards, so that the deepest
@ -2476,7 +2476,7 @@ delete_symbols(symbol * root, int level, int delete_labels,
/* for user defined operators, also remove the "prototyped" flag, as /* for user defined operators, also remove the "prototyped" flag, as
* user-defined operators *must* be declared before use * user-defined operators *must* be declared before use
*/ */
if (sym->ident == iFUNCTN && !isalpha(*sym->name) if (sym->ident == iFUNCTN && !sc_isalpha(*sym->name)
&& *sym->name != '_' && *sym->name != PUBLIC_CHAR) && *sym->name != '_' && *sym->name != PUBLIC_CHAR)
sym->usage &= ~uPROTOTYPED; sym->usage &= ~uPROTOTYPED;
root = sym; /* skip the symbol */ root = sym; /* skip the symbol */

View File

@ -134,7 +134,7 @@ align32(long *v)
static char * static char *
skipwhitespace(char *str) skipwhitespace(char *str)
{ {
while (isspace(*str)) while (sc_isspace(*str))
str++; str++;
return str; return str;
} }
@ -272,7 +272,7 @@ do_dump(FILE * fbin, char *params, cell opcode __UNUSED__)
if (fbin) if (fbin)
write_encoded(fbin, &p, 1); write_encoded(fbin, &p, 1);
num++; num++;
while (isspace(*params)) while (sc_isspace(*params))
params++; params++;
} /* while */ } /* while */
return num * sizeof(cell); return num * sizeof(cell);
@ -286,7 +286,7 @@ do_call(FILE * fbin, char *params, cell opcode)
symbol *sym; symbol *sym;
ucell p; ucell p;
for (i = 0; !isspace(*params); i++, params++) for (i = 0; !sc_isspace(*params); i++, params++)
{ {
assert(*params != '\0'); assert(*params != '\0');
assert(i < sNAMEMAX); assert(i < sNAMEMAX);
@ -339,10 +339,10 @@ do_file(FILE * fbin, char *params, cell opcode)
p = hex2long(params, &params); p = hex2long(params, &params);
/* remove leading and trailing white space from the filename */ /* remove leading and trailing white space from the filename */
while (isspace(*params)) while (sc_isspace(*params))
params++; params++;
len = strlen(params); len = strlen(params);
while (len > 0 && isspace(params[len - 1])) while (len > 0 && sc_isspace(params[len - 1]))
len--; len--;
params[len++] = '\0'; /* zero-terminate */ params[len++] = '\0'; /* zero-terminate */
while (len % sizeof(cell) != 0) while (len % sizeof(cell) != 0)
@ -368,7 +368,7 @@ do_symbol(FILE * fbin, char *params, cell opcode)
int len; int len;
unsigned char mclass, type; unsigned char mclass, type;
for (endptr = params; !isspace(*endptr) && endptr != '\0'; endptr++) for (endptr = params; !sc_isspace(*endptr) && endptr != '\0'; endptr++)
/* nothing */ ; /* nothing */ ;
assert(*endptr == ' '); assert(*endptr == ' ');
@ -1003,7 +1003,7 @@ assemble(FILE * fout, FILE * fin)
/* get to the end of the instruction (make use of the '\n' that fgets() /* get to the end of the instruction (make use of the '\n' that fgets()
* added at the end of the line; this way we will *always* drop on a * added at the end of the line; this way we will *always* drop on a
* whitespace character) */ * whitespace character) */
for (params = instr; *params != '\0' && !isspace(*params); for (params = instr; *params != '\0' && !sc_isspace(*params);
params++) params++)
/* nothing */ ; /* nothing */ ;
assert(params > instr); assert(params > instr);
@ -1039,7 +1039,7 @@ assemble(FILE * fout, FILE * fin)
/* get to the end of the instruction (make use of the '\n' that fgets() /* get to the end of the instruction (make use of the '\n' that fgets()
* added at the end of the line; this way we will *always* drop on a * added at the end of the line; this way we will *always* drop on a
* whitespace character) */ * whitespace character) */
for (params = instr; *params != '\0' && !isspace(*params); for (params = instr; *params != '\0' && !sc_isspace(*params);
params++) params++)
/* nothing */ ; /* nothing */ ;
assert(params > instr); assert(params > instr);

View File

@ -471,7 +471,7 @@ matchsequence(char *start, char *end, char *pattern,
{ {
case '%': /* new "symbol" */ case '%': /* new "symbol" */
pattern++; pattern++;
assert(isdigit(*pattern)); assert(sc_isdigit(*pattern));
var = atoi(pattern) - 1; var = atoi(pattern) - 1;
assert(var >= 0 && var < _maxoptvars); assert(var >= 0 && var < _maxoptvars);
assert(alphanum(*start)); assert(alphanum(*start));
@ -542,7 +542,7 @@ replacesequence(char *pattern, char symbols[_maxoptvars][_aliasmax + 1],
{ {
case '%': case '%':
lptr++; /* skip '%' */ lptr++; /* skip '%' */
assert(isdigit(*lptr)); assert(sc_isdigit(*lptr));
var = atoi(lptr) - 1; var = atoi(lptr) - 1;
assert(var >= 0 && var < _maxoptvars); assert(var >= 0 && var < _maxoptvars);
assert(symbols[var][0] != '\0'); /* variable should be defined */ assert(symbols[var][0] != '\0'); /* variable should be defined */
@ -575,7 +575,7 @@ replacesequence(char *pattern, char symbols[_maxoptvars][_aliasmax + 1],
case '%': case '%':
/* write out the symbol */ /* write out the symbol */
pattern++; pattern++;
assert(isdigit(*pattern)); assert(sc_isdigit(*pattern));
var = atoi(pattern) - 1; var = atoi(pattern) - 1;
assert(var >= 0 && var < _maxoptvars); assert(var >= 0 && var < _maxoptvars);
assert(symbols[var][0] != '\0'); /* variable should be defined */ assert(symbols[var][0] != '\0'); /* variable should be defined */