From d2a6fc397ee982936dee7dd5692b1481bcd9fe8f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 28 Jun 2003 15:47:20 +0000 Subject: Add support for 'unsigned' command line arguments git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6928 91177308-0d34-0410-b5e6-96231b3b80d8 --- support/lib/Support/CommandLine.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'support/lib') diff --git a/support/lib/Support/CommandLine.cpp b/support/lib/Support/CommandLine.cpp index a0eca7a8ed..bbf996af7b 100644 --- a/support/lib/Support/CommandLine.cpp +++ b/support/lib/Support/CommandLine.cpp @@ -575,14 +575,25 @@ bool parser::parse(Option &O, const char *ArgName, // bool parser::parse(Option &O, const char *ArgName, const std::string &Arg, int &Value) { - const char *ArgStart = Arg.c_str(); char *End; - Value = (int)strtol(ArgStart, &End, 0); + Value = (int)strtol(Arg.c_str(), &End, 0); if (*End != 0) return O.error(": '" + Arg + "' value invalid for integer argument!"); return false; } +// parser implementation +// +bool parser::parse(Option &O, const char *ArgName, + const std::string &Arg, unsigned &Value) { + char *End; + long long int V = strtoll(Arg.c_str(), &End, 0); + Value = (unsigned)V; + if (*End != 0 || V < 0 || Value != V) + return O.error(": '" + Arg + "' value invalid for uint argument!"); + return false; +} + // parser/parser implementation // static bool parseDouble(Option &O, const std::string &Arg, double &Value) { -- cgit v1.2.3