Replace is*() macros with our own IS*() ones.

Get rid of non ANSI/ISO isascii().
This commit is contained in:
Yang Tse 2006-10-18 03:42:06 +00:00
parent 71c6335293
commit 9c1ad0f9f7
5 changed files with 38 additions and 39 deletions

View File

@ -225,7 +225,7 @@ int main(int argc, char **argv)
case 'T': case 'T':
/* Set the TCP port number. */ /* Set the TCP port number. */
if (!isdigit((unsigned char)*optarg)) if (!ISDIGIT(*optarg))
usage(); usage();
options.tcp_port = (unsigned short)strtol(optarg, NULL, 0); options.tcp_port = (unsigned short)strtol(optarg, NULL, 0);
optmask |= ARES_OPT_TCP_PORT; optmask |= ARES_OPT_TCP_PORT;
@ -233,7 +233,7 @@ int main(int argc, char **argv)
case 'U': case 'U':
/* Set the UDP port number. */ /* Set the UDP port number. */
if (!isdigit((unsigned char)*optarg)) if (!ISDIGIT(*optarg))
usage(); usage();
options.udp_port = (unsigned short)strtol(optarg, NULL, 0); options.udp_port = (unsigned short)strtol(optarg, NULL, 0);
optmask |= ARES_OPT_UDP_PORT; optmask |= ARES_OPT_UDP_PORT;

View File

