summaryrefslogtreecommitdiff
path: root/src/utils
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/utils
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/utils')
-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
7 files changed, 132 insertions, 47 deletions
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);
}