argument: Fix use of optarg
getopt supports no_argument, required_argument, and optional_argument
types of arguments. Getopt returns NULL in optarg if no argument was
given in the case of no_argument or optional_argument types. Use this
value to determine if we should use optarg or trueString.
Change-Id: I414c4d3c2923844cff13a070357269c5b48048c9
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/argument.cpp b/argument.cpp
index 11d9814..8931969 100644
--- a/argument.cpp
+++ b/argument.cpp
@@ -65,7 +65,7 @@
if (i->val)
{
- arguments[i->name] = (i->has_arg ? optarg : trueString);
+ arguments[i->name] = (optarg ? optarg : trueString);
}
}
}