groff
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Groff] recognize --help and --version


From: Bruno Haible
Subject: [Groff] recognize --help and --version
Date: Mon, 9 Apr 2001 15:34:24 +0200 (CEST)

Here is a patch which causes most groff programs to recognize the --help
and --version command line options. (Not because I want to be picky, but
because I hate programs which spit at me "invalid option -- -" when I
ask them for their version number.)

This patch does it for all groff programs, except afmtodit and mmroff
(which are not written in a regular programming language).

Bruno


2001-04-08  Bruno Haible  <address@hidden>

        * 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.

diff -r -c3 groff-current.orig/src/devices/grodvi/dvi.cc 
groff-current/src/devices/grodvi/dvi.cc
*** groff-current.orig/src/devices/grodvi/dvi.cc        Thu Nov 16 22:10:30 2000
--- groff-current/src/devices/grodvi/dvi.cc     Sun Apr  8 13:21:13 2001
***************
*** 1,5 ****
  // -*- C++ -*-
! /* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
--- 1,5 ----
  // -*- C++ -*-
! /* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
***************
*** 843,849 ****
      return new dvi_printer;
  }
  
! static void usage();
  
  int main(int argc, char **argv)
  {
--- 843,849 ----
      return new dvi_printer;
  }
  
! static void usage(FILE *stream);
  
  int main(int argc, char **argv)
  {
***************
*** 851,857 ****
    static char stderr_buf[BUFSIZ];
    setbuf(stderr, stderr_buf);
    int c;
!   while ((c = getopt(argc, argv, "F:vw:d")) != EOF)
      switch(c) {
      case 'v':
        {
--- 851,862 ----
    static char stderr_buf[BUFSIZ];
    setbuf(stderr, stderr_buf);
    int c;
!   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':
        {
***************
*** 873,880 ****
      case 'F':
        font::command_line_font_dir(optarg);
        break;
      case '?':
!       usage();
        break;
      default:
        assert(0);
--- 878,890 ----
      case 'F':
        font::command_line_font_dir(optarg);
        break;
+     case CHAR_MAX + 1: // --help
+       usage(stdout);
+       exit(0);
+       break;
      case '?':
!       usage(stderr);
!       exit(1);
        break;
      default:
        assert(0);
***************
*** 892,900 ****
    return 0;
  }
  
! static void usage()
  {
!   fprintf(stderr, "usage: %s [-dv] [-F dir] [-w n] [files ...]\n",
          program_name);
-   exit(1);
  }
--- 902,909 ----
    return 0;
  }
  
! static void usage(FILE *stream)
  {
!   fprintf(stream, "usage: %s [-dv] [-F dir] [-w n] [files ...]\n",
          program_name);
  }
diff -r -c3 groff-current.orig/src/devices/grohtml/post-html.cc 
groff-current/src/devices/grohtml/post-html.cc
*** groff-current.orig/src/devices/grohtml/post-html.cc Mon Mar 19 16:33:03 2001
--- groff-current/src/devices/grohtml/post-html.cc      Sun Apr  8 13:14:15 2001
***************
*** 1058,1064 ****
    return new html_printer;
  }
  
! static void usage();
  
  void html_printer::set_style(const style &sty)
  {
--- 1058,1064 ----
    return new html_printer;
  }
  
! static void usage(FILE *stream);
  
  void html_printer::set_style(const style &sty)
  {
***************
*** 2783,2795 ****
    static char stderr_buf[BUFSIZ];
    setbuf(stderr, stderr_buf);
    int c;
!   while ((c = getopt(argc, argv, "o:i:F:vd?lrn")) != EOF)
      switch(c) {
      case 'v':
        {
        extern const char *Version_string;
!       fprintf(stderr, "post-grohtml version %s\n", Version_string);
!       fflush(stderr);
        break;
        }
      case 'F':
--- 2783,2801 ----
    static char stderr_buf[BUFSIZ];
    setbuf(stderr, stderr_buf);
    int c;
!   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;
!       printf("GNU post-grohtml (groff) version %s\n", Version_string);
!       exit(0);
        break;
        }
      case 'F':
***************
*** 2801,2809 ****
      case 'r':
        auto_rule = FALSE;
        break;
-     case '?':
-       usage();
-       break;
      case 'o':
        /* handled by pre-html */
        break;
--- 2807,2812 ----
***************
*** 2813,2818 ****
--- 2816,2829 ----
      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);
      }
***************
*** 2826,2834 ****
    return 0;
  }
  
! static void usage()
  {
!   fprintf(stderr, "usage: %s [-vld?n] [-F dir] [files ...]\n",
          program_name);
-   exit(1);
  }
--- 2837,2844 ----
    return 0;
  }
  
! static void usage(FILE *stream)
  {
!   fprintf(stream, "usage: %s [-vld?n] [-F dir] [files ...]\n",
          program_name);
  }
diff -r -c3 groff-current.orig/src/devices/grohtml-old/html.cc 
groff-current/src/devices/grohtml-old/html.cc
*** groff-current.orig/src/devices/grohtml-old/html.cc  Wed Jan 17 15:56:13 2001
--- groff-current/src/devices/grohtml-old/html.cc       Sun Apr  8 13:21:24 2001
***************
*** 1,5 ****
  // -*- C++ -*-
