diff lib/human.c @ 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 0bb31cd5b7ea
children bbbbbf4cd1c5
line wrap: on
line diff
--- 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;
 }