aboutsummaryrefslogtreecommitdiff
path: root/lib/Support/CommandLine.cpp
diff options
context:
space:
mode:
authorBrian Gaeke <gaeke@uiuc.edu>2003-10-10 17:01:36 +0000
committerBrian Gaeke <gaeke@uiuc.edu>2003-10-10 17:01:36 +0000
commit2d6a2360036cf511af0a06f9720e6a1752779d1c (patch)
tree7ddc6137fc241c68016d13740c92f3dffca3a13b /lib/Support/CommandLine.cpp
parent9c9c90df8fd215bf75bd97dc80c80ac7b75e4cd4 (diff)
Change to use strtoul instead of strtoll.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9010 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/CommandLine.cpp')
-rw-r--r--lib/Support/CommandLine.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/Support/CommandLine.cpp b/lib/Support/CommandLine.cpp
index c0be0ecb34..807ff165b0 100644
--- a/lib/Support/CommandLine.cpp
+++ b/lib/Support/CommandLine.cpp
@@ -14,6 +14,8 @@
#include <map>
#include <set>
#include <iostream>
+#include <cstdlib>
+#include <cerrno>
using namespace cl;
@@ -682,9 +684,12 @@ bool parser<int>::parse(Option &O, const char *ArgName,
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;
}