From dd3b42e1ac7536e6b5445292c298b89a7fb6c605 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Wed, 18 Oct 2006 03:42:06 +0000 Subject: Replace is*() macros with our own IS*() ones. Get rid of non ANSI/ISO isascii(). --- adig.c | 4 ++-- ares__get_hostent.c | 18 +++++++++--------- ares_init.c | 32 ++++++++++++++++---------------- ares_search.c | 6 +++--- inet_net_pton.c | 17 ++++++++--------- 5 files changed, 38 insertions(+), 39 deletions(-) diff --git a/adig.c b/adig.c index 80ee7f4..fb3a432 100644 --- a/adig.c +++ b/adig.c @@ -225,7 +225,7 @@ int main(int argc, char **argv) case 'T': /* Set the TCP port number. */ - if (!isdigit((unsigned char)*optarg)) + if (!ISDIGIT(*optarg)) usage(); options.tcp_port = (unsigned short)strtol(optarg, NULL, 0); optmask |= ARES_OPT_TCP_PORT; @@ -233,7 +233,7 @@ int main(int argc, char **argv) case 'U': /* Set the UDP port number. */ - if (!isdigit((unsigned char)*optarg)) + if (!ISDIGIT(*optarg)) usage(); options.udp_port = (unsigned short)strtol(optarg, NULL, 0); optmask |= ARES_OPT_UDP_PORT; diff --git a/ares__get_hostent.c b/ares__get_hostent.c index ecfd52a..333cf50 100644 --- a/ares__get_hostent.c +++ b/ares__get_hostent.c @@ -54,7 +54,7 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host) /* Get the address part. */ p = line; - while (*p && !isspace((unsigned char)*p)) + while (*p && !ISSPACE(*p)) p++; if (!*p) continue; @@ -76,12 +76,12 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host) /* Get the canonical hostname. */ p++; - while (isspace((unsigned char)*p)) + while (ISSPACE(*p)) p++; if (!*p) continue; q = p; - while (*q && !isspace((unsigned char)*q)) + while (*q && !ISSPACE(*q)) q++; end_at_hostname = (*q == 0); *q = 0; @@ -92,13 +92,13 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host) { /* Count the aliases. */ p = q + 1; - while (isspace((unsigned char)*p)) + while (ISSPACE(*p)) p++; while (*p) { - while (*p && !isspace((unsigned char)*p)) + while (*p && !ISSPACE(*p)) p++; - while (isspace((unsigned char)*p)) + while (ISSPACE(*p)) p++; naliases++; } @@ -128,12 +128,12 @@ int ares__get_hostent(FILE *fp, int family, struct hostent **host) if (!end_at_hostname) { p = canonical + strlen(canonical) + 1; - while (isspace((unsigned char)*p)) + while (ISSPACE(*p)) p++; while (*p) { q = p; - while (*q && !isspace((unsigned char)*q)) + while (*q && !ISSPACE(*q)) q++; hostent->h_aliases[naliases] = malloc(q - p + 1); 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); hostent->h_aliases[naliases][q - p] = 0; p = q; - while (isspace((unsigned char)*p)) + while (ISSPACE(*p)) p++; naliases++; } diff --git a/ares_init.c b/ares_init.c index a0c1865..a9fa8fb 100644 --- a/ares_init.c +++ b/ares_init.c @@ -750,7 +750,7 @@ static int config_domain(ares_channel channel, char *str) /* Set a single search domain. */ q = str; - while (*q && !isspace((unsigned char)*q)) + while (*q && !ISSPACE(*q)) q++; *q = 0; return set_search(channel, str); @@ -774,9 +774,9 @@ static int config_lookup(ares_channel channel, const char *str, if (*p == *bindch) *l++ = 'b'; else *l++ = 'f'; } - while (*p && !isspace((unsigned char)*p) && (*p != ',')) + while (*p && !ISSPACE(*p) && (*p != ',')) p++; - while (*p && (isspace((unsigned char)*p) || (*p == ','))) + while (*p && (ISSPACE(*p) || (*p == ','))) p++; } *l = 0; @@ -801,7 +801,7 @@ static int config_nameserver(struct server_state **servers, int *nservers, while (more) { more = 0; - while (*p && !isspace(*p) && *p != ',') + while (*p && !ISSPACE(*p) && *p != ',') p++; if (*p) @@ -861,7 +861,7 @@ static int config_sortlist(struct apattern **sortlist, int *nsort, char ipbuf[16], ipbufpfx[32]; /* Find just the IP */ q = str; - while (*q && *q != '/' && *q != ';' && !isspace((unsigned char)*q)) + while (*q && *q != '/' && *q != ';' && !ISSPACE(*q)) q++; memcpy(ipbuf, str, (int)(q-str)); ipbuf[(int)(q-str)] = 0; @@ -869,7 +869,7 @@ static int config_sortlist(struct apattern **sortlist, int *nsort, if (*q == '/') { const char *str2 = q+1; - while (*q && *q != ';' && !isspace((unsigned char)*q)) + while (*q && *q != ';' && !ISSPACE(*q)) q++; memcpy(ipbufpfx, str, (int)(q-str)); ipbufpfx[(int)(q-str)] = 0; @@ -918,11 +918,11 @@ static int config_sortlist(struct apattern **sortlist, int *nsort, } else { - while (*q && *q != ';' && !isspace((unsigned char)*q)) + while (*q && *q != ';' && !ISSPACE(*q)) q++; } str = q; - while (isspace((unsigned char)*str)) + while (ISSPACE(*str)) str++; } @@ -948,9 +948,9 @@ static int set_search(ares_channel channel, const char *str) p = str; while (*p) { - while (*p && !isspace((unsigned char)*p)) + while (*p && !ISSPACE(*p)) p++; - while (isspace((unsigned char)*p)) + while (ISSPACE(*p)) p++; n++; } @@ -966,7 +966,7 @@ static int set_search(ares_channel channel, const char *str) { channel->ndomains = n; q = p; - while (*q && !isspace((unsigned char)*q)) + while (*q && !ISSPACE(*q)) q++; channel->domains[n] = malloc(q - p + 1); 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); channel->domains[n][q - p] = 0; p = q; - while (isspace((unsigned char)*p)) + while (ISSPACE(*p)) p++; n++; } @@ -991,7 +991,7 @@ static int set_options(ares_channel channel, const char *str) while (*p) { q = p; - while (*q && !isspace((unsigned char)*q)) + while (*q && !ISSPACE(*q)) q++; val = try_option(p, q, "ndots:"); if (val && channel->ndots == -1) @@ -1003,7 +1003,7 @@ static int set_options(ares_channel channel, const char *str) if (val && channel->tries == -1) channel->tries = atoi(val); p = q; - while (isspace((unsigned char)*p)) + while (ISSPACE(*p)) p++; } @@ -1016,10 +1016,10 @@ static char *try_config(char *s, const char *opt) size_t len; 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; s += len; - while (isspace((unsigned char)*s)) + while (ISSPACE(*s)) s++; return s; } diff --git a/ares_search.c b/ares_search.c index 099a7c7..b05b4a8 100644 --- a/ares_search.c +++ b/ares_search.c @@ -239,15 +239,15 @@ static int single_domain(ares_channel channel, const char *name, char **s) == ARES_SUCCESS) { if (strncasecmp(line, name, len) != 0 || - !isspace((unsigned char)line[len])) + !ISSPACE(line[len])) continue; p = line + len; - while (isspace((unsigned char)*p)) + while (ISSPACE(*p)) p++; if (*p) { q = p + 1; - while (*q && !isspace((unsigned char)*q)) + while (*q && !ISSPACE(*q)) q++; *s = malloc(q - p + 1); if (*s) diff --git a/inet_net_pton.c b/inet_net_pton.c index d3e672b..ef96741 100644 --- a/inet_net_pton.c +++ b/inet_net_pton.c @@ -79,14 +79,13 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size) ch = *src++; if (ch == '0' && (src[0] == 'x' || src[0] == 'X') - && isascii((unsigned char)(src[1])) - && isxdigit((unsigned char)(src[1]))) { + && ISXDIGIT(src[1])) { /* Hexadecimal: Eat nybble string. */ if (size <= 0U) goto emsgsize; dirty = 0; src++; /* skip x or X. */ - while ((ch = *src++) != '\0' && isascii(ch) && isxdigit(ch)) { + while ((ch = *src++) != '\0' && ISXDIGIT(ch)) { if (isupper(ch)) ch = tolower(ch); 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; *dst++ = (unsigned char) (tmp << 4); } - } else if (isascii(ch) && isdigit(ch)) { + } else if (ISDIGIT(ch)) { /* Decimal: eat dotted digit string. */ for (;;) { tmp = 0; @@ -117,7 +116,7 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size) if (tmp > 255) goto enoent; } while ((ch = *src++) != '\0' && - isascii(ch) && isdigit(ch)); + ISDIGIT(ch)); if (size-- <= 0U) goto emsgsize; *dst++ = (unsigned char) tmp; @@ -126,15 +125,15 @@ inet_net_pton_ipv4(const char *src, unsigned char *dst, size_t size) if (ch != '.') goto enoent; ch = *src++; - if (!isascii(ch) || !isdigit(ch)) + if (!ISDIGIT(ch)) goto enoent; } } else goto enoent; bits = -1; - if (ch == '/' && isascii((unsigned char)(src[0])) && - isdigit((unsigned char)(src[0])) && dst > odst) { + if (ch == '/' && + ISDIGIT(src[0]) && dst > odst) { /* CIDR width specifier. Nothing can follow it. */ ch = *src++; /* Skip over the /. */ 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); bits *= 10; bits += n; - } while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch)); + } while ((ch = *src++) != '\0' && ISDIGIT(ch)); if (ch != '\0') goto enoent; if (bits > 32) -- cgit v1.2.3