Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 11/12] Remove "numbuf" global
Date: Thu, 21 Mar 2024 13:03:39 -0600	[thread overview]
Message-ID: <20240321-ada-iterated-assign-v1-11-925cdd4f1f4a@adacore.com> (raw)
In-Reply-To: <20240321-ada-iterated-assign-v1-0-925cdd4f1f4a@adacore.com>

The lexer has a "numbuf" global that is only used for temporary
storage.  This patch removes the global and redeclares it at the
points of use.
---
 gdb/ada-lex.l | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l
index 11221723eb3..4e99eaab036 100644
--- a/gdb/ada-lex.l
+++ b/gdb/ada-lex.l
@@ -59,9 +59,7 @@ DIAGNOSTIC_IGNORE_DEPRECATED_REGISTER
 #define NUMERAL_WIDTH 256
 #define LONGEST_SIGN ((ULONGEST) 1 << (sizeof(LONGEST) * HOST_CHAR_BIT - 1))
 
-/* Temporary staging for numeric literals.  */
-static char numbuf[NUMERAL_WIDTH];
- static void canonicalizeNumeral (char *s1, const char *);
+static void canonicalizeNumeral (char *s1, const char *);
 static struct stoken processString (const char*, int);
 static int processInt (struct parser_state *, const char *, const char *,
 		       const char *);
@@ -114,6 +112,7 @@ static void rewind_to_char (int);
 "--".*		 { yyterminate(); }
 
 {NUM10}{POSEXP}  {
+		   char numbuf[NUMERAL_WIDTH];
 		   canonicalizeNumeral (numbuf, yytext);
 		   char *e_ptr = strrchr (numbuf, 'e');
 		   *e_ptr = '\0';
@@ -121,11 +120,13 @@ static void rewind_to_char (int);
 		 }
 
 {NUM10}          {
+		   char numbuf[NUMERAL_WIDTH];
 		   canonicalizeNumeral (numbuf, yytext);
 		   return processInt (pstate, NULL, numbuf, NULL);
 		 }
 
 {NUM10}"#"{HEXDIG}({HEXDIG}|_)*"#"{POSEXP} {
+		   char numbuf[NUMERAL_WIDTH];
 		   canonicalizeNumeral (numbuf, yytext);
 		   char *e_ptr = strrchr (numbuf, 'e');
 		   *e_ptr = '\0';
@@ -139,23 +140,27 @@ static void rewind_to_char (int);
 	   floating-point number is formed by reinterpreting the
 	   bytes, allowing direct control over the bits.  */
 {NUM10}(l{0,2}f)?"#"{HEXDIG}({HEXDIG}|_)*"#" {
+		   char numbuf[NUMERAL_WIDTH];
 		   canonicalizeNumeral (numbuf, yytext);
 		   return processInt (pstate, numbuf, strchr (numbuf, '#') + 1,
 				      NULL);
 		 }
 
 "0x"{HEXDIG}+	{
+		  char numbuf[NUMERAL_WIDTH];
 		  canonicalizeNumeral (numbuf, yytext+2);
 		  return processInt (pstate, "16#", numbuf, NULL);
 		}
 
 
 {NUM10}"."{NUM10}{EXP} {
+		   char numbuf[NUMERAL_WIDTH];
 		   canonicalizeNumeral (numbuf, yytext);
 		   return processReal (pstate, numbuf);
 		}
 
 {NUM10}"."{NUM10} {
+		   char numbuf[NUMERAL_WIDTH];
 		   canonicalizeNumeral (numbuf, yytext);
 		   return processReal (pstate, numbuf);
 		}

-- 
2.43.0


  parent reply	other threads:[~2024-03-21 19:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-21 19:03 [PATCH 00/12] Ada iterated assignment, plus parser cleanups Tom Tromey
2024-03-21 19:03 ` [PATCH 01/12] Introduce and use aggregate_assigner type Tom Tromey
2024-03-21 19:03 ` [PATCH 02/12] Implement Ada 2022 iterated assignment Tom Tromey
2024-03-21 19:03 ` [PATCH 03/12] Introduce ada_parse_state Tom Tromey
2024-03-21 19:03 ` [PATCH 04/12] Move "int_storage" global into ada_parse_state Tom Tromey
2024-03-21 19:03 ` [PATCH 05/12] Move "components" and "associations" " Tom Tromey
2024-03-21 19:03 ` [PATCH 06/12] Move "assignments" global " Tom Tromey
2024-03-21 19:03 ` [PATCH 07/12] Move "iterated_associations" " Tom Tromey
2024-03-21 19:03 ` [PATCH 08/12] Move "temp_parse_space" " Tom Tromey
2024-03-21 19:03 ` [PATCH 09/12] Move "paren_depth" " Tom Tromey
2024-03-21 19:03 ` [PATCH 10/12] Move "returned_complete" " Tom Tromey
2024-03-21 19:03 ` Tom Tromey [this message]
2024-03-21 19:03 ` [PATCH 12/12] Constify ada-lex.l:attributes Tom Tromey
2024-04-02 17:35 ` [PATCH 00/12] Ada iterated assignment, plus parser cleanups Tom Tromey

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=20240321-ada-iterated-assign-v1-11-925cdd4f1f4a@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