]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
Give an accurate diagnostic when `head --bytes=30M' fails.
authorJim Meyering <jim@meyering.net>
Sat, 27 Oct 2001 14:24:42 +0000 (14:24 +0000)
committerJim Meyering <jim@meyering.net>
Sat, 27 Oct 2001 14:24:42 +0000 (14:24 +0000)
(string_to_integer): Check explicitly for overflow,
and lump everything else together as `invalid'.

src/head.c

index a71a83d0316f7eb5254bf27ee9e494473a1966b2..634389771bdfc47e6a7450c6c9ec6ef0b3da71e1 100644 (file)
@@ -225,19 +225,19 @@ string_to_integer (int count_lines, const char *n_string)
 
   s_err = xstrtoumax (n_string, NULL, 10, &n, "bkm");
 
-  if (s_err == LONGINT_INVALID)
+  if (s_err == LONGINT_OVERFLOW)
     {
-      error (EXIT_FAILURE, 0, "%s: %s", n_string,
-            (count_lines
-             ? _("invalid number of lines")
-             : _("invalid number of bytes")));
+      error (EXIT_FAILURE, 0,
+            _("%s: %s is so large that it is not representable"), n_string,
+            count_lines ? _("number of lines") : _("number of bytes"));
     }
 
   if (s_err != LONGINT_OK)
     {
-      error (EXIT_FAILURE, 0,
-            _("%s: %s is so large that it is not representable"), n_string,
-            count_lines ? _("number of lines") : _("number of bytes"));
+      error (EXIT_FAILURE, 0, "%s: %s", n_string,
+            (count_lines
+             ? _("invalid number of lines")
+             : _("invalid number of bytes")));
     }
 
   return n;