@ -54,7 +54,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
/* Get the address part. */ /* Get the address part. */
p = line; p = line;
while (*p && !isspace((unsigned char)*p)) while (*p && !ISSPACE(*p))
p++; p++;
if (!*p) if (!*p)
continue; continue;
@ -76,12 +76,12 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
/* Get the canonical hostname. */ /* Get the canonical hostname. */
p++; p++;
while (isspace((unsigned char)*p)) while (ISSPACE(*p))
p++; p++;
if (!*p) if (!*p)
continue; continue;
q = p; q = p;
while (*q && !isspace((unsigned char)*q)) while (*q && !ISSPACE(*q))
q++; q++;
end_at_hostname = (*q == 0); end_at_hostname = (*q == 0);
*q = 0; *q = 0;
@ -92,13 +92,13 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
{ {
/* Count the aliases. */ /* Count the aliases. */
p = q + 1; p = q + 1;
while (isspace((unsigned char)*p)) while (ISSPACE(*p))
p++; p++;
while (*p) while (*p)
{ {
while (*p && !isspace((unsigned char)*p)) while (*p && !ISSPACE(*p))
p++; p++;
while (isspace((unsigned char)*p)) while (ISSPACE(*p))
p++; p++;
naliases++; naliases++;
} }
@ -128,12 +128,12 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
if (!end_at_hostname) if (!end_at_hostname)
{ {
p = canonical + strlen(canonical) + 1; p = canonical + strlen(canonical) + 1;
while (isspace((unsigned char)*p)) while (ISSPACE(*p))
p++; p++;
while (*p) while (*p)
{ {
q = p; q = p;
while (*q && !isspace((unsigned char)*q)) while (*q && !ISSPACE(*q))
q++; q++;
hostent->h_aliases[naliases] = malloc(q - p + 1); hostent->h_aliases[naliases] = malloc(q - p + 1);
if (hostent->h_aliases[naliases] == NULL) if (hostent->h_aliases[naliases] == NULL)
@ -141,7 +141,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host)
memcpy(hostent->h_aliases[naliases], p, q - p); memcpy(hostent->h_aliases[naliases], p, q - p);
hostent->h_aliases[naliases][q - p] = 0; hostent->h_aliases[naliases][q - p] = 0;
p = q; p = q;
while (isspace((unsigned char)*p)) while (ISSPACE(*p))
p++; p++;
naliases++; naliases++;
} }

View File

@ -750,7 +750,7 @@ static int config_domain(ares_channel channel, char *str)
/* Set a single search domain. */ /* Set a single search domain. */
q = str; q = str;
while (*q && !isspace((unsigned char)*q)) while (*q && !ISSPACE(*q))
q++; q++;
*q = 0; *q = 0;
return set_search(channel, str); return set_search(channel, str);
@ -774,9 +774,9 @@ static int config_lookup(ares_channel channel, const char *str,
if (*p == *bindch) *l++ = 'b'; if (*p == *bindch) *l++ = 'b';
else *l++ = 'f'; else *l++ = 'f';
} }
while (*p && !isspace((unsigned char)*p) && (*p != ',')) while (*p && !ISSPACE(*p) && (*p != ','))
p++; p++;
while (*p && (isspace((unsigned char)*p) || (*p == ','))) while (*p && (ISSPACE(*p) || (*p == ',')))
p++; p++;
} }
*l = 0; *l = 0;
@ -801,7 +801,7 @@ static int config_nameserver(struct server_state **servers, int *nservers,
while (more) while (more)
{ {
more = 0; more = 0;
while (*p && !isspace(*p) && *p != ',') while (*p && !ISSPACE(*p) && *p != ',')
p++; p++;
if (*p) if (*p)
@ -861,7 +861,7 @@ static int config_sortlist(struct apattern **sortlist, int *nsort,
char ipbuf[16], ipbufpfx[32]; char ipbuf[16], ipbufpfx[32];
/* Find just the IP */ /* Find just the IP */
q = str; q = str;
while (*q && *q != '/' && *q != ';' && !isspace((unsigned char)*q)) while (*q && *q != '/' && *q != ';' && !ISSPACE(*q))
q++; q++;
memcpy(ipbuf, str, (int)(q-str)); memcpy(ipbuf, str, (int)(q-str));
ipbuf[(int)(q-str)] = 0; ipbuf[(int)(q-str)] = 0;
@ -869,7 +869,7 @@ static int config_sortlist(struct apattern **sortlist, int *nsort,
if (*q == '/') if (*q == '/')
{ {
const char *str2 = q+1; const char *str2 = q+1;
while (*q && *q != ';' && !isspace((unsigned char)*q)) while (*q && *q != ';' && !ISSPACE(*q))
q++; q++;
memcpy(ipbufpfx, str, (int)(q-str)); memcpy(ipbufpfx, str, (int)(q-str));
ipbufpfx[(int)(q-str)] = 0; ipbufpfx[(int)(q-str)] = 0;
@ -918,11 +918,11 @@ static int config_sortlist(struct apattern **sortlist, int *nsort,
} }
else else
{ {
while (*q && *q != ';' && !isspace((unsigned char)*q)) while (*q && *q != ';' && !ISSPACE(*q))
q++; q++;
} }
str = q; str = q;
while (isspace((unsigned char)*str)) while (ISSPACE(*str))
str++; str++;
} }
@ -948,9 +948,9 @@ static int set_search(ares_channel channel, const char *str)
p = str; p = str;
while (*p) while (*p)
{ {
while (*p && !isspace((unsigned char)*p)) while (*p && !ISSPACE(*p))
p++; p++;
while (isspace((unsigned char)*p)) while (ISSPACE(*p))
p++; p++;
n++; n++;
} }
@ -966,7 +966,7 @@ static int set_search(ares_channel channel, const char *str)
{ {
channel->ndomains = n; channel->ndomains = n;
q = p; q = p;
while (*q && !isspace((unsigned char)*q)) while (*q && !ISSPACE(*q))
q++; q++;
channel->domains[n] = malloc(q - p + 1); channel->domains[n] = malloc(q - p + 1);
if (!channel->domains[n]) if (!channel->domains[n])
@ -974,7 +974,7 @@ static int set_search(ares_channel channel, const char *str)
memcpy(channel->domains[n], p, q - p); memcpy(channel->domains[n], p, q - p);
channel->domains[n][q - p] = 0; channel->domains[n][q - p] = 0;
p = q; p = q;
while (isspace((unsigned char)*p)) while (ISSPACE(*p))
p++; p++;
n++; n++;
} }
@ -991,7 +991,7 @@ static int set_options(ares_channel channel, const char *str)
while (*p) while (*p)
{ {
q = p; q = p;
while (*q && !isspace((unsigned char)*q)) while (*q && !ISSPACE(*q))
q++; q++;
val = try_option(p, q, "ndots:"); val = try_option(p, q, "ndots:");
if (val && channel->ndots == -1) if (val && channel->ndots == -1)
@ -1003,7 +1003,7 @@ static int set_options(ares_channel channel, const char *str)
if (val && channel->tries == -1) if (val && channel->tries == -1)
channel->tries = atoi(val); channel->tries = atoi(val);
p = q; p = q;
while (isspace((unsigned char)*p)) while (ISSPACE(*p))
p++; p++;
} }
@ -1016,10 +1016,10 @@ static char *try_config(char *s, const char *opt)
size_t len; size_t len;
len = strlen(opt); len = strlen(opt);
if (strncmp(s, opt, len) != 0 || !isspace((unsigned char)s[len])) if (strncmp(s, opt, len) != 0 || !ISSPACE(s[len]))
return NULL; return NULL;
s += len; s += len;
while (isspace((unsigned char)*s)) while (ISSPACE(*s))
s++; s++;
return s; return s;
} }

View File

@ -239,15 +239,15 @@ static int single_domain(ares_channel channel, const char *name, char **s)
== ARES_SUCCESS) == ARES_SUCCESS)
{ {
if (strncasecmp(line, name, len) != 0 || if (strncasecmp(line, name, len) != 0 ||
!isspace((unsigned char)line[len])) !ISSPACE(line[len]))
continue; continue;
p = line + len; p = line + len;
while (isspace((unsigned char)*p)) while (ISSPACE(*p))
p++; p++;
if (*p) if (*p)
{ {
q = p + 1; q = p + 1;
while (*q && !isspace((unsigned char)*q)) while (*q && !ISSPACE(*q))
q++; q++;
*s = malloc(q - p + 1); *s = malloc(q - p + 1);
if (*s) if (*s)

View File

@ -79,14 +79,13 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
ch = *src++; ch = *src++;
if (ch == '0' && (src[0] == 'x' || src[0] == 'X') if (ch == '0' && (src[0] == 'x' || src[0] == 'X')
&& isascii((unsigned char)(src[1])) && ISXDIGIT(src[1])) {
&& isxdigit((unsigned char)(src[1]))) {
/* Hexadecimal: Eat nybble string. */ /* Hexadecimal: Eat nybble string. */
if (size <= 0U) if (size <= 0U)
goto emsgsize; goto emsgsize;
dirty = 0; dirty = 0;
src++; /* skip x or X. */ src++; /* skip x or X. */
while ((ch = *src++) != '\0' && isascii(ch) && isxdigit(ch)) { while ((ch = *src++) != '\0' && ISXDIGIT(ch)) {
if (isupper(ch)) if (isupper(ch))
ch = tolower(ch); ch = tolower(ch);
n = (int)(strchr(xdigits, ch) - xdigits); n = (int)(strchr(xdigits, ch) - xdigits);
@ -106,7 +105,7 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
goto emsgsize; goto emsgsize;
*dst++ = (unsigned char) (tmp << 4); *dst++ = (unsigned char) (tmp << 4);
} }
} else if (isascii(ch) && isdigit(ch)) { } else if (ISDIGIT(ch)) {
/* Decimal: eat dotted digit string. */ /* Decimal: eat dotted digit string. */
for (;;) { for (;;) {
tmp = 0; tmp = 0;
@ -117,7 +116,7 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
if (tmp > 255) if (tmp > 255)
goto enoent; goto enoent;
} while ((ch = *src++) != '\0' && } while ((ch = *src++) != '\0' &&
isascii(ch) && isdigit(ch)); ISDIGIT(ch));
if (size-- <= 0U) if (size-- <= 0U)
goto emsgsize; goto emsgsize;
*dst++ = (unsigned char) tmp; *dst++ = (unsigned char) tmp;
@ -126,15 +125,15 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
if (ch != '.') if (ch != '.')
goto enoent; goto enoent;
ch = *src++; ch = *src++;
if (!isascii(ch) || !isdigit(ch)) if (!ISDIGIT(ch))
goto enoent; goto enoent;
} }
} else } else
goto enoent; goto enoent;
bits = -1; bits = -1;
if (ch == '/' && isascii((unsigned char)(src[0])) && if (ch == '/' &&
isdigit((unsigned char)(src[0])) && dst > odst) { ISDIGIT(src[0]) && dst > odst) {
/* CIDR width specifier. Nothing can follow it. */ /* CIDR width specifier. Nothing can follow it. */
ch = *src++; /* Skip over the /. */ ch = *src++; /* Skip over the /. */
bits = 0; bits = 0;
@ -142,7 +141,7 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size)
n = (int)(strchr(digits, ch) - digits); n = (int)(strchr(digits, ch) - digits);
bits *= 10; bits *= 10;
bits += n; bits += n;
} while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch)); } while ((ch = *src++) != '\0' && ISDIGIT(ch));
if (ch != '\0') if (ch != '\0')
goto enoent; goto enoent;
if (bits > 32) if (bits > 32)