numfmt: fix strtol() return code handling
authorAssaf Gordon <assafgordon@gmail.com>
Tue, 12 Feb 2013 20:28:22 +0000 (15:28 -0500)
committerPádraig Brady <P@draigBrady.com>
Wed, 13 Feb 2013 22:20:10 +0000 (22:20 +0000)
src/numfmt.c (parse_format_string): On some systems, strtol() returns
EINVAL if no conversion was performed.  So only handle ERANGE here,
and handle other format errors directly.

src/numfmt.c

index d87d8ef..9a321d6 100644 (file)
@@ -970,7 +970,7 @@ parse_format_string (char const *fmt)
   i += strspn (fmt + i, " ");
   errno = 0;
   pad = strtol (fmt + i, &endptr, 10);
-  if (errno != 0)
+  if (errno == ERANGE)
     error (EXIT_FAILURE, 0,
            _("invalid format %s (width overflow)"), quote (fmt));