public inbox for gdb-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] Remove "numbuf" global
@ 2024-04-02 17:36 Tom Tromey
0 siblings, 0 replies; only message in thread
From: Tom Tromey @ 2024-04-02 17:36 UTC (permalink / raw)
To: gdb-cvs
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=0298128e07b7e58f93d745b657413e41766de3cb
commit 0298128e07b7e58f93d745b657413e41766de3cb
Author: Tom Tromey <tromey@adacore.com>
Date: Thu Mar 14 12:28:26 2024 -0600
Remove "numbuf" global
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.
Diff:
---
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);
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2024-04-02 17:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-02 17:36 [binutils-gdb] Remove "numbuf" global Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).