From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id eIipHmBVk2haNAUAWB0awg (envelope-from ) for ; Wed, 06 Aug 2025 09:15:12 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=ffJjNZ3+; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 798C21E100; Wed, 6 Aug 2025 09:15:12 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-9.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL, RCVD_IN_VALIDITY_SAFE autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id DAFC51E089 for ; Wed, 6 Aug 2025 09:15:10 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5194C385842D for ; Wed, 6 Aug 2025 13:15:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5194C385842D Authentication-Results: sourceware.org; dkim=pass (2048-bit key, secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=ffJjNZ3+ Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by sourceware.org (Postfix) with ESMTPS id 7A42F3858D39 for ; Wed, 6 Aug 2025 13:13:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7A42F3858D39 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 7A42F3858D39 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::d2f ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1754486019; cv=none; b=jqGPJcAwixKzBQmFTV1YCPh1DiVQHft50qx5My/nDhJDrPTVLERnWIQCTjhZSucL7vaR6H/a8sxS/IqU/D3qtF5C9L+zsmqKY8YB46sOpbO6ZOOxpBrszxKLHn+ETlWxC5VpTU/KQBmPZR1JLVsjondf0YHlE83bDs2Bg/CFGCQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1754486019; c=relaxed/simple; bh=A7pvZUc/MGYb6DZu66JzRrH31OdkrRRPLoqRLmVnFv4=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=QoRRweeo4lnj8ZRhBvOUSkeD3YYPsIX93AT/mfGMcBJK95M3cB+fksTMoEzao44zrI2cQ/bBf4YC6ebVe1FUGBKtZ8c/aGB6yadmhlj65F/vbtDptQLiIhBUD03W1O8edusVufKmFPcFdFsxGx68751f5AySQNxigr9PE3/W7oY= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7A42F3858D39 Received: by mail-io1-xd2f.google.com with SMTP id ca18e2360f4ac-87c0bb1ee4eso102775939f.2 for ; Wed, 06 Aug 2025 06:13:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1754486018; x=1755090818; darn=sourceware.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=/C9tNZldrT5PifJfKydOl/hIrnPs6TXJIzTDQDnNO2I=; b=ffJjNZ3+DpY91p/EYKsmXleKOyl0lUC6pzePLpFmnZ6l9AzwId2PUHFg8rx1UdIm0O 7apVJKfUrdgdylQI9iNVL2qvTGYZmkPvLq2LZaThcuw9vd8dV0ZJdgsdLxat1W0pzFGy QoStm6T4JFrWewoy+bunROSnCDkaO85fcxM624Q4kNf8z4+PgZegWr682byVdtRtjfG+ QrlKjA74E9euyPL+Dg4Azw5PKoCpgMg55MdZG7TCgHH0lNxp4Ti47k+CuaUMAsplrJfl 5DfhAoYxpT7ljKFyJSkexZw6Za+yA1AsLTbfUoUMaJK0BNPzb/hEZAAP+9r0+A7KMYGa XDQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754486018; x=1755090818; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/C9tNZldrT5PifJfKydOl/hIrnPs6TXJIzTDQDnNO2I=; b=hF8CxvPOjyJTJtSCpl5o3vSFdW9/RtLWEaxC145/OTjxme3up2mka+AdoVc8VetCrL pTVBqpPhRPaD+bF91V731BdO9IvziN7tsSg7jC/O3acijn+va/N4Va/VptAglo6VYMk2 EI82j9sqVrSmEQLl7vvHERLd2bGMkD94GuoyeDsLWZhyYfUdkyA/fuVVQCFimlm6732v I/a/p06sZHlGqCCDIo5Z5LcNyIeG+/bq4GSUydTkeOmHNa66d4h+uty8f/DDR5BUXUpf LEZB2D0IF0txP7vWXwmkRnhe8R8+g5M9fjbRjf35pgGzeIqbVWs5I1ISSjCzOiPkWjZs +F6Q== X-Gm-Message-State: AOJu0Yx8+Eco9rd3DjOZ3IytVSYuMZfrHGMI2kZL7mbmu4FowZV59+v5 c1BxCPJ9yDsDVOU2Wqw7P+ygHwxHnlbUAIuenZF9FzUMFqHVOQpAVqfoBc/7aRMlc7pA/vW2T5F 8ZzM8ww== X-Gm-Gg: ASbGncvodVPbmQX3KnZfFcm3hTDiSd2mfYAKKavn9wolfPro/fx6e0kH4mgbE6UPdpe zn04pPjoG5tD3tFguDsjU3TE5md3Xi6Ee6kPGv7wrZtU2DbzGYub90s20UwdZ0S4of8VEt140Q3 RTyTlK91IrBKyoLY3PZKXs5M/ww9KSCtMs/Rmqn6YFDF0eSXgmQg/Lu2EugywiqI0usk5dsFhIf PuFPf9t+aNUW+FGJ3hipoWFoWoLQ9jJ2jEPUVteoGC4K7rp4Zn6ENVtneVXWpWtapbOYokyfdZw FYBV1V+OusIRWcjuaHw7pmfyN2rJBv7rvt5Vh4S3K5h0V89e1FfCHN6F7hFAbKDrChjBDbznnSL wZWSN0qrtO+82+Kg6qTWKalW9eJLTF0BXUDbBTtHKpqc0FyWalAdnCPECvPBHDW4= X-Google-Smtp-Source: AGHT+IFXI4daKTKw7kTLJsLzIrKa6deGRyWqAq8ubpSXstu8aP48Om5/ed9ELDJMmrk5Fakhjx763A== X-Received: by 2002:a05:6602:1554:b0:881:8bc8:b02d with SMTP id ca18e2360f4ac-8819f3ff5edmr537756839f.12.1754486018149; Wed, 06 Aug 2025 06:13:38 -0700 (PDT) Received: from [192.168.0.26] (97-122-110-68.hlrn.qwest.net. [97.122.110.68]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-8818b151319sm181295339f.0.2025.08.06.06.13.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Aug 2025 06:13:37 -0700 (PDT) From: Tom Tromey Date: Wed, 06 Aug 2025 07:13:33 -0600 Subject: [PATCH 2/3] Use c-ctype.h (not safe-ctype.h) in gdb MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20250806-gnulib-c-ctype-v1-2-10f33e9f22a4@adacore.com> References: <20250806-gnulib-c-ctype-v1-0-10f33e9f22a4@adacore.com> In-Reply-To: <20250806-gnulib-c-ctype-v1-0-10f33e9f22a4@adacore.com> To: gdb-patches@sourceware.org Cc: Tom Tromey X-Mailer: b4 0.14.2 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org This changes gdb and related programs to use the gnulib c-ctype code rather than safe-ctype.h. The gdb-safe-ctype.h header is removed. This changes common-defs.h to include the c-ctype header, making it available everywhere in gdb. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33217 --- gdb/c-exp.y | 18 +++++++-------- gdb/c-lang.c | 10 ++++----- gdb/c-support.h | 10 ++++----- gdb/completer.c | 2 +- gdb/cp-name-parser.y | 11 +++++---- gdb/cp-support.c | 9 ++++---- gdb/dictionary.c | 3 +-- gdb/disasm.c | 1 - gdb/dwarf2/cooked-index-entry.c | 3 +-- gdb/mi/mi-cmd-stack.c | 1 - gdb/minsyms.c | 1 - gdb/minsyms.h | 2 +- gdb/or1k-tdep.c | 1 - gdb/printcmd.c | 1 - gdb/riscv-tdep.c | 5 ++--- gdb/tui/tui-layout.c | 7 +++--- gdb/tui/tui-winsource.c | 3 +-- gdb/utils.c | 46 ++++++++++++++++++-------------------- gdb/xml-support.c | 5 ++--- gdbserver/linux-low.cc | 3 +-- gdbsupport/common-defs.h | 6 +++++ gdbsupport/common-utils.cc | 21 +++++++++--------- gdbsupport/gdb-safe-ctype.h | 49 ----------------------------------------- 23 files changed, 78 insertions(+), 140 deletions(-) diff --git a/gdb/c-exp.y b/gdb/c-exp.y index 14d4b704ff1f5731804b1d3bab4c00649dac40ea..15682a5f33523c7321fd8c1131e5077d8e94f2a0 100644 --- a/gdb/c-exp.y +++ b/gdb/c-exp.y @@ -1969,13 +1969,13 @@ parse_number (struct parser_state *par_state, 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; @@ -2181,9 +2181,9 @@ c_parse_escape (const char **ptr, struct obstack *output) 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); @@ -2206,7 +2206,7 @@ c_parse_escape (const char **ptr, struct obstack *output) 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) @@ -2231,9 +2231,9 @@ c_parse_escape (const char **ptr, struct obstack *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); @@ -2818,7 +2818,7 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name) 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; @@ -2827,7 +2827,7 @@ lex_one_token (struct parser_state *par_state, bool *is_quoted_name) 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]) diff --git a/gdb/c-lang.c b/gdb/c-lang.c index 9fccc1f761452cc6cb33644a28869a659ab26398..7fff11a76f75c71f569bf1583ed1c1cd9c09e48f 100644 --- a/gdb/c-lang.c +++ b/gdb/c-lang.c @@ -408,7 +408,7 @@ convert_ucn (const char *p, const char *limit, const char *dest_charset, 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) @@ -450,7 +450,7 @@ convert_octal (struct type *type, const char *p, 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); @@ -473,7 +473,7 @@ convert_hex (struct type *type, const char *p, { unsigned long value = 0; - while (p < limit && ISXDIGIT (*p)) + while (p < limit && c_isxdigit (*p)) { value = 16 * value + fromhex (*p); ++p; @@ -518,7 +518,7 @@ convert_escape (struct type *type, const char *dest_charset, 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; @@ -540,7 +540,7 @@ convert_escape (struct type *type, const char *dest_charset, 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); } diff --git a/gdb/c-support.h b/gdb/c-support.h index 47f40661a0905ebc722ef82f243ca724bb0fdf19..5fd1118e592f3b1ecbb1e5535fe430abbbec48a9 100644 --- a/gdb/c-support.h +++ b/gdb/c-support.h @@ -19,9 +19,7 @@ #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++ @@ -32,15 +30,15 @@ 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 */ diff --git a/gdb/completer.c b/gdb/completer.c index deecbc209f7d2308edd86ae42589ac112e717365..b919b4c4dc35c10473c7b8988881857a1cb71d20 100644 --- a/gdb/completer.c +++ b/gdb/completer.c @@ -3006,7 +3006,7 @@ gdb_printable_part (char *pathname) 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 diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y index cafd6b2367abd73005bee62b66521e1a03c5fc7b..7221b785211d44d8407c45f75a46251caad18104 100644 --- a/gdb/cp-name-parser.y +++ b/gdb/cp-name-parser.y @@ -39,7 +39,6 @@ #include -#include "gdbsupport/gdb-safe-ctype.h" #include "demangle.h" #include "cp-support.h" #include "c-support.h" @@ -1362,7 +1361,7 @@ cpname_state::parse_number (const char *p, int len, int parsed_float, /* 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') { @@ -1374,7 +1373,7 @@ cpname_state::parse_number (const char *p, int len, int parsed_float, 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; @@ -1439,10 +1438,10 @@ cpname_state::parse_number (const char *p, int len, int parsed_float, 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; @@ -1769,7 +1768,7 @@ yylex (YYSTYPE *lvalp, cpname_state *state) } /* 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); diff --git a/gdb/cp-support.c b/gdb/cp-support.c index cab711051dc16af867e0c8e47493936a0a10d8e6..d31fbbfe50128832c7c766f1092a6e1d426fac28 100644 --- a/gdb/cp-support.c +++ b/gdb/cp-support.c @@ -35,7 +35,6 @@ #include "namespace.h" #include #include "gdbsupport/gdb_setjmp.h" -#include "gdbsupport/gdb-safe-ctype.h" #include "gdbsupport/selftest.h" #include "gdbsupport/gdb-sigmask.h" #include @@ -105,7 +104,7 @@ static int 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 @@ -117,7 +116,7 @@ cp_already_canonical (const char *string) 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') @@ -1135,7 +1134,7 @@ cp_find_first_component_aux (const char *name, int permissive) && startswith (name + index, CP_OPERATOR_STR)) { index += CP_OPERATOR_LEN; - while (ISSPACE(name[index])) + while (c_isspace(name[index])) ++index; switch (name[index]) { @@ -2349,7 +2348,7 @@ find_toplevel_char (const char *s, char c) scan += CP_OPERATOR_LEN; if (*scan == c) return scan; - while (ISSPACE (*scan)) + while (c_isspace (*scan)) { ++scan; if (*scan == c) diff --git a/gdb/dictionary.c b/gdb/dictionary.c index 28e900d9c07a9c39c89a8aa3dffb90d7a1b635ac..17c9b448f592cf4ed5b8308c89d2ea8844d42c9e 100644 --- a/gdb/dictionary.c +++ b/gdb/dictionary.c @@ -25,7 +25,6 @@ #include "symtab.h" #include "buildsym.h" #include "dictionary.h" -#include "gdbsupport/gdb-safe-ctype.h" #include "gdbsupport/unordered_map.h" #include "language.h" @@ -772,7 +771,7 @@ language_defn::search_name_hash (const char *string0) const if (c == 'B' && string[3] == '_') { - for (string += 4; ISDIGIT (*string); ++string) + for (string += 4; c_isdigit (*string); ++string) ; continue; } diff --git a/gdb/disasm.c b/gdb/disasm.c index b7311923618509537de01a9f25357ee3b3df6636..c8e830ed471cb66e4f1f102e4c1bd1bab229609b 100644 --- a/gdb/disasm.c +++ b/gdb/disasm.c @@ -28,7 +28,6 @@ #include "cli/cli-cmds.h" #include "dis-asm.h" #include "source.h" -#include "gdbsupport/gdb-safe-ctype.h" #include #include #include "valprint.h" diff --git a/gdb/dwarf2/cooked-index-entry.c b/gdb/dwarf2/cooked-index-entry.c index 863ddd6499c4578e2156f89872adb7ab09297b0b..a5e3fcb6caaad517f4b7a2033c234c7688ee70bc 100644 --- a/gdb/dwarf2/cooked-index-entry.c +++ b/gdb/dwarf2/cooked-index-entry.c @@ -19,7 +19,6 @@ #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. */ @@ -57,7 +56,7 @@ cooked_index_entry::compare (const char *stra, const char *strb, template functions" section in the manual. */ if (c == '<') return '\0'; - return TOLOWER ((unsigned char) c); + return c_tolower (c); }; unsigned char a = munge (*stra); diff --git a/gdb/mi/mi-cmd-stack.c b/gdb/mi/mi-cmd-stack.c index cc26747cfa0e3a4d04b1103daa52b75c18251cc8..9ee2d27b70e40b4d6e89a1b4205b9b1bcf635244 100644 --- a/gdb/mi/mi-cmd-stack.c +++ b/gdb/mi/mi-cmd-stack.c @@ -32,7 +32,6 @@ #include #include "mi-parse.h" #include -#include "gdbsupport/gdb-safe-ctype.h" #include "inferior.h" enum what_to_list { locals, arguments, all }; diff --git a/gdb/minsyms.c b/gdb/minsyms.c index 4a6459a6f2d2f5543c511c4e01788a6e7b430b41..2cf3d9d1c683ad875d9185160c3f4995d416da95 100644 --- a/gdb/minsyms.c +++ b/gdb/minsyms.c @@ -52,7 +52,6 @@ #include "cli/cli-utils.h" #include "gdbsupport/symbol.h" #include -#include "gdbsupport/gdb-safe-ctype.h" #include "gdbsupport/parallel-for.h" #include "inferior.h" diff --git a/gdb/minsyms.h b/gdb/minsyms.h index 709faa5e8f4ce3de303ef2bc0c99babadcf3b9f3..dcab475bcd31e32bcee0cc7f9fc3f00d46667259 100644 --- a/gdb/minsyms.h +++ b/gdb/minsyms.h @@ -195,7 +195,7 @@ unsigned int msymbol_hash_iw (const char *); requirements. */ #define SYMBOL_HASH_NEXT(hash, c) \ - ((hash) * 67 + TOLOWER ((unsigned char) (c)) - 113) + ((hash) * 67 + c_tolower (c) - 113) diff --git a/gdb/or1k-tdep.c b/gdb/or1k-tdep.c index 27748401f6f8c72596de7f766f3b50aea6f5bcaa..2db207dafdd1439fbc0f8490c20bdcfdcc8b4e02 100644 --- a/gdb/or1k-tdep.c +++ b/gdb/or1k-tdep.c @@ -29,7 +29,6 @@ #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" diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 19fbc20074e03bf1787fa1a43e373768d447c5ee..f0487479f6875c51151db6cb70280548e994b52b 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -54,7 +54,6 @@ #include "source.h" #include "gdbsupport/byte-vector.h" #include -#include "gdbsupport/gdb-safe-ctype.h" #include "inferior.h" /* Chain containing all defined memory-tag subcommands. */ diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index f5b85230e71114eac7b112ba26fd0ac0b5e2ef13..ea8c475afa1cd94b9017cdc72187b41df549ce94 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -56,7 +56,6 @@ #include "arch/riscv.h" #include "record-full.h" #include "riscv-ravenscar-thread.h" -#include "gdbsupport/gdb-safe-ctype.h" #include @@ -4183,9 +4182,9 @@ riscv_print_insn (bfd_vma addr, struct disassemble_info *info) 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 diff --git a/gdb/tui/tui-layout.c b/gdb/tui/tui-layout.c index 558055d4edd9c2aa08cc8af29d285abc927430f4..95d20fbf22cf82d9852bd8a451a8c2bccd09826e 100644 --- a/gdb/tui/tui-layout.c +++ b/gdb/tui/tui-layout.c @@ -37,7 +37,6 @@ #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> layouts; @@ -381,14 +380,14 @@ tui_register_window (const char *name, window_factory &&factory) 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 diff --git a/gdb/tui/tui-winsource.c b/gdb/tui/tui-winsource.c index a545c4870e1e8d2128ffd1676514c359f0537212..fe2e0fadd33a6bfa6d14246d5c91fb21ed484357 100644 --- a/gdb/tui/tui-winsource.c +++ b/gdb/tui/tui-winsource.c @@ -26,7 +26,6 @@ #include "value.h" #include "source.h" #include "objfiles.h" -#include "gdbsupport/gdb-safe-ctype.h" #include "tui/tui.h" #include "tui/tui-data.h" @@ -109,7 +108,7 @@ tui_copy_source_line (const char **ptr, int *length) } else if (c == '\t') process_tab (); - else if (ISCNTRL (c)) + else if (c_iscntrl (c)) { result.push_back ('^'); result.push_back (c + 0100); diff --git a/gdb/utils.c b/gdb/utils.c index 10d3d51e481b789a4f060c6071139d4c01c976bd..c1a36025b6cfe70f997e750b8175d86bd9a8deb6 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -75,7 +75,6 @@ #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" @@ -1008,7 +1007,7 @@ parse_escape (struct gdbarch *gdbarch, 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; @@ -2053,7 +2052,7 @@ fprintf_symbol (struct ui_file *stream, const char *name, 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 @@ -2063,7 +2062,7 @@ static const char * 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)) { @@ -2117,9 +2116,9 @@ cp_skip_operator_token (const char *token, const char *end) 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++; } @@ -2183,7 +2182,7 @@ skip_template_parameter_list (const char **name) /* 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; @@ -2215,8 +2214,8 @@ strncmp_iw_with_mode (const char *string1, const char *string2, 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; @@ -2249,7 +2248,7 @@ strncmp_iw_with_mode (const char *string1, const char *string2, 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++; } @@ -2316,9 +2315,9 @@ strncmp_iw_with_mode (const char *string1, const char *string2, 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; } @@ -2418,14 +2417,13 @@ strncmp_iw_with_mode (const char *string1, const char *string2, 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++; @@ -3138,16 +3136,16 @@ strcmp_iw_ordered (const char *string1, const char *string2) 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; @@ -3256,17 +3254,17 @@ string_to_core_addr (const char *my_string) { 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); } @@ -3278,7 +3276,7 @@ string_to_core_addr (const char *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); diff --git a/gdb/xml-support.c b/gdb/xml-support.c index 08524f85309dc8af7ab2d3f74f1929d28984194f..ebf6ea6b966c4007bee9066d4fb6defdeba17a10 100644 --- a/gdb/xml-support.c +++ b/gdb/xml-support.c @@ -21,7 +21,6 @@ #include "xml-builtin.h" #include "xml-support.h" #include "gdbsupport/filestuff.h" -#include "gdbsupport/gdb-safe-ctype.h" #include #include @@ -430,10 +429,10 @@ gdb_xml_parser::end_element (const XML_Char *name) 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++; } diff --git a/gdbserver/linux-low.cc b/gdbserver/linux-low.cc index 39642705b0d8bc614e7da84f0d0e1c34cd045b12..6d0a7a363719982886c4d1104a7f5b7b6a4d7235 100644 --- a/gdbserver/linux-low.cc +++ b/gdbserver/linux-low.cc @@ -46,7 +46,6 @@ #include #include #include "gdbsupport/filestuff.h" -#include "gdbsupport/gdb-safe-ctype.h" #include "tracepoint.h" #include #include "gdbsupport/common-inferior.h" @@ -6990,7 +6989,7 @@ replace_non_ascii (char *dest, const char *name) const char *result = dest; while (*name != '\0') { - if (!ISPRINT (*name)) + if (!c_isprint (*name)) *dest++ = '?'; else *dest++ = *name; diff --git a/gdbsupport/common-defs.h b/gdbsupport/common-defs.h index 8d7e2a9353c198adbcb63f5473634702a3c4e563..6f58914ccd5855a3df08b503baf65a40c6e85708 100644 --- a/gdbsupport/common-defs.h +++ b/gdbsupport/common-defs.h @@ -222,6 +222,12 @@ /* 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 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 diff --git a/gdbsupport/common-utils.cc b/gdbsupport/common-utils.cc index 266d836b3c69899af3118ba0d8c58f9a1089140e..5c7ba313996ac8521d0329d623ba71283b2f1071 100644 --- a/gdbsupport/common-utils.cc +++ b/gdbsupport/common-utils.cc @@ -19,7 +19,6 @@ #include "common-utils.h" #include "host-defs.h" -#include "gdbsupport/gdb-safe-ctype.h" #include "gdbsupport/gdb-xfree.h" void * @@ -180,7 +179,7 @@ extract_string_maybe_quoted (const char **arg) /* Parse p similarly to gdb_argv buildargv function. */ while (*p != '\0') { - if (ISSPACE (*p) && !squote && !dquote && !bsquote) + if (c_isspace (*p) && !squote && !dquote && !bsquote) break; else { @@ -254,21 +253,21 @@ make_quoted_string (const char *str) 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. */ @@ -282,7 +281,7 @@ strtoulst (const char *num, const char **trailer, int base) int i = 0; /* Skip leading whitespace. */ - while (ISSPACE (num[i])) + while (c_isspace (num[i])) i++; /* Handle prefixes. */ @@ -349,7 +348,7 @@ skip_spaces (char *chp) { if (chp == NULL) return NULL; - while (*chp && ISSPACE (*chp)) + while (*chp && c_isspace (*chp)) chp++; return chp; } @@ -361,7 +360,7 @@ skip_spaces (const char *chp) { if (chp == NULL) return NULL; - while (*chp && ISSPACE (*chp)) + while (*chp && c_isspace (*chp)) chp++; return chp; } @@ -373,7 +372,7 @@ skip_to_space (const char *chp) { if (chp == NULL) return NULL; - while (*chp && !ISSPACE (*chp)) + while (*chp && !c_isspace (*chp)) chp++; return chp; } diff --git a/gdbsupport/gdb-safe-ctype.h b/gdbsupport/gdb-safe-ctype.h deleted file mode 100644 index 36b78f58ca8ae569c8bae37dcb3157351d00cc43..0000000000000000000000000000000000000000 --- a/gdbsupport/gdb-safe-ctype.h +++ /dev/null @@ -1,49 +0,0 @@ -/* 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 . */ - -#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 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 -#include "safe-ctype.h" - -#endif /* GDBSUPPORT_GDB_SAFE_CTYPE_H */ -- 2.50.1