diff options
author | Tom Tromey <tromey@adacore.com> | 2025-08-04 10:39:02 -0600 |
---|---|---|
committer | Tom Tromey <tromey@adacore.com> | 2025-09-09 11:59:04 -0600 |
commit | 3719472095d25d799ed269f36034006c79460090 (patch) | |
tree | f910dab837d83fa21aed9c596d7e6d076c9b0395 | |
parent | 15e11aac9cccfe38e0afaa07af55bb835e39789c (diff) | |
download | binutils-3719472095d25d799ed269f36034006c79460090.zip binutils-3719472095d25d799ed269f36034006c79460090.tar.gz binutils-3719472095d25d799ed269f36034006c79460090.tar.bz2 |
Use gnulib c-ctype module in gdb
PR ada/33217 points out that gdb incorrectly calls the <ctype.h>
functions. In particular, gdb feels free to pass a 'char' like:
char *str = ...;
... isdigit (*str)
This is incorrect as isdigit only accepts EOF and values that can be
represented as 'unsigned char' -- that is, a cast is needed here to
avoid undefined behavior when 'char' is signed and a character in the
string might be sign-extended. (As an aside, I think this API seems
obviously bad, but unfortunately this is what the standard says, and
some systems check this.)
Rather than adding casts everywhere, this changes all the code in gdb
that uses any <ctype.h> API to instead call the corresponding c-ctype
function.
Now, c-ctype has some limitations compared to <ctype.h>. It works as
if the C locale is in effect, so in theory some non-ASCII characters
may be misclassified. This would only affect a subset of character
sets, though, and in most places I think ASCII is sufficient -- for
example the many places in gdb that check for whitespace.
Furthermore, in practice most users are using UTF-8-based locales,
where these functions aren't really informative for non-ASCII
characters anyway; see the existing workarounds in gdb/c-support.h.
Note that safe-ctype.h cannot be used because it causes conflicts with
readline.h. And, we canot poison the <ctype.h> identifiers as this
provokes errors from some libstdc++ headers.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33217
Approved-By: Simon Marchi <simon.marchi@efficios.com>
112 files changed, 312 insertions, 401 deletions
diff --git a/gdb/aarch64-linux-tdep.c b/gdb/aarch64-linux-tdep.c index 76bde85..048be4f 100644 --- a/gdb/aarch64-linux-tdep.c +++ b/gdb/aarch64-linux-tdep.c @@ -47,7 +47,6 @@ #include "parser-defs.h" #include "user-regs.h" #include "xml-syscall.h" -#include <ctype.h> #include "record-full.h" #include "linux-record.h" @@ -1749,9 +1748,9 @@ aarch64_linux_core_read_description (struct gdbarch *gdbarch, static int aarch64_stap_is_single_operand (struct gdbarch *gdbarch, const char *s) { - return (*s == '#' || isdigit (*s) /* Literal number. */ + return (*s == '#' || c_isdigit (*s) /* Literal number. */ || *s == '[' /* Register indirection. */ - || isalpha (*s)); /* Register value. */ + || c_isalpha (*s)); /* Register value. */ } /* This routine is used to parse a special token in AArch64's assembly. @@ -1782,7 +1781,7 @@ aarch64_stap_parse_special_token (struct gdbarch *gdbarch, start = tmp; /* Register name. */ - while (isalnum (*tmp)) + while (c_isalnum (*tmp)) ++tmp; if (*tmp != ',') @@ -1810,7 +1809,7 @@ aarch64_stap_parse_special_token (struct gdbarch *gdbarch, else if (*tmp == '+') ++tmp; - if (!isdigit (*tmp)) + if (!c_isdigit (*tmp)) return {}; displacement = strtol (tmp, &endp, 10); diff --git a/gdb/ada-exp.y b/gdb/ada-exp.y index 7ac103d..ed5694e 100644 --- a/gdb/ada-exp.y +++ b/gdb/ada-exp.y @@ -35,7 +35,6 @@ %{ -#include <ctype.h> #include "gdbsupport/unordered_map.h" #include "expression.h" #include "value.h" @@ -1380,7 +1379,7 @@ write_object_renaming (struct parser_state *par_state, [[fallthrough]]; case 'S': renaming_expr += 1; - if (isdigit (*renaming_expr)) + if (c_isdigit (*renaming_expr)) { char *next; long val = strtol (renaming_expr, &next, 10); @@ -1888,7 +1887,7 @@ ada_parse_state::find_completion_bounds () const char *end = pstate->lexptr; /* First the end of the prefix. Here we stop at the token start or at '.' or space. */ - for (; end > m_original_expr && end[-1] != '.' && !isspace (end[-1]); --end) + for (; end > m_original_expr && end[-1] != '.' && !c_isspace (end[-1]); --end) { /* Nothing. */ } diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index b7039fd..b403c5a 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -18,7 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <ctype.h> #include "event-top.h" #include "exceptions.h" #include "extract-store-integer.h" @@ -875,7 +874,7 @@ is_compiler_suffix (const char *str) { gdb_assert (*str == '['); ++str; - while (*str != '\0' && isalpha (*str)) + while (*str != '\0' && c_isalpha (*str)) ++str; /* We accept a missing "]" in order to support completion. */ return *str == '\0' || (str[0] == ']' && str[1] == '\0'); @@ -1167,7 +1166,7 @@ ada_encode (const char *decoded, bool fold) static int is_lower_alphanum (const char c) { - return (isdigit (c) || (isalpha (c) && islower (c))); + return (c_isdigit (c) || (c_isalpha (c) && c_islower (c))); } /* ENCODED is the linkage name of a symbol and LEN contains its length. @@ -1185,11 +1184,11 @@ is_lower_alphanum (const char c) static void ada_remove_trailing_digits (const char *encoded, int *len) { - if (*len > 1 && isdigit (encoded[*len - 1])) + if (*len > 1 && c_isdigit (encoded[*len - 1])) { int i = *len - 2; - while (i > 0 && isdigit (encoded[i])) + while (i > 0 && c_isdigit (encoded[i])) i--; if (i >= 0 && encoded[i] == '.') *len = i; @@ -1220,7 +1219,7 @@ ada_remove_po_subprogram_suffix (const char *encoded, int *len) if (*len > 1 && encoded[*len - 1] == 'N' - && (isdigit (encoded[*len - 2]) || islower (encoded[*len - 2]))) + && (c_isdigit (encoded[*len - 2]) || c_islower (encoded[*len - 2]))) *len = *len - 1; } @@ -1232,7 +1231,7 @@ static int remove_compiler_suffix (const char *encoded, int *len) { int offset = *len - 1; - while (offset > 0 && isalpha (encoded[offset])) + while (offset > 0 && c_isalpha (encoded[offset])) --offset; if (offset > 0 && encoded[offset] == '.') { @@ -1252,7 +1251,7 @@ convert_hex (const char *str, int n, uint32_t *out) for (int i = 0; i < n; ++i) { - if (!isxdigit (str[i])) + if (!c_isxdigit (str[i])) return false; result <<= 4; result |= fromhex (str[i]); @@ -1384,11 +1383,11 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide) /* Remove trailing __{digit}+ or trailing ${digit}+. */ - if (len0 > 1 && isdigit (encoded[len0 - 1])) + if (len0 > 1 && c_isdigit (encoded[len0 - 1])) { i = len0 - 2; - while ((i >= 0 && isdigit (encoded[i])) - || (i >= 1 && encoded[i] == '_' && isdigit (encoded[i - 1]))) + while ((i >= 0 && c_isdigit (encoded[i])) + || (i >= 1 && encoded[i] == '_' && c_isdigit (encoded[i - 1]))) i -= 1; if (i > 1 && encoded[i] == '_' && encoded[i - 1] == '_') len0 = i - 1; @@ -1399,7 +1398,7 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide) /* The first few characters that are not alphabetic are not part of any encoding we use, so we can copy them over verbatim. */ - for (i = 0; i < len0 && !isalpha (encoded[i]); i += 1) + for (i = 0; i < len0 && !c_isalpha (encoded[i]); i += 1) decoded.push_back (encoded[i]); at_start_name = 1; @@ -1415,7 +1414,7 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide) int op_len = strlen (ada_opname_table[k].encoded); if ((strncmp (ada_opname_table[k].encoded + 1, encoded + i + 1, op_len - 1) == 0) - && !isalnum (encoded[i + op_len])) + && !c_isalnum (encoded[i + op_len])) { decoded.append (ada_opname_table[k].decoded); at_start_name = 0; @@ -1440,11 +1439,11 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide) if (len0 - i > 5 && encoded [i] == '_' && encoded [i+1] == '_' && encoded [i+2] == 'B' && encoded [i+3] == '_' - && isdigit (encoded [i+4])) + && c_isdigit (encoded [i+4])) { int k = i + 5; - while (k < len0 && isdigit (encoded[k])) + while (k < len0 && c_isdigit (encoded[k])) k++; /* Skip any extra digit. */ /* Double-check that the "__B_{DIGITS}+" sequence we found @@ -1467,11 +1466,11 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide) internally generated. */ if (len0 - i > 3 && encoded [i] == '_' && encoded[i+1] == 'E' - && isdigit (encoded[i+2])) + && c_isdigit (encoded[i+2])) { int k = i + 3; - while (k < len0 && isdigit (encoded[k])) + while (k < len0 && c_isdigit (encoded[k])) k++; if (k < len0 @@ -1505,7 +1504,7 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide) i++; } - if (wide && i < len0 + 3 && encoded[i] == 'U' && isxdigit (encoded[i + 1])) + if (wide && i < len0 + 3 && encoded[i] == 'U' && c_isxdigit (encoded[i + 1])) { if (convert_from_hex_encoded (decoded, &encoded[i + 1], 2)) { @@ -1513,7 +1512,7 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide) continue; } } - else if (wide && i < len0 + 5 && encoded[i] == 'W' && isxdigit (encoded[i + 1])) + else if (wide && i < len0 + 5 && encoded[i] == 'W' && c_isxdigit (encoded[i + 1])) { if (convert_from_hex_encoded (decoded, &encoded[i + 1], 4)) { @@ -1522,7 +1521,7 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide) } } else if (wide && i < len0 + 10 && encoded[i] == 'W' && encoded[i + 1] == 'W' - && isxdigit (encoded[i + 2])) + && c_isxdigit (encoded[i + 2])) { if (convert_from_hex_encoded (decoded, &encoded[i + 2], 8)) { @@ -1531,7 +1530,7 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide) } } - if (encoded[i] == 'X' && i != 0 && isalnum (encoded[i - 1])) + if (encoded[i] == 'X' && i != 0 && c_isalnum (encoded[i - 1])) { /* This is a X[bn]* sequence not separated from the previous part of the name with a non-alpha-numeric character (in other @@ -1568,7 +1567,7 @@ ada_decode (const char *encoded, bool wrap, bool operators, bool wide) if (operators) { for (i = 0; i < decoded.length(); ++i) - if (isupper (decoded[i]) || decoded[i] == ' ') + if (c_isupper (decoded[i]) || decoded[i] == ' ') goto Suppress; } @@ -5729,10 +5728,10 @@ is_name_suffix (const char *str) /* Skip optional leading __[0-9]+. */ - if (len > 3 && str[0] == '_' && str[1] == '_' && isdigit (str[2])) + if (len > 3 && str[0] == '_' && str[1] == '_' && c_isdigit (str[2])) { str += 3; - while (isdigit (str[0])) + while (c_isdigit (str[0])) str += 1; } @@ -5741,7 +5740,7 @@ is_name_suffix (const char *str) if (str[0] == '.' || str[0] == '$') { matching = str + 1; - while (isdigit (matching[0])) + while (c_isdigit (matching[0])) matching += 1; if (matching[0] == '\0') return 1; @@ -5752,7 +5751,7 @@ is_name_suffix (const char *str) if (len > 3 && str[0] == '_' && str[1] == '_' && str[2] == '_') { matching = str + 3; - while (isdigit (matching[0])) + while (c_isdigit (matching[0])) matching += 1; if (matching[0] == '\0') return 1; @@ -5781,10 +5780,10 @@ is_name_suffix (const char *str) #endif /* _E[0-9]+[bs]$ */ - if (len > 3 && str[0] == '_' && str [1] == 'E' && isdigit (str[2])) + if (len > 3 && str[0] == '_' && str [1] == 'E' && c_isdigit (str[2])) { matching = str + 3; - while (isdigit (matching[0])) + while (c_isdigit (matching[0])) matching += 1; if ((matching[0] == 'b' || matching[0] == 's') && matching [1] == '\0') @@ -5834,17 +5833,17 @@ is_name_suffix (const char *str) return 1; return 0; } - if (!isdigit (str[2])) + if (!c_isdigit (str[2])) return 0; for (k = 3; str[k] != '\0'; k += 1) - if (!isdigit (str[k]) && str[k] != '_') + if (!c_isdigit (str[k]) && str[k] != '_') return 0; return 1; } - if (str[0] == '$' && isdigit (str[1])) + if (str[0] == '$' && c_isdigit (str[1])) { for (k = 2; str[k] != '\0'; k += 1) - if (!isdigit (str[k]) && str[k] != '_') + if (!c_isdigit (str[k]) && str[k] != '_') return 0; return 1; } @@ -5867,7 +5866,7 @@ is_valid_name_for_wild_match (const char *name0) return 0; for (i=0; decoded_name[i] != '\0'; i++) - if (isalpha (decoded_name[i]) && !islower (decoded_name[i])) + if (c_isalpha (decoded_name[i]) && !c_islower (decoded_name[i])) return 0; return 1; @@ -6091,7 +6090,7 @@ ada_lookup_name_info::matches angle bracket notation. */ const char *tmp; - for (tmp = sym_name; *tmp != '\0' && !isupper (*tmp); tmp++); + for (tmp = sym_name; *tmp != '\0' && !c_isupper (*tmp); tmp++); if (*tmp != '\0') match = false; } @@ -6206,7 +6205,7 @@ ada_is_ignored_field (struct type *type, int field_num) { /* Wrapper field. */ } - else if (isupper (name[0])) + else if (c_isupper (name[0])) return 1; } @@ -6717,14 +6716,14 @@ ada_scan_number (const char str[], int k, LONGEST * R, int *new_k) { ULONGEST RU; - if (!isdigit (str[k])) + if (!c_isdigit (str[k])) return 0; /* Do it the hard way so as not to make any assumption about the relationship of unsigned long (%lu scan format code) and LONGEST. */ RU = 0; - while (isdigit (str[k])) + while (c_isdigit (str[k])) { RU = RU * 10 + (str[k] - '0'); k += 1; @@ -7380,10 +7379,10 @@ field_alignment (struct type *type, int f) len = strlen (name); - if (!isdigit (name[len - 1])) + if (!c_isdigit (name[len - 1])) return 1; - if (isdigit (name[len - 2])) + if (c_isdigit (name[len - 2])) align_offset = len - 2; else align_offset = len - 1; @@ -8964,7 +8963,7 @@ ada_unqualify_enum_name (const char *name) { while ((tmp = strstr (name, "__")) != NULL) { - if (isdigit (tmp[2])) + if (c_isdigit (tmp[2])) break; else name = tmp + 2; @@ -9007,7 +9006,7 @@ ada_enum_name (const char *name) else return name; - if (isascii (v) && isprint (v)) + if (c_isascii (v) && c_isprint (v)) storage = string_printf ("'%c'", v); else if (name[1] == 'U') storage = string_printf ("'[\"%02x\"]'", v); @@ -12556,7 +12555,7 @@ catch_ada_exception_command_split (const char *args, args = skip_spaces (args); if (startswith (args, "if") - && (isspace (args[2]) || args[2] == '\0')) + && (c_isspace (args[2]) || args[2] == '\0')) { args += 2; args = skip_spaces (args); @@ -12833,7 +12832,7 @@ catch_ada_assert_command_split (const char *args, std::string &cond_string) /* Check whether a condition was provided. */ if (startswith (args, "if") - && (isspace (args[2]) || args[2] == '\0')) + && (c_isspace (args[2]) || args[2] == '\0')) { args += 2; args = skip_spaces (args); @@ -13237,7 +13236,7 @@ do_full_match (const char *symbol_search_name, && symbol_search_name[1] == '_') { symbol_search_name += 2; - while (isdigit (*symbol_search_name)) + while (c_isdigit (*symbol_search_name)) ++symbol_search_name; if (symbol_search_name[0] == '_' && symbol_search_name[1] == '_') diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l index 0cfa0c8..eec80cf 100644 --- a/gdb/ada-lex.l +++ b/gdb/ada-lex.l @@ -335,7 +335,6 @@ false { return FALSEKEYWORD; } . { error (_("Invalid character '%s' in expression."), yytext); } %% -#include <ctype.h> /* Initialize the lexer for processing new expression. */ static void @@ -355,7 +354,7 @@ canonicalizeNumeral (char *s1, const char *s2) { if (*s2 != '_') { - *s1 = tolower(*s2); + *s1 = c_tolower(*s2); s1 += 1; } } @@ -411,7 +410,7 @@ processInt (struct parser_state *par_state, const char *base0, exp = strtol(exp0, (char **) NULL, 10); gdb_mpz result; - while (isxdigit (*num0)) + while (c_isxdigit (*num0)) { int dig = fromhex (*num0); if (dig >= base) @@ -527,7 +526,7 @@ processId (const char *name0, int len) struct stoken result; result.ptr = name; - while (len > 0 && isspace (name0[len-1])) + while (len > 0 && c_isspace (name0[len-1])) len -= 1; if (name0[0] == '<' || strstr (name0, "___") != NULL) @@ -549,12 +548,12 @@ processId (const char *name0, int len) } else if (in_quotes) name[i++] = name0[i0++]; - else if (isalnum (name0[i0])) + else if (c_isalnum (name0[i0])) { - name[i] = tolower (name0[i0]); + name[i] = c_tolower (name0[i0]); i += 1; i0 += 1; } - else if (isspace (name0[i0])) + else if (c_isspace (name0[i0])) i0 += 1; else if (name0[i0] == '\'') { @@ -634,10 +633,10 @@ find_dot_all (const char *str) do i += 1; - while (isspace (str[i])); + while (c_isspace (str[i])); if (strncasecmp (str + i, "all", 3) == 0 - && !isalnum (str[i + 3]) && str[i + 3] != '_') + && !c_isalnum (str[i + 3]) && str[i + 3] != '_') return i0; } return -1; @@ -653,7 +652,7 @@ subseqMatch (const char *subseq, const char *str) return 1; else if (str[0] == '\0') return 0; - else if (tolower (subseq[0]) == tolower (str[0])) + else if (c_tolower (subseq[0]) == c_tolower (str[0])) return subseqMatch (subseq+1, str+1) || subseqMatch (subseq, str+1); else return subseqMatch (subseq, str+1); @@ -690,7 +689,7 @@ processAttribute (const char *str) { gdb_assert (*str == '\''); ++str; - while (isspace (*str)) + while (c_isspace (*str)) ++str; int len = strlen (str); @@ -749,7 +748,7 @@ static void rewind_to_char (int ch) { pstate->lexptr -= yyleng; - while (toupper (*pstate->lexptr) != toupper (ch)) + while (c_toupper (*pstate->lexptr) != c_toupper (ch)) pstate->lexptr -= 1; yyrestart (NULL); } diff --git a/gdb/ada-typeprint.c b/gdb/ada-typeprint.c index defd828..5829a9b 100644 --- a/gdb/ada-typeprint.c +++ b/gdb/ada-typeprint.c @@ -23,7 +23,6 @@ #include "cli/cli-style.h" #include "typeprint.h" #include "ada-lang.h" -#include <ctype.h> static int print_selected_record_field_types (struct type *, struct type *, int, int, @@ -70,7 +69,7 @@ decoded_type_name (struct type *type) if (s == name_buffer) return name_buffer; - if (!islower (s[1])) + if (!c_islower (s[1])) return NULL; for (s = q = name_buffer; *s != '\0'; q += 1) diff --git a/gdb/ada-valprint.c b/gdb/ada-valprint.c index 7c6826e..c198fa5 100644 --- a/gdb/ada-valprint.c +++ b/gdb/ada-valprint.c @@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <ctype.h> #include "event-top.h" #include "extract-store-integer.h" #include "gdbtypes.h" @@ -265,10 +264,10 @@ ada_emit_char (int c, struct type *type, struct ui_file *stream, /* If this character fits in the normal ASCII range, and is a printable character, then print the character as if it was an ASCII character, even if this is a wide character. - The UCHAR_MAX check is necessary because the isascii function + The UCHAR_MAX check is necessary because the c_isascii function requires that its argument have a value of an unsigned char, or EOF (EOF is obviously not printable). */ - if (c <= UCHAR_MAX && isascii (c) && isprint (c)) + if (c <= UCHAR_MAX && c_isascii (c) && c_isprint (c)) { if (c == quoter && c == '"') gdb_printf (stream, "\"\""); diff --git a/gdb/arm-linux-tdep.c b/gdb/arm-linux-tdep.c index cc10679..ff20ed8 100644 --- a/gdb/arm-linux-tdep.c +++ b/gdb/arm-linux-tdep.c @@ -56,7 +56,6 @@ #include "stap-probe.h" #include "parser-defs.h" #include "user-regs.h" -#include <ctype.h> #include "elf/common.h" /* Under ARM GNU/Linux the traditional way of performing a breakpoint @@ -1167,10 +1166,10 @@ arm_linux_displaced_step_copy_insn (struct gdbarch *gdbarch, static int arm_stap_is_single_operand (struct gdbarch *gdbarch, const char *s) { - return (*s == '#' || *s == '$' || isdigit (*s) /* Literal number. */ + return (*s == '#' || *s == '$' || c_isdigit (*s) /* Literal number. */ || *s == '[' /* Register indirection or displacement. */ - || isalpha (*s)); /* Register value. */ + || c_isalpha (*s)); /* Register value. */ } /* This routine is used to parse a special token in ARM's assembly. @@ -1202,7 +1201,7 @@ arm_stap_parse_special_token (struct gdbarch *gdbarch, start = tmp; /* Register name. */ - while (isalnum (*tmp)) + while (c_isalnum (*tmp)) ++tmp; if (*tmp != ',') @@ -1212,7 +1211,7 @@ arm_stap_parse_special_token (struct gdbarch *gdbarch, regname = (char *) alloca (len + 2); offset = 0; - if (isdigit (*start)) + if (c_isdigit (*start)) { /* If we are dealing with a register whose name begins with a digit, it means we should prefix the name with the letter diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index a4bc0bd..940d05f 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -18,7 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <ctype.h> #include "extract-store-integer.h" #include "frame.h" diff --git a/gdb/auto-load.c b/gdb/auto-load.c index 114a7d5..8817bd1 100644 --- a/gdb/auto-load.c +++ b/gdb/auto-load.c @@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <ctype.h> #include "auto-load.h" #include "gdbsupport/gdb_vecs.h" #include "progspace.h" @@ -1045,7 +1044,7 @@ execute_script_contents (struct auto_load_pspace_info *pspace_info, buf = name_holder.c_str (); for (p = buf; *p != '\0'; ++p) { - if (isspace (*p)) + if (c_isspace (*p)) break; } /* We don't allow nameless scripts, they're not helpful to the user. */ diff --git a/gdb/break-catch-exec.c b/gdb/break-catch-exec.c index 570018c..9bfdb44 100644 --- a/gdb/break-catch-exec.c +++ b/gdb/break-catch-exec.c @@ -164,7 +164,7 @@ ep_parse_optional_if_clause (const char **arg) { const char *cond_string; - if (((*arg)[0] != 'i') || ((*arg)[1] != 'f') || !isspace ((*arg)[2])) + if (((*arg)[0] != 'i') || ((*arg)[1] != 'f') || !c_isspace ((*arg)[2])) return NULL; /* Skip the "if" keyword. */ @@ -204,7 +204,7 @@ catch_exec_command_1 (const char *arg, int from_tty, First, check if there's an if clause. */ cond_string = ep_parse_optional_if_clause (&arg); - if ((*arg != '\0') && !isspace (*arg)) + if ((*arg != '\0') && !c_isspace (*arg)) error (_("Junk at end of arguments.")); std::unique_ptr<exec_catchpoint> c diff --git a/gdb/break-catch-fork.c b/gdb/break-catch-fork.c index c8a6330..535040c9 100644 --- a/gdb/break-catch-fork.c +++ b/gdb/break-catch-fork.c @@ -221,7 +221,7 @@ catch_fork_command_1 (const char *arg, int from_tty, First, check if there's an if clause. */ cond_string = ep_parse_optional_if_clause (&arg); - if ((*arg != '\0') && !isspace (*arg)) + if ((*arg != '\0') && !c_isspace (*arg)) error (_("Junk at end of arguments.")); /* If this target supports it, create a fork or vfork catchpoint diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c index 96f22a1..fad76e7 100644 --- a/gdb/break-catch-syscall.c +++ b/gdb/break-catch-syscall.c @@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <ctype.h> #include "breakpoint.h" #include "inferior.h" #include "cli/cli-utils.h" @@ -369,7 +368,7 @@ catch_syscall_split_args (const char *arg) /* Skip whitespace. */ arg = skip_spaces (arg); - for (i = 0; i < 127 && arg[i] && !isspace (arg[i]); ++i) + for (i = 0; i < 127 && arg[i] && !c_isspace (arg[i]); ++i) cur_name[i] = arg[i]; cur_name[i] = '\0'; arg += i; diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c index 6da38eb..1a45d7c 100644 --- a/gdb/break-catch-throw.c +++ b/gdb/break-catch-throw.c @@ -18,7 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "arch-utils.h" -#include <ctype.h> #include "breakpoint.h" #include "exceptions.h" #include "inferior.h" @@ -420,7 +419,7 @@ catch_exception_event (enum exception_event_kind ex_event, cond_string = ep_parse_optional_if_clause (&arg); - if ((*arg != '\0') && !isspace (*arg)) + if ((*arg != '\0') && !c_isspace (*arg)) error (_("Junk at end of arguments.")); if (ex_event != EX_EVENT_THROW diff --git a/gdb/break-cond-parse.c b/gdb/break-cond-parse.c index 31b5343..b771344 100644 --- a/gdb/break-cond-parse.c +++ b/gdb/break-cond-parse.c @@ -66,12 +66,12 @@ find_next_token (const char **curr, parse_direction direction) { gdb_assert (direction == parse_direction::backward); - while (isspace (**curr)) + while (c_isspace (**curr)) --(*curr); tok_end = *curr; - while (!isspace (**curr)) + while (!c_isspace (**curr)) --(*curr); tok_start = (*curr) + 1; diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index 4609342..5d87fb9 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -18,7 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "arch-utils.h" -#include <ctype.h> #include "event-top.h" #include "exceptions.h" #include "gdbsupport/gdb_vecs.h" @@ -1288,7 +1287,7 @@ condition_completer (struct cmd_list_element *cmd, { tracker.advance_custom_word_point_by (1); /* We don't support completion of history indices. */ - if (!isdigit (text[1])) + if (!c_isdigit (text[1])) complete_internalvar (tracker, &text[1]); return; } @@ -10465,7 +10464,7 @@ watch_command_1 (const char *arg, int accessflag, int from_tty, int len; len = exp_end - exp_start; - while (len > 0 && isspace (exp_start[len - 1])) + while (len > 0 && c_isspace (exp_start[len - 1])) len--; error (_("Cannot watch constant value `%.*s'."), len, exp_start); } @@ -14111,7 +14110,7 @@ strace_command (const char *arg, int from_tty) /* Decide if we are dealing with a static tracepoint marker (`-m'), or with a normal static tracepoint. */ - if (arg && startswith (arg, "-m") && isspace (arg[2])) + if (arg && startswith (arg, "-m") && c_isspace (arg[2])) { ops = &strace_marker_breakpoint_ops; locspec = new_linespec_location_spec (&arg, diff --git a/gdb/btrace.c b/gdb/btrace.c index b23de88..3d43261 100644 --- a/gdb/btrace.c +++ b/gdb/btrace.c @@ -39,7 +39,6 @@ #include "record-btrace.h" #include <inttypes.h> -#include <ctype.h> #include <algorithm> #include <string> @@ -3258,7 +3257,7 @@ get_uint (const char **arg) begin = *arg; pos = skip_spaces (begin); - if (!isdigit (*pos)) + if (!c_isdigit (*pos)) error (_("Expected positive number, got: %s."), pos); number = strtoul (pos, &end, 10); @@ -3277,7 +3276,7 @@ get_context_size (const char **arg) { const char *pos = skip_spaces (*arg); - if (!isdigit (*pos)) + if (!c_isdigit (*pos)) error (_("Expected positive number, got: %s."), pos); char *end; diff --git a/gdb/c-exp.y b/gdb/c-exp.y index cd5dc26..98be2da 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -35,7 +35,6 @@ %{ -#include <ctype.h> #include "expression.h" #include "value.h" #include "parser-defs.h" diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 7fff11a..e8e66a6 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -33,7 +33,6 @@ #include "cp-abi.h" #include "cp-support.h" #include "gdbsupport/gdb_obstack.h" -#include <ctype.h> #include "gdbcore.h" #include "gdbarch.h" #include "c-exp.h" diff --git a/gdb/charset.c b/gdb/charset.c index 2593625..fe725ef 100644 --- a/gdb/charset.c +++ b/gdb/charset.c @@ -24,7 +24,6 @@ #include "charset-list.h" #include "gdbsupport/environ.h" #include "arch-utils.h" -#include <ctype.h> #ifdef USE_WIN32API #include <windows.h> diff --git a/gdb/cli/cli-cmds.c b/gdb/cli/cli-cmds.c index a15a04a..d353654 100644 --- a/gdb/cli/cli-cmds.c +++ b/gdb/cli/cli-cmds.c @@ -301,8 +301,8 @@ with_command_completer_1 (const char *set_cmd_prefix, command as if it was a "set" command. */ if (delim == text || delim == nullptr - || !isspace (delim[-1]) - || !(isspace (delim[2]) || delim[2] == '\0')) + || !c_isspace (delim[-1]) + || !(c_isspace (delim[2]) || delim[2] == '\0')) { std::string new_text = std::string (set_cmd_prefix) + text; tracker.advance_custom_word_point_by (-(int) strlen (set_cmd_prefix)); @@ -785,14 +785,14 @@ source_command (const char *args, int from_tty) if (args[0] != '-') break; - if (args[1] == 'v' && isspace (args[2])) + if (args[1] == 'v' && c_isspace (args[2])) { source_verbose = 1; /* Skip passed -v. */ args = &args[3]; } - else if (args[1] == 's' && isspace (args[2])) + else if (args[1] == 's' && c_isspace (args[2])) { search_path = 1; @@ -1184,7 +1184,7 @@ pipe_command_completer (struct cmd_list_element *ignore, delimiter = opts.delimiter.c_str (); /* Check if we're past option values already. */ - if (text > org_text && !isspace (text[-1])) + if (text > org_text && !c_isspace (text[-1])) return; const char *delim = strstr (text, delimiter); @@ -1669,7 +1669,7 @@ disassemble_command (const char *arg, int from_tty) if (*p == '\0') error (_("Missing modifier.")); - while (*p && ! isspace (*p)) + while (*p && ! c_isspace (*p)) { switch (*p++) { @@ -1938,8 +1938,8 @@ alias_command_completer (struct cmd_list_element *ignore, typing COMMAND DEFAULT-ARGS... */ if (delim != text && delim != nullptr - && isspace (delim[-1]) - && (isspace (delim[1]) || delim[1] == '\0')) + && c_isspace (delim[-1]) + && (c_isspace (delim[1]) || delim[1] == '\0')) { std::string new_text = std::string (delim + 1); diff --git a/gdb/cli/cli-decode.c b/gdb/cli/cli-decode.c index 48a3466..2b30a6e 100644 --- a/gdb/cli/cli-decode.c +++ b/gdb/cli/cli-decode.c @@ -16,7 +16,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "symtab.h" -#include <ctype.h> #include "gdbsupport/gdb_regex.h" #include "completer.h" #include "ui-out.h" @@ -2053,8 +2052,8 @@ print_doc_line (struct ui_file *stream, const char *str, if (for_value_prefix) { char &c = (*line_buffer)[0]; - if (islower (c)) - c = toupper (c); + if (c_islower (c)) + c = c_toupper (c); if (line_buffer->back () == '.') line_buffer->pop_back (); } @@ -2227,7 +2226,7 @@ valid_cmd_char_p (int c) /* Alas "42" is a legitimate user-defined command. In the interests of not breaking anything we preserve that. */ - return isalnum (c) || c == '-' || c == '_' || c == '.'; + return c_isalnum (c) || c == '-' || c == '_' || c == '.'; } /* See command.h. */ @@ -2491,7 +2490,7 @@ lookup_cmd (const char **line, struct cmd_list_element *list, } else { - if (c->type == set_cmd && **line != '\0' && !isspace (**line)) + if (c->type == set_cmd && **line != '\0' && !c_isspace (**line)) error (_("Argument must be preceded by space.")); /* We've got something. It may still not be what the caller diff --git a/gdb/cli/cli-dump.c b/gdb/cli/cli-dump.c index afbbea6..3cdd9a3 100644 --- a/gdb/cli/cli-dump.c +++ b/gdb/cli/cli-dump.c @@ -23,7 +23,6 @@ #include "cli/cli-cmds.h" #include "value.h" #include "completer.h" -#include <ctype.h> #include "target.h" #include "readline/tilde.h" #include "gdbcore.h" diff --git a/gdb/cli/cli-option.c b/gdb/cli/cli-option.c index a30261e..5da8c73 100644 --- a/gdb/cli/cli-option.c +++ b/gdb/cli/cli-option.c @@ -227,7 +227,7 @@ parse_option (gdb::array_view<const option_def_group> options_group, match = &o; match_ctx = grp.ctx; - if ((isspace (arg[len]) || arg[len] == '\0') + if ((c_isspace (arg[len]) || arg[len] == '\0') && strlen (o.name) == len) break; /* Exact match. */ } @@ -635,7 +635,7 @@ complete_options (completion_tracker &tracker, if (ov && !tracker.have_completions () && **args == '\0' - && *args > text && !isspace ((*args)[-1])) + && *args > text && !c_isspace ((*args)[-1])) { tracker.advance_custom_word_point_by (*args - text); diff --git a/gdb/cli/cli-script.c b/gdb/cli/cli-script.c index 3ea80a5..048d391 100644 --- a/gdb/cli/cli-script.c +++ b/gdb/cli/cli-script.c @@ -19,7 +19,6 @@ #include "event-top.h" #include "value.h" -#include <ctype.h> #include "ui-out.h" #include "top.h" @@ -829,7 +828,7 @@ locate_arg (const char *p) while ((p = strchr (p, '$'))) { if (startswith (p, "$arg") - && (isdigit (p[4]) || p[4] == 'c')) + && (c_isdigit (p[4]) || p[4] == 'c')) return p; p++; } @@ -1324,9 +1323,9 @@ validate_comname (const char **comname) /* Find the last word of the argument. */ p = *comname + strlen (*comname); - while (p > *comname && isspace (p[-1])) + while (p > *comname && c_isspace (p[-1])) p--; - while (p > *comname && !isspace (p[-1])) + while (p > *comname && !c_isspace (p[-1])) p--; last_word = p; diff --git a/gdb/cli/cli-setshow.c b/gdb/cli/cli-setshow.c index 4d4695f..8528ac5 100644 --- a/gdb/cli/cli-setshow.c +++ b/gdb/cli/cli-setshow.c @@ -17,7 +17,6 @@ #include "readline/tilde.h" #include "value.h" -#include <ctype.h> #include "arch-utils.h" #include "observable.h" #include "interps.h" @@ -49,7 +48,7 @@ parse_auto_binary_operation (const char *arg) { int length = strlen (arg); - while (isspace (arg[length - 1]) && length > 0) + while (c_isspace (arg[length - 1]) && length > 0) length--; /* Note that "o" is ambiguous. */ diff --git a/gdb/cli/cli-utils.c b/gdb/cli/cli-utils.c index 23706e0..d0ca594 100644 --- a/gdb/cli/cli-utils.c +++ b/gdb/cli/cli-utils.c @@ -20,7 +20,6 @@ #include "cli/cli-utils.h" #include "value.h" -#include <ctype.h> /* See documentation in cli-utils.h. */ @@ -46,7 +45,7 @@ get_ulongest (const char **pp, int trailer) /* Internal variable. Make a copy of the name, so we can null-terminate it to pass to lookup_internalvar(). */ const char *start = ++p; - while (isalnum (*p) || *p == '_') + while (c_isalnum (*p) || *p == '_') p++; std::string varname (start, p - start); if (!get_internalvar_integer (lookup_internalvar (varname.c_str ()), @@ -67,7 +66,7 @@ get_ulongest (const char **pp, int trailer) p = end; } - if (!(isspace (*p) || *p == '\0' || *p == trailer)) + if (!(c_isspace (*p) || *p == '\0' || *p == trailer)) error (_("Trailing junk at: %s"), p); p = skip_spaces (p); *pp = p; @@ -111,7 +110,7 @@ get_number_trailer (const char **pp, int trailer) const char *start = ++p; LONGEST longest_val; - while (isalnum (*p) || *p == '_') + while (c_isalnum (*p) || *p == '_') p++; varname = (char *) alloca (p - start + 1); strncpy (varname, start, p - start); @@ -136,7 +135,7 @@ get_number_trailer (const char **pp, int trailer) /* There is no number here. (e.g. "cond a == b"). */ { /* Skip non-numeric token. */ - while (*p && !isspace((int) *p)) + while (*p && !c_isspace((int) *p)) ++p; /* Return zero, which caller must interpret as error. */ retval = 0; @@ -144,10 +143,10 @@ get_number_trailer (const char **pp, int trailer) else retval = atoi (p1); } - if (!(isspace (*p) || *p == '\0' || *p == trailer)) + if (!(c_isspace (*p) || *p == '\0' || *p == trailer)) { /* Trailing junk: return 0 and let caller print error msg. */ - while (!(isspace (*p) || *p == '\0' || *p == trailer)) + while (!(c_isspace (*p) || *p == '\0' || *p == trailer)) ++p; retval = 0; } @@ -262,8 +261,8 @@ number_or_range_parser::get_number () option rather than an incomplete range, so check for end of string as well. */ if (m_cur_tok[0] == '-' - && !(isspace (m_cur_tok[-1]) - && (isalpha (m_cur_tok[1]) + && !(c_isspace (m_cur_tok[-1]) + && (c_isalpha (m_cur_tok[1]) || m_cur_tok[1] == '-' || m_cur_tok[1] == '\0'))) { @@ -293,7 +292,7 @@ number_or_range_parser::get_number () } else { - if (isdigit (*(m_cur_tok + 1))) + if (c_isdigit (*(m_cur_tok + 1))) error (_("negative value")); if (*(m_cur_tok + 1) == '$') { @@ -330,9 +329,9 @@ number_or_range_parser::finished () const integer, convenience var or negative convenience var. */ return (m_cur_tok == NULL || *m_cur_tok == '\0' || (!m_in_range - && !(isdigit (*m_cur_tok) || *m_cur_tok == '$') + && !(c_isdigit (*m_cur_tok) || *m_cur_tok == '$') && !(*m_cur_tok == '-' - && (isdigit (m_cur_tok[1]) || m_cur_tok[1] == '$')))); + && (c_isdigit (m_cur_tok[1]) || m_cur_tok[1] == '$')))); } /* Accept a number and a string-form list of numbers such as is @@ -370,7 +369,7 @@ number_is_in_list (const char *list, int number) const char * remove_trailing_whitespace (const char *start, const char *s) { - while (s > start && isspace (*(s - 1))) + while (s > start && c_isspace (*(s - 1))) --s; return s; @@ -420,7 +419,7 @@ int check_for_argument (const char **str, const char *arg, int arg_len) { if (strncmp (*str, arg, arg_len) == 0 - && ((*str)[arg_len] == '\0' || isspace ((*str)[arg_len]))) + && ((*str)[arg_len] == '\0' || c_isspace ((*str)[arg_len]))) { *str += arg_len; *str = skip_spaces (*str); diff --git a/gdb/coff-pe-read.c b/gdb/coff-pe-read.c index 0061007..9255555 100644 --- a/gdb/coff-pe-read.c +++ b/gdb/coff-pe-read.c @@ -35,7 +35,6 @@ #include "gdbsupport/common-utils.h" #include "coff/internal.h" -#include <ctype.h> /* Internal section information */ @@ -189,7 +188,7 @@ add_pe_forwarded_sym (minimal_symbol_reader &reader, int i; for (i = 0; i < forward_dll_name_len; i++) - forward_qualified_name[i] = tolower (forward_qualified_name[i]); + forward_qualified_name[i] = c_tolower (forward_qualified_name[i]); msymbol = lookup_minimal_symbol (current_program_space, forward_qualified_name.c_str ()); } diff --git a/gdb/coffread.c b/gdb/coffread.c index b69c06f..44e761a 100644 --- a/gdb/coffread.c +++ b/gdb/coffread.c @@ -25,7 +25,6 @@ #include "bfd.h" #include "gdbsupport/gdb_obstack.h" -#include <ctype.h> #include "coff/internal.h" #include "libcoff.h" @@ -336,7 +335,7 @@ coff_locate_sections (bfd *abfd, asection *sectp, void *csip) /* We can have multiple .stab sections if linked with --split-by-reloc. */ for (s = name + sizeof ".stab" - 1; *s != '\0'; s++) - if (!isdigit (*s)) + if (!c_isdigit (*s)) break; if (*s == '\0') csi->stabsects->push_back (sectp); @@ -525,9 +524,9 @@ is_import_fixup_symbol (struct coff_symbol *cs, /* The name must start with "__fu<digits>__". */ if (!startswith (cs->c_name, "__fu")) return 0; - if (! isdigit (cs->c_name[4])) + if (! c_isdigit (cs->c_name[4])) return 0; - for (i = 5; cs->c_name[i] != '\0' && isdigit (cs->c_name[i]); i++) + for (i = 5; cs->c_name[i] != '\0' && c_isdigit (cs->c_name[i]); i++) /* Nothing, just incrementing index past all digits. */; if (cs->c_name[i] != '_' || cs->c_name[i + 1] != '_') return 0; diff --git a/gdb/d-exp.y b/gdb/d-exp.y index f77b15e..6b4fd04 100644 --- a/gdb/d-exp.y +++ b/gdb/d-exp.y @@ -38,7 +38,6 @@ %{ -#include <ctype.h> #include "expression.h" #include "value.h" #include "parser-defs.h" @@ -684,15 +683,15 @@ parse_number (struct parser_state *ps, const char *p, len = strlen (s); /* Check suffix for `i' , `fi' or `li' (idouble, ifloat or ireal). */ - if (len >= 1 && tolower (s[len - 1]) == 'i') + if (len >= 1 && c_tolower (s[len - 1]) == 'i') { - if (len >= 2 && tolower (s[len - 2]) == 'f') + if (len >= 2 && c_tolower (s[len - 2]) == 'f') { putithere->typed_val_float.type = parse_d_type (ps)->builtin_ifloat; len -= 2; } - else if (len >= 2 && tolower (s[len - 2]) == 'l') + else if (len >= 2 && c_tolower (s[len - 2]) == 'l') { putithere->typed_val_float.type = parse_d_type (ps)->builtin_ireal; @@ -706,13 +705,13 @@ parse_number (struct parser_state *ps, const char *p, } } /* Check suffix for `f' or `l'' (float or real). */ - else if (len >= 1 && tolower (s[len - 1]) == 'f') + else if (len >= 1 && c_tolower (s[len - 1]) == 'f') { putithere->typed_val_float.type = parse_d_type (ps)->builtin_float; len -= 1; } - else if (len >= 1 && tolower (s[len - 1]) == 'l') + else if (len >= 1 && c_tolower (s[len - 1]) == 'l') { putithere->typed_val_float.type = parse_d_type (ps)->builtin_real; @@ -1133,8 +1132,8 @@ lex_one_token (struct parser_state *par_state) /* Hex exponents start with 'p', because 'e' is a valid hex digit and thus does not indicate a floating point number when the radix is hex. */ - if ((!hex && !got_e && tolower (p[0]) == 'e') - || (hex && !got_e && tolower (p[0] == 'p'))) + if ((!hex && !got_e && c_tolower (p[0]) == 'e') + || (hex && !got_e && c_tolower (p[0] == 'p'))) got_dot = got_e = 1; /* A '.' always indicates a decimal floating point number regardless of the radix. If we have a '..' then its the @@ -1142,7 +1141,8 @@ lex_one_token (struct parser_state *par_state) else if (!got_dot && (p[0] == '.' && p[1] != '.')) got_dot = 1; /* This is the sign of the exponent, not the end of the number. */ - else if (got_e && (tolower (p[-1]) == 'e' || tolower (p[-1]) == 'p') + else if (got_e && (c_tolower (p[-1]) == 'e' + || c_tolower (p[-1]) == 'p') && (*p == '-' || *p == '+')) continue; /* We will take any letters or digits, ignoring any embedded '_'. @@ -1167,9 +1167,9 @@ lex_one_token (struct parser_state *par_state) const char *p = &tokstart[1]; size_t len = strlen ("entry"); - while (isspace (*p)) + while (c_isspace (*p)) p++; - if (strncmp (p, "entry", len) == 0 && !isalnum (p[len]) + if (strncmp (p, "entry", len) == 0 && !c_isalnum (p[len]) && p[len] != '_') { pstate->lexptr = &p[len]; diff --git a/gdb/darwin-nat.c b/gdb/darwin-nat.c index 7acf639..e73b5a1 100644 --- a/gdb/darwin-nat.c +++ b/gdb/darwin-nat.c @@ -47,7 +47,6 @@ #include <sys/types.h> #include <unistd.h> #include <signal.h> -#include <ctype.h> #include <sys/sysctl.h> #include <sys/proc.h> #include <libproc.h> diff --git a/gdb/dictionary.c b/gdb/dictionary.c index 17c9b44..e53331b 100644 --- a/gdb/dictionary.c +++ b/gdb/dictionary.c @@ -20,7 +20,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <ctype.h> #include "gdbsupport/gdb_obstack.h" #include "symtab.h" #include "buildsym.h" diff --git a/gdb/dwarf2/index-common.c b/gdb/dwarf2/index-common.c index c24c8fc..a314ce7 100644 --- a/gdb/dwarf2/index-common.c +++ b/gdb/dwarf2/index-common.c @@ -31,7 +31,7 @@ mapped_index_string_hash (int index_version, const void *p) while ((c = *str++) != 0) { if (index_version >= 5) - c = tolower (c); + c = c_tolower (c); r = r * 67 + c - 113; } @@ -45,12 +45,12 @@ dwarf5_djb_hash (const char *str_) { const unsigned char *str = (const unsigned char *) str_; - /* Note: tolower here ignores UTF-8, which isn't fully compliant. + /* Note: c_tolower here ignores UTF-8, which isn't fully compliant. See http://dwarfstd.org/ShowIssue.php?issue=161027.1. */ uint32_t hash = 5381; while (int c = *str++) - hash = hash * 33 + tolower (c); + hash = hash * 33 + c_tolower (c); return hash; } @@ -59,11 +59,11 @@ dwarf5_djb_hash (const char *str_) uint32_t dwarf5_djb_hash (std::string_view str) { - /* Note: tolower here ignores UTF-8, which isn't fully compliant. + /* Note: c_tolower here ignores UTF-8, which isn't fully compliant. See http://dwarfstd.org/ShowIssue.php?issue=161027.1. */ uint32_t hash = 5381; for (char c : str) - hash = hash * 33 + tolower (c & 0xff); + hash = hash * 33 + c_tolower (c & 0xff); return hash; } diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 30a0141..c76086f 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -13440,7 +13440,7 @@ ada_get_gnat_encoded_number (const char *encoding, int &k, gdb_mpz *result) { /* The next character should be an underscore ('_') followed by a digit. */ - if (encoding[k] != '_' || !isdigit (encoding[k + 1])) + if (encoding[k] != '_' || !c_isdigit (encoding[k + 1])) return false; /* Skip the underscore. */ @@ -13448,7 +13448,7 @@ ada_get_gnat_encoded_number (const char *encoding, int &k, gdb_mpz *result) int start = k; /* Determine the number of digits for our number. */ - while (isdigit (encoding[k])) + while (c_isdigit (encoding[k])) k++; if (k == start) return false; @@ -38,7 +38,6 @@ #include "gdbsupport/gdb_obstack.h" #include "objfiles.h" #include "typeprint.h" -#include <ctype.h> #include "expop.h" #include "c-exp.h" #include "inferior.h" @@ -42,7 +42,6 @@ #include "readline/tilde.h" #include "gdbcore.h" -#include <ctype.h> #include <sys/stat.h> #include "solib.h" #include <algorithm> @@ -1015,7 +1014,7 @@ set_section_command (const char *args, int from_tty) error (_("Must specify section name and its virtual address")); /* Parse out section name. */ - for (secname = args; !isspace (*args); args++); + for (secname = args; !c_isspace (*args); args++); unsigned seclen = args - secname; /* Parse out new virtual address. */ diff --git a/gdb/expprint.c b/gdb/expprint.c index c87be74..a32b7ac 100644 --- a/gdb/expprint.c +++ b/gdb/expprint.c @@ -33,7 +33,6 @@ #include "expop.h" #include "ada-exp.h" -#include <ctype.h> /* Meant to be used in debug sessions, so don't export it in a header file. */ extern void ATTRIBUTE_USED debug_exp (struct expression *exp); diff --git a/gdb/f-exp.y b/gdb/f-exp.y index afcdc41..07fc54c 100644 --- a/gdb/f-exp.y +++ b/gdb/f-exp.y @@ -48,7 +48,6 @@ #include "language.h" #include "f-lang.h" #include "block.h" -#include <ctype.h> #include <algorithm> #include "type-stack.h" #include "f-exp.h" @@ -1061,8 +1060,8 @@ parse_number (struct parser_state *par_state, while (len-- > 0) { c = *p++; - if (isupper (c)) - c = tolower (c); + if (c_isupper (c)) + c = c_tolower (c); if (len == 0 && c == 'l') long_p = 1; else if (len == 0 && c == 'u') diff --git a/gdb/fbsd-nat.c b/gdb/fbsd-nat.c index 935b947..81bd6d9 100644 --- a/gdb/fbsd-nat.c +++ b/gdb/fbsd-nat.c @@ -304,7 +304,7 @@ fbsd_nat_target::info_proc (const char *args, enum info_proc_what what) if (pid == 0) error (_("No current process: you must name one.")); } - else if (built_argv.count () == 1 && isdigit (built_argv[0][0])) + else if (built_argv.count () == 1 && c_isdigit (built_argv[0][0])) pid = strtol (built_argv[0], NULL, 10); else error (_("Invalid arguments.")); diff --git a/gdb/findcmd.c b/gdb/findcmd.c index 4e47877..03c3fcc 100644 --- a/gdb/findcmd.c +++ b/gdb/findcmd.c @@ -18,7 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "arch-utils.h" -#include <ctype.h> #include "cli/cli-cmds.h" #include "value.h" #include "target.h" @@ -76,12 +75,12 @@ parse_find_args (const char *args, ULONGEST *max_countp, { ++s; - while (*s != '\0' && *s != '/' && !isspace (*s)) + while (*s != '\0' && *s != '/' && !c_isspace (*s)) { - if (isdigit (*s)) + if (c_isdigit (*s)) { max_count = atoi (s); - while (isdigit (*s)) + while (c_isdigit (*s)) ++s; continue; } diff --git a/gdb/gdb_wchar.h b/gdb/gdb_wchar.h index 417d5ba..9db0d5e 100644 --- a/gdb/gdb_wchar.h +++ b/gdb/gdb_wchar.h @@ -113,8 +113,8 @@ typedef char gdb_wchar_t; typedef int gdb_wint_t; #define gdb_wcslen strlen -#define gdb_iswprint isprint -#define gdb_iswxdigit isxdigit +#define gdb_iswprint c_isprint +#define gdb_iswxdigit c_isxdigit #define gdb_btowc /* empty */ #define gdb_WEOF EOF diff --git a/gdb/gnu-nat.c b/gdb/gnu-nat.c index dd639fe..33391ba 100644 --- a/gdb/gnu-nat.c +++ b/gdb/gnu-nat.c @@ -50,7 +50,6 @@ extern "C" } -#include <ctype.h> #include <setjmp.h> #include <signal.h> #include <sys/ptrace.h> @@ -2926,7 +2925,7 @@ set_sig_thread_cmd (const char *args, int from_tty) { struct inf *inf = cur_inf (); - if (!args || (!isdigit (*args) && strcmp (args, "none") != 0)) + if (!args || (!c_isdigit (*args) && strcmp (args, "none") != 0)) error (_("Illegal argument to \"set signal-thread\" command.\n" "Should be a thread ID, or \"none\".")); diff --git a/gdb/gnu-v2-abi.c b/gdb/gnu-v2-abi.c index 9246788..1fbc41d 100644 --- a/gdb/gnu-v2-abi.c +++ b/gdb/gnu-v2-abi.c @@ -26,7 +26,6 @@ #include "gdb-demangle.h" #include "cp-abi.h" #include "cp-support.h" -#include <ctype.h> static cp_abi_ops gnu_v2_abi_ops; @@ -46,7 +45,7 @@ static enum ctor_kinds gnuv2_is_constructor_name (const char *name) { if ((name[0] == '_' && name[1] == '_' - && (isdigit (name[2]) || strchr ("Qt", name[2]))) + && (c_isdigit (name[2]) || strchr ("Qt", name[2]))) || startswith (name, "__ct__")) return complete_object_ctor; else diff --git a/gdb/go-exp.y b/gdb/go-exp.y index a617242..5da8cef 100644 --- a/gdb/go-exp.y +++ b/gdb/go-exp.y @@ -51,7 +51,6 @@ %{ -#include <ctype.h> #include "expression.h" #include "value.h" #include "parser-defs.h" @@ -663,13 +662,13 @@ parse_number (struct parser_state *par_state, /* Handle suffixes: 'f' for float32, 'l' for long double. FIXME: This appears to be an extension -- do we want this? */ - if (len >= 1 && tolower (p[len - 1]) == 'f') + if (len >= 1 && c_tolower (p[len - 1]) == 'f') { putithere->typed_val_float.type = builtin_go_types->builtin_float32; len--; } - else if (len >= 1 && tolower (p[len - 1]) == 'l') + else if (len >= 1 && c_tolower (p[len - 1]) == 'l') { putithere->typed_val_float.type = parse_type (par_state)->builtin_long_double; @@ -1113,9 +1112,9 @@ lex_one_token (struct parser_state *par_state) const char *p = &tokstart[1]; size_t len = strlen ("entry"); - while (isspace (*p)) + while (c_isspace (*p)) p++; - if (strncmp (p, "entry", len) == 0 && !isalnum (p[len]) + if (strncmp (p, "entry", len) == 0 && !c_isalnum (p[len]) && p[len] != '_') { par_state->lexptr = &p[len]; diff --git a/gdb/go-lang.c b/gdb/go-lang.c index bad2ccf..23ffedb 100644 --- a/gdb/go-lang.c +++ b/gdb/go-lang.c @@ -41,7 +41,6 @@ #include "parser-defs.h" #include "gdbarch.h" -#include <ctype.h> /* The main function in the main package. */ static const char GO_MAIN_MAIN[] = "main.main"; @@ -292,7 +291,7 @@ unpack_mangled_go_symbol (const char *mangled_name, while (p > buf) { int current = *(const unsigned char *) --p; - int current_is_digit = isdigit (current); + int current_is_digit = c_isdigit (current); if (saw_digit) { diff --git a/gdb/go32-nat.c b/gdb/go32-nat.c index 4d8e6c9..ab13b57 100644 --- a/gdb/go32-nat.c +++ b/gdb/go32-nat.c @@ -103,7 +103,6 @@ #include "cli/cli-utils.h" #include "inf-child.h" -#include <ctype.h> #include <unistd.h> #include <sys/utsname.h> #include <io.h> diff --git a/gdb/guile/scm-cmd.c b/gdb/guile/scm-cmd.c index 19fb742..ef4c9d6 100644 --- a/gdb/guile/scm-cmd.c +++ b/gdb/guile/scm-cmd.c @@ -20,7 +20,6 @@ /* See README file in this directory for implementation notes, coding conventions, et.al. */ -#include <ctype.h> #include "charset.h" #include "cli/cli-cmds.h" #include "cli/cli-decode.h" diff --git a/gdb/i386-tdep.c b/gdb/i386-tdep.c index f75745a..d3ad402 100644 --- a/gdb/i386-tdep.c +++ b/gdb/i386-tdep.c @@ -61,7 +61,6 @@ #include "stap-probe.h" #include "user-regs.h" #include "expression.h" -#include <ctype.h> #include <algorithm> #include <unordered_set> #include "producer.h" @@ -3895,9 +3894,9 @@ int i386_stap_is_single_operand (struct gdbarch *gdbarch, const char *s) { return (*s == '$' /* Literal number. */ - || (isdigit (*s) && s[1] == '(' && s[2] == '%') /* Displacement. */ + || (c_isdigit (*s) && s[1] == '(' && s[2] == '%') /* Displacement. */ || (*s == '(' && s[1] == '%') /* Register indirection. */ - || (*s == '%' && isalpha (s[1]))); /* Register access. */ + || (*s == '%' && c_isalpha (s[1]))); /* Register access. */ } /* Helper function for i386_stap_parse_special_token. @@ -3914,7 +3913,7 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch, { const char *s = p->arg; - if (isdigit (*s) || *s == '-' || *s == '+') + if (c_isdigit (*s) || *s == '-' || *s == '+') { bool got_minus[3]; int i; @@ -3932,7 +3931,7 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch, got_minus[0] = true; } - if (!isdigit ((unsigned char) *s)) + if (!c_isdigit (*s)) return {}; displacements[0] = strtol (s, &endp, 10); @@ -3953,7 +3952,7 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch, got_minus[1] = true; } - if (!isdigit ((unsigned char) *s)) + if (!c_isdigit (*s)) return {}; displacements[1] = strtol (s, &endp, 10); @@ -3974,7 +3973,7 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch, got_minus[2] = true; } - if (!isdigit ((unsigned char) *s)) + if (!c_isdigit (*s)) return {}; displacements[2] = strtol (s, &endp, 10); @@ -3986,7 +3985,7 @@ i386_stap_parse_special_token_triplet (struct gdbarch *gdbarch, s += 2; start = s; - while (isalnum (*s)) + while (c_isalnum (*s)) ++s; if (*s++ != ')') @@ -4047,7 +4046,7 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch, { const char *s = p->arg; - if (isdigit (*s) || *s == '(' || *s == '-' || *s == '+') + if (c_isdigit (*s) || *s == '(' || *s == '-' || *s == '+') { bool offset_minus = false; long offset = 0; @@ -4065,10 +4064,10 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch, offset_minus = true; } - if (offset_minus && !isdigit (*s)) + if (offset_minus && !c_isdigit (*s)) return {}; - if (isdigit (*s)) + if (c_isdigit (*s)) { char *endp; @@ -4082,7 +4081,7 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch, s += 2; start = s; - while (isalnum (*s)) + while (c_isalnum (*s)) ++s; if (*s != ',' || s[1] != '%') @@ -4098,7 +4097,7 @@ i386_stap_parse_special_token_three_arg_disp (struct gdbarch *gdbarch, s += 2; start = s; - while (isalnum (*s)) + while (c_isalnum (*s)) ++s; len_index = s - start; diff --git a/gdb/ia64-linux-tdep.c b/gdb/ia64-linux-tdep.c index 6afffee..8b4e1f9 100644 --- a/gdb/ia64-linux-tdep.c +++ b/gdb/ia64-linux-tdep.c @@ -29,7 +29,6 @@ #include "solib-svr4-linux.h" #include "regset.h" -#include <ctype.h> /* The sigtramp code is in a non-readable (executable-only) region of memory called the ``gate page''. The addresses in question @@ -128,9 +127,9 @@ ia64_linux_write_pc (struct regcache *regcache, CORE_ADDR pc) static int ia64_linux_stap_is_single_operand (struct gdbarch *gdbarch, const char *s) { - return ((isdigit (*s) && s[1] == '[' && s[2] == 'r') /* Displacement. */ + return ((c_isdigit (*s) && s[1] == '[' && s[2] == 'r') /* Displacement. */ || *s == 'r' /* Register value. */ - || isdigit (*s)); /* Literal number. */ + || c_isdigit (*s)); /* Literal number. */ } /* Core file support. */ diff --git a/gdb/infcmd.c b/gdb/infcmd.c index a785ae3..d20b646 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -40,7 +40,6 @@ #include "reggroups.h" #include "block.h" #include "solib.h" -#include <ctype.h> #include "observable.h" #include "target-descriptions.h" #include "user-regs.h" @@ -210,7 +209,7 @@ strip_bg_char (const char *args, int *bg_char_p) if (p[-1] == '&') { p--; - while (p > args && isspace (p[-1])) + while (p > args && c_isspace (p[-1])) p--; *bg_char_p = 1; @@ -2309,12 +2308,12 @@ registers_info (const char *addr_exp, int fpregs) resembling a register following it. */ if (addr_exp[0] == '$') addr_exp++; - if (isspace ((*addr_exp)) || (*addr_exp) == '\0') + if (c_isspace ((*addr_exp)) || (*addr_exp) == '\0') error (_("Missing register name")); /* Find the start/end of this register name/num/group. */ start = addr_exp; - while ((*addr_exp) != '\0' && !isspace ((*addr_exp))) + while ((*addr_exp) != '\0' && !c_isspace ((*addr_exp))) addr_exp++; end = addr_exp; diff --git a/gdb/infrun.c b/gdb/infrun.c index 3b5cff7..289c503 100644 --- a/gdb/infrun.c +++ b/gdb/infrun.c @@ -22,7 +22,6 @@ #include "cli/cli-style.h" #include "displaced-stepping.h" #include "infrun.h" -#include <ctype.h> #include "exceptions.h" #include "symtab.h" #include "frame.h" @@ -9843,7 +9842,7 @@ handle_command (const char *args, int from_tty) for (char *arg : built_argv) { wordlen = strlen (arg); - for (digits = 0; isdigit (arg[digits]); digits++) + for (digits = 0; c_isdigit (arg[digits]); digits++) {; } allsigs = 0; diff --git a/gdb/language.c b/gdb/language.c index 212a236..c070169 100644 --- a/gdb/language.c +++ b/gdb/language.c @@ -28,7 +28,6 @@ return data out of a "language-specific" struct pointer that is set whenever the working language changes. That would be a lot faster. */ -#include <ctype.h> #include "symtab.h" #include "gdbtypes.h" #include "value.h" diff --git a/gdb/linespec.c b/gdb/linespec.c index e634bf2..70e2af9 100644 --- a/gdb/linespec.c +++ b/gdb/linespec.c @@ -35,7 +35,6 @@ #include "interps.h" #include "target.h" #include "arch-utils.h" -#include <ctype.h> #include "cli/cli-utils.h" #include "filenames.h" #include "ada-lang.h" @@ -459,7 +458,7 @@ linespec_lexer_lex_number (linespec_parser *parser, linespec_token *tokenp) ++(parser->lexer.stream); } - while (isdigit (*parser->lexer.stream)) + while (c_isdigit (*parser->lexer.stream)) { ++tokenp->data.string.length; ++(parser->lexer.stream); @@ -468,7 +467,7 @@ linespec_lexer_lex_number (linespec_parser *parser, linespec_token *tokenp) /* If the next character in the input buffer is not a space, comma, quote, or colon, this input does not represent a number. */ if (*parser->lexer.stream != '\0' - && !isspace (*parser->lexer.stream) && *parser->lexer.stream != ',' + && !c_isspace (*parser->lexer.stream) && *parser->lexer.stream != ',' && *parser->lexer.stream != ':' && !strchr (linespec_quote_characters, *parser->lexer.stream)) { @@ -512,7 +511,7 @@ linespec_lexer_lex_keyword (const char *p) if (i == FORCE_KEYWORD_INDEX && p[len] == '\0') return linespec_keywords[i]; - if (!isspace (p[len])) + if (!c_isspace (p[len])) continue; if (i == FORCE_KEYWORD_INDEX) @@ -524,7 +523,7 @@ linespec_lexer_lex_keyword (const char *p) int nextlen = strlen (linespec_keywords[j]); if (strncmp (p, linespec_keywords[j], nextlen) == 0 - && isspace (p[nextlen])) + && c_isspace (p[nextlen])) return linespec_keywords[i]; } } @@ -538,7 +537,7 @@ linespec_lexer_lex_keyword (const char *p) int nextlen = strlen (linespec_keywords[j]); if (strncmp (p, linespec_keywords[j], nextlen) == 0 - && isspace (p[nextlen])) + && c_isspace (p[nextlen])) return NULL; } } @@ -763,7 +762,7 @@ linespec_lexer_lex_string (linespec_parser *parser) while (1) { - if (isspace (*parser->lexer.stream)) + if (c_isspace (*parser->lexer.stream)) { p = skip_spaces (parser->lexer.stream); /* When we get here we know we've found something followed by @@ -841,14 +840,14 @@ linespec_lexer_lex_string (linespec_parser *parser) { const char *op = parser->lexer.stream; - while (op > start && isspace (op[-1])) + while (op > start && c_isspace (op[-1])) op--; if (op - start >= CP_OPERATOR_LEN) { op -= CP_OPERATOR_LEN; if (strncmp (op, CP_OPERATOR_STR, CP_OPERATOR_LEN) == 0 && (op == start - || !(isalnum (op[-1]) || op[-1] == '_'))) + || !(c_isalnum (op[-1]) || op[-1] == '_'))) { /* This is an operator name. Keep going. */ ++(parser->lexer.stream); @@ -1642,7 +1641,7 @@ linespec_parse_line_offset (const char *string) else line_offset.sign = LINE_OFFSET_NONE; - if (*string != '\0' && !isdigit (*string)) + if (*string != '\0' && !c_isdigit (*string)) error (_("malformed line offset: \"%s\""), start); /* Right now, we only allow base 10 for offsets. */ diff --git a/gdb/linux-fork.c b/gdb/linux-fork.c index 9e986d8..0171259 100644 --- a/gdb/linux-fork.c +++ b/gdb/linux-fork.c @@ -37,7 +37,6 @@ #include "gdbsupport/eintr.h" #include "target/waitstatus.h" #include <dirent.h> -#include <ctype.h> #include <list> @@ -421,7 +420,7 @@ fork_save_infrun_state (struct fork_info *fp) /* Now find actual file positions. */ rewinddir (d); while ((de = readdir (d)) != NULL) - if (isdigit (de->d_name[0])) + if (c_isdigit (de->d_name[0])) { tmp = strtol (&de->d_name[0], NULL, 10); fp->filepos[tmp] = call_lseek (tmp, 0, SEEK_CUR); diff --git a/gdb/linux-nat.c b/gdb/linux-nat.c index c3c5ddf..87fb800 100644 --- a/gdb/linux-nat.c +++ b/gdb/linux-nat.c @@ -42,7 +42,6 @@ #include "elf-bfd.h" #include "gregset.h" #include "gdbcore.h" -#include <ctype.h> #include <sys/stat.h> #include <fcntl.h> #include "inf-loop.h" diff --git a/gdb/linux-tdep.c b/gdb/linux-tdep.c index f07f987..4b679c8 100644 --- a/gdb/linux-tdep.c +++ b/gdb/linux-tdep.c @@ -46,7 +46,6 @@ #include "cli/cli-style.h" #include "gdbsupport/unordered_map.h" -#include <ctype.h> #include <algorithm> /* This enum represents the values that the user can choose when @@ -488,7 +487,7 @@ read_mapping (const char *line) p = skip_spaces (p); const char *permissions_start = p; - while (*p && !isspace (*p)) + while (*p && !c_isspace (*p)) p++; mapping.permissions = std::string (permissions_start, (size_t) (p - permissions_start)); @@ -497,7 +496,7 @@ read_mapping (const char *line) p = skip_spaces (p); const char *device_start = p; - while (*p && !isspace (*p)) + while (*p && !c_isspace (*p)) p++; mapping.device = {device_start, (size_t) (p - device_start)}; @@ -843,7 +842,7 @@ linux_info_proc (struct gdbarch *gdbarch, const char *args, char filename[100]; fileio_error target_errno; - if (args && isdigit (args[0])) + if (args && c_isdigit (args[0])) { char *tem; @@ -2227,7 +2226,7 @@ linux_fill_prpsinfo (struct elf_internal_linux_prpsinfo *p) specifically under the entry of `/proc/[pid]/stat'. */ /* Getting rid of the PID, since we already have it. */ - while (isdigit (*proc_stat)) + while (c_isdigit (*proc_stat)) ++proc_stat; proc_stat = skip_spaces (proc_stat); @@ -2299,10 +2298,10 @@ linux_fill_prpsinfo (struct elf_internal_linux_prpsinfo *p) { /* Advancing the pointer to the beginning of the UID. */ tmpstr += sizeof ("Uid:"); - while (*tmpstr != '\0' && !isdigit (*tmpstr)) + while (*tmpstr != '\0' && !c_isdigit (*tmpstr)) ++tmpstr; - if (isdigit (*tmpstr)) + if (c_isdigit (*tmpstr)) p->pr_uid = strtol (tmpstr, &tmpstr, 10); } @@ -2312,10 +2311,10 @@ linux_fill_prpsinfo (struct elf_internal_linux_prpsinfo *p) { /* Advancing the pointer to the beginning of the GID. */ tmpstr += sizeof ("Gid:"); - while (*tmpstr != '\0' && !isdigit (*tmpstr)) + while (*tmpstr != '\0' && !c_isdigit (*tmpstr)) ++tmpstr; - if (isdigit (*tmpstr)) + if (c_isdigit (*tmpstr)) p->pr_gid = strtol (tmpstr, &tmpstr, 10); } diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 8d49508..82bfe08 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -43,7 +43,6 @@ #include "auto-load.h" #include "cli/cli-utils.h" #include <signal.h> -#include <ctype.h> #include "nat/linux-namespaces.h" #include <algorithm> #include "gdbsupport/pathstuff.h" diff --git a/gdb/location.c b/gdb/location.c index 378fafc..197c47b 100644 --- a/gdb/location.c +++ b/gdb/location.c @@ -26,7 +26,6 @@ #include "probe.h" #include "cp-support.h" -#include <ctype.h> #include <string.h> static std::string @@ -408,15 +407,15 @@ explicit_location_spec_lex_one (const char **inp, whitespace or comma. */ if (*start == '-' || *start == '+') { - while (*inp[0] != '\0' && *inp[0] != ',' && !isspace (*inp[0])) + while (*inp[0] != '\0' && *inp[0] != ',' && !c_isspace (*inp[0])) ++(*inp); } else { /* Handle numbers first, stopping at the next whitespace or ','. */ - while (isdigit (*inp[0])) + while (c_isdigit (*inp[0])) ++(*inp); - if (*inp[0] == '\0' || isspace (*inp[0]) || *inp[0] == ',') + if (*inp[0] == '\0' || c_isspace (*inp[0]) || *inp[0] == ',') return gdb::unique_xmalloc_ptr<char> (savestring (start, *inp - start)); @@ -425,7 +424,7 @@ explicit_location_spec_lex_one (const char **inp, *inp = start; while ((*inp)[0] && (*inp)[0] != ',' - && !(isspace ((*inp)[0]) + && !(c_isspace ((*inp)[0]) || linespec_lexer_lex_keyword (&(*inp)[1]))) { /* Special case: C++ operator,. */ @@ -454,14 +453,14 @@ is_cp_operator (const char *start, const char *comma) { const char *p = comma; - while (p > start && isspace (p[-1])) + while (p > start && c_isspace (p[-1])) p--; if (p - start >= CP_OPERATOR_LEN) { p -= CP_OPERATOR_LEN; if (strncmp (p, CP_OPERATOR_STR, CP_OPERATOR_LEN) == 0 && (p == start - || !(isalnum (p[-1]) || p[-1] == '_'))) + || !(c_isalnum (p[-1]) || p[-1] == '_'))) { return true; } @@ -624,7 +623,7 @@ string_to_explicit_location_spec (const char **argp, if (argp == NULL || *argp == NULL || *argp[0] != '-' - || !isalpha ((*argp)[1]) + || !c_isalpha ((*argp)[1]) || ((*argp)[0] == '-' && (*argp)[1] == 'p')) return NULL; @@ -728,7 +727,7 @@ string_to_explicit_location_spec (const char **argp, } /* Only emit an "invalid argument" error for options that look like option strings. */ - else if (opt.get ()[0] == '-' && !isdigit (opt.get ()[1])) + else if (opt.get ()[0] == '-' && !c_isdigit (opt.get ()[1])) { if (completion_info == NULL) error (_("invalid explicit location argument, \"%s\""), opt.get ()); @@ -30,7 +30,6 @@ #include <sys/types.h> #include <sys/stat.h> -#include <ctype.h> #include "gdbsupport/event-loop.h" #include "ui-out.h" @@ -1254,7 +1253,7 @@ captured_main_1 (struct captured_main_args *context) If pid_or_core_arg's first character is a digit, try attach first and then corefile. Otherwise try just corefile. */ - if (isdigit (pid_or_core_arg[0])) + if (c_isdigit (pid_or_core_arg[0])) { ret = catch_command_errors (attach_command, pid_or_core_arg, !batch_flag); diff --git a/gdb/maint.c b/gdb/maint.c index d76d957..8bc2856 100644 --- a/gdb/maint.c +++ b/gdb/maint.c @@ -21,7 +21,6 @@ #include "arch-utils.h" -#include <ctype.h> #include <cmath> #include <signal.h> #include "command.h" @@ -571,9 +570,9 @@ maintenance_translate_address (const char *arg, int from_tty) sect = NULL; p = arg; - if (!isdigit (*p)) + if (!c_isdigit (*p)) { /* See if we have a valid section name. */ - while (*p && !isspace (*p)) /* Find end of section name. */ + while (*p && !c_isspace (*p)) /* Find end of section name. */ p++; if (*p == '\000') /* End of command? */ error (_("Need to specify section name and address")); diff --git a/gdb/mi/mi-cmd-break.c b/gdb/mi/mi-cmd-break.c index e4cb2e7..1cb8435 100644 --- a/gdb/mi/mi-cmd-break.c +++ b/gdb/mi/mi-cmd-break.c @@ -28,7 +28,6 @@ #include "language.h" #include "location.h" #include "linespec.h" -#include <ctype.h> #include "tracepoint.h" enum @@ -133,7 +132,7 @@ mi_argv_to_format (const char *const *argv, int argc) result += "\\\""; break; default: - if (isprint (argv[0][i])) + if (c_isprint (argv[0][i])) result += argv[0][i]; else { diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index fad058e..52ae11b 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -29,7 +29,6 @@ #include "valprint.h" #include "mi-getopt.h" #include "extension.h" -#include <ctype.h> #include "mi-parse.h" #include <optional> #include "inferior.h" diff --git a/gdb/mi/mi-cmd-var.c b/gdb/mi/mi-cmd-var.c index 9cbb857..09d6107 100644 --- a/gdb/mi/mi-cmd-var.c +++ b/gdb/mi/mi-cmd-var.c @@ -25,7 +25,6 @@ #include "varobj.h" #include "language.h" #include "value.h" -#include <ctype.h> #include "mi-getopt.h" #include "gdbthread.h" #include "mi-parse.h" @@ -109,7 +108,7 @@ mi_cmd_var_create (const char *command, const char *const *argv, int argc) gen_name = varobj_gen_name (); name = gen_name.c_str (); } - else if (!isalpha (name[0])) + else if (!c_isalpha (name[0])) error (_("-var-create: name of object must begin with a letter")); if (strcmp (frame, "*") == 0) diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 789e6fa..bcc32f9 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -52,7 +52,6 @@ #include <optional> #include "gdbsupport/byte-vector.h" -#include <ctype.h> #include "gdbsupport/run-time-clock.h" #include <chrono> #include "progspace-and-thread.h" diff --git a/gdb/mi/mi-parse.c b/gdb/mi/mi-parse.c index 0af90cb..58bdf4a 100644 --- a/gdb/mi/mi-parse.c +++ b/gdb/mi/mi-parse.c @@ -22,7 +22,6 @@ #include "mi-cmds.h" #include "mi-parse.h" -#include <ctype.h> #include "cli/cli-utils.h" #include "language.h" @@ -61,7 +60,7 @@ mi_parse_escape (const char **string_ptr) while (++count < 3) { c = (**string_ptr); - if (isdigit (c) && c != '8' && c != '9') + if (c_isdigit (c) && c != '8' && c != '9') { (*string_ptr)++; i *= 8; @@ -162,7 +161,7 @@ mi_parse::parse_argv () return; } /* Insist on trailing white space. */ - if (chp[1] != '\0' && !isspace (chp[1])) + if (chp[1] != '\0' && !c_isspace (chp[1])) { freeargv (argv); return; @@ -193,7 +192,7 @@ mi_parse::parse_argv () int len; const char *start = chp; - while (*chp != '\0' && !isspace (*chp)) + while (*chp != '\0' && !c_isspace (*chp)) { chp++; } @@ -313,7 +312,7 @@ mi_parse::mi_parse (const char *cmd, std::string *token) { const char *tmp = chp + 1; /* discard ``-'' */ - for (; *chp && !isspace (*chp); chp++) + for (; *chp && !c_isspace (*chp); chp++) ; this->command = make_unique_xstrndup (tmp, chp - tmp); } @@ -391,7 +390,7 @@ mi_parse::mi_parse (const char *cmd, std::string *token) else break; - if (*chp != '\0' && !isspace (*chp)) + if (*chp != '\0' && !c_isspace (*chp)) error (_("Invalid value for the '%s' option"), option); chp = skip_spaces (chp); } diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 765535c..c4a0fa8 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -36,7 +36,6 @@ to figure out what full symbol table entries need to be read in. */ -#include <ctype.h> #include "maint.h" #include "symtab.h" #include "bfd.h" diff --git a/gdb/nat/linux-osdata.c b/gdb/nat/linux-osdata.c index b52a8ed..0a309b8 100644 --- a/gdb/nat/linux-osdata.c +++ b/gdb/nat/linux-osdata.c @@ -21,7 +21,6 @@ #include <sys/types.h> #include <sys/sysinfo.h> -#include <ctype.h> #include <utmp.h> #include <time.h> #include <unistd.h> @@ -205,7 +204,7 @@ get_cores_used_by_process (PID_T pid, int *cores, const int num_cores) PID_T tid; int core; - if (!isdigit (dp->d_name[0]) + if (!c_isdigit (dp->d_name[0]) || NAMELEN (dp) > MAX_PID_T_STRLEN) continue; @@ -310,7 +309,7 @@ linux_xfer_osdata_processes () std::string cores_str; int i; - if (!isdigit (dp->d_name[0]) + if (!c_isdigit (dp->d_name[0]) || NAMELEN (dp) > MAX_PID_T_STRLEN) continue; @@ -419,7 +418,7 @@ linux_xfer_osdata_processgroups () { PID_T pid, pgid; - if (!isdigit (dp->d_name[0]) + if (!c_isdigit (dp->d_name[0]) || NAMELEN (dp) > MAX_PID_T_STRLEN) continue; @@ -483,7 +482,7 @@ linux_xfer_osdata_threads () struct stat statbuf; char procentry[sizeof ("/proc/4294967295")]; - if (!isdigit (dp->d_name[0]) + if (!c_isdigit (dp->d_name[0]) || NAMELEN (dp) > sizeof ("4294967295") - 1) continue; @@ -513,7 +512,7 @@ linux_xfer_osdata_threads () PID_T tid; int core; - if (!isdigit (dp2->d_name[0]) + if (!c_isdigit (dp2->d_name[0]) || NAMELEN (dp2) > sizeof ("4294967295") - 1) continue; @@ -633,7 +632,7 @@ linux_xfer_osdata_fds () struct stat statbuf; char procentry[sizeof ("/proc/4294967295")]; - if (!isdigit (dp->d_name[0]) + if (!c_isdigit (dp->d_name[0]) || NAMELEN (dp) > sizeof ("4294967295") - 1) continue; @@ -662,7 +661,7 @@ linux_xfer_osdata_fds () char buf[1000]; ssize_t rslt; - if (!isdigit (dp2->d_name[0])) + if (!c_isdigit (dp2->d_name[0])) continue; std::string fdname diff --git a/gdb/netbsd-nat.c b/gdb/netbsd-nat.c index 060134f..207e69c 100644 --- a/gdb/netbsd-nat.c +++ b/gdb/netbsd-nat.c @@ -318,7 +318,7 @@ nbsd_nat_target::info_proc (const char *args, enum info_proc_what what) if (pid == 0) error (_("No current process: you must name one.")); } - else if (built_argv.count () == 1 && isdigit (built_argv[0][0])) + else if (built_argv.count () == 1 && c_isdigit (built_argv[0][0])) pid = strtol (built_argv[0], NULL, 10); else error (_("Invalid arguments.")); diff --git a/gdb/objc-lang.c b/gdb/objc-lang.c index 6bba8d3..492020d 100644 --- a/gdb/objc-lang.c +++ b/gdb/objc-lang.c @@ -46,7 +46,6 @@ #include "cli/cli-utils.h" #include "c-exp.h" -#include <ctype.h> #include <algorithm> struct objc_object { @@ -850,9 +849,9 @@ parse_selector (char *method, char **selector) for (;;) { - if (isalnum (*s2) || (*s2 == '_') || (*s2 == ':')) + if (c_isalnum (*s2) || (*s2 == '_') || (*s2 == ':')) *s1++ = *s2; - else if (isspace (*s2)) + else if (c_isspace (*s2)) ; else if ((*s2 == '\0') || (*s2 == '\'')) break; @@ -914,7 +913,7 @@ parse_method (char *method, char *type, char **theclass, s1++; nclass = s1; - while (isalnum (*s1) || (*s1 == '_')) + while (c_isalnum (*s1) || (*s1 == '_')) s1++; s2 = s1; @@ -925,7 +924,7 @@ parse_method (char *method, char *type, char **theclass, s2++; s2 = skip_spaces (s2); ncategory = s2; - while (isalnum (*s2) || (*s2 == '_')) + while (c_isalnum (*s2) || (*s2 == '_')) s2++; *s2++ = '\0'; } @@ -938,9 +937,9 @@ parse_method (char *method, char *type, char **theclass, for (;;) { - if (isalnum (*s2) || (*s2 == '_') || (*s2 == ':')) + if (c_isalnum (*s2) || (*s2 == '_') || (*s2 == ':')) *s1++ = *s2; - else if (isspace (*s2)) + else if (c_isspace (*s2)) ; else if (*s2 == ']') break; diff --git a/gdb/p-exp.y b/gdb/p-exp.y index 2b923ab..a68443a 100644 --- a/gdb/p-exp.y +++ b/gdb/p-exp.y @@ -43,7 +43,6 @@ Probably also lots of other problems, less well defined PM. */ %{ -#include <ctype.h> #include "expression.h" #include "value.h" #include "parser-defs.h" @@ -817,13 +816,13 @@ parse_number (struct parser_state *par_state, { /* Handle suffixes: 'f' for float, 'l' for long double. FIXME: This appears to be an extension -- do we want this? */ - if (len >= 1 && tolower (p[len - 1]) == 'f') + if (len >= 1 && c_tolower (p[len - 1]) == 'f') { putithere->typed_val_float.type = parse_type (par_state)->builtin_float; len--; } - else if (len >= 1 && tolower (p[len - 1]) == 'l') + else if (len >= 1 && c_tolower (p[len - 1]) == 'l') { putithere->typed_val_float.type = parse_type (par_state)->builtin_long_double; @@ -1089,9 +1088,9 @@ yylex (void) if (explen > 2) for (const auto &token : tokentab3) if (strncasecmp (tokstart, token.oper, 3) == 0 - && (!isalpha (token.oper[0]) || explen == 3 - || (!isalpha (tokstart[3]) - && !isdigit (tokstart[3]) && tokstart[3] != '_'))) + && (!c_isalpha (token.oper[0]) || explen == 3 + || (!c_isalpha (tokstart[3]) + && !c_isdigit (tokstart[3]) && tokstart[3] != '_'))) { pstate->lexptr += 3; yylval.opcode = token.opcode; @@ -1102,9 +1101,9 @@ yylex (void) if (explen > 1) for (const auto &token : tokentab2) if (strncasecmp (tokstart, token.oper, 2) == 0 - && (!isalpha (token.oper[0]) || explen == 2 - || (!isalpha (tokstart[2]) - && !isdigit (tokstart[2]) && tokstart[2] != '_'))) + && (!c_isalpha (token.oper[0]) || explen == 2 + || (!c_isalpha (tokstart[2]) + && !c_isdigit (tokstart[2]) && tokstart[2] != '_'))) { pstate->lexptr += 2; yylval.opcode = token.opcode; diff --git a/gdb/p-lang.c b/gdb/p-lang.c index 3ded152..1dc1a34 100644 --- a/gdb/p-lang.c +++ b/gdb/p-lang.c @@ -30,7 +30,6 @@ #include "p-lang.h" #include "valprint.h" #include "value.h" -#include <ctype.h> #include "c-lang.h" #include "gdbarch.h" #include "cli/cli-style.h" diff --git a/gdb/p-typeprint.c b/gdb/p-typeprint.c index 7994ccf..8b5f2b5 100644 --- a/gdb/p-typeprint.c +++ b/gdb/p-typeprint.c @@ -30,7 +30,6 @@ #include "p-lang.h" #include "typeprint.h" #include "gdb-demangle.h" -#include <ctype.h> #include "cli/cli-style.h" /* See language.h. */ @@ -138,13 +137,13 @@ pascal_language::type_print_method_args (const char *physname, { gdb_puts (" (", stream); /* We must demangle this. */ - while (isdigit (physname[0])) + while (c_isdigit (physname[0])) { int len = 0; int i, j; char *argname; - while (isdigit (physname[len])) + while (c_isdigit (physname[len])) { len++; } diff --git a/gdb/parse.c b/gdb/parse.c index 6ad4e71..e24a0d0 100644 --- a/gdb/parse.c +++ b/gdb/parse.c @@ -29,7 +29,6 @@ during the process of parsing; the lower levels of the tree always come first in the result. */ -#include <ctype.h> #include "arch-utils.h" #include "symtab.h" #include "gdbtypes.h" diff --git a/gdb/ppc-linux-tdep.c b/gdb/ppc-linux-tdep.c index 39566a4..b5f8bbf 100644 --- a/gdb/ppc-linux-tdep.c +++ b/gdb/ppc-linux-tdep.c @@ -61,7 +61,6 @@ #include "cli/cli-utils.h" #include "parser-defs.h" #include "user-regs.h" -#include <ctype.h> #include "elf-bfd.h" #include "producer.h" #include "target-float.h" @@ -1712,10 +1711,10 @@ static int ppc_stap_is_single_operand (struct gdbarch *gdbarch, const char *s) { return (*s == 'i' /* Literal number. */ - || (isdigit (*s) && s[1] == '(' - && isdigit (s[2])) /* Displacement. */ - || (*s == '(' && isdigit (s[1])) /* Register indirection. */ - || isdigit (*s)); /* Register value. */ + || (c_isdigit (*s) && s[1] == '(' + && c_isdigit (s[2])) /* Displacement. */ + || (*s == '(' && c_isdigit (s[1])) /* Register indirection. */ + || c_isdigit (*s)); /* Register value. */ } /* Implementation of `gdbarch_stap_parse_special_token', as defined in @@ -1725,7 +1724,7 @@ static expr::operation_up ppc_stap_parse_special_token (struct gdbarch *gdbarch, struct stap_parse_info *p) { - if (isdigit (*p->arg)) + if (c_isdigit (*p->arg)) { /* This temporary pointer is needed because we have to do a lookahead. We could be dealing with a register displacement, and in such case @@ -1734,7 +1733,7 @@ ppc_stap_parse_special_token (struct gdbarch *gdbarch, char *regname; int len; - while (isdigit (*s)) + while (c_isdigit (*s)) ++s; if (*s == '(') diff --git a/gdb/probe.c b/gdb/probe.c index 6679f39..c2b8270 100644 --- a/gdb/probe.c +++ b/gdb/probe.c @@ -33,7 +33,6 @@ #include "ax.h" #include "ax-gdb.h" #include "location.h" -#include <ctype.h> #include <algorithm> #include <optional> @@ -826,7 +825,7 @@ probe_is_linespec_by_keyword (const char **linespecp, const char *const *keyword const char *keyword = *csp; size_t len = strlen (keyword); - if (strncmp (s, keyword, len) == 0 && isspace (s[len])) + if (strncmp (s, keyword, len) == 0 && c_isspace (s[len])) { *linespecp += len + 1; return 1; diff --git a/gdb/procfs.c b/gdb/procfs.c index a10574a..ca7ecbb 100644 --- a/gdb/procfs.c +++ b/gdb/procfs.c @@ -38,7 +38,6 @@ #include <sys/syscall.h> #include "gdbsupport/gdb_wait.h" #include <signal.h> -#include <ctype.h> #include "gdb_bfd.h" #include "auxv.h" #include "procfs.h" @@ -3304,7 +3303,7 @@ procfs_target::info_proc (const char *args, enum info_proc_what what) gdb_argv built_argv (args); for (char *arg : built_argv) { - if (isdigit (arg[0])) + if (c_isdigit (arg[0])) { pid = strtoul (arg, &tmp, 10); if (*tmp == '/') @@ -3415,7 +3414,7 @@ proc_trace_syscalls (const char *args, int from_tty, int entry_or_exit, int mode error_no_arg (_("system call to trace")); pi = find_procinfo_or_die (inferior_ptid.pid (), 0); - if (isdigit (args[0])) + if (c_isdigit (args[0])) { const int syscallnum = atoi (args); diff --git a/gdb/producer.c b/gdb/producer.c index 5d754fa..71e1b92 100644 --- a/gdb/producer.c +++ b/gdb/producer.c @@ -66,9 +66,9 @@ producer_is_gcc (const char *producer, int *major, int *minor) "GNU Fortran 4.8.2 20140120 (Red Hat 4.8.2-16) -mtune=generic ..." "GNU C++14 5.0.0 20150123 (experimental)" */ - while (*cs && !isspace (*cs)) + while (*cs && !c_isspace (*cs)) cs++; - if (*cs && isspace (*cs)) + if (*cs && c_isspace (*cs)) cs++; if (sscanf (cs, "%d.%d", major, minor) == 2) return 1; diff --git a/gdb/python/py-mi.c b/gdb/python/py-mi.c index 9b871d4..b2ab4e2 100644 --- a/gdb/python/py-mi.c +++ b/gdb/python/py-mi.c @@ -218,11 +218,11 @@ py_object_to_mi_key (PyObject *key_obj) { gdb_assert (name != nullptr); - if (*name == '\0' || !isalpha (*name)) + if (*name == '\0' || !c_isalpha (*name)) return false; for (; *name != '\0'; ++name) - if (!isalnum (*name) && *name != '_' && *name != '-') + if (!c_isalnum (*name) && *name != '_' && *name != '-') return false; return true; @@ -363,7 +363,7 @@ gdbpy_notify_mi (PyObject *self, PyObject *args, PyObject *kwargs) } for (int i = 0; i < name_len; i++) { - if (!isalnum (name[i]) && name[i] != '-') + if (!c_isalnum (name[i]) && name[i] != '-') { PyErr_Format (PyExc_ValueError, diff --git a/gdb/python/py-micmd.c b/gdb/python/py-micmd.c index 72f427f..07db0cc 100644 --- a/gdb/python/py-micmd.c +++ b/gdb/python/py-micmd.c @@ -350,7 +350,7 @@ micmdpy_init (PyObject *self, PyObject *args, PyObject *kwargs) PyErr_SetString (PyExc_ValueError, _("MI command name is empty.")); return -1; } - else if ((name_len < 2) || (name[0] != '-') || !isalnum (name[1])) + else if ((name_len < 2) || (name[0] != '-') || !c_isalnum (name[1])) { PyErr_SetString (PyExc_ValueError, _("MI command name does not start with '-'" @@ -361,7 +361,7 @@ micmdpy_init (PyObject *self, PyObject *args, PyObject *kwargs) { for (int i = 2; i < name_len; i++) { - if (!isalnum (name[i]) && name[i] != '-') + if (!c_isalnum (name[i]) && name[i] != '-') { PyErr_Format (PyExc_ValueError, diff --git a/gdb/python/py-objfile.c b/gdb/python/py-objfile.c index 8f92642..a9f5754 100644 --- a/gdb/python/py-objfile.c +++ b/gdb/python/py-objfile.c @@ -556,7 +556,7 @@ objfpy_build_id_ok (const char *string) return 0; for (i = 0; i < n; ++i) { - if (!isxdigit (string[i])) + if (!c_isxdigit (string[i])) return 0; } return 1; diff --git a/gdb/python/python.c b/gdb/python/python.c index 3b5d069..740b196 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -31,7 +31,6 @@ #include "python.h" #include "extension-priv.h" #include "cli/cli-utils.h" -#include <ctype.h> #include "location.h" #include "run-on-main-thread.h" #include "observable.h" diff --git a/gdb/record.c b/gdb/record.c index 248cfaa..de1a7a8 100644 --- a/gdb/record.c +++ b/gdb/record.c @@ -28,7 +28,6 @@ #include "interps.h" #include "top.h" -#include <ctype.h> /* This is the debug switch for process record. */ unsigned int record_debug = 0; @@ -423,7 +422,7 @@ get_insn_number (const char **arg) begin = *arg; pos = skip_spaces (begin); - if (!isdigit (*pos)) + if (!c_isdigit (*pos)) error (_("Expected positive number, got: %s."), pos); number = strtoulst (pos, &end, 10); @@ -443,7 +442,7 @@ get_context_size (const char **arg) pos = skip_spaces (*arg); - if (!isdigit (*pos)) + if (!c_isdigit (*pos)) error (_("Expected positive number, got: %s."), pos); long result = strtol (pos, &end, 10); @@ -483,7 +482,7 @@ get_insn_history_modifiers (const char **arg) for (; *args; ++args) { - if (isspace (*args)) + if (c_isspace (*args)) break; if (*args == '/') @@ -627,7 +626,7 @@ get_call_history_modifiers (const char **arg) for (; *args; ++args) { - if (isspace (*args)) + if (c_isspace (*args)) break; if (*args == '/') diff --git a/gdb/remote-sim.c b/gdb/remote-sim.c index 425e50d..a325ffa 100644 --- a/gdb/remote-sim.c +++ b/gdb/remote-sim.c @@ -25,7 +25,6 @@ #include "inferior.h" #include "infrun.h" #include "value.h" -#include <ctype.h> #include <fcntl.h> #include <signal.h> #include <setjmp.h> diff --git a/gdb/remote.c b/gdb/remote.c index 1d8d9b1..1eb4f72 100644 --- a/gdb/remote.c +++ b/gdb/remote.c @@ -19,7 +19,6 @@ /* See the GDB User Guide for details of the GDB remote protocol. */ -#include <ctype.h> #include <fcntl.h> #include "exceptions.h" #include "gdbsupport/common-inferior.h" @@ -2559,7 +2558,7 @@ packet_check_result (const char *buf) /* The stub recognized the packet request. Check that the operation succeeded. */ if (buf[0] == 'E' - && isxdigit (buf[1]) && isxdigit (buf[2]) + && c_isxdigit (buf[1]) && c_isxdigit (buf[2]) && buf[3] == '\0') /* "Enn" - definitely an error. */ return packet_result::make_numeric_error (buf + 1); @@ -11950,7 +11949,7 @@ remote_target::xfer_partial (enum target_object object, while (annex[i] && (i < (get_remote_packet_size () - 8))) { /* Bad caller may have sent forbidden characters. */ - gdb_assert (isprint (annex[i]) && annex[i] != '$' && annex[i] != '#'); + gdb_assert (c_isprint (annex[i]) && annex[i] != '$' && annex[i] != '#'); *p2++ = annex[i]; i++; } @@ -12200,7 +12199,7 @@ private: for (int i = 0; i < buf.size (); ++i) { gdb_byte c = buf[i]; - if (isprint (c)) + if (c_isprint (c)) gdb_putc (c, &stb); else gdb_printf (&stb, "\\x%02x", (unsigned char) c); diff --git a/gdb/rust-lang.c b/gdb/rust-lang.c index 3605552..4626685 100644 --- a/gdb/rust-lang.c +++ b/gdb/rust-lang.c @@ -18,7 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <ctype.h> #include "block.h" #include "c-lang.h" @@ -1788,7 +1787,7 @@ rust_language::emitchar (int ch, struct type *chtype, gdb_puts ("\\t", stream); else if (ch == '\0') gdb_puts ("\\0", stream); - else if (ch >= 32 && ch <= 127 && isprint (ch)) + else if (ch >= 32 && ch <= 127 && c_isprint (ch)) gdb_putc (ch, stream); else if (ch <= 255) gdb_printf (stream, "\\x%02x", ch); diff --git a/gdb/s12z-tdep.c b/gdb/s12z-tdep.c index 28d5635..0d49f98 100644 --- a/gdb/s12z-tdep.c +++ b/gdb/s12z-tdep.c @@ -516,7 +516,7 @@ s12z_print_ccw_info (struct gdbarch *gdbarch, gdb_putc (ccw_bits[b], file); } else - gdb_putc (tolower (ccw_bits[b]), file); + gdb_putc (c_tolower (ccw_bits[b]), file); } gdb_putc ('\n', file); } diff --git a/gdb/s390-tdep.c b/gdb/s390-tdep.c index c5fa24e..0cef5f4 100644 --- a/gdb/s390-tdep.c +++ b/gdb/s390-tdep.c @@ -7057,10 +7057,10 @@ s390_gnu_triplet_regexp (struct gdbarch *gdbarch) static int s390_stap_is_single_operand (struct gdbarch *gdbarch, const char *s) { - return ((isdigit (*s) && s[1] == '(' && s[2] == '%') /* Displacement + return ((c_isdigit (*s) && s[1] == '(' && s[2] == '%') /* Displacement or indirection. */ || *s == '%' /* Register access. */ - || isdigit (*s)); /* Literal number. */ + || c_isdigit (*s)); /* Literal number. */ } /* gdbarch init. */ diff --git a/gdb/serial.c b/gdb/serial.c index d66c637..d047fdf 100644 --- a/gdb/serial.c +++ b/gdb/serial.c @@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <ctype.h> #include "serial.h" #include "cli/cli-cmds.h" #include "cli/cli-utils.h" @@ -116,7 +115,7 @@ serial_logchar (struct ui_file *stream, int ch_type, int ch, int timeout) break; default: gdb_printf (stream, - isprint (ch) ? "%c" : "\\x%02x", ch & 0xFF); + c_isprint (ch) ? "%c" : "\\x%02x", ch & 0xFF); break; } } diff --git a/gdb/solib-rocm.c b/gdb/solib-rocm.c index c39d9d7..c3c2e44 100644 --- a/gdb/solib-rocm.c +++ b/gdb/solib-rocm.c @@ -511,7 +511,7 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior) protocol_end += protocol_delim.length (); std::transform (protocol.begin (), protocol.end (), protocol.begin (), - [] (unsigned char c) { return std::tolower (c); }); + [] (unsigned char c) { return c_tolower (c); }); std::string_view path; size_t path_end = uri.find_first_of ("#?", protocol_end); @@ -526,8 +526,8 @@ rocm_bfd_iovec_open (bfd *abfd, inferior *inferior) for (size_t i = 0; i < path.length (); ++i) if (path[i] == '%' && i < path.length () - 2 - && std::isxdigit (path[i + 1]) - && std::isxdigit (path[i + 2])) + && c_isxdigit (path[i + 1]) + && c_isxdigit (path[i + 2])) { std::string_view hex_digits = path.substr (i + 1, 2); decoded_path += std::stoi (std::string (hex_digits), 0, 16); diff --git a/gdb/stabsread.c b/gdb/stabsread.c index 2d1411e..733fc9e 100644 --- a/gdb/stabsread.c +++ b/gdb/stabsread.c @@ -46,7 +46,6 @@ #include "c-lang.h" #include "cp-abi.h" #include "cp-support.h" -#include <ctype.h> #include "block.h" #include "filenames.h" @@ -3067,7 +3066,7 @@ process_reference (const char **string) p = *string + 1; /* Read number as reference id. */ - while (*p && isdigit (*p)) + while (*p && c_isdigit (*p)) { refnum = refnum * 10 + *p - '0'; p++; @@ -3251,7 +3250,7 @@ define_symbol (CORE_ADDR valu, const char *string, int desc, int type, deftypes we know how to handle is a local. */ if (!strchr ("cfFGpPrStTvVXCR", *p)) #else - if (isdigit (*p) || *p == '(' || *p == '-') + if (c_isdigit (*p) || *p == '(' || *p == '-') #endif deftype = 'l'; else @@ -4340,7 +4339,7 @@ again: break; case '@': - if (isdigit (**pp) || **pp == '(' || **pp == '-') + if (c_isdigit (**pp) || **pp == '(' || **pp == '-') { /* Member (class & variable) type */ /* FIXME -- we should be doing smash_to_XXX types here. */ diff --git a/gdb/stack.c b/gdb/stack.c index c0af030..add1c54 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -3064,7 +3064,7 @@ frame_apply_level_cmd_completer (struct cmd_list_element *ignore, /* Check if we're past a valid LEVEL already. */ if (levels.finished () - && cmd > text && !isspace (cmd[-1])) + && cmd > text && !c_isspace (cmd[-1])) return; /* We're past LEVELs, advance word point. */ @@ -3098,7 +3098,7 @@ frame_apply_cmd_completer (struct cmd_list_element *ignore, return; /* Check if we're past a valid COUNT already. */ - if (cmd > text && !isspace (cmd[-1])) + if (cmd > text && !c_isspace (cmd[-1])) return; /* We're past COUNT, advance word point. */ diff --git a/gdb/stap-probe.c b/gdb/stap-probe.c index 3b692e2..6c15bce 100644 --- a/gdb/stap-probe.c +++ b/gdb/stap-probe.c @@ -39,7 +39,6 @@ #include "expop.h" #include "gdbsupport/unordered_map.h" -#include <ctype.h> /* The name of the SystemTap section where we will find information about the probes. */ @@ -575,14 +574,14 @@ stap_is_integer_prefix (struct gdbarch *gdbarch, const char *s, if (r != NULL) *r = ""; - return isdigit (*s) > 0; + return c_isdigit (*s) > 0; } for (p = t; *p != NULL; ++p) { size_t len = strlen (*p); - if ((len == 0 && isdigit (*s)) + if ((len == 0 && c_isdigit (*s)) || (len > 0 && strncasecmp (s, *p, len) == 0)) { /* Integers may or may not have a prefix. The "len == 0" @@ -732,7 +731,7 @@ stap_parse_register_operand (struct stap_parse_info *p) struct type *long_type = builtin_type (gdbarch)->builtin_long; operation_up disp_op; - if (isdigit (*p->arg)) + if (c_isdigit (*p->arg)) { /* The value of the displacement. */ long displacement; @@ -767,14 +766,14 @@ stap_parse_register_operand (struct stap_parse_info *p) start = p->arg; /* We assume the register name is composed by letters and numbers. */ - while (isalnum (*p->arg)) + while (c_isalnum (*p->arg)) ++p->arg; std::string regname (start, p->arg - start); /* We only add the GDB's register prefix/suffix if we are dealing with a numeric register. */ - if (isdigit (*start)) + if (c_isdigit (*start)) { if (gdb_reg_prefix != NULL) regname = gdb_reg_prefix + regname; @@ -921,7 +920,7 @@ stap_parse_single_operand (struct stap_parse_info *p) if (p->inside_paren_p) tmp = skip_spaces (tmp); - while (isdigit (*tmp)) + while (c_isdigit (*tmp)) { /* We skip the digit here because we are only interested in knowing what kind of unary operation this is. The digit @@ -959,7 +958,7 @@ stap_parse_single_operand (struct stap_parse_info *p) (std::move (result))); } } - else if (isdigit (*p->arg)) + else if (c_isdigit (*p->arg)) { /* A temporary variable, needed for lookahead. */ const char *tmp = p->arg; @@ -1042,7 +1041,7 @@ stap_parse_argument_conditionally (struct stap_parse_info *p) expr::operation_up result; if (*p->arg == '-' || *p->arg == '~' || *p->arg == '+' || *p->arg == '!' - || isdigit (*p->arg) + || c_isdigit (*p->arg) || gdbarch_stap_is_single_operand (p->gdbarch, p->arg)) result = stap_parse_single_operand (p); else if (*p->arg == '(') @@ -1111,7 +1110,7 @@ stap_parse_argument_1 (struct stap_parse_info *p, This loop shall continue until we run out of characters in the input, or until we find a close-parenthesis, which means that we've reached the end of a sub-expression. */ - while (*p->arg != '\0' && *p->arg != ')' && !isspace (*p->arg)) + while (*p->arg != '\0' && *p->arg != ')' && !c_isspace (*p->arg)) { const char *tmp_exp_buf; enum exp_opcode opcode; @@ -1270,8 +1269,8 @@ stap_probe::parse_arguments (struct gdbarch *gdbarch) Where `N' can be [+,-][1,2,4,8]. This is not mandatory, so we check it here. If we don't find it, go to the next state. */ - if ((cur[0] == '-' && isdigit (cur[1]) && cur[2] == '@') - || (isdigit (cur[0]) && cur[1] == '@')) + if ((cur[0] == '-' && c_isdigit (cur[1]) && cur[2] == '@') + || (c_isdigit (cur[0]) && cur[1] == '@')) { if (*cur == '-') { diff --git a/gdb/symfile.c b/gdb/symfile.c index 8e4888f..15e9ed3 100644 --- a/gdb/symfile.c +++ b/gdb/symfile.c @@ -58,7 +58,6 @@ #include <sys/types.h> #include <fcntl.h> #include <sys/stat.h> -#include <ctype.h> #include <chrono> #include <algorithm> @@ -2748,7 +2747,7 @@ set_ext_lang_command (const char *args, error (_("'%s': Filename extension must begin with '.'"), ext_args.c_str ()); /* Find end of first arg. */ - while (*end != '\0' && !isspace (*end)) + while (*end != '\0' && !c_isspace (*end)) end++; if (*end == '\0') diff --git a/gdb/symtab.c b/gdb/symtab.c index 245eab2..1341607 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -56,7 +56,6 @@ #include <sys/types.h> #include <fcntl.h> #include <sys/stat.h> -#include <ctype.h> #include "cp-abi.h" #include "cp-support.h" #include "observable.h" @@ -4332,7 +4331,7 @@ operator_chars (const char *p, const char **end) /* Don't get faked out by `operator' being part of a longer identifier. */ - if (isalpha (*p) || *p == '_' || *p == '$' || *p == '\0') + if (c_isalpha (*p) || *p == '_' || *p == '$' || *p == '\0') return *end; /* Allow some whitespace between `operator' and the operator symbol. */ @@ -4341,11 +4340,11 @@ operator_chars (const char *p, const char **end) /* Recognize 'operator TYPENAME'. */ - if (isalpha (*p) || *p == '_' || *p == '$') + if (c_isalpha (*p) || *p == '_' || *p == '$') { const char *q = p + 1; - while (isalnum (*q) || *q == '_' || *q == '$') + while (c_isalnum (*q) || *q == '_' || *q == '$') q++; *end = q; return p; @@ -5119,7 +5118,7 @@ global_symbol_searcher::search () const int fix = -1; /* -1 means ok; otherwise number of spaces needed. */ - if (isalpha (*opname) || *opname == '_' || *opname == '$') + if (c_isalpha (*opname) || *opname == '_' || *opname == '$') { /* There should 1 space between 'operator' and 'TYPENAME'. */ if (opname[-1] != ' ' || opname[-2] == ' ') @@ -5601,7 +5600,7 @@ rbreak_command (const char *regexp, int from_tty) if (colon && *(colon + 1) != ':') { int colon_index = colon - regexp; - while (colon_index > 0 && isspace (regexp[colon_index - 1])) + while (colon_index > 0 && c_isspace (regexp[colon_index - 1])) --colon_index; file_name = make_unique_xstrndup (regexp, colon_index); @@ -5853,7 +5852,7 @@ language_search_unquoted_string (const char *text, const char *p) { for (; p > text; --p) { - if (isalnum (p[-1]) || p[-1] == '_' || p[-1] == '\0') + if (c_isalnum (p[-1]) || p[-1] == '_' || p[-1] == '\0') continue; else { @@ -5873,7 +5872,7 @@ language_search_unquoted_string (const char *text, const char *p) Unfortunately we have to find it now to decide. */ while (t > text) - if (isalnum (t[-1]) || t[-1] == '_' || + if (c_isalnum (t[-1]) || t[-1] == '_' || t[-1] == ' ' || t[-1] == ':' || t[-1] == '(' || t[-1] == ')') --t; @@ -6081,7 +6080,7 @@ default_collect_symbol_completion_matches_break_on which are in symbols. */ while (p > text) { - if (isalnum (p[-1]) || p[-1] == '_' || p[-1] == '\0' + if (c_isalnum (p[-1]) || p[-1] == '_' || p[-1] == '\0' || p[-1] == ':' || strchr (break_on, p[-1]) != NULL) --p; else diff --git a/gdb/thread.c b/gdb/thread.c index 920d8dc..b6c19f9 100644 --- a/gdb/thread.c +++ b/gdb/thread.c @@ -33,7 +33,6 @@ #include "regcache.h" #include "btrace.h" -#include <ctype.h> #include <sys/types.h> #include <signal.h> #include "ui-out.h" @@ -1808,7 +1807,7 @@ thread_apply_command_completer (cmd_list_element *ignore, /* Check if we're past a valid thread ID list already. */ if (parser.finished () - && cmd > text && !isspace (cmd[-1])) + && cmd > text && !c_isspace (cmd[-1])) return; /* We're past the thread ID list, advance word point. */ @@ -1871,7 +1870,7 @@ thread_apply_command (const char *tidlist, int from_tty) if (*cmd == '\0') error (_("Please specify a command following the thread ID list")); - if (tidlist == cmd || isdigit (cmd[0])) + if (tidlist == cmd || c_isdigit (cmd[0])) invalid_thread_id_error (cmd); scoped_restore_current_thread restore_thread; diff --git a/gdb/tid-parse.c b/gdb/tid-parse.c index 4e45798..9f79fba 100644 --- a/gdb/tid-parse.c +++ b/gdb/tid-parse.c @@ -20,7 +20,6 @@ #include "tid-parse.h" #include "inferior.h" #include "gdbthread.h" -#include <ctype.h> /* See tid-parse.h. */ @@ -184,7 +183,7 @@ tid_range_parser::finished () const or we are not in a range and not in front of an integer, negative integer, convenience var or negative convenience var. */ return (*m_cur_tok == '\0' - || !(isdigit (*m_cur_tok) + || !(c_isdigit (*m_cur_tok) || *m_cur_tok == '$' || *m_cur_tok == '*')); case STATE_THREAD_RANGE: @@ -261,7 +260,7 @@ tid_range_parser::get_tid_or_range (int *inf_num, m_qualified = true; p = dot + 1; - if (isspace (*p)) + if (c_isspace (*p)) return false; } else @@ -272,7 +271,7 @@ tid_range_parser::get_tid_or_range (int *inf_num, } m_range_parser.init (p); - if (p[0] == '*' && (p[1] == '\0' || isspace (p[1]))) + if (p[0] == '*' && (p[1] == '\0' || c_isspace (p[1]))) { /* Setup the number range parser to return numbers in the whole [1,INT_MAX] range. */ @@ -69,7 +69,6 @@ #include "event-top.h" #include <sys/stat.h> -#include <ctype.h> #include "ui-out.h" #include "cli-out.h" #include "tracepoint.h" diff --git a/gdb/tracectf.c b/gdb/tracectf.c index 0f80d08..c2231ff 100644 --- a/gdb/tracectf.c +++ b/gdb/tracectf.c @@ -28,7 +28,6 @@ #include "inferior.h" #include "gdbthread.h" #include "tracefile.h" -#include <ctype.h> #include <algorithm> #include "gdbsupport/filestuff.h" #include "gdbarch.h" diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 58aad44..879e4a6 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -308,12 +308,12 @@ validate_trace_state_variable_name (const char *name) /* All digits in the name is reserved for value history references. */ - for (p = name; isdigit (*p); p++) + for (p = name; c_isdigit (*p); p++) ; if (*p == '\0') error (_("$%s is not a valid trace state variable name"), name); - for (p = name; isalnum (*p) || *p == '_'; p++) + for (p = name; c_isalnum (*p) || *p == '_'; p++) ; if (*p != '\0') error (_("$%s is not a valid trace state variable name"), name); @@ -339,7 +339,7 @@ trace_variable_command (const char *args, int from_tty) error (_("Name of trace variable should start with '$'")); name_start = p; - while (isalnum (*p) || *p == '_') + while (c_isalnum (*p) || *p == '_') p++; std::string name (name_start, p - name_start); diff --git a/gdb/tui/tui-win.c b/gdb/tui/tui-win.c index d4fbbf1..b411d07 100644 --- a/gdb/tui/tui-win.c +++ b/gdb/tui/tui-win.c @@ -45,7 +45,6 @@ #include "tui/tui-win.h" #include "gdb_curses.h" -#include <ctype.h> #include "readline/readline.h" #include <signal.h> #include <string_view> @@ -1041,7 +1040,7 @@ parse_scrolling_args (const char *arg, /* Process the number of lines to scroll. */ std::string copy = arg; buf_ptr = ©[0]; - if (isdigit (*buf_ptr)) + if (c_isdigit (*buf_ptr)) { char *num_str; diff --git a/gdb/typeprint.c b/gdb/typeprint.c index 8f2836a..42fbf38 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -31,7 +31,6 @@ #include "cp-abi.h" #include "typeprint.h" #include "valprint.h" -#include <ctype.h> #include "cli/cli-utils.h" #include "extension.h" #include "completer.h" @@ -367,7 +366,7 @@ whatis_exp (const char *exp, int show) { int seen_one = 0; - for (++exp; *exp && !isspace (*exp); ++exp) + for (++exp; *exp && !c_isspace (*exp); ++exp) { switch (*exp) { @@ -413,7 +412,7 @@ whatis_exp (const char *exp, int show) if (!*exp && !seen_one) error (_("flag expected")); - if (!isspace (*exp)) + if (!c_isspace (*exp)) error (_("expected space after format")); exp = skip_spaces (exp); } diff --git a/gdb/unittests/command-def-selftests.c b/gdb/unittests/command-def-selftests.c index 0a54d31..095b57f 100644 --- a/gdb/unittests/command-def-selftests.c +++ b/gdb/unittests/command-def-selftests.c @@ -72,7 +72,7 @@ check_doc (struct cmd_list_element *commandlist, const char *prefix) "first line is not terminated with a '.' character"); /* Checks the doc is not terminated with a new line. */ - if (isspace (c->doc[strlen (c->doc) - 1])) + if (c_isspace (c->doc[strlen (c->doc) - 1])) broken_doc_invariant (prefix, c->name, "has superfluous trailing whitespace"); @@ -87,7 +87,7 @@ check_doc (struct cmd_list_element *commandlist, const char *prefix) else { /* \n\n is ok, so we check that explicitly here. */ - if (isspace (nl[-1]) && nl[-1] != '\n') + if (c_isspace (nl[-1]) && nl[-1] != '\n') broken_doc_invariant (prefix, c->name, "has whitespace before a newline"); } diff --git a/gdb/utils.c b/gdb/utils.c index 5994ef9..57c739e 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -17,7 +17,6 @@ You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include <ctype.h> #include "gdbsupport/gdb_wait.h" #include "gdbsupport/scoped_signal_handler.h" #include "event-top.h" diff --git a/gdb/valprint.c b/gdb/valprint.c index 305faf7..b8c1c06 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -34,7 +34,6 @@ #include "gdbsupport/gdb_obstack.h" #include "charset.h" #include "typeprint.h" -#include <ctype.h> #include <algorithm> #include "gdbsupport/byte-vector.h" #include "cli/cli-option.h" diff --git a/gdb/value.c b/gdb/value.c index 82d9a86..c78bb98 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -35,7 +35,6 @@ #include "valprint.h" #include "cli/cli-decode.h" #include "extension.h" -#include <ctype.h> #include "tracepoint.h" #include "cp-abi.h" #include "user-regs.h" @@ -3723,11 +3722,11 @@ value_from_history_ref (const char *h, const char **endp) len = 2; /* Find length of numeral string. */ - for (; isdigit (h[len]); len++) + for (; c_isdigit (h[len]); len++) ; /* Make sure numeral string is not part of an identifier. */ - if (h[len] == '_' || isalpha (h[len])) + if (h[len] == '_' || c_isalpha (h[len])) return NULL; /* Now collect the index value. */ diff --git a/gdb/windows-nat.c b/gdb/windows-nat.c index c001d38..f74ea0c 100644 --- a/gdb/windows-nat.c +++ b/gdb/windows-nat.c @@ -2426,7 +2426,7 @@ redir_set_redirection (const char *s, int *inp, int *out, int *err) /* cmd.exe recognizes "&N" only immediately after the redirection symbol. */ if (*s != '&') { - while (isspace (*s)) /* skip whitespace before file name */ + while (c_isspace (*s)) /* skip whitespace before file name */ s++; *d++ = ' '; /* separate file name with a single space */ } @@ -2453,7 +2453,7 @@ redir_set_redirection (const char *s, int *inp, int *out, int *err) s++; *d++ = *s++; } - else if (isspace (*s) && !quote) + else if (c_isspace (*s) && !quote) break; else *d++ = *s++; @@ -2489,7 +2489,7 @@ redirect_inferior_handles (const char *cmd_orig, char *cmd, int quote = 0; bool retval = false; - while (isspace (*s)) + while (c_isspace (*s)) *d++ = *s++; while (*s) diff --git a/gdb/xcoffread.c b/gdb/xcoffread.c index 6528cab..d8b99a0 100644 --- a/gdb/xcoffread.c +++ b/gdb/xcoffread.c @@ -23,7 +23,6 @@ #include <sys/types.h> #include <fcntl.h> -#include <ctype.h> #ifdef HAVE_SYS_FILE_H #include <sys/file.h> #endif diff --git a/gdbserver/gdbreplay.cc b/gdbserver/gdbreplay.cc index a517031..1c6c41c 100644 --- a/gdbserver/gdbreplay.cc +++ b/gdbserver/gdbreplay.cc @@ -32,7 +32,6 @@ #if HAVE_SIGNAL_H #include <signal.h> #endif -#include <ctype.h> #if HAVE_FCNTL_H #include <fcntl.h> #endif diff --git a/gdbserver/remote-utils.cc b/gdbserver/remote-utils.cc index 15f073d..7606559 100644 --- a/gdbserver/remote-utils.cc +++ b/gdbserver/remote-utils.cc @@ -30,7 +30,6 @@ #include "gdbsupport/netstuff.h" #include "gdbsupport/filestuff.h" #include "gdbsupport/gdb-sigmask.h" -#include <ctype.h> #if HAVE_SYS_IOCTL_H #include <sys/ioctl.h> #endif @@ -759,7 +758,7 @@ input_interrupt (int unused) else if (cc != 1 || c != '\003') { fprintf (stderr, "input_interrupt, count = %d c = %d ", cc, c); - if (isprint (c)) + if (c_isprint (c)) fprintf (stderr, "('%c')\n", c); else fprintf (stderr, "('\\x%02x')\n", c & 0xff); @@ -1165,8 +1164,8 @@ prepare_resume_reply (char *buf, ptid_t ptid, const target_waitstatus &status) here is convert the buffer from a T packet to an S packet and the avoid adding any extra content by breaking out. */ gdb_assert (buf_start[0] == 'T'); - gdb_assert (isxdigit (buf_start[1])); - gdb_assert (isxdigit (buf_start[2])); + gdb_assert (c_isxdigit (buf_start[1])); + gdb_assert (c_isxdigit (buf_start[2])); buf_start[0] = 'S'; buf_start[3] = '\0'; break; diff --git a/gdbserver/server.cc b/gdbserver/server.cc index 669c761..6dc805a 100644 --- a/gdbserver/server.cc +++ b/gdbserver/server.cc @@ -22,7 +22,6 @@ #include "tdesc.h" #include "gdbsupport/rsp-low.h" #include "gdbsupport/signals-state-save-restore.h" -#include <ctype.h> #include <unistd.h> #if HAVE_SIGNAL_H #include <signal.h> @@ -1427,7 +1426,7 @@ parse_debug_format_options (const char *arg, int is_monitor) debug_timestamp = 0; /* First remove leading spaces, for "monitor set debug-format". */ - while (isspace (*arg)) + while (c_isspace (*arg)) ++arg; std::vector<gdb::unique_xmalloc_ptr<char>> options @@ -1473,8 +1472,8 @@ parse_debug_format_options (const char *arg, int is_monitor) struct debug_opt { /* NAME is the name of this debug option, this should be a simple string - containing no whitespace, starting with a letter from isalpha(), and - contain only isalnum() characters and '_' underscore and '-' hyphen. + containing no whitespace, starting with a letter from c_isalpha(), and + contain only c_isalnum() characters and '_' underscore and '-' hyphen. SETTER is a callback function used to set the debug variable. This callback will be passed true to enable the debug setting, or false to @@ -1483,7 +1482,7 @@ struct debug_opt : m_name (name), m_setter (setter) { - gdb_assert (isalpha (*name)); + gdb_assert (c_isalpha (*name)); } /* Called to enable or disable the debug setting. */ diff --git a/gdbserver/thread-db.cc b/gdbserver/thread-db.cc index 20e1dcc..b964389 100644 --- a/gdbserver/thread-db.cc +++ b/gdbserver/thread-db.cc @@ -32,7 +32,6 @@ #include <dlfcn.h> #endif #include <limits.h> -#include <ctype.h> struct thread_db { @@ -849,7 +848,7 @@ thread_db_handle_monitor_command (char *mon) free (libthread_db_search_path); /* Skip leading space (if any). */ - while (isspace (*cp)) + while (c_isspace (*cp)) ++cp; if (*cp == '\0') diff --git a/gdbserver/tracepoint.cc b/gdbserver/tracepoint.cc index b308c82..e1044dc 100644 --- a/gdbserver/tracepoint.cc +++ b/gdbserver/tracepoint.cc @@ -20,7 +20,6 @@ #include "gdbthread.h" #include "gdbsupport/rsp-low.h" -#include <ctype.h> #include <fcntl.h> #include <unistd.h> #include <chrono> @@ -1867,7 +1866,7 @@ add_tracepoint_action (struct tracepoint *tpoint, const char *packet) trace_debug ("Want to collect registers"); ++act; /* skip past hex digits of mask for now */ - while (isxdigit(*act)) + while (c_isxdigit(*act)) ++act; break; } diff --git a/gdbsupport/pathstuff.cc b/gdbsupport/pathstuff.cc index ce01c95..1866949 100644 --- a/gdbsupport/pathstuff.cc +++ b/gdbsupport/pathstuff.cc @@ -106,7 +106,7 @@ gdb_realpath_keepfile (const char *filename) #ifdef HAVE_DOS_BASED_FILE_SYSTEM /* We need to be careful when filename is of the form 'd:foo', which is equivalent of d:./foo, which is totally different from d:/foo. */ - if (strlen (dir_name) == 2 && isalpha (dir_name[0]) && dir_name[1] == ':') + if (strlen (dir_name) == 2 && c_isalpha (dir_name[0]) && dir_name[1] == ':') { dir_name[2] = '.'; dir_name[3] = '\000'; |