[llvm-commits] [llvm] r106032 - /llvm/trunk/lib/Support/FileUtilities.cpp

Daniel Dunbar daniel at zuster.org
Tue Jun 15 12:20:28 PDT 2010


Author: ddunbar
Date: Tue Jun 15 14:20:28 2010
New Revision: 106032

URL: http://llvm.org/viewvc/llvm-project?rev=106032&view=rev
Log:
fpcmp: Fix a possible infinite loop when comparing something like:
  1..19 ok
to
  1..20 o k
(yes, the odd space is necessary).

Modified:
    llvm/trunk/lib/Support/FileUtilities.cpp

Modified: llvm/trunk/lib/Support/FileUtilities.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/FileUtilities.cpp?rev=106032&r1=106031&r2=106032&view=diff
==============================================================================
--- llvm/trunk/lib/Support/FileUtilities.cpp (original)
+++ llvm/trunk/lib/Support/FileUtilities.cpp Tue Jun 15 14:20:28 2010
@@ -51,7 +51,15 @@
   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;





More information about the llvm-commits mailing list