fpcmp: Fix a possible infinite loop when comparing something like:

1..19 ok
to
  1..20 o k
(yes, the odd space is necessary).

llvm-svn: 106032
This commit is contained in:
Daniel Dunbar 2010-06-15 19:20:28 +00:00
parent 874c92bd47
commit b645fa13a9
1 changed files with 8 additions and 0 deletions

View File

@ -51,7 +51,15 @@ static const char *BackupNumber(const char *Pos, const char *FirstChar) {
if (!isNumberChar(*Pos)) return Pos;
// Otherwise, return to the start of the number.
bool HasPeriod = false;
while (Pos > FirstChar && isNumberChar(Pos[-1])) {
// Backup over at most one period.
if (Pos[-1] == '.') {
if (HasPeriod)
break;
HasPeriod = true;
}
--Pos;
if (Pos > FirstChar && isSignedChar(Pos[0]) && !isExponentChar(Pos[-1]))
break;