From 2749384c8aaa69fbc36ce543a91a2bd725cf0fa7 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Sun, 13 Jun 2010 10:34:46 +0000 Subject: [PATCH] pass only unsigned char to isspace and the like --- src/arm/gnunet-service-arm.c | 2 +- src/fs/fs_uri.c | 10 +++++----- src/testing/testing_group.c | 6 +++--- src/topology/gnunet-daemon-topology.c | 8 ++++---- src/transport/gnunet-service-transport.c | 14 +++++++------- src/util/configuration.c | 4 ++-- src/util/program.c | 4 ++-- 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c index a298576b0..52c7dec20 100644 --- a/src/arm/gnunet-service-arm.c +++ b/src/arm/gnunet-service-arm.c @@ -382,7 +382,7 @@ start_process (struct ServiceList *sl) while (NULL != (optpos = strstr (options, "$"))) { optend = optpos + 1; - while (isupper (*optend)) optend++; + while (isupper ( (unsigned char) *optend)) optend++; b = *optend; if ('\0' == b) next = ""; diff --git a/src/fs/fs_uri.c b/src/fs/fs_uri.c index 5ddb48f2a..95a161370 100644 --- a/src/fs/fs_uri.c +++ b/src/fs/fs_uri.c @@ -927,7 +927,7 @@ canonicalize_keyword (const char *in) rpos = in; while ('\0' != *rpos) { - switch (tolower(*rpos)) + switch (tolower( (unsigned char) *rpos)) { case 'a': case 'e': @@ -962,7 +962,7 @@ canonicalize_keyword (const char *in) case 'y': case 'z': /* convert characters listed above to lower case */ - *wpos = tolower(*rpos); + *wpos = tolower( (unsigned char)*rpos); wpos++; case '!': case '.': @@ -1149,7 +1149,7 @@ GNUNET_FS_uri_ksk_create (const char *keywords, pos = searchString; while ('\0' != *pos) { - if ((saw_quote == 0) && (isspace (*pos))) + if ((saw_quote == 0) && (isspace ((unsigned char) *pos))) { inWord = 0; } @@ -1180,7 +1180,7 @@ GNUNET_FS_uri_ksk_create (const char *keywords, pos = searchString; while ('\0' != *pos) { - if ((saw_quote == 0) && (isspace (*pos))) + if ((saw_quote == 0) && (isspace ( (unsigned char) *pos))) { inWord = 0; *pos = '\0'; @@ -1573,7 +1573,7 @@ GNUNET_FS_uri_ksk_create_from_meta_data (const struct GNUNET_CONTAINER_MetaData static int needs_percent (char c) { - return (!((isalnum (c)) || + return (!((isalnum ( (unsigned char) c)) || (c == '-') || (c == '_') || (c == '.') || (c == '~'))); } diff --git a/src/testing/testing_group.c b/src/testing/testing_group.c index f4057e6d1..32af2efa9 100644 --- a/src/testing/testing_group.c +++ b/src/testing/testing_group.c @@ -2542,12 +2542,12 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, { off = 2; /* skip leading spaces */ - while ((0 != *hostnames) && (isspace (*hostnames))) + while ((0 != *hostnames) && (isspace ( (unsigned char) *hostnames))) hostnames++; rpos = hostnames; while ('\0' != *rpos) { - if (isspace (*rpos)) + if (isspace ( (unsigned char) *rpos)) off++; rpos++; } @@ -2557,7 +2557,7 @@ GNUNET_TESTING_daemons_start (struct GNUNET_SCHEDULER_Handle *sched, pos = start; while ('\0' != *pos) { - if (isspace (*pos)) + if (isspace ( (unsigned char) *pos)) { *pos = '\0'; if (strlen (start) > 0) diff --git a/src/topology/gnunet-daemon-topology.c b/src/topology/gnunet-daemon-topology.c index 8c31fea58..33eda8a0d 100644 --- a/src/topology/gnunet-daemon-topology.c +++ b/src/topology/gnunet-daemon-topology.c @@ -1100,19 +1100,19 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) } entries_found = 0; pos = 0; - while ((pos < frstat.st_size) && isspace (data[pos])) + while ((pos < frstat.st_size) && isspace ( (unsigned char) data[pos])) pos++; while ((frstat.st_size >= sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)) && (pos <= frstat.st_size - sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded))) { memcpy (&enc, &data[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); - if (!isspace (enc.encoding[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1])) + if (!isspace ( (unsigned char) enc.encoding[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1])) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Syntax error in topology specification at offset %llu, skipping bytes.\n"), (unsigned long long) pos); pos++; - while ((pos < frstat.st_size) && (!isspace (data[pos]))) + while ((pos < frstat.st_size) && (!isspace ( (unsigned char) data[pos]))) pos++; continue; } @@ -1146,7 +1146,7 @@ read_friends_file (const struct GNUNET_CONFIGURATION_Handle *cfg) } } pos = pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded); - while ((pos < frstat.st_size) && isspace (data[pos])) + while ((pos < frstat.st_size) && isspace ( (unsigned char) data[pos])) pos++; } GNUNET_free (data); diff --git a/src/transport/gnunet-service-transport.c b/src/transport/gnunet-service-transport.c index fd47130a1..4ad9f2339 100644 --- a/src/transport/gnunet-service-transport.c +++ b/src/transport/gnunet-service-transport.c @@ -1054,13 +1054,13 @@ read_blacklist_file (const struct GNUNET_CONFIGURATION_Handle *cfg) } entries_found = 0; pos = 0; - while ((pos < frstat.st_size) && isspace (data[pos])) + while ((pos < frstat.st_size) && isspace ( (unsigned char) data[pos])) pos++; while ((frstat.st_size >= sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)) && (pos <= frstat.st_size - sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded))) { colon_pos = pos; - while ((colon_pos < frstat.st_size) && (data[colon_pos] != ':') && !isspace (data[colon_pos])) + while ((colon_pos < frstat.st_size) && (data[colon_pos] != ':') && !isspace ( (unsigned char) data[colon_pos])) colon_pos++; if (colon_pos >= frstat.st_size) @@ -1073,13 +1073,13 @@ read_blacklist_file (const struct GNUNET_CONFIGURATION_Handle *cfg) return; } - if (isspace(data[colon_pos])) + if (isspace( (unsigned char) data[colon_pos])) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Syntax error in blacklist file at offset %llu, skipping bytes.\n"), (unsigned long long) colon_pos); pos = colon_pos; - while ((pos < frstat.st_size) && isspace (data[pos])) + while ((pos < frstat.st_size) && isspace ( (unsigned char) data[pos])) pos++; continue; } @@ -1104,13 +1104,13 @@ read_blacklist_file (const struct GNUNET_CONFIGURATION_Handle *cfg) transport_name); memcpy (&enc, &data[pos], sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded)); - if (!isspace (enc.encoding[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1])) + if (!isspace ( (unsigned char) enc.encoding[sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded) - 1])) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, _("Syntax error in blacklist file at offset %llu, skipping bytes.\n"), (unsigned long long) pos); pos++; - while ((pos < frstat.st_size) && (!isspace (data[pos]))) + while ((pos < frstat.st_size) && (!isspace ( (unsigned char) data[pos]))) pos++; GNUNET_free_non_null(transport_name); continue; @@ -1145,7 +1145,7 @@ read_blacklist_file (const struct GNUNET_CONFIGURATION_Handle *cfg) } pos = pos + sizeof (struct GNUNET_CRYPTO_HashAsciiEncoded); GNUNET_free_non_null(transport_name); - while ((pos < frstat.st_size) && isspace (data[pos])) + while ((pos < frstat.st_size) && isspace ( (unsigned char) data[pos])) pos++; } GNUNET_free (data); diff --git a/src/util/configuration.c b/src/util/configuration.c index d033e0a72..b8b6e49cd 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c @@ -204,7 +204,7 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, if (emptyline == 1) continue; /* remove tailing whitespace */ - for (i = strlen (line) - 1; (i >= 0) && (isspace (line[i])); i--) + for (i = strlen (line) - 1; (i >= 0) && (isspace ( (unsigned char) line[i])); i--) line[i] = '\0'; if (1 == sscanf (line, "@INLINE@ %191[^\n]", value)) { @@ -223,7 +223,7 @@ GNUNET_CONFIGURATION_parse (struct GNUNET_CONFIGURATION_Handle *cfg, /* tag = value */ /* Strip LF */ i = strlen (value) - 1; - while ((i >= 0) && (isspace (value[i]))) + while ((i >= 0) && (isspace ( (unsigned char) value[i]))) value[i--] = '\0'; /* remove quotes */ i = 0; diff --git a/src/util/program.c b/src/util/program.c index 145d97a57..bbedc05d0 100644 --- a/src/util/program.c +++ b/src/util/program.c @@ -102,9 +102,9 @@ cmd_sorter (__const void *a1, __const void *a2) { __const struct GNUNET_GETOPT_CommandLineOption *c1 = a1; __const struct GNUNET_GETOPT_CommandLineOption *c2 = a2; - if (toupper (c1->shortName) > toupper (c2->shortName)) + if (toupper ( (unsigned char) c1->shortName) > toupper ( (unsigned char) c2->shortName)) return 1; - if (toupper (c1->shortName) < toupper (c2->shortName)) + if (toupper ( (unsigned char) c1->shortName) < toupper ( (unsigned char) c2->shortName)) return -1; if (c1->shortName > c2->shortName) return 1; -- 2.25.1