! /* Copyright (C) 1999 Free Software Foundation, Inc.
   *
   *  Gaius Mulley (address@hidden) wrote grohtml
   *  but it owes a huge amount of ideas and raw code from
--- 1,5 ----
  // -*- C++ -*-
! /* Copyright (C) 1999, 2001 Free Software Foundation, Inc.
   *
   *  Gaius Mulley (address@hidden) wrote grohtml
   *  but it owes a huge amount of ideas and raw code from
***************
*** 6531,6537 ****
    return new html_printer;
  }
  
! static void usage();
  
  int main(int argc, char **argv)
  {
--- 6531,6537 ----
    return new html_printer;
  }
  
! static void usage(FILE *stream);
  
  int main(int argc, char **argv)
  {
***************
*** 6539,6545 ****
    static char stderr_buf[BUFSIZ];
    setbuf(stderr, stderr_buf);
    int c;
!   while ((c = getopt(argc, argv, "F:atTvdgmx?I:r:")) != EOF)
      switch(c) {
      case 'v':
        {
--- 6539,6551 ----
    static char stderr_buf[BUFSIZ];
    setbuf(stderr, stderr_buf);
    int c;
!   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':
        {
***************
*** 6583,6590 ****
        // leave margins alone
        margin_on = TRUE;
        break;
      case '?':
!       usage();
        break;
      default:
        assert(0);
--- 6589,6601 ----
        // leave margins alone
        margin_on = TRUE;
        break;
+     case CHAR_MAX + 1: // --help
+       usage(stdout);
+       exit(0);
+       break;
      case '?':
!       usage(stderr);
!       exit(1);
        break;
      default:
        assert(0);
***************
*** 6599,6607 ****
    return 0;
  }
  
! static void usage()
  {
!   fprintf(stderr, "usage: %s [-avdgmt?] [-r resolution] [-F dir] [-I 
imagetype] [files ...]\n",
          program_name);
-   exit(1);
  }
--- 6610,6617 ----
    return 0;
  }
  
! static void usage(FILE *stream)
  {
!   fprintf(stream, "usage: %s [-avdgmt?] [-r resolution] [-F dir] [-I 
imagetype] [files ...]\n",
          program_name);
  }
diff -r -c3 groff-current.orig/src/devices/grolbp/lbp.cc 
groff-current/src/devices/grolbp/lbp.cc
*** groff-current.orig/src/devices/grolbp/lbp.cc        Thu Nov 16 22:10:35 2000
--- groff-current/src/devices/grolbp/lbp.cc     Sun Apr  8 13:21:33 2001
***************
*** 1,5 ****
  // -*- C++ -*-
! /* Copyright (C) 1994, 2000 Free Software Foundation, Inc.
       Written by Francisco Andrés Verdú <address@hidden> with many ideas
       taken from the other groff drivers.
  
--- 1,5 ----
  // -*- C++ -*-
! /* Copyright (C) 1994, 2000, 2001 Free Software Foundation, Inc.
       Written by Francisco Andrés Verdú <address@hidden> with many ideas
       taken from the other groff drivers.
  
***************
*** 663,681 ****
  };
  
  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}
   };
  
! static void usage()
  {
!   fprintf(stderr,
          "usage: %s [-lvh] [-c n] [-p paper_size] [-F dir] [-o or] "\
          " [files ...]\n"\
          "          -o --orientation=[portrait|landscape]\n"\
--- 663,681 ----
  };
  
  static struct option long_options[] = {
!   { "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(FILE *stream)
  {
!   fprintf(stream,
          "usage: %s [-lvh] [-c n] [-p paper_size] [-F dir] [-o or] "\
          " [files ...]\n"\
          "          -o --orientation=[portrait|landscape]\n"\
***************
*** 686,692 ****
          "       -F --fontdir=dir\n"\
          "       -h --help\n",
          program_name);
-   exit(1);
  }; // usage
  
  int main(int argc, char **argv)
--- 686,691 ----
***************
*** 717,724 ****
                                break;
                  case 'v'  :   {
                                extern const char *Version_string;
!                               printf("GNU grolbp (groff) version %s\n",\
!                               Version_string);
                                exit(0);
                                break;
                                        };
--- 716,723 ----
                                break;
                  case 'v'  :   {
                                extern const char *Version_string;
!                               printf("GNU grolbp (groff) version %s\n",
!                                      Version_string);
                                exit(0);
                                break;
                                        };
***************
*** 744,752 ****
                                        ncopies = unsigned(n);
                                break;
                                      }
!                 case 'h'  : usage();
                                      break;
!                               
                                
                }; // switch (c)
        }; // while (c > 0 )
--- 743,754 ----
                                        ncopies = unsigned(n);
                                break;
                                      }
!                 case 'h'  : usage(stdout);
!                             exit(0);
                                      break;
!                 case '?'  : usage(stderr);
!                             exit(1);
!                             break;
                                
                }; // switch (c)
        }; // while (c > 0 )
diff -r -c3 groff-current.orig/src/devices/grolj4/lj4.cc 
groff-current/src/devices/grolj4/lj4.cc
*** groff-current.orig/src/devices/grolj4/lj4.cc        Thu Nov 16 22:10:35 2000
--- groff-current/src/devices/grolj4/lj4.cc     Sun Apr  8 13:21:39 2001
***************
*** 1,5 ****
  // -*- C++ -*-
! /* Copyright (C) 1994, 2000 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
--- 1,5 ----
  // -*- C++ -*-
! /* Copyright (C) 1994, 2000, 2001 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
***************
*** 595,601 ****
    }
  }
  
! static void usage();
  
  extern "C" int optopt, optind;
  
--- 595,601 ----
    }
  }
  
! static void usage(FILE *stream);
  
  extern "C" int optopt, optind;
  
***************
*** 606,612 ****
    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)
      switch(c) {
      case 'l':
        landscape_flag = 1;
--- 606,618 ----
    setbuf(stderr, stderr_buf);
    font::set_unknown_desc_command_handler(handle_unknown_desc_command);
    int c;
!   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,678 ****
          line_width_factor = int(n);
        break;
        }
      case '?':
!       usage();
        break;
      default:
        assert(0);
--- 677,689 ----
          line_width_factor = int(n);
        break;
        }
+     case CHAR_MAX + 1: // --help
+       usage(stdout);
+       exit(0);
+       break;
      case '?':
!       usage(stderr);
!       exit(1);
        break;
      default:
        assert(0);
***************
*** 690,700 ****
    return 0;
  }
  
! static void usage()
  {
!   fprintf(stderr,
          "usage: %s [-lv] [-d [n]] [-c n] [-p paper_size]\n"
          "       [-w n] [-F dir] [files ...]\n",
          program_name);
-   exit(1);
  }
--- 701,710 ----
    return 0;
  }
  
! static void usage(FILE *stream)
  {
!   fprintf(stream,
          "usage: %s [-lv] [-d [n]] [-c n] [-p paper_size]\n"
          "       [-w n] [-F dir] [files ...]\n",
          program_name);
  }
diff -r -c3 groff-current.orig/src/devices/grops/ps.cc 
groff-current/src/devices/grops/ps.cc
*** groff-current.orig/src/devices/grops/ps.cc  Thu Nov 16 22:10:36 2000
--- groff-current/src/devices/grops/ps.cc       Sun Apr  8 13:21:54 2001
***************
*** 1,5 ****
  // -*- C++ -*-
! /* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
--- 1,5 ----
  // -*- C++ -*-
! /* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
***************
*** 1473,1479 ****
    return new ps_printer;
  }
  
! static void usage();
  
  int main(int argc, char **argv)
  {
--- 1473,1479 ----
    return new ps_printer;
  }
  
! static void usage(FILE *stream);
  
  int main(int argc, char **argv)
  {
***************
*** 1482,1488 ****
    static char stderr_buf[BUFSIZ];
    setbuf(stderr, stderr_buf);
    int c;
!   while ((c = getopt(argc, argv, "F:P:glmc:w:vb:")) != EOF)
      switch(c) {
      case 'v':
        {
--- 1482,1494 ----
    static char stderr_buf[BUFSIZ];
    setbuf(stderr, stderr_buf);
    int c;
!   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':
        {
***************
*** 1528,1535 ****
        broken_flags = atoi(optarg);
        bflag = 1;
        break;
      case '?':
!       usage();
        break;
      default:
        assert(0);
--- 1534,1546 ----
        broken_flags = atoi(optarg);
        bflag = 1;
        break;
+     case CHAR_MAX + 1: // --help
+       usage(stdout);
+       exit(0);
+       break;
      case '?':
!       usage(stderr);
!       exit(1);
        break;
      default:
        assert(0);
***************
*** 1548,1558 ****
    return 0;
  }
  
! static void usage()
  {
!   fprintf(
!     stderr,
      "usage: %s [-glmv] [-b n] [-c n] [-w n] [-P prologue] [-F dir] [files 
...]\n",
      program_name);
-   exit(1);
  }
--- 1559,1567 ----
    return 0;
  }
  
! static void usage(FILE *stream)
  {
!   fprintf(stream,
      "usage: %s [-glmv] [-b n] [-c n] [-w n] [-P prologue] [-F dir] [files 
...]\n",
      program_name);
  }
diff -r -c3 groff-current.orig/src/devices/grotty/tty.cc 
groff-current/src/devices/grotty/tty.cc
*** groff-current.orig/src/devices/grotty/tty.cc        Thu Mar 29 14:54:37 2001
--- groff-current/src/devices/grotty/tty.cc     Sun Apr  8 13:22:02 2001
***************
*** 1,5 ****
  // -*- C++ -*-
! /* Copyright (C) 1989-2000 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
--- 1,5 ----
  // -*- C++ -*-
! /* Copyright (C) 1989-2001 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
***************
*** 400,406 ****
    return new tty_printer(device);
  }
  
! static void usage();
  
  int main(int argc, char **argv)
  {
--- 400,406 ----
    return new tty_printer(device);
  }
  
! static void usage(FILE *stream);
  
  int main(int argc, char **argv)
  {
***************
*** 408,414 ****
    static char stderr_buf[BUFSIZ];
    setbuf(stderr, stderr_buf);
    int c;
!   while ((c = getopt(argc, argv, "F:vhfbuoBUd")) != EOF)
      switch(c) {
      case 'v':
        {
--- 408,420 ----
    static char stderr_buf[BUFSIZ];
    setbuf(stderr, stderr_buf);
    int c;
!   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':
        {
***************
*** 451,458 ****
        // Ignore \D commands.
        draw_flag = 0;
        break;
      case '?':
!       usage();
        break;
      default:
        assert(0);
--- 457,469 ----
        // Ignore \D commands.
        draw_flag = 0;
        break;
+     case CHAR_MAX + 1: // --help
+       usage(stdout);
+       exit(0);
+       break;
      case '?':
!       usage(stderr);
!       exit(1);
        break;
      default:
        assert(0);
***************
*** 467,475 ****
    return 0;
  }
  
! static void usage()
  {
!   fprintf(stderr, "usage: %s [-hfvbuodBU] [-F dir] [files ...]\n",
          program_name);
-   exit(1);
  }
--- 478,485 ----
    return 0;
  }
  
! static void usage(FILE *stream)
  {
!   fprintf(stream, "usage: %s [-hfvbuodBU] [-F dir] [files ...]\n",
          program_name);
  }
diff -r -c3 groff-current.orig/src/preproc/eqn/main.cc 
groff-current/src/preproc/eqn/main.cc
*** groff-current.orig/src/preproc/eqn/main.cc  Tue Jan 23 23:00:09 2001
--- groff-current/src/preproc/eqn/main.cc       Sun Apr  8 13:15:03 2001
***************
*** 234,245 ****
    return 0;
  }
  
! void usage()
  {
!   fprintf(stderr,
          "usage: %s [ -rvDCNR ] -dxx -fn -sn -pn -mn -Mdir -Ts [ files ... 
]\n",
        program_name);
-   exit(1);
  }
  
  int main(int argc, char **argv)
--- 234,244 ----
    return 0;
  }
  
! void usage(FILE *stream)
  {
!   fprintf(stream,
          "usage: %s [ -rvDCNR ] -dxx -fn -sn -pn -mn -Mdir -Ts [ files ... 
]\n",
        program_name);
  }
  
  int main(int argc, char **argv)
***************
*** 249,255 ****
    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)
      switch (opt) {
      case 'C':
        compatible_flag = 1;
--- 248,261 ----
    setbuf(stderr, stderr_buf);
    int opt;
    int load_startup_file = 1;
!   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,324 ****
      case 'N':
        no_newline_in_delim_flag = 1;
        break;
      case '?':
!       usage();
        break;
      default:
        assert(0);
--- 323,335 ----
      case 'N':
        no_newline_in_delim_flag = 1;
        break;
+     case CHAR_MAX + 1: // --help
+       usage(stdout);
+       exit(0);
+       break;
      case '?':
!       usage(stderr);
!       exit(1);
        break;
      default:
        assert(0);
diff -r -c3 groff-current.orig/src/preproc/grn/main.cc 
groff-current/src/preproc/grn/main.cc
*** groff-current.orig/src/preproc/grn/main.cc  Thu Nov 16 22:10:38 2000
--- groff-current/src/preproc/grn/main.cc       Sun Apr  8 04:05:48 2001
***************
*** 220,231 ****
  
  
  void
! usage()
  {
!   fprintf(stderr,
          "usage: %s [ -vCs ] [ -M dir ] [ -F dir ] [ -T dev ] [ file ]\n",
          program_name);
-   exit(1);
  }
  
  
--- 220,230 ----
  
  
  void
! usage(FILE *stream)
  {
!   fprintf(stream,
          "usage: %s [ -vCs ] [ -M dir ] [ -F dir ] [ -T dev ] [ file ]\n",
          program_name);
  }
  
  
***************
*** 260,273 ****
        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;
--- 259,264 ----
***************
*** 288,300 ****
        sflag = 1;
        break;
  
        case '?':
!       usage();
!       break;
! 
        default:
        error("unknown switch: %1", c);
!       usage();
        }
    }
  
--- 279,303 ----
        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(stdout);
!         exit(0);
!         break;
!       }
!       // fallthrough
        default:
        error("unknown switch: %1", c);
!       usage(stderr);
!       exit(1);
        }
    }
  
diff -r -c3 groff-current.orig/src/preproc/html/pre-html.cc 
groff-current/src/preproc/html/pre-html.cc
*** groff-current.orig/src/preproc/html/pre-html.cc     Sun Mar  4 23:22:56 2001
--- groff-current/src/preproc/html/pre-html.cc  Sun Apr  8 02:55:16 2001
***************
*** 985,998 ****
  
  
  /*
!  *  usage - emit usage arguments and exit.
   */
  
