From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH 1/7] Use compiled_regex in rust-parse.c
Date: Thu, 19 Nov 2026 10:58:16 -0700 [thread overview]
Message-ID: <20261119-more-parser-cleanups-v1-1-d85241f3fede@adacore.com> (raw)
In-Reply-To: <20261119-more-parser-cleanups-v1-0-d85241f3fede@adacore.com>
This changes rust-parse.c to use compiled_regex, similar to a recent
change done for the Ada lexer.
---
gdb/rust-parse.c | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/gdb/rust-parse.c b/gdb/rust-parse.c
index fc441a1b042..c520dc158a6 100644
--- a/gdb/rust-parse.c
+++ b/gdb/rust-parse.c
@@ -77,7 +77,8 @@ static const char number_regex_text[] =
/* The compiled number-matching regex. */
-static regex_t number_regex;
+static compiled_regex number_regex (number_regex_text, REG_EXTENDED,
+ _("internal error"));
/* The kinds of tokens. Note that single-character tokens are
represented by themselves, so for instance '[' is a token. */
@@ -910,8 +911,8 @@ rust_parser::lex_number ()
int end_index;
int type_index = -1;
- match = regexec (&number_regex, pstate->lexptr, ARRAY_SIZE (subexps),
- subexps, 0);
+ match = number_regex.exec (pstate->lexptr, ARRAY_SIZE (subexps),
+ subexps, 0);
/* Failure means the regexp is broken. */
gdb_assert (match == 0);
@@ -2403,11 +2404,6 @@ rust_lex_tests ()
INIT_GDB_FILE (rust_exp)
{
- int code = regcomp (&number_regex, number_regex_text, REG_EXTENDED);
- /* If the regular expression was incorrect, it was a programming
- error. */
- gdb_assert (code == 0);
-
#if GDB_SELF_TEST
selftests::register_test ("rust-lex", rust_lex_tests);
#endif
--
2.56.0
next prev parent reply other threads:[~2026-11-19 17:58 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 ` Tom Tromey [this message]
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 ` [PATCH 7/7] Remove canonicalize_numeral Tom Tromey
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-1-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