aboutsummaryrefslogtreecommitdiff
path: root/gdb/ada-lex.l
diff options
context:
space:
mode:
authorTom Tromey <tromey@adacore.com>2022-02-16 12:01:52 -0700
committerTom Tromey <tromey@adacore.com>2022-03-07 08:25:11 -0700
commitc9bfa277e9e6467dad91641357e09bf0a7ac0dc2 (patch)
tree0ff02e7601896ff486779069c992446f2dc60306 /gdb/ada-lex.l
parent47a39c6e18324360b3ef9b72f03e206417f2ce9c (diff)
downloadgdb-c9bfa277e9e6467dad91641357e09bf0a7ac0dc2.zip
gdb-c9bfa277e9e6467dad91641357e09bf0a7ac0dc2.tar.gz
gdb-c9bfa277e9e6467dad91641357e09bf0a7ac0dc2.tar.bz2
Fix Ada integer literals with exponents
While working on another patch, I noticed that Ada integer literals with exponents did not work. For example, with one form you get an error: (gdb) print 8e2 Invalid digit `e' in based literal And with another form you get an incorrect value: (gdb) print 16#8#e2 $2 = 8 This patch fixes the bugs and adds tests.
Diffstat (limited to 'gdb/ada-lex.l')
-rw-r--r--gdb/ada-lex.l9
1 files changed, 6 insertions, 3 deletions
diff --git a/gdb/ada-lex.l b/gdb/ada-lex.l
index f698ad4..e4f18f1 100644
--- a/gdb/ada-lex.l
+++ b/gdb/ada-lex.l
@@ -103,8 +103,9 @@ static int paren_depth;
{NUM10}{POSEXP} {
canonicalizeNumeral (numbuf, yytext);
- return processInt (pstate, NULL, numbuf,
- strrchr (numbuf, 'e') + 1);
+ char *e_ptr = strrchr (numbuf, 'e');
+ *e_ptr = '\0';
+ return processInt (pstate, nullptr, numbuf, e_ptr + 1);
}
{NUM10} {
@@ -114,9 +115,11 @@ static int paren_depth;
{NUM10}"#"{HEXDIG}({HEXDIG}|_)*"#"{POSEXP} {
canonicalizeNumeral (numbuf, yytext);
+ char *e_ptr = strrchr (numbuf, 'e');
+ *e_ptr = '\0';
return processInt (pstate, numbuf,
strchr (numbuf, '#') + 1,
- strrchr(numbuf, '#') + 1);
+ e_ptr + 1);
}
{NUM10}"#"{HEXDIG}({HEXDIG}|_)*"#" {