[llvm-commits] CVS: llvm/utils/fpcmp/fpcmp.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Jun 9 13:34:02 PDT 2004


Changes in directory llvm/utils/fpcmp:

fpcmp.cpp updated: 1.6 -> 1.7

---
Log message:

Fix the really bizarre stuff that happened last night in the tester
due to non-numeric diff failures that caused fpcmp to go into infinite loops


---
Diffs of the changes:  (+14 -2)

Index: llvm/utils/fpcmp/fpcmp.cpp
diff -u llvm/utils/fpcmp/fpcmp.cpp:1.6 llvm/utils/fpcmp/fpcmp.cpp:1.7
--- llvm/utils/fpcmp/fpcmp.cpp:1.6	Thu May 27 19:35:51 2004
+++ llvm/utils/fpcmp/fpcmp.cpp	Wed Jun  9 13:28:53 2004
@@ -54,6 +54,10 @@
 }
 
 static char *BackupNumber(char *Pos, char *FirstChar) {
+  // If we didn't stop in the middle of a number, don't backup.
+  if (!isNumberChar(*Pos)) return Pos;
+
+  // Otherwise, return to the start of the number.
   while (Pos > FirstChar && isNumberChar(Pos[-1]))
     --Pos;
   return Pos;
@@ -61,8 +65,16 @@
 
 static void CompareNumbers(char *&F1P, char *&F2P, char *F1End, char *F2End) {
   char *F1NumEnd, *F2NumEnd;
-  double V1 = strtod(F1P, &F1NumEnd);
-  double V2 = strtod(F2P, &F2NumEnd);
+  double V1, V2; 
+  // If we stop on numbers, compare their difference.
+  if (isNumberChar(*F1P) && isNumberChar(*F2P)) {
+    V1 = strtod(F1P, &F1NumEnd);
+    V2 = strtod(F2P, &F2NumEnd);
+  } else {
+    // Otherwise, the diff failed.
+    F1NumEnd = F1P;
+    F2NumEnd = F2P;
+  }
 
   if (F1NumEnd == F1P || F2NumEnd == F2P) {
     std::cerr << "Comparison failed, not a numeric difference.\n";





More information about the llvm-commits mailing list