len -= 2;
}
/* Handle suffixes: 'f' for float, 'l' for long double. */
- else if (len >= 1 && TOLOWER (buf[len - 1]) == 'f')
+ else if (len >= 1 && c_tolower (buf[len - 1]) == 'f')
{
putithere->typed_val_float.type
= parse_type (par_state)->builtin_float;
len -= 1;
}
- else if (len >= 1 && TOLOWER (buf[len - 1]) == 'l')
+ else if (len >= 1 && c_tolower (buf[len - 1]) == 'l')
{
putithere->typed_val_float.type
= parse_type (par_state)->builtin_long_double;
if (output)
obstack_grow_str (output, "\\x");
++tokptr;
- if (!ISXDIGIT (*tokptr))
+ if (!c_isxdigit (*tokptr))
error (_("\\x escape without a following hex digit"));
- while (ISXDIGIT (*tokptr))
+ while (c_isxdigit (*tokptr))
{
if (output)
obstack_1grow (output, *tokptr);
if (output)
obstack_grow_str (output, "\\");
for (i = 0;
- i < 3 && ISDIGIT (*tokptr) && *tokptr != '8' && *tokptr != '9';
+ i < 3 && c_isdigit (*tokptr) && *tokptr != '8' && *tokptr != '9';
++i)
{
if (output)
obstack_1grow (output, *tokptr);
}
++tokptr;
- if (!ISXDIGIT (*tokptr))
+ if (!c_isxdigit (*tokptr))
error (_("\\%c escape without a following hex digit"), c);
- for (i = 0; i < len && ISXDIGIT (*tokptr); ++i)
+ for (i = 0; i < len && c_isxdigit (*tokptr); ++i)
{
if (output)
obstack_1grow (output, *tokptr);
size_t len = strlen ("selector");
if (strncmp (p, "selector", len) == 0
- && (p[len] == '\0' || ISSPACE (p[len])))
+ && (p[len] == '\0' || c_isspace (p[len])))
{
pstate->lexptr = p + len;
return SELECTOR;
goto parse_string;
}
- while (ISSPACE (*p))
+ while (c_isspace (*p))
p++;
size_t len = strlen ("entry");
if (strncmp (p, "entry", len) == 0 && !c_ident_is_alnum (p[len])
gdb_byte data[4];
int i;
- for (i = 0; i < length && p < limit && ISXDIGIT (*p); ++i, ++p)
+ for (i = 0; i < length && p < limit && c_isxdigit (*p); ++i, ++p)
result = (result << 4) + fromhex (*p);
for (i = 3; i >= 0; --i)
unsigned long value = 0;
for (i = 0;
- i < 3 && p < limit && ISDIGIT (*p) && *p != '8' && *p != '9';
+ i < 3 && p < limit && c_isdigit (*p) && *p != '8' && *p != '9';
++i)
{
value = 8 * value + fromhex (*p);
{
unsigned long value = 0;
- while (p < limit && ISXDIGIT (*p))
+ while (p < limit && c_isxdigit (*p))
{
value = 16 * value + fromhex (*p);
++p;
case 'x':
advance ();
- if (!ISXDIGIT (*p))
+ if (!c_isxdigit (*p))
error (_("\\x used with no following hex digits."));
p = convert_hex (type, p, limit, output);
break;
int length = *p == 'u' ? 4 : 8;
advance ();
- if (!ISXDIGIT (*p))
+ if (!c_isxdigit (*p))
error (_("\\u used with no following hex digits"));
p = convert_ucn (p, limit, dest_charset, output, length);
}
#ifndef GDB_C_SUPPORT_H
#define GDB_C_SUPPORT_H
-#include "safe-ctype.h"
-
-/* Like ISALPHA, but also returns true for the union of all UTF-8
+/* Like isalpha, but also returns true for the union of all UTF-8
multi-byte sequence bytes and non-ASCII characters in
extended-ASCII charsets (e.g., Latin1). I.e., returns true if the
high bit is set. Note that not all UTF-8 ranges are allowed in C++
static inline bool
c_ident_is_alpha (unsigned char ch)
{
- return ISALPHA (ch) || ch >= 0x80;
+ return c_isalpha (ch) || ch >= 0x80;
}
-/* Similarly, but Like ISALNUM. */
+/* Similarly, but Like isalnum. */
static inline bool
c_ident_is_alnum (unsigned char ch)
{
- return ISALNUM (ch) || ch >= 0x80;
+ return c_isalnum (ch) || ch >= 0x80;
}
#endif /* GDB_C_SUPPORT_H */
temp = strrchr (pathname, '/');
#if defined (__MSDOS__)
- if (temp == 0 && ISALPHA ((unsigned char)pathname[0]) && pathname[1] == ':')
+ if (temp == 0 && c_isalpha (pathname[0]) && pathname[1] == ':')
temp = pathname + 1;
#endif
#include <unistd.h>
-#include "gdbsupport/gdb-safe-ctype.h"
#include "demangle.h"
#include "cp-support.h"
#include "c-support.h"
/* See if it has `f' or `l' suffix (float or long double). */
- c = TOLOWER (p[len - 1]);
+ c = c_tolower (p[len - 1]);
if (c == 'f')
{
len--;
type = make_builtin_type ("long double");
}
- else if (ISDIGIT (c) || c == '.')
+ else if (c_isdigit (c) || c == '.')
type = make_builtin_type ("double");
else
return ERROR;
for (int off = 0; off < len; ++off)
{
int dig;
- if (ISDIGIT (p[off]))
+ if (c_isdigit (p[off]))
dig = p[off] - '0';
else
- dig = TOLOWER (p[off]) - 'a' + 10;
+ dig = c_tolower (p[off]) - 'a' + 10;
if (dig >= base)
return ERROR;
value *= base;
}
/* We will take any letters or digits. parse_number will
complain if past the radix, or if L or U are not final. */
- else if (! ISALNUM (*p))
+ else if (! c_isalnum (*p))
break;
if (no_tick.has_value ())
no_tick->push_back (*p);
#include "namespace.h"
#include <signal.h>
#include "gdbsupport/gdb_setjmp.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include "gdbsupport/selftest.h"
#include "gdbsupport/gdb-sigmask.h"
#include <atomic>
cp_already_canonical (const char *string)
{
/* Identifier start character [a-zA-Z_]. */
- if (!ISIDST (string[0]))
+ if (!c_isalpha (string[0]) || string[0] == '_')
return 0;
/* These are the only two identifiers which canonicalize to other
return 0;
/* Identifier character [a-zA-Z0-9_]. */
- while (ISIDNUM (string[1]))
+ while (c_isalpha (string[1]) || c_isdigit (string[1]) || string[1] == '_')
string++;
if (string[1] == '\0')
&& startswith (name + index, CP_OPERATOR_STR))
{
index += CP_OPERATOR_LEN;
- while (ISSPACE(name[index]))
+ while (c_isspace(name[index]))
++index;
switch (name[index])
{
scan += CP_OPERATOR_LEN;
if (*scan == c)
return scan;
- while (ISSPACE (*scan))
+ while (c_isspace (*scan))
{
++scan;
if (*scan == c)
#include "symtab.h"
#include "buildsym.h"
#include "dictionary.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include "gdbsupport/unordered_map.h"
#include "language.h"
if (c == 'B' && string[3] == '_')
{
- for (string += 4; ISDIGIT (*string); ++string)
+ for (string += 4; c_isdigit (*string); ++string)
;
continue;
}
#include "cli/cli-cmds.h"
#include "dis-asm.h"
#include "source.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include <algorithm>
#include <optional>
#include "valprint.h"
#include "dwarf2/cooked-index-entry.h"
#include "dwarf2/tag.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include "gdbsupport/selftest.h"
/* See cooked-index-entry.h. */
template functions" section in the manual. */
if (c == '<')
return '\0';
- return TOLOWER ((unsigned char) c);
+ return c_tolower (c);
};
unsigned char a = munge (*stra);
#include <ctype.h>
#include "mi-parse.h"
#include <optional>
-#include "gdbsupport/gdb-safe-ctype.h"
#include "inferior.h"
enum what_to_list { locals, arguments, all };
#include "cli/cli-utils.h"
#include "gdbsupport/symbol.h"
#include <algorithm>
-#include "gdbsupport/gdb-safe-ctype.h"
#include "gdbsupport/parallel-for.h"
#include "inferior.h"
requirements. */
#define SYMBOL_HASH_NEXT(hash, c) \
- ((hash) * 67 + TOLOWER ((unsigned char) (c)) - 113)
+ ((hash) * 67 + c_tolower (c) - 113)
\f
#include "gdbtypes.h"
#include "target.h"
#include "regcache.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include "reggroups.h"
#include "arch-utils.h"
#include "frame-unwind.h"
#include "source.h"
#include "gdbsupport/byte-vector.h"
#include <optional>
-#include "gdbsupport/gdb-safe-ctype.h"
#include "inferior.h"
/* Chain containing all defined memory-tag subcommands. */
#include "arch/riscv.h"
#include "record-full.h"
#include "riscv-ravenscar-thread.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include <vector>
static int
riscv_stap_is_single_operand (struct gdbarch *gdbarch, const char *s)
{
- return (ISDIGIT (*s) /* Literal number. */
+ return (c_isdigit (*s) /* Literal number. */
|| *s == '(' /* Register indirection. */
- || ISALPHA (*s)); /* Register value. */
+ || c_isalpha (*s)); /* Register value. */
}
/* String that appears before a register name in a SystemTap register
#include "tui/tui-layout.h"
#include "tui/tui-source.h"
#include "gdb_curses.h"
-#include "gdbsupport/gdb-safe-ctype.h"
/* The layouts. */
static std::vector<std::unique_ptr<tui_layout_split>> layouts;
for (const char &c : name_copy)
{
- if (ISSPACE (c))
+ if (c_isspace (c))
error (_("invalid whitespace character in window name"));
- if (!ISALNUM (c) && strchr ("-_.", c) == nullptr)
+ if (!c_isalnum (c) && strchr ("-_.", c) == nullptr)
error (_("invalid character '%c' in window name"), c);
}
- if (!ISALPHA (name_copy[0]))
+ if (!c_isalpha (name_copy[0]))
error (_("window name must start with a letter, not '%c'"), name_copy[0]);
/* We already check above for all the builtin window names. If we get
#include "value.h"
#include "source.h"
#include "objfiles.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include "tui/tui.h"
#include "tui/tui-data.h"
}
else if (c == '\t')
process_tab ();
- else if (ISCNTRL (c))
+ else if (c_iscntrl (c))
{
result.push_back ('^');
result.push_back (c + 0100);
#include "gdbsupport/scope-exit.h"
#include "gdbarch.h"
#include "cli-out.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include "bt-utils.h"
#include "gdbsupport/buildargv.h"
#include "pager.h"
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;
static bool
valid_identifier_name_char (int ch)
{
- return (ISALNUM (ch) || ch == '_');
+ return (c_isalnum (ch) || ch == '_');
}
/* Skip to end of token, or to END, whatever comes first. Input is
cp_skip_operator_token (const char *token, const char *end)
{
const char *p = token;
- while (p != end && !ISSPACE (*p) && *p != '(')
+ while (p != end && !c_isspace (*p) && *p != '(')
{
if (valid_identifier_name_char (*p))
{
static void
skip_ws (const char *&string1, const char *&string2, const char *end_str2)
{
- while (ISSPACE (*string1))
+ while (c_isspace (*string1))
string1++;
- while (string2 < end_str2 && ISSPACE (*string2))
+ while (string2 < end_str2 && c_isspace (*string2))
string2++;
}
/* Skip any whitespace that might occur after the closing of the
parameter list, but only if it is the end of parameter list. */
const char *q = p;
- while (ISSPACE (*q))
+ while (c_isspace (*q))
++q;
if (*q == '>')
p = q;
while (1)
{
if (skip_spaces
- || ((ISSPACE (*string1) && !valid_identifier_name_char (*string2))
- || (ISSPACE (*string2) && !valid_identifier_name_char (*string1))))
+ || ((c_isspace (*string1) && !valid_identifier_name_char (*string2))
+ || (c_isspace (*string2) && !valid_identifier_name_char (*string1))))
{
skip_ws (string1, string2, end_str2);
skip_spaces = false;
if (match_for_lcd != NULL && abi_start != string1)
match_for_lcd->mark_ignored_range (abi_start, string1);
- while (ISSPACE (*string1))
+ while (c_isspace (*string1))
string1++;
}
string1++;
string2++;
- while (ISSPACE (*string1))
+ while (c_isspace (*string1))
string1++;
- while (string2 < end_str2 && ISSPACE (*string2))
+ while (string2 < end_str2 && c_isspace (*string2))
string2++;
continue;
}
if (case_sensitivity == case_sensitive_on && *string1 != *string2)
break;
if (case_sensitivity == case_sensitive_off
- && (TOLOWER ((unsigned char) *string1)
- != TOLOWER ((unsigned char) *string2)))
+ && c_tolower (*string1) != c_tolower (*string2))
break;
/* If we see any non-whitespace, non-identifier-name character
(any of "()<>*&" etc.), then skip spaces the next time
around. */
- if (!ISSPACE (*string1) && !valid_identifier_name_char (*string1))
+ if (!c_isspace (*string1) && !valid_identifier_name_char (*string1))
skip_spaces = true;
string1++;
while (*string1 != '\0' && *string2 != '\0')
{
- while (ISSPACE (*string1))
+ while (c_isspace (*string1))
string1++;
- while (ISSPACE (*string2))
+ while (c_isspace (*string2))
string2++;
switch (case_pass)
{
case case_sensitive_off:
- c1 = TOLOWER ((unsigned char) *string1);
- c2 = TOLOWER ((unsigned char) *string2);
+ c1 = c_tolower (*string1);
+ c2 = c_tolower (*string2);
break;
case case_sensitive_on:
c1 = *string1;
{
CORE_ADDR addr = 0;
- if (my_string[0] == '0' && TOLOWER (my_string[1]) == 'x')
+ if (my_string[0] == '0' && c_tolower (my_string[1]) == 'x')
{
/* Assume that it is in hex. */
int i;
for (i = 2; my_string[i] != '\0'; i++)
{
- if (ISDIGIT (my_string[i]))
+ if (c_isdigit (my_string[i]))
addr = (my_string[i] - '0') + (addr * 16);
- else if (ISXDIGIT (my_string[i]))
- addr = (TOLOWER (my_string[i]) - 'a' + 0xa) + (addr * 16);
+ else if (c_isxdigit (my_string[i]))
+ addr = (c_tolower (my_string[i]) - 'a' + 0xa) + (addr * 16);
else
error (_("invalid hex \"%s\""), my_string);
}
for (i = 0; my_string[i] != '\0'; i++)
{
- if (ISDIGIT (my_string[i]))
+ if (c_isdigit (my_string[i]))
addr = (my_string[i] - '0') + (addr * 10);
else
error (_("invalid decimal \"%s\""), my_string);
#include "xml-builtin.h"
#include "xml-support.h"
#include "gdbsupport/filestuff.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include <vector>
#include <string>
body = scope->body.c_str ();
/* Strip leading and trailing whitespace. */
- while (length > 0 && ISSPACE (body[length - 1]))
+ while (length > 0 && c_isspace (body[length - 1]))
length--;
scope->body.erase (length);
- while (*body && ISSPACE (*body))
+ while (*body && c_isspace (*body))
body++;
}
#include <langinfo.h>
#include <iconv.h>
#include "gdbsupport/filestuff.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include "tracepoint.h"
#include <inttypes.h>
#include "gdbsupport/common-inferior.h"
const char *result = dest;
while (*name != '\0')
{
- if (!ISPRINT (*name))
+ if (!c_isprint (*name))
*dest++ = '?';
else
*dest++ = *name;
/* Pull in gdb::unique_xmalloc_ptr. */
#include "gdbsupport/gdb_unique_ptr.h"
+/* Note that there's no simple way to enforce the use of the c-ctype
+ functions. We can't poison the <ctype.h> functions (see
+ safe-ctype.h) because that will provoke errors from libstdc++
+ headers. */
+#include "c-ctype.h"
+
/* sbrk on macOS is not useful for our purposes, since sbrk(0) always
returns the same value. brk/sbrk on macOS is just an emulation
that always returns a pointer to a 4MB section reserved for
#include "common-utils.h"
#include "host-defs.h"
-#include "gdbsupport/gdb-safe-ctype.h"
#include "gdbsupport/gdb-xfree.h"
void *
/* Parse p similarly to gdb_argv buildargv function. */
while (*p != '\0')
{
- if (ISSPACE (*p) && !squote && !dquote && !bsquote)
+ if (c_isspace (*p) && !squote && !dquote && !bsquote)
break;
else
{
static int
is_digit_in_base (unsigned char digit, int base)
{
- if (!ISALNUM (digit))
+ if (!c_isalnum (digit))
return 0;
if (base <= 10)
- return (ISDIGIT (digit) && digit < base + '0');
+ return (c_isdigit (digit) && digit < base + '0');
else
- return (ISDIGIT (digit) || TOLOWER (digit) < base - 10 + 'a');
+ return (c_isdigit (digit) || c_tolower (digit) < base - 10 + 'a');
}
static int
digit_to_int (unsigned char c)
{
- if (ISDIGIT (c))
+ if (c_isdigit (c))
return c - '0';
else
- return TOLOWER (c) - 'a' + 10;
+ return c_tolower (c) - 'a' + 10;
}
/* As for strtoul, but for ULONGEST results. */
int i = 0;
/* Skip leading whitespace. */
- while (ISSPACE (num[i]))
+ while (c_isspace (num[i]))
i++;
/* Handle prefixes. */
{
if (chp == NULL)
return NULL;
- while (*chp && ISSPACE (*chp))
+ while (*chp && c_isspace (*chp))
chp++;
return chp;
}
{
if (chp == NULL)
return NULL;
- while (*chp && ISSPACE (*chp))
+ while (*chp && c_isspace (*chp))
chp++;
return chp;
}
{
if (chp == NULL)
return NULL;
- while (*chp && !ISSPACE (*chp))
+ while (*chp && !c_isspace (*chp))
chp++;
return chp;
}
+++ /dev/null
-/* Wrapper around libiberty's safe-ctype.h for GDB, the GNU debugger.
-
- Copyright (C) 2019-2025 Free Software Foundation, Inc.
-
- This file is part of GDB.
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program. If not, see <http://www.gnu.org/licenses/>. */
-
-#ifndef GDBSUPPORT_GDB_SAFE_CTYPE_H
-#define GDBSUPPORT_GDB_SAFE_CTYPE_H
-
-/* After safe-ctype.h is included, we can no longer use the host's
- ctype routines. Trying to do so results in compile errors. Code
- that uses safe-ctype.h that wants to refer to the locale-dependent
- ctype functions must call these wrapper versions instead.
- When compiling in C++ mode, also include <locale> before "safe-ctype.h"
- which also defines is* functions. */
-
-static inline int
-gdb_isprint (int ch)
-{
- return isprint (ch);
-}
-
-/* readline.h defines these symbols too, but we want libiberty's
- versions. */
-#undef ISALPHA
-#undef ISALNUM
-#undef ISDIGIT
-#undef ISLOWER
-#undef ISPRINT
-#undef ISUPPER
-#undef ISXDIGIT
-
-#include <locale>
-#include "safe-ctype.h"
-
-#endif /* GDBSUPPORT_GDB_SAFE_CTYPE_H */