diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2015-07-04 17:13:50 +0300 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2015-07-04 17:13:50 +0300 |
commit | 71cd8e3a743046573744123777061b64881bf372 (patch) | |
tree | 82522befe647f4fff186a5630cad0cad33f8ef53 /src/fmt.c | |
parent | c18578632fd3c9e513e613a86ba2b7c4ebee6c45 (diff) | |
download | coreutils-upstream.tar.gz |
Imported Upstream version 8.24upstream/8.24upstream
Diffstat (limited to 'src/fmt.c')
-rw-r--r-- | src/fmt.c | 29 |
1 files changed, 9 insertions, 20 deletions
@@ -1,5 +1,5 @@ /* GNU fmt -- simple text formatter. - Copyright (C) 1994-2014 Free Software Foundation, Inc. + Copyright (C) 1994-2015 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 @@ -30,7 +30,7 @@ #include "error.h" #include "fadvise.h" #include "quote.h" -#include "xstrtol.h" +#include "xdectoint.h" /* The official name of this program (e.g., no 'g' prefix). */ #define PROGRAM_NAME "fmt" @@ -273,6 +273,7 @@ Reformat each paragraph in the FILE(s), writing to standard output.\n\ The option -WIDTH is an abbreviated form of --width=DIGITS.\n\ "), stdout); + emit_stdin_note (); emit_mandatory_arg_note (); fputs (_("\ @@ -292,11 +293,7 @@ The option -WIDTH is an abbreviated form of --width=DIGITS.\n\ "), stdout); fputs (HELP_OPTION_DESCRIPTION, stdout); fputs (VERSION_OPTION_DESCRIPTION, stdout); - fputs (_("\ -\n\ -With no FILE, or when FILE is -, read standard input.\n"), - stdout); - emit_ancillary_info (); + emit_ancillary_info (PROGRAM_NAME); } exit (status); } @@ -399,23 +396,15 @@ main (int argc, char **argv) { /* Limit max_width to MAXCHARS / 2; otherwise, the resulting output can be quite ugly. */ - unsigned long int tmp; - if (! (xstrtoul (max_width_option, NULL, 10, &tmp, "") == LONGINT_OK - && tmp <= MAXCHARS / 2)) - error (EXIT_FAILURE, 0, _("invalid width: %s"), - quote (max_width_option)); - max_width = tmp; + max_width = xdectoumax (max_width_option, 0, MAXCHARS / 2, "", + _("invalid width"), 0); } if (goal_width_option) { /* Limit goal_width to max_width. */ - unsigned long int tmp; - if (! (xstrtoul (goal_width_option, NULL, 10, &tmp, "") == LONGINT_OK - && tmp <= max_width)) - error (EXIT_FAILURE, 0, _("invalid width: %s"), - quote (goal_width_option)); - goal_width = tmp; + goal_width = xdectoumax (goal_width_option, 0, max_width, "", + _("invalid width"), 0); if (max_width_option == NULL) max_width = goal_width + 10; } @@ -456,7 +445,7 @@ main (int argc, char **argv) } } - exit (ok ? EXIT_SUCCESS : EXIT_FAILURE); + return ok ? EXIT_SUCCESS : EXIT_FAILURE; } /* Trim space from the front and back of the string P, yielding the prefix, |