! void usage()
  {
!   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);
  }
  
  /*
--- 985,998 ----
  
  
  /*
!  *  usage - emit usage arguments.
   */
  
! void usage(FILE *stream)
  {
!   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,1019 ****
        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) {
        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();
        exit(0);
      } else if (strcmp(argv[i], "troff") == 0) {
        /* remember troff argument number */
--- 1008,1022 ----
        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)
!              || (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], "--help") == 0)
!              || (strcmp(argv[i], "-?") == 0)) {
!       usage(stdout);
        exit(0);
      } else if (strcmp(argv[i], "troff") == 0) {
        /* remember troff argument number */
diff -r -c3 groff-current.orig/src/preproc/pic/main.cc 
groff-current/src/preproc/pic/main.cc
*** groff-current.orig/src/preproc/pic/main.cc  Thu Nov 16 22:10:40 2000
--- groff-current/src/preproc/pic/main.cc       Sun Apr  8 13:22:24 2001
***************
*** 1,5 ****
  // -*- C++ -*-
! /* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
--- 1,5 ----
  // -*- C++ -*-
! /* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
***************
*** 464,479 ****
  }
  #endif
  
! void usage()
  {
!   fprintf(stderr, "usage: %s [ -nvC ] [ filename ... ]\n", program_name);
  #ifdef TEX_SUPPORT
!   fprintf(stderr, "       %s -t [ -cvzC ] [ filename ... ]\n", program_name);
  #endif
  #ifdef FIG_SUPPORT
!   fprintf(stderr, "       %s -f [ -v ] [ filename ]\n", program_name);
  #endif
-   exit(1);
  }
  
  #ifdef __MSDOS__
--- 464,478 ----
  }
  #endif
  
! void usage(FILE *stream)
  {
!   fprintf(stream, "usage: %s [ -nvC ] [ filename ... ]\n", program_name);
  #ifdef TEX_SUPPORT
!   fprintf(stream, "       %s -t [ -cvzC ] [ filename ... ]\n", program_name);
  #endif
  #ifdef FIG_SUPPORT
!   fprintf(stream, "       %s -f [ -v ] [ filename ]\n", program_name);
  #endif
  }
  
  #ifdef __MSDOS__
***************
*** 518,524 ****
    int whole_file_flag = 0;
    int fig_flag = 0;
  #endif
!   while ((opt = getopt(argc, argv, "T:CDSUtcvnxzpf")) != EOF)
      switch (opt) {
      case 'C':
        compatible_flag = 1;
--- 517,529 ----
    int whole_file_flag = 0;
    int fig_flag = 0;
  #endif
!   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,579 ****
        // zero length lines will be printed as dots
        zero_length_line_flag++;
        break;
      case '?':
!       usage();
        break;
      default:
        assert(0);
--- 577,589 ----
        // 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(stderr);
!       exit(1);
        break;
      default:
        assert(0);
***************
*** 601,609 ****
    if (whole_file_flag) {
      if (optind >= argc)
        do_whole_file("-");
!     else if (argc - optind > 1)
!       usage();
!     else
        do_whole_file(argv[optind]);
    }
    else {
--- 611,620 ----
    if (whole_file_flag) {
      if (optind >= argc)
        do_whole_file("-");
!     else if (argc - optind > 1) {
!       usage(stderr);
!       exit(1);
!     } else
        do_whole_file(argv[optind]);
    }
    else {
diff -r -c3 groff-current.orig/src/preproc/refer/refer.cc 
groff-current/src/preproc/refer/refer.cc
*** groff-current.orig/src/preproc/refer/refer.cc       Thu Nov 16 22:10:40 2000
--- groff-current/src/preproc/refer/refer.cc    Sun Apr  8 13:20:30 2001
***************
*** 1,5 ****
  // -*- C++ -*-
! /* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
--- 1,5 ----
  // -*- C++ -*-
! /* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
***************
*** 99,105 ****
  static unsigned store_reference(const string &);
  static void divert_to_temporary_file();
  static reference *make_reference(const string &, unsigned *);
! static void usage();
  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);
--- 99,105 ----
  static unsigned store_reference(const string &);
  static void divert_to_temporary_file();
  static reference *make_reference(const string &, unsigned *);
! 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,178 ****
            }
            else {
              error("option `f' requires an argument");
!             usage();
            }
          }
          else {
--- 172,179 ----
            }
            else {
              error("option `f' requires an argument");
!             usage(stderr);
!             exit(1);
            }
          }
          else {
***************
*** 300,306 ****
            }
            else {
              error("option `p' requires an argument");
!             usage();
            }
          }
          else {
--- 301,308 ----
            }
            else {
              error("option `p' requires an argument");
!             usage(stderr);
!             exit(1);
            }
          }
          else {
***************
*** 334,356 ****
          opt = ptr;
          break;
        }
        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++;
          break;
        }
        // fall through
        default:
        error("unrecognized option `%1'", *opt);
!       usage();
        break;
        }
      }
--- 336,364 ----
          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;
        }
!       if (strcmp(opt,"-help")==0) {
!         usage(stdout);
!         exit(0);
          break;
        }
        // fall through
        default:
        error("unrecognized option `%1'", *opt);
!       usage(stderr);
!       exit(1);
        break;
        }
      }
***************
*** 378,390 ****
    return 0;
  }
  
! static void usage()
  {
!   fprintf(stderr,
  "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()
--- 386,397 ----
    return 0;
  }
  
! static void usage(FILE *stream)
  {
!   fprintf(stream,
  "usage: %s [-benvCPRS] [-aN] [-cXYZ] [-fN] [-iXYZ] [-kX] [-lM,N] [-p file]\n"
  "       [-sXYZ] [-tN] [-BL.M] [files ...]\n",
          program_name);
  }
  
  static void possibly_load_default_database()
diff -r -c3 groff-current.orig/src/preproc/soelim/soelim.cc 
groff-current/src/preproc/soelim/soelim.cc
*** groff-current.orig/src/preproc/soelim/soelim.cc     Thu Nov 16 22:10:41 2000
--- groff-current/src/preproc/soelim/soelim.cc  Sun Apr  8 13:22:36 2001
***************
*** 1,5 ****
  // -*- C++ -*-
! /* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
--- 1,5 ----
  // -*- C++ -*-
! /* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
***************
*** 58,67 ****
  }
  
  
! void usage()
  {
!   fprintf(stderr, "usage: %s [ -vC ] [ -I file ] [ files ]\n", program_name);
!   exit(1);
  }
  
  int main(int argc, char **argv)
--- 58,66 ----
  }
  
  
! void usage(FILE *stream)
  {
!   fprintf(stream, "usage: %s [ -vC ] [ -I file ] [ files ]\n", program_name);
  }
  
  int main(int argc, char **argv)
***************
*** 69,75 ****
    program_name = argv[0];
    include_path_append(".");
    int opt;
!   while ((opt = getopt(argc, argv, "CI:v")) != EOF)
      switch (opt) {
      case 'v':
        {
--- 68,79 ----
    program_name = argv[0];
    include_path_append(".");
    int opt;
!   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,91 ****
      case 'I':
        include_path_append(optarg);
        break;
      case '?':
!       usage();
        break;
      default:
        assert(0);
--- 88,100 ----
      case 'I':
        include_path_append(optarg);
        break;
+     case CHAR_MAX + 1: // --help
+       usage(stdout);
+       exit(0);
+       break;
      case '?':
!       usage(stderr);
!       exit(1);
        break;
      default:
        assert(0);
diff -r -c3 groff-current.orig/src/preproc/tbl/main.cc 
groff-current/src/preproc/tbl/main.cc
*** groff-current.orig/src/preproc/tbl/main.cc  Wed Jan 17 15:17:25 2001
--- groff-current/src/preproc/tbl/main.cc       Sun Apr  8 13:15:21 2001
***************
*** 1447,1456 ****
      error("premature end of file");
  }
  
! static void usage()
  {
!   fprintf(stderr, "usage: %s [ -vC ] [ files... ]\n", program_name);
!   exit(1);
  }
  
  int main(int argc, char **argv)
--- 1447,1455 ----
      error("premature end of file");
  }
  
! static void usage(FILE *stream)
  {
!   fprintf(stream, "usage: %s [ -vC ] [ files... ]\n", program_name);
  }
  
  int main(int argc, char **argv)
***************
*** 1459,1465 ****
    static char stderr_buf[BUFSIZ];
    setbuf(stderr, stderr_buf);
    int opt;
!   while ((opt = getopt(argc, argv, "vCT:")) != EOF)
      switch (opt) {
      case 'C':
        compatible_flag = 1;
--- 1458,1469 ----
    static char stderr_buf[BUFSIZ];
    setbuf(stderr, stderr_buf);
    int opt;
!   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,1481 ****
      case 'T':
        // I'm sick of getting bug reports from IRIX users
        break;
      case '?':
!       usage();
        break;
      default:
        assert(0);
--- 1478,1490 ----
      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(stderr);
!       exit(1);
        break;
      default:
        assert(0);
diff -r -c3 groff-current.orig/src/roff/groff/groff.cc 
groff-current/src/roff/groff/groff.cc
*** groff-current.orig/src/roff/groff/groff.cc  Wed Jan 17 15:17:25 2001
--- groff-current/src/roff/groff/groff.cc       Sun Apr  8 13:15:26 2001
***************
*** 96,102 ****
                                 const char *filename, int lineno);
  const char *xbasename(const char *);
  
! void usage();
  void help();
  
  int main(int argc, char **argv)
--- 96,102 ----
                                 const char *filename, int lineno);
  const char *xbasename(const char *);
  
! void usage(FILE *stream);
  void help();
  
  int main(int argc, char **argv)
***************
*** 117,124 ****
    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"))
         != EOF) {
      char buf[3];
      buf[0] = '-';
--- 117,130 ----
    if (!command_prefix)
      command_prefix = PROG_PREFIX;
    commands[TROFF_INDEX].set_name(command_prefix, "troff");
!   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,177 ****
        {
        extern const char *Version_string;
        printf("GNU groff version %s\n", Version_string);
!       printf("Copyright (C) 2000 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"
--- 177,183 ----
        {
        extern const char *Version_string;
        printf("GNU groff version %s\n", Version_string);
!       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,262 ****
        Xflag++;
        break;
      case '?':
!       usage();
        break;
      default:
        assert(0);
--- 262,269 ----
        Xflag++;
        break;
      case '?':
!       usage(stderr);
!       exit(1);
        break;
      default:
        assert(0);
***************
*** 647,655 ****
    return argv;
  }
  
! void synopsis()
  {
!   fprintf(stderr,
  "usage: %s [-abeghilpstvzCENRSUVXZ] [-Fdir] [-mname] [-Tdev] [-ffam]\n"
  "       [-wname] [-Wname] [-Mdir] [-dcs] [-rcn] [-nnum] [-olist] [-Parg]\n"
  "       [-Larg] [-Idir] [files...]\n",
--- 654,662 ----
    return argv;
  }
  
! void synopsis(FILE *stream)
  {
!   fprintf(stream,
  "usage: %s [-abeghilpstvzCENRSUVXZ] [-Fdir] [-mname] [-Tdev] [-ffam]\n"
  "       [-wname] [-Wname] [-Mdir] [-dcs] [-rcn] [-nnum] [-olist] [-Parg]\n"
  "       [-Larg] [-Idir] [files...]\n",
***************
*** 658,664 ****
  
  void help()
  {
!   synopsis();
    fputs("\n"
  "-h\tprint this message\n"
  "-t\tpreprocess with tbl\n"
--- 665,671 ----
  
  void help()
  {
!   synopsis(stdout);
    fputs("\n"
  "-h\tprint this message\n"
  "-t\tpreprocess with tbl\n"
***************
*** 697,711 ****
  "-U\tenable unsafe mode\n"
  "-Idir\tsearch dir for soelim.  Implies -s\n"
  "\n",
!       stderr);
    exit(0);
  }
  
! void usage()
  {
!   synopsis();
!   fprintf(stderr, "%s -h gives more help\n", program_name);
!   exit(1);
  }
  
  extern "C" {
--- 704,717 ----
  "-U\tenable unsafe mode\n"
  "-Idir\tsearch dir for soelim.  Implies -s\n"
  "\n",
!       stdout);
    exit(0);
  }
  
! void usage(FILE *stream)
  {
!   synopsis(stream);
!   fprintf(stream, "%s -h gives more help\n", program_name);
  }
  
  extern "C" {
diff -r -c3 groff-current.orig/src/roff/grog/grog.pl 
groff-current/src/roff/grog/grog.pl
*** groff-current.orig/src/roff/grog/grog.pl    Thu Nov 16 22:10:43 2000
--- groff-current/src/roff/grog/grog.pl Sun Apr  8 03:58:11 2001
***************
*** 13,19 ****
  while ($ARGV[0] =~ /^-./) {
      $arg = shift(@ARGV);
      $sp = "" if $arg eq "-C";
!     &usage(0) if $arg eq "-v";
      last if $arg eq "--";
      push(@command, $arg);
  }
--- 13,20 ----
  while ($ARGV[0] =~ /^-./) {
      $arg = shift(@ARGV);
      $sp = "" if $arg eq "-C";
!     &usage(0) if $arg eq "-v" || $arg eq "--version";
!     &help() if $arg eq "--help";
      last if $arg eq "--";
      push(@command, $arg);
  }
***************
*** 133,138 ****
--- 134,144 ----
      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 -r -c3 groff-current.orig/src/roff/grog/grog.sh 
groff-current/src/roff/grog/grog.sh
*** groff-current.orig/src/roff/grog/grog.sh    Thu Nov 16 22:10:43 2000
--- groff-current/src/roff/grog/grog.sh Sun Apr  8 03:23:08 2001
***************
*** 16,24 ****
                break;;
        -C)
                sp=; opts="$opts -C"; shift; break;;
!       -v)
                echo "GNU grog (groff) version @VERSION@"
                exit 0;;
        -*)
                opts="$opts $arg"; shift;;
        *)
--- 16,27 ----
                break;;
        -C)
                sp=; opts="$opts -C"; shift; break;;
!       -v | --version)
                echo "GNU grog (groff) version @VERSION@"
                exit 0;;
+       --help)
+               echo "usage: grog [ option ...] [files...]"
+               exit 0;;
        -*)
                opts="$opts $arg"; shift;;
        *)
diff -r -c3 groff-current.orig/src/roff/nroff/nroff.sh 
groff-current/src/roff/nroff/nroff.sh
*** groff-current.orig/src/roff/nroff/nroff.sh  Thu Nov 16 22:10:44 2000
--- groff-current/src/roff/nroff/nroff.sh       Sun Apr  8 03:50:12 2001
***************
*** 66,74 ****
        # Solaris 2.2 `man' uses -u0; ignore it,
        # since `less' and `more' can use the emboldening info.
        ;;
!     -v)
        echo "GNU nroff (groff) version @VERSION@"
        exit 0 ;;
      --)
        shift
        break ;;
--- 66,77 ----
        # Solaris 2.2 `man' uses -u0; ignore it,
        # since `less' and `more' can use the emboldening info.
        ;;
!     -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 -r -c3 groff-current.orig/src/roff/troff/input.cc 
groff-current/src/roff/troff/input.cc
*** groff-current.orig/src/roff/troff/input.cc  Fri Mar  9 01:18:21 2001
--- groff-current/src/roff/troff/input.cc       Sun Apr  8 13:15:31 2001
***************
*** 58,64 ****
  #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"
--- 58,63 ----
***************
*** 6031,6043 ****
    *p = new string_list(s);
  }
  
! void usage(const char *prog)
  {
!   errprint(
! "usage: %1 -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)
--- 6030,6041 ----
    *p = new string_list(s);
  }
  
! void usage(FILE *stream, const char *prog)
  {
!   fprintf(stream,
! "usage: %s -abivzCERU -wname -Wname -dcs -ffam -mname -nnum -olist\n"
  "       -rcn -Tname -Fdir -Mdir [files...]\n",
          prog);
  }
  
  int main(int argc, char **argv)
***************
*** 6068,6074 ****
      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"))
         != EOF)
      switch(c) {
      case 'v':
--- 6066,6078 ----
      if (putenv(strsave(e.contents())))
        fatal("putenv failed");
    }
!   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,6161 ****
      case 'U':
        safer_flag = 0; // unsafe behaviour
        break;
      case '?':
!       usage(argv[0]);
        break;          // never reached
      default:
        assert(0);
--- 6158,6170 ----
      case 'U':
        safer_flag = 0; // unsafe behaviour
        break;
+     case CHAR_MAX + 1: // --help
+       usage(stdout,argv[0]);
+       exit(0);
+       break;
      case '?':
!       usage(stderr,argv[0]);
!       exit(1);
        break;          // never reached
      default:
        assert(0);
diff -r -c3 groff-current.orig/src/utils/addftinfo/addftinfo.cc 
groff-current/src/utils/addftinfo/addftinfo.cc
*** groff-current.orig/src/utils/addftinfo/addftinfo.cc Thu Nov 16 22:10:45 2000
--- groff-current/src/utils/addftinfo/addftinfo.cc      Sun Apr  8 13:20:44 2001
***************
*** 1,5 ****
  // -*- C++ -*-
! /* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
--- 1,5 ----
  // -*- C++ -*-
! /* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
***************
*** 31,36 ****
--- 31,37 ----
  #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,74 ****
  {
    program_name = argv[0];
    for (int i = 1; i < argc; i++) {
!     if (!strcmp(argv[i], "-v"))
        version();
    }
    if (argc < 4)
      usage();
--- 68,79 ----
  {
    program_name = argv[0];
    for (int i = 1; i < argc; i++) {
!     if (!strcmp(argv[i], "-v") || !strcmp(argv[i],"--version"))
        version();
+     if (!strcmp(argv[i],"--help")) {
+       usage(stdout);
+       exit(0);
+     }
    }
    if (argc < 4)
      usage();
***************
*** 123,133 ****
    return 0;
  }
  
! static void usage()
  {
!   fprintf(stderr, "usage: %s [-v] [-param value] ... "
                  "resolution unitwidth font\n",
          program_name);
    exit(1);
  }
  
--- 128,142 ----
    return 0;
  }
  
! static void usage(FILE *stream)
  {
!   fprintf(stream, "usage: %s [-v] [-param value] ... "
                  "resolution unitwidth font\n",
          program_name);
+ }
+ static void usage()
+ {
+   usage(stderr);
    exit(1);
  }
  
diff -r -c3 groff-current.orig/src/utils/hpftodit/hpftodit.cc 
groff-current/src/utils/hpftodit/hpftodit.cc
*** groff-current.orig/src/utils/hpftodit/hpftodit.cc   Thu Nov 16 22:10:47 2000
--- groff-current/src/utils/hpftodit/hpftodit.cc        Sun Apr  8 13:22:54 2001
***************
*** 1,5 ****
  // -*- C++ -*-
! /* Copyright (C) 1994, 2000 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
--- 1,5 ----
  // -*- C++ -*-
! /* Copyright (C) 1994, 2000, 2001 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
***************
*** 173,178 ****
--- 173,179 ----
  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,212 ****
    int opt;
    int debug_flag = 0;
  
!   while ((opt = getopt(argc, argv, "dsvi:")) != EOF) {
      switch (opt) {
      case 'd':
        debug_flag = 1;
--- 207,218 ----
    int opt;
    int debug_flag = 0;
  
!   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,232 ****
--- 231,243 ----
        exit(0);
        }
        break;
+     case CHAR_MAX + 1: // --help
+       usage(stdout);
+       exit(0);
+       break;
      case '?':
        usage();
+       break;
      default:
        assert(0);
      }
***************
*** 264,273 ****
  }
  
  static
! void usage()
  {
!   fprintf(stderr, "usage: %s [-s] [-i n] tfm_file map_file output_font\n",
          program_name);
    exit(1);
  }
  
--- 275,289 ----
  }
  
  static
! void usage(FILE *stream)
  {
!   fprintf(stream, "usage: %s [-s] [-i n] tfm_file map_file output_font\n",
          program_name);
+ }
+ static
+ void usage()
+ {
+   usage(stderr);
    exit(1);
  }
  
diff -r -c3 groff-current.orig/src/utils/indxbib/indxbib.cc 
groff-current/src/utils/indxbib/indxbib.cc
*** groff-current.orig/src/utils/indxbib/indxbib.cc     Thu Nov 16 22:10:48 2000
--- groff-current/src/utils/indxbib/indxbib.cc  Sun Apr  8 13:23:07 2001
***************
*** 1,5 ****
  // -*- C++ -*-
! /* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
--- 1,5 ----
  // -*- C++ -*-
! /* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
***************
*** 98,104 ****
  int shortest_len = 3;
  int max_keys_per_item = 100;
  
! static void usage();
  static void write_hash_table();
  static void init_hash_table();
  static void read_common_words_file();
--- 98,104 ----
  int shortest_len = 3;
  int max_keys_per_item = 100;
  
! static void usage(FILE *stream);
  static void write_hash_table();
  static void init_hash_table();
  static void read_common_words_file();
***************
*** 131,137 ****
    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)
      switch (opt) {
      case 'c':
        common_words_file = optarg;
--- 131,144 ----
    const char *directory = 0;
    const char *foption = 0;
    int opt;
!   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,185 ****
        exit(0);
        break;
        }
      case '?':
!       usage();
        break;
      default:
        assert(0);
--- 185,197 ----
        exit(0);
        break;
        }
+     case CHAR_MAX + 1: // --help
+       usage(stdout);
+       exit(0);
+       break;
      case '?':
!       usage(stderr);
!       exit(1);
        break;
      default:
        assert(0);
***************
*** 323,335 ****
    return failed;
  }
  
! static void usage()
  {
!   fprintf(stderr,
  "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)
--- 335,346 ----
    return failed;
  }
  
! static void usage(FILE *stream)
  {
!   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);
  }
  
  static void check_integer_arg(char opt, const char *arg, int min, int *res)
diff -r -c3 groff-current.orig/src/utils/lkbib/lkbib.cc 
groff-current/src/utils/lkbib/lkbib.cc
*** groff-current.orig/src/utils/lkbib/lkbib.cc Thu Nov 16 22:10:49 2000
--- groff-current/src/utils/lkbib/lkbib.cc      Sun Apr  8 13:23:21 2001
***************
*** 1,5 ****
  // -*- C++ -*-
! /* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
--- 1,5 ----
  // -*- C++ -*-
! /* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
***************
*** 32,42 ****
  #include "refid.h"
  #include "search.h"
  
! static void usage()
  {
!   fprintf(stderr, "usage: %s [-nv] [-p database] [-i XYZ] [-t N] keys ...\n",
          program_name);
-   exit(1);
  }
  
  int main(int argc, char **argv)
--- 32,41 ----
  #include "refid.h"
  #include "search.h"
  
! static void usage(FILE *stream)
  {
!   fprintf(stream, "usage: %s [-nv] [-p database] [-i XYZ] [-t N] keys ...\n",
          program_name);
  }
  
  int main(int argc, char **argv)
***************
*** 47,53 ****
    int search_default = 1;
    search_list list;
    int opt;
!   while ((opt = getopt(argc, argv, "nvVi:t:p:")) != EOF)
      switch (opt) {
      case 'V':
        verify_flag = 1;
--- 46,58 ----
    int search_default = 1;
    search_list list;
    int opt;
!   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,93 ****
      case 'p':
        list.add_file(optarg);
        break;
      case '?':
!       usage();
      default:
        assert(0);
      }
!   if (optind >= argc)
!     usage();
    char *filename = getenv("REFER");
    if (filename)
      list.add_file(filename);
--- 86,106 ----
      case 'p':
        list.add_file(optarg);
        break;
+     case CHAR_MAX + 1: // --help
+       usage(stdout);
+       exit(0);
+       break;
      case '?':
!       usage(stderr);
!       exit(1);
!       break;
      default:
        assert(0);
      }
!   if (optind >= argc) {
!     usage(stderr);
!     exit(1);
!   }
    char *filename = getenv("REFER");
    if (filename)
      list.add_file(filename);
diff -r -c3 groff-current.orig/src/utils/lookbib/lookbib.cc 
groff-current/src/utils/lookbib/lookbib.cc
*** groff-current.orig/src/utils/lookbib/lookbib.cc     Thu Nov 16 22:10:49 2000
--- groff-current/src/utils/lookbib/lookbib.cc  Sun Apr  8 13:23:33 2001
***************
*** 1,5 ****
  // -*- C++ -*-
! /* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
--- 1,5 ----
  // -*- C++ -*-
! /* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
***************
*** 36,46 ****
    int isatty(int);
  }
  
! static void usage()
  {
!   fprintf(stderr, "usage: %s [-v] [-i XYZ] [-t N] database ...\n",
          program_name);
-   exit(1);
  }
  
  int main(int argc, char **argv)
--- 36,45 ----
    int isatty(int);
  }
  
! static void usage(FILE *stream)
  {
!   fprintf(stream, "usage: %s [-v] [-i XYZ] [-t N] database ...\n",
          program_name);
  }
  
  int main(int argc, char **argv)
***************
*** 49,55 ****
    static char stderr_buf[BUFSIZ];
    setbuf(stderr, stderr_buf);
    int opt;
!   while ((opt = getopt(argc, argv, "vVi:t:")) != EOF)
      switch (opt) {
      case 'V':
        verify_flag = 1;
--- 48,59 ----
    static char stderr_buf[BUFSIZ];
    setbuf(stderr, stderr_buf);
    int opt;
!   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,89 ****
        exit(0);
        break;
        }
      case '?':
!       usage();
      default:
        assert(0);
      }
!   if (optind >= argc)
!     usage();
    search_list list;
    for (int i = optind; i < argc; i++)
      list.add_file(argv[i]);
--- 81,101 ----
        exit(0);
        break;
        }
+     case CHAR_MAX + 1: // --help
+       usage(stdout);
+       exit(0);
+       break;
      case '?':
!       usage(stderr);
!       exit(1);
!       break;
      default:
        assert(0);
      }
!   if (optind >= argc) {
!     usage(stderr);
!     exit(1);
!   }
    search_list list;
    for (int i = optind; i < argc; i++)
      list.add_file(argv[i]);
diff -r -c3 groff-current.orig/src/utils/pfbtops/pfbtops.c 
groff-current/src/utils/pfbtops/pfbtops.c
*** groff-current.orig/src/utils/pfbtops/pfbtops.c      Thu Nov 16 22:10:50 2000
--- groff-current/src/utils/pfbtops/pfbtops.c   Sun Apr  8 13:11:45 2001
***************
*** 2,7 ****
--- 2,8 ----
  
  #include <stdio.h>
  #include <getopt.h>
+ #include <limits.h>
  
  #include "nonposix.h"
  
***************
*** 18,27 ****
    exit(2);
  }
  
! static void usage()
  {
!   fprintf(stderr, "usage: %s [-v] [pfb_file]\n", program_name);
!   exit(1);
  }
  
  int main(argc, argv)
--- 19,27 ----
    exit(2);
  }
  
! static void usage(FILE *stream)
  {
!   fprintf(stream, "usage: %s [-v] [pfb_file]\n", program_name);
  }
  
  int main(argc, argv)
***************
*** 30,39 ****
  {
    int opt;
    extern int optind;
  
    program_name = argv[0];
  
!   while ((opt = getopt(argc, argv, "v")) != EOF) {
      switch (opt) {
      case 'v':
        {
--- 30,44 ----
  {
    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_long(argc, argv, "v", long_options, NULL)) != EOF) {
      switch (opt) {
      case 'v':
        {
***************
*** 42,54 ****
        exit(0);
        break;
        }
      case '?':
!       usage();
      }
    }
  
!   if (argc - optind > 1)
!     usage();
    if (argc > optind && !freopen(argv[optind], "r", stdin))
      {
        perror(argv[optind]);
--- 47,67 ----
        exit(0);
        break;
        }
+     case CHAR_MAX + 1: // --help
+       usage(stdout);
+       exit(0);
+       break;
      case '?':
!       usage(stderr);
!       exit(1);
!       break;
      }
    }
  
!   if (argc - optind > 1) {
!     usage(stderr);
!     exit(1);
!   }
    if (argc > optind && !freopen(argv[optind], "r", stdin))
      {
        perror(argv[optind]);
diff -r -c3 groff-current.orig/src/utils/tfmtodit/tfmtodit.cc 
groff-current/src/utils/tfmtodit/tfmtodit.cc
*** groff-current.orig/src/utils/tfmtodit/tfmtodit.cc   Thu Nov 16 22:10:50 2000
--- groff-current/src/utils/tfmtodit/tfmtodit.cc        Sun Apr  8 13:23:45 2001
***************
*** 1,5 ****
  // -*- C++ -*-
! /* Copyright (C) 1989, 1990, 1991, 1992, 2000 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
--- 1,5 ----
  // -*- C++ -*-
! /* Copyright (C) 1989-1992, 2000, 2001 Free Software Foundation, Inc.
       Written by James Clark (address@hidden)
  
  This file is part of groff.
***************
*** 680,686 ****
    { CH_ff, CH_l, CH_ffl, "ffl" },
    };
  
! static void usage();
    
  int main(int argc, char **argv)
  {
--- 680,686 ----
    { CH_ff, CH_l, CH_ffl, "ffl" },
    };
  
! static void usage(FILE *stream);
    
  int main(int argc, char **argv)
  {
***************
*** 689,695 ****
    int skewchar = -1;
    int opt;
    const char *gf_file = 0;
!   while ((opt = getopt(argc, argv, "svg:k:")) != EOF)
      switch (opt) {
      case 'g':
        gf_file = optarg;
--- 689,700 ----
    int skewchar = -1;
    int opt;
    const char *gf_file = 0;
!   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,730 ****
        exit(0);
        break;
        }
      case '?':
!       usage();
        break;
      case EOF:
        assert(0);
      }
!   if (argc - optind != 3)
!     usage();
    gf g;
    if (gf_file) {
      if (!g.load(gf_file))
--- 722,742 ----
        exit(0);
        break;
        }
+     case CHAR_MAX + 1: // --help
+       usage(stdout);
+       exit(0);
+       break;
      case '?':
!       usage(stderr);
!       exit(1);
        break;
      case EOF:
        assert(0);
      }
!   if (argc - optind != 3) {
!     usage(stderr);
!     exit(1);
!   }
    gf g;
    if (gf_file) {
      if (!g.load(gf_file))
***************
*** 855,863 ****
    return 0;
  }
  
! static void usage()
  {
!   fprintf(stderr, "usage: %s [-sv] [-g gf_file] [-k skewchar] tfm_file 
map_file font\n",
          program_name);
-   exit(1);
  }
--- 867,874 ----
    return 0;
  }
  
! static void usage(FILE *stream)
  {
!   fprintf(stream, "usage: %s [-sv] [-g gf_file] [-k skewchar] tfm_file 
map_file font\n",
          program_name);
  }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]