summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorwlemb <wlemb>2001-04-10 12:54:10 +0000
committerwlemb <wlemb>2001-04-10 12:54:10 +0000
commit3eba6c39c3d6e7fd573a1c3f74063a35f9861407 (patch)
tree2c32998fa8ed173ab84325e9d345f5ea49f86a2c /src
parent21ebecd3dc1722faa746a7f5e943a580beffb138 (diff)
downloadgroff-3eba6c39c3d6e7fd573a1c3f74063a35f9861407.tar.gz
* NEWS: Updated.
* doc/groff.texinfo: Many fixes, additions, clarifications, etc. * src/devices/grodvi/dvi.cc (main): Accept --help and --version. (usage): Add stream argument. Don't exit. * src/devices/grohtml/post-html.cc (main): Accept --help and --version. Write --version output to stdout, not stderr. (usage): Add stream argument. Don't exit. * src/devices/grohtml-old/html.cc (main): Accept --help and --version. (usage): Add stream argument. Don't exit. * src/devices/grolbp/lbp.cc (long_options): Use symbolic getopt.h constants. (usage): Add stream argument. Don't exit. (main): Write --help output to stdout, not stderr. * src/devices/grolj4/lj4.cc (main): Accept --help and --version. (usage): Add stream argument. Don't exit. * src/devices/grops/ps.cc (main): Accept --help and --version. (usage): Add stream argument. Don't exit. * src/devices/grotty/tty.cc (main): Accept --help and --version. (usage): Add stream argument. Don't exit. * src/preproc/eqn/main.cc (usage): Add stream argument. Don't exit. (main): Accept --help and --version. * src/preproc/grn/main.cc (usage): Add stream argument. Don't exit. (main): Accept --help and --version. * src/preproc/html/pre-html.cc (usage): Add stream argument. (scanArguments): Accept --help and --version. * src/preproc/pic/main.cc (usage): Add stream argument. Don't exit. (main): Accept --help and --version. * src/preproc/refer/refer.cc (main): Accept --help and --version. (usage): Add stream argument. Don't exit. * src/preproc/soelim/soelim.cc (usage): Add stream argument. Don't exit. (main): Accept --help and --version. * src/preproc/tbl/main.cc (usage): Add stream argument. Don't exit. (main): Accept --help and --version. * src/roff/groff/groff.cc (main): Accept --help and --version. (synopsis): Add stream argument. (help): Write --help output to stdout, not stderr. (usage): Add stream argument. Don't exit. * src/roff/grog/grog.pl: Accept --help and --version. (help): New sub. * src/roff/grog/grog.sh: Accept --help and --version. * src/roff/nroff/nroff.sh: Accept --help and --version. * src/roff/troff/input.cc (USAGE_EXIT_CODE): Remove macro. (usage): Add stream argument. Don't exit. (main): Accept --help and --version. * src/utils/addftinfo/addftinfo.cc (main): Accept --help and --version. (usage): New function with stream argument, doesn't exit. * src/utils/hpftodit/hpftodit.cc (main): Accept --help and --version. (usage): New function with stream argument, doesn't exit. * src/utils/indxbib/indxbib.cc (main): Accept --help and --version. (usage): Add stream argument. Don't exit. * src/utils/lkbib/lkbib.cc (usage): Add stream argument. Don't exit. (main): Accept --help and --version. * src/utils/lookbib/lookbib.cc (usage): Add stream argument. Don't exit. (main): Accept --help and --version. * src/utils/pfbtops/pfbtops.c (usage): Add stream argument. Don't exit. (main): Accept --help and --version. * src/utils/tfmtodit/tfmtodit.cc (main): Accept --help and --version. (usage): Add stream argument. Don't exit.
Diffstat (limited to 'src')
-rw-r--r--src/devices/grodvi/dvi.cc21
-rwxr-xr-xsrc/devices/grohtml-old/html.cc22
-rw-r--r--src/devices/grohtml/post-html.cc30
-rw-r--r--src/devices/grolbp/lbp.cc34
-rw-r--r--src/devices/grolj4/lj4.cc24
-rw-r--r--src/devices/grops/ps.cc23
-rw-r--r--src/devices/grotty/tty.cc22
-rw-r--r--src/preproc/eqn/main.cc21
-rw-r--r--src/preproc/grn/main.cc33
-rw-r--r--src/preproc/html/pre-html.cc19
-rw-r--r--src/preproc/pic/main.cc33
-rw-r--r--src/preproc/refer/refer.cc33
-rw-r--r--src/preproc/soelim/soelim.cc21
-rw-r--r--src/preproc/tbl/main.cc19
-rw-r--r--src/roff/groff/groff.cc32
-rw-r--r--src/roff/grog/grog.pl8
-rw-r--r--src/roff/grog/grog.sh5
-rw-r--r--src/roff/nroff/nroff.sh5
-rw-r--r--src/roff/troff/input.cc23
-rw-r--r--src/utils/addftinfo/addftinfo.cc17
-rw-r--r--src/utils/hpftodit/hpftodit.cc24
-rw-r--r--src/utils/indxbib/indxbib.cc25
-rw-r--r--src/utils/lkbib/lkbib.cc29
-rw-r--r--src/utils/lookbib/lookbib.cc28
-rw-r--r--src/utils/pfbtops/pfbtops.c27
-rw-r--r--src/utils/tfmtodit/tfmtodit.cc29
26 files changed, 416 insertions, 191 deletions
diff --git a/src/devices/grodvi/dvi.cc b/src/devices/grodvi/dvi.cc
index 68774de0..74422f80 100644
--- a/src/devices/grodvi/dvi.cc
+++ b/src/devices/grodvi/dvi.cc
@@ -846,7 +846,7 @@ printer *make_printer()
return new dvi_printer;
}
-static void usage();
+static void usage(FILE *stream);
int main(int argc, char **argv)
{
@@ -854,7 +854,12 @@ int main(int argc, char **argv)
static char stderr_buf[BUFSIZ];
setbuf(stderr, stderr_buf);
int c;
- while ((c = getopt(argc, argv, "F:vw:d")) != EOF)
+ static const struct option long_options[] = {
+ { "help", no_argument, 0, CHAR_MAX + 1 },
+ { "version", no_argument, 0, 'v' },
+ { NULL, 0, 0, 0 }
+ };
+ while ((c = getopt_long(argc, argv, "F:vw:d", long_options, NULL)) != EOF)
switch(c) {
case 'v':
{
@@ -876,8 +881,13 @@ int main(int argc, char **argv)
case 'F':
font::command_line_font_dir(optarg);
break;
+ case CHAR_MAX + 1: // --help
+ usage(stdout);
+ exit(0);
+ break;
case '?':
- usage();
+ usage(stderr);
+ exit(1);
break;
default:
assert(0);
@@ -895,9 +905,8 @@ int main(int argc, char **argv)
return 0;
}
-static void usage()
+static void usage(FILE *stream)
{
- fprintf(stderr, "usage: %s [-dv] [-F dir] [-w n] [files ...]\n",
+ fprintf(stream, "usage: %s [-dv] [-F dir] [-w n] [files ...]\n",
program_name);
- exit(1);
}
diff --git a/src/devices/grohtml-old/html.cc b/src/devices/grohtml-old/html.cc
index 89247256..102c043a 100755
--- a/src/devices/grohtml-old/html.cc
+++ b/src/devices/grohtml-old/html.cc
@@ -6533,7 +6533,7 @@ printer *make_printer()
return new html_printer;
}
-static void usage();
+static void usage(FILE *stream);
int main(int argc, char **argv)
{
@@ -6541,7 +6541,13 @@ int main(int argc, char **argv)
static char stderr_buf[BUFSIZ];
setbuf(stderr, stderr_buf);
int c;
- while ((c = getopt(argc, argv, "F:atTvdgmx?I:r:")) != EOF)
+ static const struct option long_options[] = {
+ { "help", no_argument, 0, CHAR_MAX + 1 },
+ { "version", no_argument, 0, 'v' },
+ { NULL, 0, 0, 0 }
+ };
+ while ((c = getopt_long(argc, argv, "F:atTvdgmx?I:r:", long_options, NULL))
+ != EOF)
switch(c) {
case 'v':
{
@@ -6585,8 +6591,13 @@ int main(int argc, char **argv)
// leave margins alone
margin_on = TRUE;
break;
+ case CHAR_MAX + 1: // --help
+ usage(stdout);
+ exit(0);
+ break;
case '?':
- usage();
+ usage(stderr);
+ exit(1);
break;
default:
assert(0);
@@ -6601,9 +6612,8 @@ int main(int argc, char **argv)
return 0;
}
-static void usage()
+static void usage(FILE *stream)
{
- fprintf(stderr, "usage: %s [-avdgmt?] [-r resolution] [-F dir] [-I imagetype] [files ...]\n",
+ fprintf(stream, "usage: %s [-avdgmt?] [-r resolution] [-F dir] [-I imagetype] [files ...]\n",
program_name);
- exit(1);
}
diff --git a/src/devices/grohtml/post-html.cc b/src/devices/grohtml/post-html.cc
index 63965652..716e138d 100644
--- a/src/devices/grohtml/post-html.cc
+++ b/src/devices/grohtml/post-html.cc
@@ -1058,7 +1058,7 @@ printer *make_printer()
return new html_printer;
}
-static void usage();
+static void usage(FILE *stream);
void html_printer::set_style(const style &sty)
{
@@ -2785,13 +2785,19 @@ int main(int argc, char **argv)
static char stderr_buf[BUFSIZ];
setbuf(stderr, stderr_buf);
int c;
- while ((c = getopt(argc, argv, "o:i:F:vd?lrn")) != EOF)
+ static const struct option long_options[] = {
+ { "help", no_argument, 0, CHAR_MAX + 1 },
+ { "version", no_argument, 0, 'v' },
+ { NULL, 0, 0, 0 }
+ };
+ while ((c = getopt_long(argc, argv, "o:i:F:vd?lrn", long_options, NULL))
+ != EOF)
switch(c) {
case 'v':
{
extern const char *Version_string;
- fprintf(stderr, "post-grohtml version %s\n", Version_string);
- fflush(stderr);
+ printf("GNU post-grohtml (groff) version %s\n", Version_string);
+ exit(0);
break;
}
case 'F':
@@ -2803,9 +2809,6 @@ int main(int argc, char **argv)
case 'r':
auto_rule = FALSE;
break;
- case '?':
- usage();
- break;
case 'o':
/* handled by pre-html */
break;
@@ -2815,6 +2818,14 @@ int main(int argc, char **argv)
case 'n':
simple_anchors = TRUE;
break;
+ case CHAR_MAX + 1: // --help
+ usage(stdout);
+ exit(0);
+ break;
+ case '?':
+ usage(stderr);
+ exit(1);
+ break;
default:
assert(0);
}
@@ -2828,9 +2839,8 @@ int main(int argc, char **argv)
return 0;
}
-static void usage()
+static void usage(FILE *stream)
{
- fprintf(stderr, "usage: %s [-vld?n] [-F dir] [files ...]\n",
+ fprintf(stream, "usage: %s [-vld?n] [-F dir] [files ...]\n",
program_name);
- exit(1);
}
diff --git a/src/devices/grolbp/lbp.cc b/src/devices/grolbp/lbp.cc
index edd49fd2..69196af4 100644
--- a/src/devices/grolbp/lbp.cc
+++ b/src/devices/grolbp/lbp.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1994, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1994, 2000, 2001 Free Software Foundation, Inc.
Written by Francisco Andrés Verdú <pandres@dragonet.es> with many ideas
taken from the other groff drivers.
@@ -663,19 +663,19 @@ static void handle_unknown_desc_command(const char *command, const char *arg,
};
static struct option long_options[] = {
- {"orientation",1,NULL,'o'},
- {"version",0,NULL,'v'},
- {"copies",1,NULL,'c'},
- {"landscape",0,NULL,'l'},
- {"papersize",1,NULL,'p'},
- {"fontdir",1,NULL,'F'},
- {"help",0,NULL,'h'},
- {0, 0, 0, 0}
+ { "orientation", required_argument, NULL, 'o' },
+ { "version", no_argument, NULL, 'v' },
+ { "copies", required_argument, NULL, 'c' },
+ { "landscape", no_argument, NULL, 'l' },
+ { "papersize", required_argument, NULL, 'p' },
+ { "fontdir", required_argument, NULL, 'F' },
+ { "help", no_argument, NULL, 'h' },
+ { NULL, 0, 0, 0 }
};
-static void usage()
+static void usage(FILE *stream)
{
- fprintf(stderr,
+ fprintf(stream,
"usage: %s [-lvh] [-c n] [-p paper_size] [-F dir] [-o or] "\
" [files ...]\n"\
" -o --orientation=[portrait|landscape]\n"\
@@ -686,7 +686,6 @@ static void usage()
" -F --fontdir=dir\n"\
" -h --help\n",
program_name);
- exit(1);
}; // usage
int main(int argc, char **argv)
@@ -717,8 +716,8 @@ int main(int argc, char **argv)
break;
case 'v' : {
extern const char *Version_string;
- printf("GNU grolbp (groff) version %s\n",\
- Version_string);
+ printf("GNU grolbp (groff) version %s\n",
+ Version_string);
exit(0);
break;
};
@@ -744,9 +743,12 @@ int main(int argc, char **argv)
ncopies = unsigned(n);
break;
}
- case 'h' : usage();
+ case 'h' : usage(stdout);
+ exit(0);
break;
-
+ case '?' : usage(stderr);
+ exit(1);
+ break;
}; // switch (c)
}; // while (c > 0 )
diff --git a/src/devices/grolj4/lj4.cc b/src/devices/grolj4/lj4.cc
index 4bbb5f5a..9fbc6afa 100644
--- a/src/devices/grolj4/lj4.cc
+++ b/src/devices/grolj4/lj4.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1994, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1994, 2000, 2001 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -595,7 +595,7 @@ void handle_unknown_desc_command(const char *command, const char *arg,
}
}
-static void usage();
+static void usage(FILE *stream);
extern "C" int optopt, optind;
@@ -606,7 +606,13 @@ int main(int argc, char **argv)
setbuf(stderr, stderr_buf);
font::set_unknown_desc_command_handler(handle_unknown_desc_command);
int c;
- while ((c = getopt(argc, argv, ":F:p:d:lvw:c:")) != EOF)
+ static const struct option long_options[] = {
+ { "help", no_argument, 0, CHAR_MAX + 1 },
+ { "version", no_argument, 0, 'v' },
+ { NULL, 0, 0, 0 }
+ };
+ while ((c = getopt_long(argc, argv, ":F:p:d:lvw:c:", long_options, NULL))
+ != EOF)
switch(c) {
case 'l':
landscape_flag = 1;
@@ -671,8 +677,13 @@ int main(int argc, char **argv)
line_width_factor = int(n);
break;
}
+ case CHAR_MAX + 1: // --help
+ usage(stdout);
+ exit(0);
+ break;
case '?':
- usage();
+ usage(stderr);
+ exit(1);
break;
default:
assert(0);
@@ -690,11 +701,10 @@ int main(int argc, char **argv)
return 0;
}
-static void usage()
+static void usage(FILE *stream)
{
- fprintf(stderr,
+ fprintf(stream,
"usage: %s [-lv] [-d [n]] [-c n] [-p paper_size]\n"
" [-w n] [-F dir] [files ...]\n",
program_name);
- exit(1);
}
diff --git a/src/devices/grops/ps.cc b/src/devices/grops/ps.cc
index eb3b6cc8..98b1a910 100644
--- a/src/devices/grops/ps.cc
+++ b/src/devices/grops/ps.cc
@@ -1476,7 +1476,7 @@ printer *make_printer()
return new ps_printer;
}
-static void usage();
+static void usage(FILE *stream);
int main(int argc, char **argv)
{
@@ -1485,7 +1485,13 @@ int main(int argc, char **argv)
static char stderr_buf[BUFSIZ];
setbuf(stderr, stderr_buf);
int c;
- while ((c = getopt(argc, argv, "F:P:glmc:w:vb:")) != EOF)
+ static const struct option long_options[] = {
+ { "help", no_argument, 0, CHAR_MAX + 1 },
+ { "version", no_argument, 0, 'v' },
+ { NULL, 0, 0, 0 }
+ };
+ while ((c = getopt_long(argc, argv, "F:P:glmc:w:vb:", long_options, NULL))
+ != EOF)
switch(c) {
case 'v':
{
@@ -1531,8 +1537,13 @@ int main(int argc, char **argv)
broken_flags = atoi(optarg);
bflag = 1;
break;
+ case CHAR_MAX + 1: // --help
+ usage(stdout);
+ exit(0);
+ break;
case '?':
- usage();
+ usage(stderr);
+ exit(1);
break;
default:
assert(0);
@@ -1551,11 +1562,9 @@ int main(int argc, char **argv)
return 0;
}
-static void usage()
+static void usage(FILE *stream)
{
- fprintf(
- stderr,
+ fprintf(stream,
"usage: %s [-glmv] [-b n] [-c n] [-w n] [-P prologue] [-F dir] [files ...]\n",
program_name);
- exit(1);
}
diff --git a/src/devices/grotty/tty.cc b/src/devices/grotty/tty.cc
index 497275ce..a8ee0653 100644
--- a/src/devices/grotty/tty.cc
+++ b/src/devices/grotty/tty.cc
@@ -424,7 +424,7 @@ printer *make_printer()
return new tty_printer(device);
}
-static void usage();
+static void usage(FILE *stream);
int main(int argc, char **argv)
{
@@ -432,7 +432,13 @@ int main(int argc, char **argv)
static char stderr_buf[BUFSIZ];
setbuf(stderr, stderr_buf);
int c;
- while ((c = getopt(argc, argv, "F:vhfbuoBUd")) != EOF)
+ static const struct option long_options[] = {
+ { "help", no_argument, 0, CHAR_MAX + 1 },
+ { "version", no_argument, 0, 'v' },
+ { NULL, 0, 0, 0 }
+ };
+ while ((c = getopt_long(argc, argv, "F:vhfbuoBUd", long_options, NULL))
+ != EOF)
switch(c) {
case 'v':
{
@@ -475,8 +481,13 @@ int main(int argc, char **argv)
// Ignore \D commands.
draw_flag = 0;
break;
+ case CHAR_MAX + 1: // --help
+ usage(stdout);
+ exit(0);
+ break;
case '?':
- usage();
+ usage(stderr);
+ exit(1);
break;
default:
assert(0);
@@ -491,9 +502,8 @@ int main(int argc, char **argv)
return 0;
}
-static void usage()
+static void usage(FILE *stream)
{
- fprintf(stderr, "usage: %s [-hfvbuodBU] [-F dir] [files ...]\n",
+ fprintf(stream, "usage: %s [-hfvbuodBU] [-F dir] [files ...]\n",
program_name);
- exit(1);
}
diff --git a/src/preproc/eqn/main.cc b/src/preproc/eqn/main.cc
index a0d27ee4..e5c03aa4 100644
--- a/src/preproc/eqn/main.cc
+++ b/src/preproc/eqn/main.cc
@@ -234,12 +234,11 @@ static char *delim_search(char *ptr, int delim)
return 0;
}
-void usage()
+void usage(FILE *stream)
{
- fprintf(stderr,
+ fprintf(stream,
"usage: %s [ -rvDCNR ] -dxx -fn -sn -pn -mn -Mdir -Ts [ files ... ]\n",
program_name);
- exit(1);
}
int main(int argc, char **argv)
@@ -249,7 +248,14 @@ int main(int argc, char **argv)
setbuf(stderr, stderr_buf);
int opt;
int load_startup_file = 1;
- while ((opt = getopt(argc, argv, "DCRvd:f:p:s:m:T:M:rN")) != EOF)
+ static const struct option long_options[] = {
+ { "help", no_argument, 0, CHAR_MAX + 1 },
+ { "version", no_argument, 0, 'v' },
+ { NULL, 0, 0, 0 }
+ };
+ while ((opt = getopt_long(argc, argv, "DCRvd:f:p:s:m:T:M:rN", long_options,
+ NULL))
+ != EOF)
switch (opt) {
case 'C':
compatible_flag = 1;
@@ -317,8 +323,13 @@ int main(int argc, char **argv)
case 'N':
no_newline_in_delim_flag = 1;
break;
+ case CHAR_MAX + 1: // --help
+ usage(stdout);
+ exit(0);
+ break;
case '?':
- usage();
+ usage(stderr);
+ exit(1);
break;
default:
assert(0);
diff --git a/src/preproc/grn/main.cc b/src/preproc/grn/main.cc
index 209d60c0..76c067ff 100644
--- a/src/preproc/grn/main.cc
+++ b/src/preproc/grn/main.cc
@@ -220,12 +220,11 @@ void interpret(char *line);
void
-usage()
+usage(FILE *stream)
{
- fprintf(stderr,
+ fprintf(stream,
"usage: %s [ -vCs ] [ -M dir ] [ -F dir ] [ -T dev ] [ file ]\n",
program_name);
- exit(1);
}
@@ -260,14 +259,6 @@ main(int argc,
file[gfil++] = NULL;
break;
- case 'v':
- {
- extern const char *Version_string;
- printf("GNU grn (groff) version %s\n", Version_string);
- fflush(stdout);
- exit(0);
- break;
- }
case 'C': /* compatibility mode */
compatibility_flag = TRUE;
break;
@@ -288,13 +279,25 @@ main(int argc,
sflag = 1;
break;
+ case '-':
+ if (strcmp(*argv,"--version")==0) {
+ case 'v':
+ extern const char *Version_string;
+ printf("GNU grn (groff) version %s\n", Version_string);
+ exit(0);
+ break;
+ }
+ if (strcmp(*argv,"--help")==0) {
case '?':
- usage();
- break;
-
+ usage(stdout);
+ exit(0);
+ break;
+ }
+ // fallthrough
default:
error("unknown switch: %1", c);
- usage();
+ usage(stderr);
+ exit(1);
}
}
diff --git a/src/preproc/html/pre-html.cc b/src/preproc/html/pre-html.cc
index 2f00f786..6aae6cb4 100644
--- a/src/preproc/html/pre-html.cc
+++ b/src/preproc/html/pre-html.cc
@@ -985,14 +985,14 @@ static char_buffer inputFile;
/*
- * usage - emit usage arguments and exit.
+ * usage - emit usage arguments.
*/
-void usage()
+void usage(FILE *stream)
{
- fprintf(stderr, "usage: %s troffname [-P-o vertical_image_offset] [-P-i image_resolution] [troff flags] [files]\n", program_name);
- fprintf(stderr, " vertical_image_offset (default %d/72 of an inch)\n", vertical_offset);
- fprintf(stderr, " image_resolution (default %d) pixels per inch\n", image_res);
+ fprintf(stream, "usage: %s troffname [-P-o vertical_image_offset] [-P-i image_resolution] [troff flags] [files]\n", program_name);
+ fprintf(stream, " vertical_image_offset (default %d/72 of an inch)\n", vertical_offset);
+ fprintf(stream, " image_resolution (default %d) pixels per inch\n", image_res);
}
/*
@@ -1008,12 +1008,15 @@ int scanArguments (int argc, char **argv)
image_res = atoi((char *)(argv[i]+2));
} else if (strncmp(argv[i], "-o", 2) == 0) {
vertical_offset = atoi((char *)(argv[i]+2));
- } else if (strcmp(argv[i], "-v") == 0) {
+ } else if ((strcmp(argv[i], "-v") == 0)
+ || (strcmp(argv[i], "--version") == 0)) {
extern const char *Version_string;
printf("GNU pre-grohtml (groff) version %s\n", Version_string);
exit(0);
- } else if ((strcmp(argv[i], "-h") == 0) || (strcmp(argv[i], "-?") == 0)) {
- usage();
+ } else if ((strcmp(argv[i], "-h") == 0)
+ || (strcmp(argv[i], "--help") == 0)
+ || (strcmp(argv[i], "-?") == 0)) {
+ usage(stdout);
exit(0);
} else if (strcmp(argv[i], "troff") == 0) {
/* remember troff argument number */
diff --git a/src/preproc/pic/main.cc b/src/preproc/pic/main.cc
index 95ec3c31..87d2b930 100644
--- a/src/preproc/pic/main.cc
+++ b/src/preproc/pic/main.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -464,16 +464,15 @@ void do_whole_file(const char *filename)
}
#endif
-void usage()
+void usage(FILE *stream)
{
- fprintf(stderr, "usage: %s [ -nvC ] [ filename ... ]\n", program_name);
+ fprintf(stream, "usage: %s [ -nvC ] [ filename ... ]\n", program_name);
#ifdef TEX_SUPPORT
- fprintf(stderr, " %s -t [ -cvzC ] [ filename ... ]\n", program_name);
+ fprintf(stream, " %s -t [ -cvzC ] [ filename ... ]\n", program_name);
#endif
#ifdef FIG_SUPPORT
- fprintf(stderr, " %s -f [ -v ] [ filename ]\n", program_name);
+ fprintf(stream, " %s -f [ -v ] [ filename ]\n", program_name);
#endif
- exit(1);
}
#ifdef __MSDOS__
@@ -518,7 +517,13 @@ int main(int argc, char **argv)
int whole_file_flag = 0;
int fig_flag = 0;
#endif
- while ((opt = getopt(argc, argv, "T:CDSUtcvnxzpf")) != EOF)
+ static const struct option long_options[] = {
+ { "help", no_argument, 0, CHAR_MAX + 1 },
+ { "version", no_argument, 0, 'v' },
+ { NULL, 0, 0, 0 }
+ };
+ while ((opt = getopt_long(argc, argv, "T:CDSUtcvnxzpf", long_options, NULL))
+ != EOF)
switch (opt) {
case 'C':
compatible_flag = 1;
@@ -572,8 +577,13 @@ int main(int argc, char **argv)
// zero length lines will be printed as dots
zero_length_line_flag++;
break;
+ case CHAR_MAX + 1: // --help
+ usage(stdout);
+ exit(0);
+ break;
case '?':
- usage();
+ usage(stderr);
+ exit(1);
break;
default:
assert(0);
@@ -601,9 +611,10 @@ int main(int argc, char **argv)
if (whole_file_flag) {
if (optind >= argc)
do_whole_file("-");
- else if (argc - optind > 1)
- usage();
- else
+ else if (argc - optind > 1) {
+ usage(stderr);
+ exit(1);
+ } else
do_whole_file(argv[optind]);
}
else {
diff --git a/src/preproc/refer/refer.cc b/src/preproc/refer/refer.cc
index 19ac01be..b6cefc58 100644
--- a/src/preproc/refer/refer.cc
+++ b/src/preproc/refer/refer.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -99,7 +99,7 @@ static void immediately_output_references();
static unsigned store_reference(const string &);
static void divert_to_temporary_file();
static reference *make_reference(const string &, unsigned *);
-static void usage();
+static void usage(FILE *stream);
static void do_file(const char *);
static void split_punct(string &line, string &punct);
static void output_citation_group(reference **v, int n, label_type, FILE *fp);
@@ -172,7 +172,8 @@ int main(int argc, char **argv)
}
else {
error("option `f' requires an argument");
- usage();
+ usage(stderr);
+ exit(1);
}
}
else {
@@ -300,7 +301,8 @@ int main(int argc, char **argv)
}
else {
error("option `p' requires an argument");
- usage();
+ usage(stderr);
+ exit(1);
}
}
else {
@@ -334,23 +336,29 @@ int main(int argc, char **argv)
opt = ptr;
break;
}
+ case '-':
+ if (opt[1] == '\0') {
+ finished_options = 1;
+ opt++;
+ break;
+ }
+ if (strcmp(opt,"-version")==0) {
case 'v':
- {
extern const char *Version_string;
printf("GNU refer (groff) version %s\n", Version_string);
exit(0);
break;
}
- case '-':
- if (opt[1] == '\0') {
- finished_options = 1;
- opt++;
+ if (strcmp(opt,"-help")==0) {
+ usage(stdout);
+ exit(0);
break;
}
// fall through
default:
error("unrecognized option `%1'", *opt);
- usage();
+ usage(stderr);
+ exit(1);
break;
}
}
@@ -378,13 +386,12 @@ int main(int argc, char **argv)
return 0;
}
-static void usage()
+static void usage(FILE *stream)
{
- fprintf(stderr,
+ fprintf(stream,
"usage: %s [-benvCPRS] [-aN] [-cXYZ] [-fN] [-iXYZ] [-kX] [-lM,N] [-p file]\n"
" [-sXYZ] [-tN] [-BL.M] [files ...]\n",
program_name);
- exit(1);
}
static void possibly_load_default_database()
diff --git a/src/preproc/soelim/soelim.cc b/src/preproc/soelim/soelim.cc
index 7fa05af3..e05f2406 100644
--- a/src/preproc/soelim/soelim.cc
+++ b/src/preproc/soelim/soelim.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -58,10 +58,9 @@ include_path_append(char *path)
}
-void usage()
+void usage(FILE *stream)
{
- fprintf(stderr, "usage: %s [ -vC ] [ -I file ] [ files ]\n", program_name);
- exit(1);
+ fprintf(stream, "usage: %s [ -vC ] [ -I file ] [ files ]\n", program_name);
}
int main(int argc, char **argv)
@@ -69,7 +68,12 @@ int main(int argc, char **argv)
program_name = argv[0];
include_path_append(".");
int opt;
- while ((opt = getopt(argc, argv, "CI:v")) != EOF)
+ static const struct option long_options[] = {
+ { "help", no_argument, 0, CHAR_MAX + 1 },
+ { "version", no_argument, 0, 'v' },
+ { NULL, 0, 0, 0 }
+ };
+ while ((opt = getopt_long(argc, argv, "CI:v", long_options, NULL)) != EOF)
switch (opt) {
case 'v':
{
@@ -84,8 +88,13 @@ int main(int argc, char **argv)
case 'I':
include_path_append(optarg);
break;
+ case CHAR_MAX + 1: // --help
+ usage(stdout);
+ exit(0);
+ break;
case '?':
- usage();
+ usage(stderr);
+ exit(1);
break;
default:
assert(0);
diff --git a/src/preproc/tbl/main.cc b/src/preproc/tbl/main.cc
index d13f026c..efc8fdcc 100644
--- a/src/preproc/tbl/main.cc
+++ b/src/preproc/tbl/main.cc
@@ -1447,10 +1447,9 @@ void process_table(table_input &in)
error("premature end of file");
}
-static void usage()
+static void usage(FILE *stream)
{
- fprintf(stderr, "usage: %s [ -vC ] [ files... ]\n", program_name);
- exit(1);
+ fprintf(stream, "usage: %s [ -vC ] [ files... ]\n", program_name);
}
int main(int argc, char **argv)
@@ -1459,7 +1458,12 @@ int main(int argc, char **argv)
static char stderr_buf[BUFSIZ];
setbuf(stderr, stderr_buf);
int opt;
- while ((opt = getopt(argc, argv, "vCT:")) != EOF)
+ static const struct option long_options[] = {
+ { "help", no_argument, 0, CHAR_MAX + 1 },
+ { "version", no_argument, 0, 'v' },
+ { NULL, 0, 0, 0 }
+ };
+ while ((opt = getopt_long(argc, argv, "vCT:", long_options, NULL)) != EOF)
switch (opt) {
case 'C':
compatible_flag = 1;
@@ -1474,8 +1478,13 @@ int main(int argc, char **argv)
case 'T':
// I'm sick of getting bug reports from IRIX users
break;
+ case CHAR_MAX + 1: // --help
+ usage(stdout);
+ exit(0);
+ break;
case '?':
- usage();
+ usage(stderr);
+ exit(1);
break;
default:
assert(0);
diff --git a/src/roff/groff/groff.cc b/src/roff/groff/groff.cc
index ff0b9d67..0cdfb94b 100644
--- a/src/roff/groff/groff.cc
+++ b/src/roff/groff/groff.cc
@@ -96,7 +96,7 @@ void handle_unknown_desc_command(const char *command, const char *arg,
const char *filename, int lineno);
const char *xbasename(const char *);
-void usage();
+void usage(FILE *stream);
void help();
int main(int argc, char **argv)
@@ -117,8 +117,14 @@ int main(int argc, char **argv)
if (!command_prefix)
command_prefix = PROG_PREFIX;
commands[TROFF_INDEX].set_name(command_prefix, "troff");
- while ((opt = getopt(argc, argv,
- "abCd:eEf:F:gGhiI:lL:m:M:n:No:pP:r:RsStT:UvVw:W:XzZ"))
+ static const struct option long_options[] = {
+ { "help", no_argument, 0, 'h' },
+ { "version", no_argument, 0, 'v' },
+ { NULL, 0, 0, 0 }
+ };
+ while ((opt = getopt_long(argc, argv,
+ "abCd:eEf:F:gGhiI:lL:m:M:n:No:pP:r:RsStT:UvVw:W:XzZ",
+ long_options, NULL))
!= EOF) {
char buf[3];
buf[0] = '-';
@@ -171,7 +177,7 @@ int main(int argc, char **argv)
{
extern const char *Version_string;
printf("GNU groff version %s\n", Version_string);
- printf("Copyright (C) 2000 Free Software Foundation, Inc.\n"
+ printf("Copyright (C) 1989-2001 Free Software Foundation, Inc.\n"
"GNU groff comes with ABSOLUTELY NO WARRANTY.\n"
"You may redistribute copies of groff and its subprograms\n"
"under the terms of the GNU General Public License.\n"
@@ -256,7 +262,8 @@ int main(int argc, char **argv)
Xflag++;
break;
case '?':
- usage();
+ usage(stderr);
+ exit(1);
break;
default:
assert(0);
@@ -647,9 +654,9 @@ char **possible_command::get_argv()
return argv;
}
-void synopsis()
+void synopsis(FILE *stream)
{
- fprintf(stderr,
+ fprintf(stream,
"usage: %s [-abeghilpstvzCENRSUVXZ] [-Fdir] [-mname] [-Tdev] [-ffam]\n"
" [-wname] [-Wname] [-Mdir] [-dcs] [-rcn] [-nnum] [-olist] [-Parg]\n"
" [-Larg] [-Idir] [files...]\n",
@@ -658,7 +665,7 @@ void synopsis()
void help()
{
- synopsis();
+ synopsis(stdout);
fputs("\n"
"-h\tprint this message\n"
"-t\tpreprocess with tbl\n"
@@ -697,15 +704,14 @@ void help()
"-U\tenable unsafe mode\n"
"-Idir\tsearch dir for soelim. Implies -s\n"
"\n",
- stderr);
+ stdout);
exit(0);
}
-void usage()
+void usage(FILE *stream)
{
- synopsis();
- fprintf(stderr, "%s -h gives more help\n", program_name);
- exit(1);
+ synopsis(stream);
+ fprintf(stream, "%s -h gives more help\n", program_name);
}
extern "C" {
diff --git a/src/roff/grog/grog.pl b/src/roff/grog/grog.pl
index da31514b..57cd1594 100644
--- a/src/roff/grog/grog.pl
+++ b/src/roff/grog/grog.pl
@@ -13,7 +13,8 @@ push(@command, "groff");
while ($ARGV[0] =~ /^-./) {
$arg = shift(@ARGV);
$sp = "" if $arg eq "-C";
- &usage(0) if $arg eq "-v";
+ &usage(0) if $arg eq "-v" || $arg eq "--version";
+ &help() if $arg eq "--help";
last if $arg eq "--";
push(@command, $arg);
}
@@ -133,6 +134,11 @@ sub usage {
exit $exit_status;
}
+sub help {
+ print "usage: grog [ option ...] [files...]\n";
+ exit 0;
+}
+
if ($pic || $tbl || $eqn || $grn || $grap || $refer) {
$s = "-";
$s .= "s" if $soelim;
diff --git a/src/roff/grog/grog.sh b/src/roff/grog/grog.sh
index 01056df9..7919dbf5 100644
--- a/src/roff/grog/grog.sh
+++ b/src/roff/grog/grog.sh
@@ -16,9 +16,12 @@ do
break;;
-C)
sp=; opts="$opts -C"; shift; break;;
- -v)
+ -v | --version)
echo "GNU grog (groff) version @VERSION@"
exit 0;;
+ --help)
+ echo "usage: grog [ option ...] [files...]"
+ exit 0;;
-*)
opts="$opts $arg"; shift;;
*)
diff --git a/src/roff/nroff/nroff.sh b/src/roff/nroff/nroff.sh
index 4f15e464..0e9eebdd 100644
--- a/src/roff/nroff/nroff.sh
+++ b/src/roff/nroff/nroff.sh
@@ -66,9 +66,12 @@ for i
# Solaris 2.2 `man' uses -u0; ignore it,
# since `less' and `more' can use the emboldening info.
;;
- -v)
+ -v | --version)
echo "GNU nroff (groff) version @VERSION@"
exit 0 ;;
+ --help)
+ echo "usage: nroff [-h] [-i] [-mNAME] [-nNUM] [-oLIST] [-rCN] [-Tname] [FILE...]"
+ exit 0 ;;
--)
shift
break ;;
diff --git a/src/roff/troff/input.cc b/src/roff/troff/input.cc
index bcbdb2a1..472298d7 100644
--- a/src/roff/troff/input.cc
+++ b/src/roff/troff/input.cc
@@ -58,7 +58,6 @@ extern "C" {
#endif /* not isatty */
#endif /* not ISATTY_MISSING */
-#define USAGE_EXIT_CODE 1
#define MACRO_PREFIX "tmac."
#define MACRO_POSTFIX ".tmac"
#define INITIAL_STARTUP_FILE "troffrc"
@@ -6031,13 +6030,12 @@ static void add_string(const char *s, string_list **p)
*p = new string_list(s);
}
-void usage(const char *prog)
+void usage(FILE *stream, const char *prog)
{
- errprint(
-"usage: %1 -abivzCERU -wname -Wname -dcs -ffam -mname -nnum -olist\n"
+ fprintf(stream,
+"usage: %s -abivzCERU -wname -Wname -dcs -ffam -mname -nnum -olist\n"
" -rcn -Tname -Fdir -Mdir [files...]\n",
prog);
- exit(USAGE_EXIT_CODE);
}
int main(int argc, char **argv)
@@ -6068,7 +6066,13 @@ int main(int argc, char **argv)
if (putenv(strsave(e.contents())))
fatal("putenv failed");
}
- while ((c = getopt(argc, argv, "abivw:W:zCEf:m:n:o:r:d:F:M:T:tqs:RU"))
+ static const struct option long_options[] = {
+ { "help", no_argument, 0, CHAR_MAX + 1 },
+ { "version", no_argument, 0, 'v' },
+ { NULL, 0, 0, 0 }
+ };
+ while ((c = getopt_long(argc, argv, "abivw:W:zCEf:m:n:o:r:d:F:M:T:tqs:RU",
+ long_options, NULL))
!= EOF)
switch(c) {
case 'v':
@@ -6154,8 +6158,13 @@ int main(int argc, char **argv)
case 'U':
safer_flag = 0; // unsafe behaviour
break;
+ case CHAR_MAX + 1: // --help
+ usage(stdout,argv[0]);
+ exit(0);
+ break;
case '?':
- usage(argv[0]);
+ usage(stderr,argv[0]);
+ exit(1);
break; // never reached
default:
assert(0);
diff --git a/src/utils/addftinfo/addftinfo.cc b/src/utils/addftinfo/addftinfo.cc
index 73a05870..43a81bcb 100644
--- a/src/utils/addftinfo/addftinfo.cc
+++ b/src/utils/addftinfo/addftinfo.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -31,6 +31,7 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "cset.h"
#include "guess.h"
+static void usage(FILE *stream);
static void usage();
static void version();
static void convert_font(const font_params &, FILE *, FILE *);
@@ -67,8 +68,12 @@ int main(int argc, char **argv)
{
program_name = argv[0];
for (int i = 1; i < argc; i++) {
- if (!strcmp(argv[i], "-v"))
+ if (!strcmp(argv[i], "-v") || !strcmp(argv[i],"--version"))
version();
+ if (!strcmp(argv[i],"--help")) {
+ usage(stdout);
+ exit(0);
+ }
}
if (argc < 4)
usage();
@@ -123,11 +128,15 @@ int main(int argc, char **argv)
return 0;
}
-static void usage()
+static void usage(FILE *stream)
{
- fprintf(stderr, "usage: %s [-v] [-param value] ... "
+ fprintf(stream, "usage: %s [-v] [-param value] ... "
"resolution unitwidth font\n",
program_name);
+}
+static void usage()
+{
+ usage(stderr);
exit(1);
}
diff --git a/src/utils/hpftodit/hpftodit.cc b/src/utils/hpftodit/hpftodit.cc
index f2a7afee..f81f5ad8 100644
--- a/src/utils/hpftodit/hpftodit.cc
+++ b/src/utils/hpftodit/hpftodit.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1994, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1994, 2000, 2001 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -173,6 +173,7 @@ static int special_flag = 0;
static int italic_flag = 0;
static int italic_sep;
+static void usage(FILE *stream);
static void usage();
static const char *xbasename(const char *);
static void read_tags(File &);
@@ -206,7 +207,12 @@ int main(int argc, char **argv)
int opt;
int debug_flag = 0;
- while ((opt = getopt(argc, argv, "dsvi:")) != EOF) {
+ static const struct option long_options[] = {
+ { "help", no_argument, 0, CHAR_MAX + 1 },
+ { "version", no_argument, 0, 'v' },
+ { NULL, 0, 0, 0 }
+ };
+ while ((opt = getopt_long(argc, argv, "dsvi:", long_options, NULL)) != EOF) {
switch (opt) {
case 'd':
debug_flag = 1;
@@ -225,8 +231,13 @@ int main(int argc, char **argv)
exit(0);
}
break;
+ case CHAR_MAX + 1: // --help
+ usage(stdout);
+ exit(0);
+ break;
case '?':
usage();
+ break;
default:
assert(0);
}
@@ -264,10 +275,15 @@ int main(int argc, char **argv)
}
static
-void usage()
+void usage(FILE *stream)
{
- fprintf(stderr, "usage: %s [-s] [-i n] tfm_file map_file output_font\n",
+ fprintf(stream, "usage: %s [-s] [-i n] tfm_file map_file output_font\n",
program_name);
+}
+static
+void usage()
+{
+ usage(stderr);
exit(1);
}
diff --git a/src/utils/indxbib/indxbib.cc b/src/utils/indxbib/indxbib.cc
index 321a7c28..99a6baf4 100644
--- a/src/utils/indxbib/indxbib.cc
+++ b/src/utils/indxbib/indxbib.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -98,7 +98,7 @@ int truncate_len = 6;
int shortest_len = 3;
int max_keys_per_item = 100;
-static void usage();
+static void usage(FILE *stream);
static void write_hash_table();
static void init_hash_table();
static void read_common_words_file();
@@ -131,7 +131,14 @@ int main(int argc, char **argv)
const char *directory = 0;
const char *foption = 0;
int opt;
- while ((opt = getopt(argc, argv, "c:o:h:i:k:l:t:n:c:d:f:vw")) != EOF)
+ static const struct option long_options[] = {
+ { "help", no_argument, 0, CHAR_MAX + 1 },
+ { "version", no_argument, 0, 'v' },
+ { NULL, 0, 0, 0 }
+ };
+ while ((opt = getopt_long(argc, argv, "c:o:h:i:k:l:t:n:c:d:f:vw",
+ long_options, NULL))
+ != EOF)
switch (opt) {
case 'c':
common_words_file = optarg;
@@ -178,8 +185,13 @@ int main(int argc, char **argv)
exit(0);
break;
}
+ case CHAR_MAX + 1: // --help
+ usage(stdout);
+ exit(0);
+ break;
case '?':
- usage();
+ usage(stderr);
+ exit(1);
break;
default:
assert(0);
@@ -323,13 +335,12 @@ int main(int argc, char **argv)
return failed;
}
-static void usage()
+static void usage(FILE *stream)
{
- fprintf(stderr,
+ fprintf(stream,
"usage: %s [-vw] [-c file] [-d dir] [-f file] [-h n] [-i XYZ] [-k n]\n"
" [-l n] [-n n] [-o base] [-t n] [files...]\n",
program_name);
- exit(1);
}
static void check_integer_arg(char opt, const char *arg, int min, int *res)
diff --git a/src/utils/lkbib/lkbib.cc b/src/utils/lkbib/lkbib.cc
index bc9bd535..4d3cadcb 100644
--- a/src/utils/lkbib/lkbib.cc
+++ b/src/utils/lkbib/lkbib.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -32,11 +32,10 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
#include "refid.h"
#include "search.h"
-static void usage()
+static void usage(FILE *stream)
{
- fprintf(stderr, "usage: %s [-nv] [-p database] [-i XYZ] [-t N] keys ...\n",
+ fprintf(stream, "usage: %s [-nv] [-p database] [-i XYZ] [-t N] keys ...\n",
program_name);
- exit(1);
}
int main(int argc, char **argv)
@@ -47,7 +46,13 @@ int main(int argc, char **argv)
int search_default = 1;
search_list list;
int opt;
- while ((opt = getopt(argc, argv, "nvVi:t:p:")) != EOF)
+ static const struct option long_options[] = {
+ { "help", no_argument, 0, CHAR_MAX + 1 },
+ { "version", no_argument, 0, 'v' },
+ { NULL, 0, 0, 0 }
+ };
+ while ((opt = getopt_long(argc, argv, "nvVi:t:p:", long_options, NULL))
+ != EOF)
switch (opt) {
case 'V':
verify_flag = 1;
@@ -81,13 +86,21 @@ int main(int argc, char **argv)
case 'p':
list.add_file(optarg);
break;
+ case CHAR_MAX + 1: // --help
+ usage(stdout);
+ exit(0);
+ break;
case '?':
- usage();
+ usage(stderr);
+ exit(1);
+ break;
default:
assert(0);
}
- if (optind >= argc)
- usage();
+ if (optind >= argc) {
+ usage(stderr);
+ exit(1);
+ }
char *filename = getenv("REFER");
if (filename)
list.add_file(filename);
diff --git a/src/utils/lookbib/lookbib.cc b/src/utils/lookbib/lookbib.cc
index 96192aee..dc55ed93 100644
--- a/src/utils/lookbib/lookbib.cc
+++ b/src/utils/lookbib/lookbib.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -36,11 +36,10 @@ extern "C" {
int isatty(int);
}
-static void usage()
+static void usage(FILE *stream)
{
- fprintf(stderr, "usage: %s [-v] [-i XYZ] [-t N] database ...\n",
+ fprintf(stream, "usage: %s [-v] [-i XYZ] [-t N] database ...\n",
program_name);
- exit(1);
}
int main(int argc, char **argv)
@@ -49,7 +48,12 @@ int main(int argc, char **argv)
static char stderr_buf[BUFSIZ];
setbuf(stderr, stderr_buf);
int opt;
- while ((opt = getopt(argc, argv, "vVi:t:")) != EOF)
+ static const struct option long_options[] = {
+ { "help", no_argument, 0, CHAR_MAX + 1 },
+ { "version", no_argument, 0, 'v' },
+ { NULL, 0, 0, 0 }
+ };
+ while ((opt = getopt_long(argc, argv, "vVi:t:", long_options, NULL)) != EOF)
switch (opt) {
case 'V':
verify_flag = 1;
@@ -77,13 +81,21 @@ int main(int argc, char **argv)
exit(0);
break;
}
+ case CHAR_MAX + 1: // --help
+ usage(stdout);
+ exit(0);
+ break;
case '?':
- usage();
+ usage(stderr);
+ exit(1);
+ break;
default:
assert(0);
}
- if (optind >= argc)
- usage();
+ if (optind >= argc) {
+ usage(stderr);
+ exit(1);
+ }
search_list list;
for (int i = optind; i < argc; i++)
list.add_file(argv[i]);
diff --git a/src/utils/pfbtops/pfbtops.c b/src/utils/pfbtops/pfbtops.c
index bb2a85ab..2159dbd8 100644
--- a/src/utils/pfbtops/pfbtops.c
+++ b/src/utils/pfbtops/pfbtops.c
@@ -2,6 +2,7 @@
#include <stdio.h>
#include <getopt.h>
+#include <limits.h>
#include "nonposix.h"
@@ -18,10 +19,9 @@ static void error(s)
exit(2);
}
-static void usage()
+static void usage(FILE *stream)
{
- fprintf(stderr, "usage: %s [-v] [pfb_file]\n", program_name);
- exit(1);
+ fprintf(stream, "usage: %s [-v] [pfb_file]\n", program_name);
}
int main(argc, argv)
@@ -30,10 +30,15 @@ int main(argc, argv)
{
int opt;
extern int optind;
+ static const struct option long_options[] = {
+ { "help", no_argument, 0, CHAR_MAX + 1 },
+ { "version", no_argument, 0, 'v' },
+ { NULL, 0, 0, 0 }
+ };
program_name = argv[0];
- while ((opt = getopt(argc, argv, "v")) != EOF) {
+ while ((opt = getopt_long(argc, argv, "v", long_options, NULL)) != EOF) {
switch (opt) {
case 'v':
{
@@ -42,13 +47,21 @@ int main(argc, argv)
exit(0);
break;
}
+ case CHAR_MAX + 1: // --help
+ usage(stdout);
+ exit(0);
+ break;
case '?':
- usage();
+ usage(stderr);
+ exit(1);
+ break;
}
}
- if (argc - optind > 1)
- usage();
+ if (argc - optind > 1) {
+ usage(stderr);
+ exit(1);
+ }
if (argc > optind && !freopen(argv[optind], "r", stdin))
{
perror(argv[optind]);
diff --git a/src/utils/tfmtodit/tfmtodit.cc b/src/utils/tfmtodit/tfmtodit.cc
index d8f2a5fe..96768d2b 100644
--- a/src/utils/tfmtodit/tfmtodit.cc
+++ b/src/utils/tfmtodit/tfmtodit.cc
@@ -1,5 +1,5 @@
// -*- C++ -*-
-/* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc.
Written by James Clark (jjc@jclark.com)
This file is part of groff.
@@ -680,7 +680,7 @@ struct {
{ CH_ff, CH_l, CH_ffl, "ffl" },
};
-static void usage();
+static void usage(FILE *stream);
int main(int argc, char **argv)
{
@@ -689,7 +689,12 @@ int main(int argc, char **argv)
int skewchar = -1;
int opt;
const char *gf_file = 0;
- while ((opt = getopt(argc, argv, "svg:k:")) != EOF)
+ static const struct option long_options[] = {
+ { "help", no_argument, 0, CHAR_MAX + 1 },
+ { "version", no_argument, 0, 'v' },
+ { NULL, 0, 0, 0 }
+ };
+ while ((opt = getopt_long(argc, argv, "svg:k:", long_options, NULL)) != EOF)
switch (opt) {
case 'g':
gf_file = optarg;
@@ -717,14 +722,21 @@ int main(int argc, char **argv)
exit(0);
break;
}
+ case CHAR_MAX + 1: // --help
+ usage(stdout);
+ exit(0);
+ break;
case '?':
- usage();
+ usage(stderr);
+ exit(1);
break;
case EOF:
assert(0);
}
- if (argc - optind != 3)
- usage();
+ if (argc - optind != 3) {
+ usage(stderr);
+ exit(1);
+ }
gf g;
if (gf_file) {
if (!g.load(gf_file))
@@ -855,9 +867,8 @@ int main(int argc, char **argv)
return 0;
}
-static void usage()
+static void usage(FILE *stream)
{
- fprintf(stderr, "usage: %s [-sv] [-g gf_file] [-k skewchar] tfm_file map_file font\n",
+ fprintf(stream, "usage: %s [-sv] [-g gf_file] [-k skewchar] tfm_file map_file font\n",
program_name);
- exit(1);
}