[long_options]: Remove the "help" and "version" entries.
Remove declarations of show_help and show_version.
(main): Use parse_long_options, including author name(s).
Remove the show_version and show_help blocks.
#endif
#include "system.h"
#include "error.h"
+#include "long-options.h"
#include "safe-read.h"
/* Undefine, to avoid warning about redefinition on some systems. */
/* If nonzero, call cat, otherwise call simple_cat to do the actual work. */
int options = 0;
- /* If nonzero, display usage information and exit. */
- static int show_help;
-
- /* If nonzero, print the version on standard output then exit. */
- static int show_version;
-
static struct option const long_options[] =
{
{"number-nonblank", no_argument, NULL, 'b'},
#if O_BINARY
{"binary", no_argument, NULL, 'B'},
#endif
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "cat", GNU_PACKAGE, VERSION,
+ "Torbjorn Granlund and Richard M. Stallman", usage);
+
/* Parse command line options. */
while ((c = getopt_long (argc, argv,
}
}
- if (show_version)
- {
- printf ("cat (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
output_desc = 1;
/* Get device, i-node number, and optimal blocksize of output. */
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
\f
/* Written by Q. Frank Xia, qx@math.columbia.edu.
Cosmetic changes and reorganization by David MacKenzie, djm@gnu.ai.mit.edu.
# include <getopt.h>
# include <sys/types.h>
# include "system.h"
+# include "long-options.h"
# include "error.h"
/* Number of bytes to read at once. */
/* The name this program was run with. */
char *program_name;
-/* If nonzero, display usage information and exit. */
-static int show_help;
-
-/* If nonzero, print the version on standard output then exit. */
-static int show_version;
-
static struct option const long_options[] =
{
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{0, 0, 0, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "cksum", GNU_PACKAGE, VERSION,
+ "Q. Frank Xia", usage);
+
have_read_stdin = 0;
while ((c = getopt_long (argc, argv, "", long_options, NULL)) != -1)
}
}
- if (show_version)
- {
- printf ("cksum (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
if (optind >= argc)
{
if (cksum ("-", 0) < 0)
#include <sys/types.h>
#include "system.h"
#include "linebuffer.h"
+#include "long-options.h"
#include "error.h"
/* Undefine, to avoid warning about redefinition on some systems. */
/* If nonzero, print lines that are found in both files. */
static int both;
-/* If nonzero, display usage information and exit. */
-static int show_help;
-
-/* If nonzero, print the version on standard output then exit. */
-static int show_version;
-
static struct option const long_options[] =
{
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{0, 0, 0, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "comm", GNU_PACKAGE, VERSION,
+ "Richard Stallman and David MacKenzie", usage);
+
only_file_1 = 1;
only_file_2 = 1;
both = 1;
usage (1);
}
- if (show_version)
- {
- printf ("comm (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
if (optind + 2 != argc)
usage (1);
#include <regex.h>
#include "error.h"
+#include "long-options.h"
+#include "safe-read.h"
#include "xstrtoul.h"
#include "xalloc.h"
-#include "safe-read.h"
#ifdef STDC_HEADERS
# include <stdlib.h>
/* Number of elements in `controls'. */
static unsigned int control_used;
-/* If nonzero, display usage information and exit. */
-static int show_help;
-
-/* If nonzero, print the version on standard output then exit. */
-static int show_version;
-
static struct option const longopts[] =
{
{"digits", required_argument, NULL, 'n'},
{"elide-empty-files", no_argument, NULL, 'z'},
{"prefix", required_argument, NULL, 'f'},
{"suffix-format", required_argument, NULL, 'b'},
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "csplit", GNU_PACKAGE, VERSION,
+ "Stuart Kemp and David MacKenzie", usage);
+
global_argv = argv;
controls = NULL;
control_used = 0;
usage (1);
}
- if (show_version)
- {
- printf ("csplit (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
if (argc - optind < 2)
{
error (0, 0, _("too few arguments"));
/* cut - remove parts of lines of files
- Copyright (C) 1984, 1997, 1998 by David M. Ihnat
+ Copyright (C) 1984, 1997, 1998, 1999 by David M. Ihnat
This program is a total rewrite of the Bell Laboratories Unix(Tm)
command of the same name, as of System V. It contains no proprietary
#include <getopt.h>
#include <sys/types.h>
#include "system.h"
+#include "long-options.h"
#include "error.h"
char *xstrdup ();
/* Nonzero if we have ever read standard input. */
static int have_read_stdin;
-/* If nonzero, display usage information and exit. */
-static int show_help;
-
-/* If nonzero, print the version on standard output then exit. */
-static int show_version;
-
static struct option const longopts[] =
{
{"bytes", required_argument, 0, 'b'},
{"delimiter", required_argument, 0, 'd'},
{"only-delimited", no_argument, 0, 's'},
{"output-delimiter", required_argument, 0, CHAR_MAX + 1},
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{0, 0, 0, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "cut", GNU_PACKAGE, VERSION,
+ "David Ihnat, David MacKenzie, and Jim Meyering", usage);
+
operating_mode = undefined_mode;
/* By default, all non-delimited lines are printed. */
}
}
- if (show_version)
- {
- printf ("cut (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
if (operating_mode == undefined_mode)
FATAL_ERROR (_("you must specify a list of bytes, characters, or fields"));
#include <sys/types.h>
#include "system.h"
#include "error.h"
+#include "long-options.h"
/* The number of bytes added at a time to the amount of memory
allocated for the output line. */
/* Status to return to the system. */
static int exit_status;
-/* If nonzero, display usage information and exit. */
-static int show_help;
-
-/* If nonzero, print the version on standard output then exit. */
-static int show_version;
-
static struct option const longopts[] =
{
{"tabs", required_argument, NULL, 't'},
{"initial", no_argument, NULL, 'i'},
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "expand", GNU_PACKAGE, VERSION,
+ "David MacKenzie", usage);
+
while ((c = getopt_long (argc, argv, "it:,0123456789", longopts, NULL)) != -1)
{
switch (c)
}
}
- if (show_version)
- {
- printf ("expand (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
add_tabstop (tabval);
validate_tabstops (tab_list, first_free_tab);
#include "system.h"
#include "error.h"
+#include "long-options.h"
#include "xstrtol.h"
/* The following parameters represent the program's idea of what is
/* The name this program was run with. */
const char *program_name;
-/* If nonzero, display usage information and exit. */
-static int show_help = 0;
-
-/* If nonzero, print the version on standard output and exit. */
-static int show_version = 0;
-
/* Option values. */
/* If TRUE, first 2 lines may have different indent (default FALSE). */
static const struct option long_options[] =
{
{"crown-margin", no_argument, NULL, 'c'},
- {"help", no_argument, &show_help, 1},
{"prefix", required_argument, NULL, 'p'},
{"split-only", no_argument, NULL, 's'},
{"tagged-paragraph", no_argument, NULL, 't'},
{"uniform-spacing", no_argument, NULL, 'u'},
- {"version", no_argument, &show_version, 1},
{"width", required_argument, NULL, 'w'},
{0, 0, 0, 0},
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "fmt", GNU_PACKAGE, VERSION,
+ "Ross Paterson", usage);
+
crown = tagged = split = uniform = FALSE;
max_width = WIDTH;
prefix = "";
}
- if (show_version)
- {
- printf ("fmt (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
best_width = max_width * (2 * (100 - LEEWAY) + 1) / 200;
if (optind == argc)
#include <sys/types.h>
#include "system.h"
-#include "xstrtol.h"
#include "error.h"
+#include "long-options.h"
+#include "xstrtol.h"
/* The name this program was run with. */
char *program_name;
/* If nonzero, at least one of the files we read was standard input. */
static int have_read_stdin;
-/* If nonzero, display usage information and exit. */
-static int show_help;
-
-/* If nonzero, print the version on standard output then exit. */
-static int show_version;
-
static struct option const longopts[] =
{
{"bytes", no_argument, NULL, 'b'},
{"spaces", no_argument, NULL, 's'},
{"width", required_argument, NULL, 'w'},
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "fold", GNU_PACKAGE, VERSION,
+ "David MacKenzie", usage);
+
break_spaces = count_bytes = have_read_stdin = 0;
/* Turn any numeric options into -w options. */
}
}
- if (show_version)
- {
- printf ("fold (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
if (argc == optind)
errs |= fold_file ("-", width);
else
#include <sys/types.h>
#include "system.h"
#include "error.h"
+#include "long-options.h"
#include "xstrtoul.h"
#include "safe-read.h"
/* Have we ever read standard input? */
static int have_read_stdin;
-/* If nonzero, display usage information and exit. */
-static int show_help;
-
-/* If nonzero, print the version on standard output then exit. */
-static int show_version;
-
static struct option const long_options[] =
{
{"bytes", required_argument, NULL, 'c'},
{"quiet", no_argument, NULL, 'q'},
{"silent", no_argument, NULL, 'q'},
{"verbose", no_argument, NULL, 'v'},
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "head", GNU_PACKAGE, VERSION,
+ "David MacKenzie", usage);
+
have_read_stdin = 0;
print_headers = 0;
}
}
- if (show_version)
- {
- printf ("head (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
if (header_mode == always
|| (header_mode == multiple_files && optind < argc - 1))
print_headers = 1;
#include <sys/types.h>
#include <getopt.h>
-#include "linebuffer.h"
#include "system.h"
#include <regex.h>
#include "error.h"
+#include "linebuffer.h"
+#include "long-options.h"
#include "xstrtol.h"
#ifndef TRUE
/* Nonzero if we have ever read standard input. */
static int have_read_stdin;
-/* If nonzero, display usage information and exit. */
-static int show_help;
-
-/* If nonzero, print the version on standard output then exit. */
-static int show_version;
-
static struct option const longopts[] =
{
{"header-numbering", required_argument, NULL, 'h'},
{"number-width", required_argument, NULL, 'w'},
{"number-format", required_argument, NULL, 'n'},
{"section-delimiter", required_argument, NULL, 'd'},
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "nl", GNU_PACKAGE, VERSION,
+ "Scott Bartram and David MacKenzie", usage);
+
have_read_stdin = 0;
while ((c = getopt_long (argc, argv, "h:b:f:v:i:pl:s:w:n:d:", longopts,
}
}
- if (show_version)
- {
- printf ("nl (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
/* Initialize the section delimiters. */
c = strlen (section_del);
#include <getopt.h>
#include <sys/types.h>
#include "system.h"
-#include "xstrtoul.h"
#include "error.h"
+#include "long-options.h"
+#include "xstrtoul.h"
#if defined(__GNUC__) || defined(STDC_HEADERS)
# include <float.h>
#define MAX_FP_TYPE_SIZE sizeof(LONG_DOUBLE)
static enum size_spec fp_type_size[MAX_FP_TYPE_SIZE + 1];
-/* If nonzero, display usage information and exit. */
-static int show_help;
-
-/* If nonzero, print the version on standard output then exit. */
-static int show_version;
-
static struct option const long_options[] =
{
/* POSIX options. */
{"strings", optional_argument, NULL, 's'},
{"traditional", no_argument, NULL, 'B'},
{"width", optional_argument, NULL, 'w'},
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "od", GNU_PACKAGE, VERSION,
+ "Jim Meyering", usage);
+
err = 0;
for (i = 0; i <= MAX_INTEGRAL_TYPE_SIZE; i++)
if (n_failed_decodes > 0)
exit (EXIT_FAILURE);
- if (show_version)
- {
- printf ("od (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
if (flag_dump_strings && n_specs > 0)
error (EXIT_FAILURE, 0,
_("no type may be specified when dumping strings"));
/* paste - merge lines of files
- Copyright (C) 1984, 1997, 1998 by David M. Ihnat
+ Copyright (C) 1984, 1997, 1998, 1999 by David M. Ihnat
This program is a total rewrite of the Bell Laboratories Unix(Tm)
command of the same name, as of System V. It contains no proprietary
#include <sys/types.h>
#include "system.h"
#include "error.h"
+#include "long-options.h"
/* Indicates that no delimiter should be added in the current position. */
#define EMPTY_DELIM '\0'
/* A pointer to the character after the end of `delims'. */
static char *delim_end;
-/* If nonzero, display usage information and exit. */
-static int show_help;
-
-/* If nonzero, print the version on standard output then exit. */
-static int show_version;
-
static struct option const longopts[] =
{
{"serial", no_argument, 0, 's'},
{"delimiters", required_argument, 0, 'd'},
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{0, 0, 0, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "paste", GNU_PACKAGE, VERSION,
+ "David M. Ihnat", usage);
+
have_read_stdin = 0;
serial_merge = 0;
delims = default_delims;
}
}
- if (show_version)
- {
- printf ("paste (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
if (optind == argc)
argv[argc++] = "-";
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-/* Author: Pete TerMaat. */
+/* By Pete TerMaat, with considerable refinement by Roland Huebner. */
\f
/* Things to watch: Sys V screws up on ...
pr -n -3 -s: /usr/dict/words
#include <time.h>
#include "system.h"
#include "error.h"
+#include "long-options.h"
#include "xstrtol.h"
#ifndef TRUE
static int *clump_buff;
-/* If nonzero, display usage information and exit. */
-static int show_help;
-
-/* If nonzero, print the version on standard output then exit. */
-static int show_version;
-
/* True means we read the line no. lines_per_body in skip_read
called by skip_to_page. That variable controls the coincidence of a
"FF set by hand" and "full_page_printed", see above the definition of
static struct option const long_options[] =
{
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{"test", no_argument, &test_suite, 1},
{"pages", required_argument, NULL, CHAR_MAX + 1},
{"columns", required_argument, NULL, CHAR_MAX + 2},
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "pr", GNU_PACKAGE, VERSION,
+ "Pete TerMaat and Roland Huebner", usage);
+
n_files = 0;
file_names = (argc > 1
? (char **) xmalloc ((argc - 1) * sizeof (char *))
}
}
- if (show_version)
- {
- printf ("pr (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
if (parallel_files && explicit_columns)
error (EXIT_FAILURE, 0,
_("Cannot specify number of columns when printing in parallel."));
#include "system.h"
#include "error.h"
-#include "xstrtol.h"
+#include "long-options.h"
#include "safe-read.h"
+#include "xstrtol.h"
int full_write ();
/* Descriptor on which output file is open. */
static int output_desc;
-/* If nonzero, display usage information and exit. */
-static int show_help;
-
-/* If nonzero, print the version on standard output then exit. */
-static int show_version;
-
/* If nonzero, print a diagnostic on standard error just before each
output file is opened. */
static int verbose;
{"lines", required_argument, NULL, 'l'},
{"line-bytes", required_argument, NULL, 'C'},
{"verbose", no_argument, NULL, 2},
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "split", GNU_PACKAGE, VERSION,
+ "Torbjorn Granlund and Richard M. Stallman", usage);
+
/* Parse command line options. */
infile = "-";
}
}
- if (show_version)
- {
- printf ("split (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
/* Handle default case. */
if (split_type == type_undef)
{
#include <getopt.h>
#include "system.h"
#include "error.h"
+#include "long-options.h"
#include "safe-read.h"
/* The name this program was run with. */
/* Right-rotate 32-bit integer variable C. */
#define ROTATE_RIGHT(c) if ((c) & 01) (c) = ((c) >>1) + 0x8000; else (c) >>= 1;
-/* If nonzero, display usage information and exit. */
-static int show_help;
-
-/* If nonzero, print the version on standard output then exit. */
-static int show_version;
-
static struct option const longopts[] =
{
{"sysv", no_argument, NULL, 's'},
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
have_read_stdin = 0;
+ parse_long_options (argc, argv, "sum", GNU_PACKAGE, VERSION,
+ "Kayvan Aghaiepour and David MacKenzie", usage);
+
while ((optc = getopt_long (argc, argv, "rs", longopts, NULL)) != -1)
{
switch (optc)
}
}
- if (show_version)
- {
- printf ("sum (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
files_given = argc - optind;
if (files_given == 0)
{
#include <regex.h>
#include "error.h"
+#include "long-options.h"
#include "safe-read.h"
#if defined __MSDOS__ || defined _WIN32
/* The compiled regular expression representing `separator'. */
static struct re_pattern_buffer compiled_separator;
-/* If nonzero, display usage information and exit. */
-static int show_help;
-
-/* If nonzero, print the version on standard output then exit. */
-static int show_version;
-
static struct option const longopts[] =
{
{"before", no_argument, NULL, 'b'},
{"regex", no_argument, NULL, 'r'},
{"separator", required_argument, NULL, 's'},
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "tac", GNU_PACKAGE, VERSION,
+ "Jay Lepreau and David MacKenzie", usage);
+
errors = 0;
separator = "\n";
sentinel_length = 1;
}
}
- if (show_version)
- {
- printf ("tac (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
if (sentinel_length == 0)
{
compiled_separator.allocated = 100;
#include "system.h"
#include "argmatch.h"
-#include "xstrtoul.h"
#include "error.h"
+#include "long-options.h"
#include "safe-read.h"
+#include "xstrtoul.h"
#ifndef OFF_T_MIN
# define OFF_T_MIN TYPE_MINIMUM (off_t)
/* Nonzero if we have ever read standard input. */
static int have_read_stdin;
-/* If nonzero, display usage information and exit. */
-static int show_help;
-
-/* If nonzero, print the version on standard output then exit. */
-static int show_version;
-
static struct option const long_options[] =
{
{"allow-missing", no_argument, NULL, CHAR_MAX + 1},
{"silent", no_argument, NULL, 'q'},
{"sleep-interval", required_argument, NULL, 's'},
{"verbose", no_argument, NULL, 'v'},
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
have_read_stdin = 0;
+ parse_long_options (argc, argv, "tail", GNU_PACKAGE, VERSION,
+ "Paul Rubin, David MacKenzie, Ian Lance Taylor, and Jim Meyering",
+ usage);
+
{
int found_obsolescent;
int fail;
}
}
- if (show_version)
- {
- printf ("tail (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
/* To start printing with item N_UNITS from the start of the file, skip
N_UNITS - 1 items. `tail +0' is actually meaningless, but for Unix
compatibility it's treated the same as `tail +1'. */
#include "system.h"
#include "error.h"
+#include "long-options.h"
#include "safe-read.h"
#define N_CHARS (UCHAR_MAX + 1)
two specification strings and the delete switch is not given. */
static char xlate[N_CHARS];
-/* If nonzero, display usage information and exit. */
-static int show_help;
-
-/* If nonzero, print the version on standard output then exit. */
-static int show_version;
-
static struct option const long_options[] =
{
{"complement", no_argument, NULL, 'c'},
{"delete", no_argument, NULL, 'd'},
{"squeeze-repeats", no_argument, NULL, 's'},
{"truncate-set1", no_argument, NULL, 't'},
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
\f
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "tr", GNU_PACKAGE, VERSION,
+ "Jim Meyering", usage);
+
while ((c = getopt_long (argc, argv, "cdst", long_options, NULL)) != -1)
{
switch (c)
}
}
- if (show_version)
- {
- printf ("tr (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
posix_pedantic = (getenv ("POSIXLY_CORRECT") != NULL);
non_option_args = argc - optind;
#include <sys/types.h>
#include "system.h"
+#include "long-options.h"
#include "error.h"
/* The number of bytes added at a time to the amount of memory
/* Status to return to the system. */
static int exit_status;
-/* If nonzero, display usage information and exit. */
-static int show_help;
-
-/* If nonzero, print the version on standard output then exit. */
-static int show_version;
-
static struct option const longopts[] =
{
{"tabs", required_argument, NULL, 't'},
{"all", no_argument, NULL, 'a'},
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "unexpand", GNU_PACKAGE, VERSION,
+ "David MacKenzie", usage);
+
have_read_stdin = 0;
exit_status = 0;
convert_entire_line = 0;
}
}
- if (show_version)
- {
- printf ("unexpand (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
add_tabstop (tabval);
validate_tabstops (tab_list, first_free_tab);
#include "system.h"
#include "linebuffer.h"
+#include "long-options.h"
#include "error.h"
#include "xstrtol.h"
#include "memcasecmp.h"
/* If nonzero, ignore case when comparing. */
static int ignore_case;
-/* If nonzero, display usage information and exit. */
-static int show_help;
-
-/* If nonzero, print the version on standard output then exit. */
-static int show_version;
-
static struct option const longopts[] =
{
{"count", no_argument, NULL, 'c'},
{"skip-fields", required_argument, NULL, 'f'},
{"skip-chars", required_argument, NULL, 's'},
{"check-chars", required_argument, NULL, 'w'},
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "uniq", GNU_PACKAGE, VERSION,
+ "Richard Stallman and David MacKenzie", usage);
+
skip_chars = 0;
skip_fields = 0;
check_chars = 0;
}
}
- if (show_version)
- {
- printf ("uniq (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
if (optind >= 2 && !STREQ (argv[optind - 1], "--"))
{
/* Interpret non-option arguments with leading `+' only
#include "system.h"
#include "error.h"
#include "human.h"
+#include "long-options.h"
#include "safe-read.h"
/* Size of atomic reads. */
/* The error code to return to the system. */
static int exit_status;
-/* If nonzero, display usage information and exit. */
-static int show_help;
-
-/* If nonzero, print the version on standard output then exits. */
-static int show_version;
-
static struct option const longopts[] =
{
{"bytes", no_argument, NULL, 'c'},
{"lines", no_argument, NULL, 'l'},
{"words", no_argument, NULL, 'w'},
{"max-line-length", no_argument, NULL, 'L'},
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "wc", GNU_PACKAGE, VERSION,
+ "Paul Rubin and David MacKenzie", usage);
+
exit_status = 0;
print_lines = print_words = print_chars = print_linelength = 0;
total_lines = total_words = total_chars = max_line_length = 0;
usage (1);
}
- if (show_version)
- {
- printf ("wc (%s) %s\n", GNU_PACKAGE, VERSION);
- exit (EXIT_SUCCESS);
- }
-
- if (show_help)
- usage (0);
-
if (print_lines + print_words + print_chars + print_linelength == 0)
print_lines = print_words = print_chars = 1;