strcat (r, s);
for (i = 0; i < len; ++i) {
- u[i] = toupper (u[i]);
+ u[i] = CTYPE(toupper, u[i]);
}
}
return r;
/* copy while upper-casing, including trailing zero */
for (i = 0; i <= preflen; ++i) {
- optname[i + sizeof (qemu_prefix) - 1] = toupper (prefix[i]);
+ optname[i + sizeof (qemu_prefix) - 1] = CTYPE(toupper, prefix[i]);
}
strcat (optname, "_");
strcat (optname, opt->name);
if (direntry->name[i] <= ' ' || direntry->name[i] > 0x7f)
return -1;
else if (s->downcase_short_names)
- lfn->name[i] = tolower(direntry->name[i]);
+ lfn->name[i] = CTYPE(tolower,direntry->name[i]);
else
lfn->name[i] = direntry->name[i];
}
if (direntry->extension[j] <= ' ' || direntry->extension[j] > 0x7f)
return -2;
else if (s->downcase_short_names)
- lfn->name[i + j] = tolower(direntry->extension[j]);
+ lfn->name[i + j] = CTYPE(tolower,direntry->extension[j]);
else
lfn->name[i + j] = direntry->extension[j];
}
p = str;
q = val;
while (*q != '\0') {
- if (toupper(*p) != toupper(*q))
+ if (CTYPE(toupper,*p) != CTYPE(toupper,*q))
return 0;
p++;
q++;
{
if (pch != '\0') {
pch++;
- while (isspace(*pch))
+ while (CTYPE(isspace,*pch))
pch++;
}
}
*q++ = *pch;
pch++;
}
- while (isspace(*pch))
+ while (CTYPE(isspace,*pch))
pch++;
*q = 0;
ret = get_monitor_def(®, buf);
expr_error("invalid char in expression");
}
pch = p;
- while (isspace(*pch))
+ while (CTYPE(isspace,*pch))
pch++;
break;
}
*pp = pch;
return -1;
}
- while (isspace(*pch))
+ while (CTYPE(isspace,*pch))
pch++;
*pval = expr_sum();
*pp = pch;
q = buf;
p = *pp;
- while (isspace(*p))
+ while (CTYPE(isspace,*p))
p++;
if (*p == '\0') {
fail:
}
p++;
} else {
- while (*p != '\0' && !isspace(*p)) {
+ while (*p != '\0' && !CTYPE(isspace,*p)) {
if ((q - buf) < buf_size - 1) {
*q++ = *p;
}
/* extract the command name */
p = cmdline;
q = cmdname;
- while (isspace(*p))
+ while (CTYPE(isspace,*p))
p++;
if (*p == '\0')
return;
pstart = p;
- while (*p != '\0' && *p != '/' && !isspace(*p))
+ while (*p != '\0' && *p != '/' && !CTYPE(isspace,*p))
p++;
len = p - pstart;
if (len > sizeof(cmdname) - 1)
int ret;
char *str;
- while (isspace(*p))
+ while (CTYPE(isspace,*p))
p++;
if (*typestr == '?') {
typestr++;
{
int count, format, size;
- while (isspace(*p))
+ while (CTYPE(isspace,*p))
p++;
if (*p == '/') {
/* format found */
}
}
next:
- if (*p != '\0' && !isspace(*p)) {
+ if (*p != '\0' && !CTYPE(isspace,*p)) {
term_printf("invalid char in format: '%c'\n", *p);
goto fail;
}
{
int64_t val;
- while (isspace(*p))
+ while (CTYPE(isspace,*p))
p++;
if (*typestr == '?' || *typestr == '.') {
if (*typestr == '?') {
} else {
if (*p == '.') {
p++;
- while (isspace(*p))
+ while (CTYPE(isspace,*p))
p++;
has_arg = 1;
} else {
c = *typestr++;
if (c == '\0')
goto bad_type;
- while (isspace(*p))
+ while (CTYPE(isspace,*p))
p++;
has_option = 0;
if (*p == '-') {
}
}
/* check that all arguments were parsed */
- while (isspace(*p))
+ while (CTYPE(isspace,*p))
p++;
if (*p != '\0') {
term_printf("%s: extraneous characters at the end of line\n",
p = cmdline;
nb_args = 0;
for(;;) {
- while (isspace(*p))
+ while (CTYPE(isspace,*p))
p++;
if (*p == '\0')
break;
/* if the line ends with a space, it means we want to complete the
next arg */
len = strlen(cmdline);
- if (len > 0 && isspace(cmdline[len - 1])) {
+ if (len > 0 && CTYPE(isspace,cmdline[len - 1])) {
if (nb_args >= MAX_ARGS)
return;
args[nb_args++] = qemu_strdup("");
int stristart(const char *str, const char *val, const char **ptr);
time_t mktimegm(struct tm *tm);
+#define CTYPE(isfoobar,argumentchar) (isfoobar((unsigned char)(argumentchar)))
+ /* One must not pass a plain `char' to isupper, toupper, et al. If
+ * it has the top bit set (ie, is negative if your chars are
+ * signed), undefined behaviour results. The <ctype.h> functions
+ * are defined to take the value of an unsigned char, as an int.
+ * So use this macro. You may pass toupper et al for isfoobar.
+ * Do not pass EOF as a character to this macro. If you might have
+ * EOF then you ought to have it in an int representing an unsigned
+ * char, which is safe for the ctype macros directly. Or test separately.
+ * Obviously don't use this for floating point things like isnan! */
+
/* Error handling. */
void hw_error(const char *fmt, ...)
/* find first word (backwards) */
while (start > 0) {
- if (!isspace(term_cmd_buf[start])) {
+ if (!CTYPE(isspace,term_cmd_buf[start])) {
break;
}
/* find first space (backwards) */
while (start > 0) {
- if (isspace(term_cmd_buf[start])) {
+ if (CTYPE(isspace,term_cmd_buf[start])) {
++start;
break;
}
#include "dis-asm.h"
#include "host-utils.h"
+#include "qemu-common.h"
//#define PPC_DUMP_CPU
//#define PPC_DEBUG_SPR
p = name;
check_pvr:
for (i = 0; i < 8; i++) {
- if (!isxdigit(*p++))
+ if (!CTYPE(isxdigit,*p++))
break;
}
if (i == 8)
if (!p)
return -1;
p += strlen(tag);
- while (isspace(*p))
+ while (CTYPE(isspace,*p))
p++;
q = buf;
while (*p != '\0' && !strchr(stopchars, *p)) {
if (buf[0] == '\0') {
saddr->sin_addr.s_addr = 0;
} else {
- if (isdigit(buf[0])) {
+ if (CTYPE(isdigit,buf[0])) {
if (!inet_aton(buf, &saddr->sin_addr))
return -1;
} else {
if( *dev ){
ptr = dev;
- while( *ptr && !isdigit((int)*ptr) ) ptr++;
+ while( *ptr && !CTYPE(isdigit,(int)*ptr) ) ptr++;
ppa = atoi(ptr);
}