summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/FileUtilities.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-03-17 04:49:04 +0000
committerChris Lattner <sabre@nondot.org>2005-03-17 04:49:04 +0000
commit252f546cebebe1e280431a0fac335ed5384a6c99 (patch)
tree884759e46f96ceb5b0b1a5711f4f396e7338cc3a /llvm/lib/Support/FileUtilities.cpp
parent6b6bdf602bfb74f84ad8f4f68b804d4eaade2c4f (diff)
downloadbcm5719-llvm-252f546cebebe1e280431a0fac335ed5384a6c99.tar.gz
bcm5719-llvm-252f546cebebe1e280431a0fac335ed5384a6c99.zip
Fix a bug where we would consider " .99" and "1.0" different because of the
leading whitespace. llvm-svn: 20647
Diffstat (limited to 'llvm/lib/Support/FileUtilities.cpp')
-rw-r--r--llvm/lib/Support/FileUtilities.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Support/FileUtilities.cpp b/llvm/lib/Support/FileUtilities.cpp
index 0a6e154d926..6a65ccae3e4 100644
--- a/llvm/lib/Support/FileUtilities.cpp
+++ b/llvm/lib/Support/FileUtilities.cpp
@@ -18,6 +18,7 @@
#include "llvm/ADT/StringExtras.h"
#include <cmath>
#include <cstring>
+#include <cctype>
using namespace llvm;
static bool isNumberChar(char C) {
@@ -47,6 +48,14 @@ static bool CompareNumbers(char *&F1P, char *&F2P, char *F1End, char *F2End,
std::string *ErrorMsg) {
char *F1NumEnd, *F2NumEnd;
double V1 = 0.0, V2 = 0.0;
+
+ // If one of the positions is at a space and the other isn't, chomp up 'til
+ // the end of the space.
+ while (isspace(*F1P) && F1P != F1End)
+ ++F1P;
+ while (isspace(*F2P) && F2P != F2End)
+ ++F2P;
+
// If we stop on numbers, compare their difference.
if (isNumberChar(*F1P) && isNumberChar(*F2P)) {
V1 = strtod(F1P, &F1NumEnd);
OpenPOWER on IntegriCloud