- change order of testing
- But report the same error types.
- Changed to report for the last error since the value is there but
not allowed characters follow.
Error found by: run-cli-tests, because the wrong string was returned.
Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
errno = 0; /* To distinguish success/failure after call (see man page) */
long long ret = strtoll(str, &endptr, base);
+ if (endptr == str) {
+ errStr = "Expected option value to be integer, got '";
+ errStr.append(str);
+ errStr.append("'");
+ *err = errStr;
+ return 0;
+ }
if ((errno == ERANGE && (ret == LLONG_MAX || ret == LLONG_MIN))
|| (errno != 0 && ret == 0)) {
errStr = "The option value '";
*err = errStr;
return 0;
}
- if (endptr == str) {
- errStr = "Expected option value to be integer, got '";
- errStr.append(str);
- errStr.append("'");
- *err = errStr;
- return 0;
- }
if (*endptr != '\0') {
errStr = "The option value '";
errStr.append(str);
errStr.append("'");
- errStr.append(" seems to be invalid");
+ errStr.append(" contains invalid digits");
*err = errStr;
return 0;
}