[llvm-commits] CVS: llvm/lib/Support/CommandLine.cpp

Brian Gaeke gaeke at cs.uiuc.edu
Fri Oct 10 12:03:01 PDT 2003


Changes in directory llvm/lib/Support:

CommandLine.cpp updated: 1.38 -> 1.39

---
Log message:

Change to use strtoul instead of strtoll.


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

Index: llvm/lib/Support/CommandLine.cpp
diff -u llvm/lib/Support/CommandLine.cpp:1.38 llvm/lib/Support/CommandLine.cpp:1.39
--- llvm/lib/Support/CommandLine.cpp:1.38	Tue Sep 16 13:00:35 2003
+++ llvm/lib/Support/CommandLine.cpp	Fri Oct 10 12:01:36 2003
@@ -14,6 +14,8 @@
 #include <map>
 #include <set>
 #include <iostream>
+#include <cstdlib>
+#include <cerrno>
 
 using namespace cl;
 
@@ -682,9 +684,12 @@
 bool parser<unsigned>::parse(Option &O, const char *ArgName,
                              const std::string &Arg, unsigned &Value) {
   char *End;
-  long long int V = strtoll(Arg.c_str(), &End, 0);
+  errno = 0;
+  unsigned long V = strtoul(Arg.c_str(), &End, 0);
   Value = (unsigned)V;
-  if (*End != 0 || V < 0 || Value != V) 
+  if (((V == ULONG_MAX) && (errno == ERANGE))
+      || (*End != 0)
+      || (Value != V))
     return O.error(": '" + Arg + "' value invalid for uint argument!");
   return false;
 }





More information about the llvm-commits mailing list