all: Don't use ctype.h macros

The ctype macros (eg, isalnum(), tolower()) are locale-dependent. Use
glib's ASCII-only versions instead.

Also, replace isascii() with g_ascii_isprint(), since isascii()
accepts control characters, which isn't what the code wanted in any of
the places where it was using it.
This commit is contained in:
Dan Winship
2012-09-25 10:44:23 -04:00
parent 74b6b9c768
commit 6878d20ac4
26 changed files with 34 additions and 60 deletions

View File

@@ -22,7 +22,6 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <nm-utils.h>
#include <nm-system-config-interface.h>
@@ -67,7 +66,7 @@ is_hex (const char *value)
if (!p)
return FALSE;
while (*p) {
if (!isxdigit (*p++))
if (!g_ascii_isxdigit (*p++))
return FALSE;
}
return TRUE;
@@ -79,7 +78,7 @@ is_ascii (const char *value)
const char *p = value;
while (*p) {
if (!isascii (*p++))
if (!g_ascii_isprint (*p++))
return FALSE;
}
return TRUE;
@@ -462,7 +461,7 @@ create_ip4_block (gchar * ip)
iblock->ip = tmp_ip4_addr.s_addr;
prefix = ip_mask[1];
i = 0;
while (i < length && isdigit (prefix[i]))
while (i < length && g_ascii_isdigit (prefix[i]))
i++;
prefix[i] = '\0';
iblock->netmask = nm_utils_ip4_prefix_to_netmask ((guint32)