aboutsummaryrefslogtreecommitdiff
path: root/gdbsupport
diff options
context:
space:
mode:
authorAndrew Burgess <andrew.burgess@embecosm.com>2020-11-20 17:23:03 +0000
committerAndrew Burgess <andrew.burgess@embecosm.com>2020-12-11 22:04:28 +0000
commit966484941738b7a474fb7e4fe29eb5693fc9096c (patch)
tree122e6dd4b2f7f7fe516f85ffc5db8aa54948494f /gdbsupport
parent94ba44a68dccb5fa2a0a40a52efebdd1faeae43d (diff)
downloadgdb-966484941738b7a474fb7e4fe29eb5693fc9096c.zip
gdb-966484941738b7a474fb7e4fe29eb5693fc9096c.tar.gz
gdb-966484941738b7a474fb7e4fe29eb5693fc9096c.tar.bz2
gdbsupport: make use of safe-ctype functions from libiberty
Make use of the safe-ctype replacements for the standard ctype character checking functions in gdbsupport/common-utils.cc. The gdbsupport library is included into both gdb and gdbserver, and on the gdbserver side there are two targets, gdbserver itself, and also libinproctrace.so. libiberty was already being included in the gdbserver link command, but was missing from the libinproctrace.so link. As a result, after changing gdbsupport/common-utils.cc to depend on libiberty, libinproctrace.so would no longer link until I modified its link line. gdbserver/ChangeLog: * Makefile.in (IPA_LIB): Include libiberty library. gdbsupport/ChangeLog: * gdbsupport/common-utils.cc: Change 'ctype.h' include to 'safe-ctype.h'. (extract_string_maybe_quoted): Use safe-ctype function versions. (is_digit_in_base): Likewise. (digit_to_int): Likewise. (strtoulst): Likewise. (skip_spaces): Likewise. (skip_to_space): Likewise.
Diffstat (limited to 'gdbsupport')
-rw-r--r--gdbsupport/ChangeLog11
-rw-r--r--gdbsupport/common-utils.cc22
2 files changed, 22 insertions, 11 deletions
diff --git a/gdbsupport/ChangeLog b/gdbsupport/ChangeLog
index 6be1f24..cc21b0b 100644
--- a/gdbsupport/ChangeLog
+++ b/gdbsupport/ChangeLog
@@ -1,3 +1,14 @@
+2020-12-11 Andrew Burgess <andrew.burgess@embecosm.com>
+
+ * gdbsupport/common-utils.cc: Change 'ctype.h' include to
+ 'safe-ctype.h'.
+ (extract_string_maybe_quoted): Use safe-ctype function versions.
+ (is_digit_in_base): Likewise.
+ (digit_to_int): Likewise.
+ (strtoulst): Likewise.
+ (skip_spaces): Likewise.
+ (skip_to_space): Likewise.
+
2020-12-11 Simon Marchi <simon.marchi@polymtl.ca>
* common-debug.h (debug_prefixed_printf_cond): New.
diff --git a/gdbsupport/common-utils.cc b/gdbsupport/common-utils.cc
index b5e4d29..4f5c26d 100644
--- a/gdbsupport/common-utils.cc
+++ b/gdbsupport/common-utils.cc
@@ -20,7 +20,7 @@
#include "common-defs.h"
#include "common-utils.h"
#include "host-defs.h"
-#include <ctype.h>
+#include "safe-ctype.h"
void *
xzalloc (size_t size)
@@ -177,7 +177,7 @@ extract_string_maybe_quoted (const char **arg)
/* Parse p similarly to gdb_argv buildargv function. */
while (*p != '\0')
{
- if (isspace (*p) && !squote && !dquote && !bsquote)
+ if (ISSPACE (*p) && !squote && !dquote && !bsquote)
break;
else
{
@@ -230,21 +230,21 @@ extract_string_maybe_quoted (const char **arg)
static int
is_digit_in_base (unsigned char digit, int base)
{
- if (!isalnum (digit))
+ if (!ISALNUM (digit))
return 0;
if (base <= 10)
- return (isdigit (digit) && digit < base + '0');
+ return (ISDIGIT (digit) && digit < base + '0');
else
- return (isdigit (digit) || tolower (digit) < base - 10 + 'a');
+ return (ISDIGIT (digit) || TOLOWER (digit) < base - 10 + 'a');
}
static int
digit_to_int (unsigned char c)
{
- if (isdigit (c))
+ if (ISDIGIT (c))
return c - '0';
else
- return tolower (c) - 'a' + 10;
+ return TOLOWER (c) - 'a' + 10;
}
/* As for strtoul, but for ULONGEST results. */
@@ -258,7 +258,7 @@ strtoulst (const char *num, const char **trailer, int base)
int i = 0;
/* Skip leading whitespace. */
- while (isspace (num[i]))
+ while (ISSPACE (num[i]))
i++;
/* Handle prefixes. */
@@ -325,7 +325,7 @@ skip_spaces (char *chp)
{
if (chp == NULL)
return NULL;
- while (*chp && isspace (*chp))
+ while (*chp && ISSPACE (*chp))
chp++;
return chp;
}
@@ -337,7 +337,7 @@ skip_spaces (const char *chp)
{
if (chp == NULL)
return NULL;
- while (*chp && isspace (*chp))
+ while (*chp && ISSPACE (*chp))
chp++;
return chp;
}
@@ -349,7 +349,7 @@ skip_to_space (const char *chp)
{
if (chp == NULL)
return NULL;
- while (*chp && !isspace (*chp))
+ while (*chp && !ISSPACE (*chp))
chp++;
return chp;
}