2007-07-25 Jim Meyering <jim@meyering.net>
authorBruno Haible <bruno@clisp.org>
Wed, 25 Jul 2007 22:42:36 +0000 (22:42 +0000)
committerBruno Haible <bruno@clisp.org>
Wed, 25 Jul 2007 22:42:36 +0000 (22:42 +0000)
            Bruno Haible  <bruno@clisp.org>
        * lib/xstrtol.h (_STRTOL_ERROR): Change third argument from a
        localized noun to an option name.
        (STRTOL_FATAL_ERROR, STRTOL_FAIL_WARN): Likewise.
        * lib/human.h (human_options): Insert a third argument.
        * lib/human.h (human_options): Likewise. Pass it to STRTOL_FATAL_ERROR.

ChangeLog
NEWS
lib/human.c
lib/human.h
lib/xstrtol.h

index e3286fb..04a1ffc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-07-25  Jim Meyering  <jim@meyering.net>
+            Bruno Haible  <bruno@clisp.org>
+
+       * lib/xstrtol.h (_STRTOL_ERROR): Change third argument from a
+       localized noun to an option name.
+       (STRTOL_FATAL_ERROR, STRTOL_FAIL_WARN): Likewise.
+       * lib/human.h (human_options): Insert a third argument.
+       * lib/human.h (human_options): Likewise. Pass it to STRTOL_FATAL_ERROR.
+
 2007-07-25  Peter O'Gorman  <peter@pogma.com>
             Bruno Haible  <bruno@clisp.org>
 
diff --git a/NEWS b/NEWS
index dd230cb..2043fb2 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,10 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2007-07-26  human           The function human_options takes an additional
+                            third argument, the option that introduced the
+                            argument that was passed to a xstrto* function.
+
 2007-07-14  gpl, lgpl       New Texinfo versions with no sectioning commands.
 
 2007-07-10  version-etc     Output now mentions GPLv3+, not GPLv2+.  Use
index ecf4c97..5b31d06 100644 (file)
@@ -1,7 +1,7 @@
 /* human.c -- print human readable file size
 
    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006 Free Software Foundation, Inc.
+   2005, 2006, 2007 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -464,7 +464,8 @@ humblock (char const *spec, uintmax_t *block_size, int *options)
 }
 
 int
-human_options (char const *spec, bool report_errors, uintmax_t *block_size)
+human_options (char const *spec, bool report_errors, char const *option,
+              uintmax_t *block_size)
 {
   int opts;
   strtol_error e = humblock (spec, block_size, &opts);
@@ -474,6 +475,6 @@ human_options (char const *spec, bool report_errors, uintmax_t *block_size)
       e = LONGINT_INVALID;
     }
   if (e != LONGINT_OK && report_errors)
-    STRTOL_FATAL_ERROR (spec, _("block size"), e);
+    STRTOL_FATAL_ERROR (spec, option, e);
   return opts;
 }
index 44b8b36..cf0ba4f 100644 (file)
@@ -1,7 +1,7 @@
 /* human.h -- print human readable file size
 
    Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-   2005, 2006 Free Software Foundation, Inc.
+   2005, 2006, 2007 Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -78,6 +78,6 @@ enum
 
 char *human_readable (uintmax_t, char *, int, uintmax_t, uintmax_t);
 
-int human_options (char const *, bool, uintmax_t *);
+int human_options (char const *, bool, char const *, uintmax_t *);
 
 #endif /* HUMAN_H_ */
index 475728a..2a5eb16 100644 (file)
@@ -1,6 +1,6 @@
 /* A more useful interface to strtol.
 
-   Copyright (C) 1995, 1996, 1998, 1999, 2001, 2002, 2003, 2004, 2006
+   Copyright (C) 1995, 1996, 1998, 1999, 2001-2004, 2006-2007
    Free Software Foundation, Inc.
 
    This program is free software; you can redistribute it and/or modify
@@ -50,7 +50,14 @@ _DECLARE_XSTRTOL (xstrtoul, unsigned long int)
 _DECLARE_XSTRTOL (xstrtoimax, intmax_t)
 _DECLARE_XSTRTOL (xstrtoumax, uintmax_t)
 
-# define _STRTOL_ERROR(Exit_code, Str, Argument_type_string, Err)      \
+/* Signal an error for an out-of-range integer argument, through the error()
+   function.
+   EXIT_CODE is the exit code (0 for a non-fatal error).
+   STR is the value of the given argument value.
+   OPTION is the option that takes the argument (usually starting with one
+   or two minus signs).
+   ERR is the error code returned by one of the xstrto* functions.  */
+# define _STRTOL_ERROR(Exit_code, Str, Option, Err)                    \
   do                                                                   \
     {                                                                  \
       switch ((Err))                                                   \
@@ -59,29 +66,29 @@ _DECLARE_XSTRTOL (xstrtoumax, uintmax_t)
          abort ();                                                     \
                                                                        \
        case LONGINT_INVALID:                                           \
-         error ((Exit_code), 0, gettext ("invalid %s `%s'"),           \
-                (Argument_type_string), (Str));                        \
+         error ((Exit_code), 0, gettext ("invalid %s argument `%s'"),  \
+                (Option), (Str));                                      \
          break;                                                        \
                                                                        \
        case LONGINT_INVALID_SUFFIX_CHAR:                               \
        case LONGINT_INVALID_SUFFIX_CHAR | LONGINT_OVERFLOW:            \
          error ((Exit_code), 0,                                        \
-                gettext ("invalid character following %s in `%s'"),    \
-                (Argument_type_string), (Str));                        \
+                gettext ("invalid character following %s argument in `%s'"), \
+                (Option), (Str));                                      \
          break;                                                        \
                                                                        \
        case LONGINT_OVERFLOW:                                          \
-         error ((Exit_code), 0, gettext ("%s `%s' too large"),         \
-                (Argument_type_string), (Str));                        \
+         error ((Exit_code), 0, gettext ("%s argument `%s' too large"), \
+                (Option), (Str));                                      \
          break;                                                        \
        }                                                               \
     }                                                                  \
   while (0)
 
-# define STRTOL_FATAL_ERROR(Str, Argument_type_string, Err)            \
-  _STRTOL_ERROR (exit_failure, Str, Argument_type_string, Err)
+# define STRTOL_FATAL_ERROR(Str, Option, Err)                          \
+  _STRTOL_ERROR (exit_failure, Str, Option, Err)
 
-# define STRTOL_FAIL_WARN(Str, Argument_type_string, Err)              \
-  _STRTOL_ERROR (0, Str, Argument_type_string, Err)
+# define STRTOL_FAIL_WARN(Str, Option, Err)                            \
+  _STRTOL_ERROR (0, Str, Option, Err)
 
 #endif /* not XSTRTOL_H_ */