[pkg-d-commits] [ldc] 62/95: Don't parse non-wellformed floating-point literals during lexing
Matthias Klumpp
mak at moszumanska.debian.org
Thu Jul 13 20:54:01 UTC 2017
This is an automated email from the git hooks/post-receive script.
mak pushed a commit to annotated tag v1.3.0-beta1
in repository ldc.
commit c8640021e4e93fa543ef36700e5eba51c67d3a23
Author: Martin <noone at nowhere.com>
Date: Sat Mar 25 14:55:46 2017 +0100
Don't parse non-wellformed floating-point literals during lexing
Cherry-picked dlang/dmd at 6039e46
---
ddmd/lexer.d | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/ddmd/lexer.d b/ddmd/lexer.d
index b8bc078..75483b5 100644
--- a/ddmd/lexer.d
+++ b/ddmd/lexer.d
@@ -2008,6 +2008,7 @@ class Lexer
{
assert(*p == '.' || isdigit(*p));
}
+ bool isWellformedString = true;
stringbuffer.reset();
auto pstart = p;
bool hex = false;
@@ -2069,12 +2070,18 @@ class Lexer
continue;
}
if (!anyexp)
+ {
error("missing exponent");
+ isWellformedString = false;
+ }
break;
}
}
else if (hex)
+ {
error("exponent required for hex float");
+ isWellformedString = false;
+ }
--p;
while (pstart < p)
{
@@ -2086,17 +2093,19 @@ class Lexer
auto sbufptr = cast(const(char)*)stringbuffer.data;
TOK result;
bool isOutOfRange = false;
- t.floatvalue = CTFloat.parse(sbufptr, &isOutOfRange);
+ t.floatvalue = (isWellformedString ? CTFloat.parse(sbufptr, &isOutOfRange) : CTFloat.zero);
switch (*p)
{
case 'F':
case 'f':
- isOutOfRange = (isOutOfRange || Port.isFloat32LiteralOutOfRange(sbufptr));
+ if (isWellformedString && !isOutOfRange)
+ isOutOfRange = Port.isFloat32LiteralOutOfRange(sbufptr);
result = TOKfloat32v;
p++;
break;
default:
- isOutOfRange = (isOutOfRange || Port.isFloat64LiteralOutOfRange(sbufptr));
+ if (isWellformedString && !isOutOfRange)
+ isOutOfRange = Port.isFloat64LiteralOutOfRange(sbufptr);
result = TOKfloat64v;
break;
case 'l':
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-d/ldc.git
More information about the pkg-d-commits
mailing list