summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--epan/addr_resolv.c7
-rw-r--r--epan/disabled_protos.c9
-rw-r--r--epan/prefs.c21
-rw-r--r--epan/proto.c5
-rw-r--r--epan/range.c5
-rw-r--r--epan/strutil.c47
-rw-r--r--epan/uat.c5
-rw-r--r--epan/uat.h2
8 files changed, 46 insertions, 55 deletions
diff --git a/epan/addr_resolv.c b/epan/addr_resolv.c
index 626f29c1ab..8001812a41 100644
--- a/epan/addr_resolv.c
+++ b/epan/addr_resolv.c
@@ -24,7 +24,6 @@
#include "config.h"
-#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -1047,7 +1046,7 @@ parse_ether_address(const char *cp, ether_t *eth, unsigned int *mask,
for (i = 0; i < 6; i++) {
/* Get a hex number, 1 or 2 digits, no sign characters allowed. */
- if (!isxdigit((unsigned char)*cp))
+ if (!g_ascii_isxdigit(*cp))
return FALSE;
num = strtoul(cp, &p, 16);
if (p == cp)
@@ -1065,13 +1064,13 @@ parse_ether_address(const char *cp, ether_t *eth, unsigned int *mask,
return FALSE;
}
cp++; /* skip past the '/' to get to the mask */
- if (!isdigit((unsigned char)*cp))
+ if (!g_ascii_isdigit(*cp))
return FALSE; /* no sign allowed */
num = strtoul(cp, &p, 10);
if (p == cp)
return FALSE; /* failed */
cp = p; /* skip past the number */
- if (*cp != '\0' && !isspace((unsigned char)*cp))
+ if (*cp != '\0' && !g_ascii_isspace(*cp))
return FALSE; /* bogus terminator */
if (num == 0 || num >= 48)
return FALSE; /* bogus mask */
diff --git a/epan/disabled_protos.c b/epan/disabled_protos.c
index 1ccaf72f2d..1afe9c96db 100644
--- a/epan/disabled_protos.c
+++ b/epan/disabled_protos.c
@@ -24,7 +24,6 @@
#include <stdio.h>
#include <string.h>
-#include <ctype.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H
@@ -179,7 +178,7 @@ read_disabled_protos_list_file(const char *ff_path, FILE *ff,
a protocol to be disabled. */
/* Skip over leading white space, if any. */
- while ((c = getc(ff)) != EOF && isspace(c)) {
+ while ((c = getc(ff)) != EOF && g_ascii_isspace(c)) {
if (c == '\n') {
/* Blank line. */
continue;
@@ -200,7 +199,7 @@ read_disabled_protos_list_file(const char *ff_path, FILE *ff,
c = getc(ff);
if (c == EOF)
break; /* End of file, or I/O error */
- if (isspace(c))
+ if (g_ascii_isspace(c))
break; /* Trailing white space, or end of line. */
if (c == '#')
break; /* Start of comment, running to end of line. */
@@ -214,9 +213,9 @@ read_disabled_protos_list_file(const char *ff_path, FILE *ff,
prot_name_index++;
}
- if (isspace(c) && c != '\n') {
+ if (g_ascii_isspace(c) && c != '\n') {
/* Skip over trailing white space. */
- while ((c = getc(ff)) != EOF && c != '\n' && isspace(c))
+ while ((c = getc(ff)) != EOF && c != '\n' && g_ascii_isspace(c))
;
if (c != EOF && c != '\n' && c != '#') {
/* Non-white-space after the protocol name; warn about it,
diff --git a/epan/prefs.c b/epan/prefs.c
index 4e1bd18b1d..00fa01ebd9 100644
--- a/epan/prefs.c
+++ b/epan/prefs.c
@@ -24,7 +24,6 @@
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
#include <errno.h>
#ifdef HAVE_UNISTD_H
@@ -367,9 +366,8 @@ prefs_register_module_or_subtree(module_t *parent, const char *name,
* shifting, etc.
*/
for (p = name; (c = *p) != '\0'; p++)
- g_assert(isascii(c) &&
- (islower(c) || isdigit(c) || c == '_' ||
- c == '-' || c == '.'));
+ g_assert(g_ascii_islower(c) || g_ascii_isdigit(c) || c == '_' ||
+ c == '-' || c == '.');
/*
* Make sure there's not already a module with that
@@ -749,8 +747,7 @@ register_preference(module_t *module, const char *name, const char *title,
* and shouldn't require quoting, shifting, etc.
*/
for (p = name; *p != '\0'; p++)
- if (!(isascii((guchar)*p) &&
- (islower((guchar)*p) || isdigit((guchar)*p) || *p == '_' || *p == '.')))
+ if (!(g_ascii_islower(*p) || g_ascii_isdigit(*p) || *p == '_' || *p == '.'))
g_error("Preference %s.%s contains invalid characters", module->name, name);
/*
@@ -2668,7 +2665,7 @@ prefs_get_string_list(const gchar *str)
state = PRE_STRING;
slstr = (gchar *) g_malloc(sizeof(gchar) * COL_MAX_LEN);
j = 0;
- } else if (!isspace(cur_c) || state != PRE_STRING) {
+ } else if (!g_ascii_isspace(cur_c) || state != PRE_STRING) {
/* Either this isn't a white-space character, or we've started a
string (i.e., already seen a non-white-space character for that
string and put it into the string).
@@ -3324,7 +3321,7 @@ read_prefs_file(const char *pf_path, FILE *pf,
switch (state) {
case START:
- if (isalnum(got_c)) {
+ if (g_ascii_isalnum(got_c)) {
if (cur_var->len > 0) {
if (got_val) {
if (cur_val->len > 0) {
@@ -3386,7 +3383,7 @@ read_prefs_file(const char *pf_path, FILE *pf,
g_string_truncate(cur_var, 0);
g_string_append_c(cur_var, (gchar) got_c);
pline = fline;
- } else if (isspace(got_c) && cur_var->len > 0 && got_val) {
+ } else if (g_ascii_isspace(got_c) && cur_var->len > 0 && got_val) {
state = PRE_VAL;
} else if (got_c == '#') {
state = IN_SKIP;
@@ -3409,7 +3406,7 @@ read_prefs_file(const char *pf_path, FILE *pf,
}
break;
case PRE_VAL:
- if (!isspace(got_c)) {
+ if (!g_ascii_isspace(got_c)) {
state = IN_VAL;
g_string_append_c(cur_val, (gchar) got_c);
}
@@ -3487,7 +3484,7 @@ prefs_set_uat_pref(char *uat_entry) {
* as we allow it in the preferences file, we might as well
* allow it here).
*/
- while (isspace((guchar)*p))
+ while (g_ascii_isspace(*p))
p++;
if (*p == '\0') {
/*
@@ -3545,7 +3542,7 @@ prefs_set_pref(char *prefarg)
* as we allow it in the preferences file, we might as well
* allow it here).
*/
- while (isspace((guchar)*p))
+ while (g_ascii_isspace(*p))
p++;
if (*p == '\0') {
/*
diff --git a/epan/proto.c b/epan/proto.c
index 8319b4abe0..1348a61ed2 100644
--- a/epan/proto.c
+++ b/epan/proto.c
@@ -24,7 +24,6 @@
#include <stdio.h>
#include <string.h>
-#include <ctype.h>
#include <glib.h>
#include <float.h>
#include <errno.h>
@@ -4824,7 +4823,7 @@ proto_register_protocol(const char *name, const char *short_name,
const char *existing_name;
gint *key;
guint i;
- guchar c;
+ gchar c;
gboolean found_invalid;
/*
@@ -4863,7 +4862,7 @@ proto_register_protocol(const char *name, const char *short_name,
found_invalid = FALSE;
for (i = 0; filter_name[i]; i++) {
c = filter_name[i];
- if (!(islower(c) || isdigit(c) || c == '-' || c == '_' || c == '.')) {
+ if (!(g_ascii_islower(c) || g_ascii_isdigit(c) || c == '-' || c == '_' || c == '.')) {
found_invalid = TRUE;
}
}
diff --git a/epan/range.c b/epan/range.c
index 05bda35933..6783ec9382 100644
--- a/epan/range.c
+++ b/epan/range.c
@@ -27,7 +27,6 @@
#include <string.h>
#include <stdlib.h>
-#include <ctype.h>
#include <errno.h>
#include <glib.h>
@@ -146,7 +145,7 @@ range_convert_str_work(range_t **rangep, const gchar *es, guint32 max_value,
if (c == '-') {
/* Subrange starts with 1. */
range->ranges[range->nranges].low = 1;
- } else if (isdigit((unsigned char)c)) {
+ } else if (g_ascii_isdigit(c)) {
/* Subrange starts with the specified number */
errno = 0;
val = strtoul(p, &endp, 10);
@@ -192,7 +191,7 @@ range_convert_str_work(range_t **rangep, const gchar *es, guint32 max_value,
* with max_value.
*/
range->ranges[range->nranges].high = max_value;
- } else if (isdigit((unsigned char)c)) {
+ } else if (g_ascii_isdigit(c)) {
/* Subrange ends with the specified number. */
errno = 0;
val = strtoul(p, &endp, 10);
diff --git a/epan/strutil.c b/epan/strutil.c
index de52320568..53c646036d 100644
--- a/epan/strutil.c
+++ b/epan/strutil.c
@@ -24,7 +24,6 @@
#include <stdlib.h>
#include <string.h>
-#include <ctype.h>
#include <glib.h>
#include "strutil.h"
#include "emem.h"
@@ -293,7 +292,7 @@ format_text_wsp(const guchar *string, size_t len)
if (g_ascii_isprint(c)) {
fmtbuf[idx][column] = c;
column++;
- } else if (isspace(c)) {
+ } else if (g_ascii_isspace(c)) {
fmtbuf[idx][column] = ' ';
column++;
} else {
@@ -404,7 +403,7 @@ format_text_chr(const guchar *string, const size_t len, const guchar chr)
fmtbuf[idx][column] = c;
column++;
}
- else if (isspace(c))
+ else if (g_ascii_isspace(c))
{
fmtbuf[idx][column] = ' ';
column++;
@@ -432,7 +431,7 @@ gboolean
hex_str_to_bytes(const char *hex_str, GByteArray *bytes, gboolean force_separators)
{
guint8 val;
- const guchar *p, *q, *r, *s, *punct;
+ const gchar *p, *q, *r, *s, *punct;
char four_digits_first_half[3];
char four_digits_second_half[3];
char two_digits[3];
@@ -442,15 +441,15 @@ hex_str_to_bytes(const char *hex_str, GByteArray *bytes, gboolean force_separato
return FALSE;
}
g_byte_array_set_size(bytes, 0);
- p = (const guchar *)hex_str;
+ p = hex_str;
while (*p) {
q = p+1;
r = p+2;
s = p+3;
if (*q && *r && *s
- && isxdigit(*p) && isxdigit(*q) &&
- isxdigit(*r) && isxdigit(*s)) {
+ && g_ascii_isxdigit(*p) && g_ascii_isxdigit(*q) &&
+ g_ascii_isxdigit(*r) && g_ascii_isxdigit(*s)) {
four_digits_first_half[0] = *p;
four_digits_first_half[1] = *q;
four_digits_first_half[2] = '\0';
@@ -486,7 +485,7 @@ hex_str_to_bytes(const char *hex_str, GByteArray *bytes, gboolean force_separato
p = punct;
continue;
}
- else if (*q && isxdigit(*p) && isxdigit(*q)) {
+ else if (*q && g_ascii_isxdigit(*p) && g_ascii_isxdigit(*q)) {
two_digits[0] = *p;
two_digits[1] = *q;
two_digits[2] = '\0';
@@ -516,7 +515,7 @@ hex_str_to_bytes(const char *hex_str, GByteArray *bytes, gboolean force_separato
p = punct;
continue;
}
- else if (*q && isxdigit(*p) && is_byte_sep(*q)) {
+ else if (*q && g_ascii_isxdigit(*p) && is_byte_sep(*q)) {
one_digit[0] = *p;
one_digit[1] = '\0';
@@ -528,7 +527,7 @@ hex_str_to_bytes(const char *hex_str, GByteArray *bytes, gboolean force_separato
p = q + 1;
continue;
}
- else if (!*q && isxdigit(*p)) {
+ else if (!*q && g_ascii_isxdigit(*p)) {
one_digit[0] = *p;
one_digit[1] = '\0';
@@ -574,7 +573,7 @@ get_valid_byte_sep(gchar c, const guint encoding)
retval = 0;
break;
default:
- if (isxdigit(c) && (encoding & ENC_SEP_NONE))
+ if (g_ascii_isxdigit(c) && (encoding & ENC_SEP_NONE))
retval = 0;
/* anything else means we've got a failure */
break;
@@ -621,7 +620,7 @@ hex_str_to_bytes_encoding(const gchar *hex_str, GByteArray *bytes, const gchar *
};
/* we must see two hex chars at the beginning, or fail */
- if (bytes && *end && isxdigit(*end) && isxdigit(*(end+1))) {
+ if (bytes && *end && g_ascii_isxdigit(*end) && g_ascii_isxdigit(*(end+1))) {
retval = TRUE;
/* set the separator character we'll allow; if this returns a -1, it means something's
@@ -682,15 +681,15 @@ gboolean
uri_str_to_bytes(const char *uri_str, GByteArray *bytes)
{
guint8 val;
- const guchar *p;
- guchar hex_digit[HEX_DIGIT_BUF_LEN];
+ const gchar *p;
+ gchar hex_digit[HEX_DIGIT_BUF_LEN];
g_byte_array_set_size(bytes, 0);
if (! uri_str) {
return FALSE;
}
- p = (const guchar *)uri_str;
+ p = uri_str;
while (*p) {
if (!g_ascii_isprint(*p))
@@ -703,9 +702,9 @@ uri_str_to_bytes(const char *uri_str, GByteArray *bytes)
if (*p == '\0') return FALSE;
hex_digit[1] = *p;
hex_digit[2] = '\0';
- if (! isxdigit(hex_digit[0]) || ! isxdigit(hex_digit[1]))
+ if (! g_ascii_isxdigit(hex_digit[0]) || ! g_ascii_isxdigit(hex_digit[1]))
return FALSE;
- val = (guint8) strtoul((char *)hex_digit, NULL, 16);
+ val = (guint8) strtoul(hex_digit, NULL, 16);
g_byte_array_append(bytes, &val, 1);
} else {
g_byte_array_append(bytes, (const guint8 *) p, 1);
@@ -826,7 +825,7 @@ rel_oid_str_to_bytes(const char *oid_str, GByteArray *bytes, gboolean is_absolut
p = oid_str;
dot = NULL;
while (*p) {
- if (!isdigit((guchar)*p) && (*p != '.')) return FALSE;
+ if (!g_ascii_isdigit(*p) && (*p != '.')) return FALSE;
if (*p == '.') {
if (p == oid_str && is_absolute) return FALSE;
if (!*(p+1)) return FALSE;
@@ -843,7 +842,7 @@ rel_oid_str_to_bytes(const char *oid_str, GByteArray *bytes, gboolean is_absolut
subid0 = 0; /* squelch GCC complaints */
while (*p) {
subid = 0;
- while (isdigit((guchar)*p)) {
+ while (g_ascii_isdigit(*p)) {
subid *= 10;
subid += *p - '0';
p++;
@@ -977,7 +976,7 @@ convert_string_to_hex(const char *string, size_t *nbytes)
{
size_t n_bytes;
const char *p;
- guchar c;
+ gchar c;
guint8 *bytes, *q, byte_val;
n_bytes = 0;
@@ -986,11 +985,11 @@ convert_string_to_hex(const char *string, size_t *nbytes)
c = *p++;
if (c == '\0')
break;
- if (isspace(c))
+ if (g_ascii_isspace(c))
continue; /* allow white space */
if (c==':' || c=='.' || c=='-')
continue; /* skip any ':', '.', or '-' between bytes */
- if (!isxdigit(c)) {
+ if (!g_ascii_isxdigit(c)) {
/* Not a valid hex digit - fail */
return NULL;
}
@@ -1000,7 +999,7 @@ convert_string_to_hex(const char *string, size_t *nbytes)
* hex digit immediately after that hex digit.
*/
c = *p++;
- if (!isxdigit(c))
+ if (!g_ascii_isxdigit(c))
return NULL;
/* 2 hex digits = 1 byte */
@@ -1026,7 +1025,7 @@ convert_string_to_hex(const char *string, size_t *nbytes)
c = *p++;
if (c == '\0')
break;
- if (isspace(c))
+ if (g_ascii_isspace(c))
continue; /* allow white space */
if (c==':' || c=='.' || c=='-')
continue; /* skip any ':', '.', or '-' between bytes */
diff --git a/epan/uat.c b/epan/uat.c
index 48da1c214b..076ac48e5a 100644
--- a/epan/uat.c
+++ b/epan/uat.c
@@ -30,7 +30,6 @@
#include <stdio.h>
#include <string.h>
#include <errno.h>
-#include <ctype.h>
#include <stdarg.h>
#include <glib.h>
@@ -463,7 +462,7 @@ gboolean uat_fld_chk_oid(void* u1 _U_, const char* strptr, guint len, const void
}
for(i = 0; i < len; i++)
- if(!(isdigit(strptr[i]) || strptr[i] == '.')) {
+ if(!(g_ascii_isdigit(strptr[i]) || strptr[i] == '.')) {
*err = "Only digits [0-9] and \".\" allowed in an OID";
break;
}
@@ -647,7 +646,7 @@ char* uat_unesc(const char* si, guint in_len, guint* len_p) {
char c1 = *(s+1);
char c0 = *(s+2);
- if (isxdigit((guchar)c1) && isxdigit((guchar)c0)) {
+ if (g_ascii_isxdigit(c1) && g_ascii_isxdigit(c0)) {
*(p++) = (ws_xton(c1) * 0x10) + ws_xton(c0);
s += 2;
} else {
diff --git a/epan/uat.h b/epan/uat.h
index b23183a32e..3495579f96 100644
--- a/epan/uat.h
+++ b/epan/uat.h
@@ -354,7 +354,7 @@ CHK_STR_IS_DECL(isxdigit);
gboolean uat_fld_chk_str_ ## what (void* UNUSED_PARAMETER(u1), const char* strptr, guint len, const void* UNUSED_PARAMETER(u2), const void* UNUSED_PARAMETER(u3), const char** err) { \
guint i; for (i=0;i<len;i++) { \
char c = strptr[i]; \
- if (! what((int)c)) { \
+ if (! g_ascii_ ## what(c)) { \
*err = ep_strdup_printf("invalid char pos=%d value=%.2x",i,c); return FALSE; } } \
*err = NULL; return TRUE; }