summaryrefslogtreecommitdiff
path: root/utils/fpcmp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2004-06-09 18:28:53 +0000
committerChris Lattner <sabre@nondot.org>2004-06-09 18:28:53 +0000
commitff2c64c979a404faab95f2cc3288fc31f88157cc (patch)
treea6b01c1a8b335d5d8e575c00431ac3f1885d3ec3 /utils/fpcmp
parentfc621e28781e3cf22f1850e07f285581334e2402 (diff)
downloadllvm-ff2c64c979a404faab95f2cc3288fc31f88157cc.tar.gz
llvm-ff2c64c979a404faab95f2cc3288fc31f88157cc.tar.bz2
llvm-ff2c64c979a404faab95f2cc3288fc31f88157cc.tar.xz
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@14098 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils/fpcmp')
-rw-r--r--utils/fpcmp/fpcmp.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/utils/fpcmp/fpcmp.cpp b/utils/fpcmp/fpcmp.cpp
index ac0e10cd74..c3cdd29047 100644
--- a/utils/fpcmp/fpcmp.cpp
+++ b/utils/fpcmp/fpcmp.cpp
@@ -54,6 +54,10 @@ static bool isNumberChar(char C) {
}
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 char *BackupNumber(char *Pos, char *FirstChar) {
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";