From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 7/7] Remove canonicalize_numeral
Date: Thu, 19 Nov 2026 10:58:22 -0700 [thread overview]
Message-ID: <20261119-more-parser-cleanups-v1-7-d85241f3fede@adacore.com> (raw)
In-Reply-To: <20261119-more-parser-cleanups-v1-0-d85241f3fede@adacore.com>
This inlines canonicalize_numeral into its sole caller.
---
gdb/ada-exp-parser.c | 35 ++++++++++++-----------------------
1 file changed, 12 insertions(+), 23 deletions(-)
diff --git a/gdb/ada-exp-parser.c b/gdb/ada-exp-parser.c
index 67f40368e9b..c1c5927664a 100644
--- a/gdb/ada-exp-parser.c
+++ b/gdb/ada-exp-parser.c
@@ -169,23 +169,6 @@ struct parser_state *pstate;
struct ada_parse_state *ada_parser;
-/* Copy S2 to S1, removing all underscores, and downcasing all
- letters. Stops at END. */
-
-static void
-canonicalize_numeral (char *s1, const char *s2, const char *end)
-{
- for (; s2 != end; s2 += 1)
- {
- if (*s2 != '_')
- {
- *s1 = c_tolower(*s2);
- s1 += 1;
- }
- }
- s1[0] = '\000';
-}
-
/* See ada-exp-parser.h. */
int
@@ -478,7 +461,14 @@ ada_parse_state::lex_number ()
char *numbuf = (char *) obstack_alloc (&temp_space,
pstate->lexptr - num_start);
- canonicalize_numeral (numbuf, num_start, pstate->lexptr);
+ /* Canonicalize the number, copying it into NUMBUF. */
+ char *out_iter = numbuf;
+ for (const char *iter = num_start; iter != pstate->lexptr; ++iter)
+ {
+ if (*iter != '_')
+ *out_iter++ = c_tolower (*iter);
+ }
+ *out_iter = '\0';
if (subexps[HEX_NUMBER].rm_so != -1)
return process_int ("16#", numbuf + 2, nullptr);
@@ -495,11 +485,10 @@ ada_parse_state::lex_number ()
char *e_ptr = nullptr;
if (subexps[EXPONENT].rm_so != -1)
{
- /* We can't use the 'rm_so' here because
- canonicalize_numeral might have removed some underscores.
- But we know the 'e' appears after the '#' so we can
- search for it and not get one of the (possibly hex)
- numerals. */
+ /* We can't use the 'rm_so' here because canonicalization
+ might have removed some underscores. But we know the 'e'
+ appears after the '#' so we can search for it and not get
+ one of the (possibly hex) numerals. */
e_ptr = strrchr (numbuf, 'e');
gdb_assert (e_ptr != nullptr);
*e_ptr = '\0';
--
2.56.0
next prev parent reply other threads:[~2026-11-19 18:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 17:58 [PATCH 0/7] More minor parser-related cleanups Tom Tromey
2026-11-19 17:58 ` [PATCH 1/7] Use compiled_regex in rust-parse.c Tom Tromey
2026-11-19 17:58 ` [PATCH 2/7] Move ada_tick_completer to ada-exp-parser.c Tom Tromey
2026-11-19 17:58 ` [PATCH 3/7] Change some Ada parser functions into methods Tom Tromey
2026-11-19 18:48 ` Simon Marchi
2026-11-20 20:57 ` Tom Tromey
2026-11-19 17:58 ` [PATCH 4/7] Simplify post-process-parser-output.sh Tom Tromey
2026-11-19 17:58 ` [PATCH 5/7] Remove fixed-sized buffer from ada_parse_state::lex_number Tom Tromey
2026-11-19 17:58 ` [PATCH 6/7] Hoist calls to canonicalize_numeral Tom Tromey
2026-11-19 17:58 ` Tom Tromey [this message]
2026-11-19 18:55 ` [PATCH 0/7] More minor parser-related cleanups Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261119-more-parser-cleanups-v1-7-d85241f3fede@adacore.com \
--to=tromey@adacore.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox