Mercurial > hg > octave-nkf > gnulib-hg
changeset 9137:629a6928f108
* NEWS: Describe interface changes to human, xstrtol.
* lib/human.h: Include <xstrtol.h>.
(human_options): Return enum strtol_error, not int. Remove
bool arg; take int * instead.
* lib/human.c: Don't include "gettext.h".
(_): Remove; no longer used.
Don't include <xstrtol.h>, since human.h does it.
(human_options): Adjust to abovementioned interface changes.
Do not report error to stderr; that's now the caller's
responsibility.
* lib/xstrtol.c (main) [defined TESTING_XSTRTO]: Adjust to
interface change.
* lib/xstrtol.h (_STRTOL_ERROR): Take Option, Arg rather than
Str, Argument_type_string. All uses changed. Put " argument"
in diagnostics to make them clearer. Change wording of suffix
message for clarity.
(STRTOL_FATAL_ERROR): Take Option, Arg rather than Str,
Argument_type_string.
(STRTOL_FATAL_WARN): Remove; no longer used.
* modules/human (Depends-on): Remove gettext-h.
author | Paul Eggert <eggert@cs.ucla.edu> |
---|---|
date | Mon, 06 Aug 2007 16:44:24 +0000 |
parents | 749d702b319d |
children | 9321c69be4bc |
files | ChangeLog NEWS lib/human.c lib/human.h lib/xstrtol.c lib/xstrtol.h modules/human |
diffstat | 7 files changed, 63 insertions(+), 31 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,27 @@ +2007-08-06 Paul Eggert <eggert@cs.ucla.edu> + and Bruno Haible <bruno@clisp.org> + + * NEWS: Describe interface changes to human, xstrtol. + * lib/human.h: Include <xstrtol.h>. + (human_options): Return enum strtol_error, not int. Remove + bool arg; take int * instead. + * lib/human.c: Don't include "gettext.h". + (_): Remove; no longer used. + Don't include <xstrtol.h>, since human.h does it. + (human_options): Adjust to abovementioned interface changes. + Do not report error to stderr; that's now the caller's + responsibility. + * lib/xstrtol.c (main) [defined TESTING_XSTRTO]: Adjust to + interface change. + * lib/xstrtol.h (_STRTOL_ERROR): Take Option, Arg rather than + Str, Argument_type_string. All uses changed. Put " argument" + in diagnostics to make them clearer. Change wording of suffix + message for clarity. + (STRTOL_FATAL_ERROR): Take Option, Arg rather than Str, + Argument_type_string. + (STRTOL_FATAL_WARN): Remove; no longer used. + * modules/human (Depends-on): Remove gettext-h. + 2007-08-06 Simon Josefsson <simon@josefsson.org> * build-aux/maint.mk, build-aux/GNUmakefile: Relicense to GPLv3+.
--- a/NEWS +++ b/NEWS @@ -6,6 +6,17 @@ Date Modules Changes +2007-08-04 human The function human_options no longer reports an + error to standard error; that is now the + caller's responsibility. It returns an + error code of type enum strtol_error + instead of the integer option value, and stores + the option value via a new int * argument. + xstrtol The first two arguments of STRTOL_FATAL_ERROR + are now an option name and option argument + instead of an option argument and a type string, + STRTOL_FAIL_WARN is removed. + 2007-07-14 gpl, lgpl New Texinfo versions with no sectioning commands. 2007-07-10 version-etc Output now mentions GPLv3+, not GPLv2+. Use
--- a/lib/human.c +++ b/lib/human.c @@ -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 @@ -28,13 +28,9 @@ #include <stdlib.h> #include <string.h> -#include "gettext.h" -#define _(msgid) gettext (msgid) - #include <argmatch.h> #include <error.h> #include <intprops.h> -#include <xstrtol.h> /* The maximum length of a suffix like "KiB". */ #define HUMAN_READABLE_SUFFIX_LENGTH_MAX 3 @@ -463,17 +459,14 @@ return LONGINT_OK; } -int -human_options (char const *spec, bool report_errors, uintmax_t *block_size) +enum strtol_error +human_options (char const *spec, int *opts, uintmax_t *block_size) { - int opts; - strtol_error e = humblock (spec, block_size, &opts); + strtol_error e = humblock (spec, block_size, opts); if (*block_size == 0) { *block_size = default_block_size (); e = LONGINT_INVALID; } - if (e != LONGINT_OK && report_errors) - STRTOL_FATAL_ERROR (spec, _("block size"), e); - return opts; + return e; }
--- a/lib/human.h +++ b/lib/human.h @@ -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 @@ -27,6 +27,8 @@ # include <stdint.h> # include <unistd.h> +# include <xstrtol.h> + /* A conservative bound on the maximum length of a human-readable string. The output can be the square of the largest uintmax_t, so double its size before converting to a bound. @@ -78,6 +80,6 @@ char *human_readable (uintmax_t, char *, int, uintmax_t, uintmax_t); -int human_options (char const *, bool, uintmax_t *); +enum strtol_error human_options (char const *, int *, uintmax_t *); #endif /* HUMAN_H_ */
--- a/lib/xstrtol.c +++ b/lib/xstrtol.c @@ -1,7 +1,7 @@ /* A more useful interface to strtol. - Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006 - Free Software Foundation, Inc. + Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2003, 2004, 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 @@ -254,7 +254,7 @@ } else { - STRTOL_FATAL_ERROR (argv[i], "arg", s_err); + STRTOL_FATAL_ERROR ("arg", argv[i], s_err); } } exit (0);
--- a/lib/xstrtol.h +++ b/lib/xstrtol.h @@ -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, 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify @@ -50,7 +50,13 @@ _DECLARE_XSTRTOL (xstrtoimax, intmax_t) _DECLARE_XSTRTOL (xstrtoumax, uintmax_t) -# define _STRTOL_ERROR(Exit_code, Str, Argument_type_string, Err) \ +/* Report an error for an out-of-range integer argument. + EXIT_CODE is the exit code (0 for a non-fatal error). + OPTION is the option that takes the argument + (usually starting with one or two minus signs). + ARG is the option's argument. + ERR is the error code returned by one of the xstrto* functions. */ +# define _STRTOL_ERROR(Exit_code, Option, Arg, Err) \ do \ { \ switch ((Err)) \ @@ -59,29 +65,26 @@ 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, Arg); \ 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 suffix in %s argument `%s'"), \ + Option, Arg); \ 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, Arg); \ break; \ } \ } \ while (0) -# define STRTOL_FATAL_ERROR(Str, Argument_type_string, Err) \ - _STRTOL_ERROR (exit_failure, Str, Argument_type_string, Err) - -# define STRTOL_FAIL_WARN(Str, Argument_type_string, Err) \ - _STRTOL_ERROR (0, Str, Argument_type_string, Err) +# define STRTOL_FATAL_ERROR(Option, Arg, Err) \ + _STRTOL_ERROR (exit_failure, Option, Arg, Err) #endif /* not XSTRTOL_H_ */