(longopts): Add --help, --version.
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 21 Sep 2004 22:11:28 +0000 (22:11 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 21 Sep 2004 22:11:28 +0000 (22:11 +0000)
(main): Use longopts rather than parse_long_options.
(main): Don't reorder arguments, so that we can check weird file names.

src/pathchk.c

index 5692509..6f6f8ac 100644 (file)
@@ -46,7 +46,6 @@
 #include "system.h"
 #include "error.h"
 #include "euidaccess.h"
-#include "long-options.h"
 
 /* The official name of this program (e.g., no `g' prefix).  */
 #define PROGRAM_NAME "pathchk"
@@ -108,6 +107,8 @@ char *program_name;
 static struct option const longopts[] =
 {
   {"portability", no_argument, NULL, 'p'},
+  {GETOPT_HELP_OPTION_DECL},
+  {GETOPT_VERSION_OPTION_DECL},
   {NULL, 0, NULL, 0}
 };
 
@@ -166,20 +167,18 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  parse_long_options (argc, argv, PROGRAM_NAME, GNU_PACKAGE, VERSION,
-                     usage, AUTHORS, (char const *) NULL);
-
-  while ((optc = getopt_long (argc, argv, "p", longopts, NULL)) != -1)
+  while ((optc = getopt_long (argc, argv, "+p", longopts, NULL)) != -1)
     {
       switch (optc)
        {
-       case 0:
-         break;
-
        case 'p':
          check_portability = true;
          break;
 
+       case_GETOPT_HELP_CHAR;
+
+       case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
+
        default:
          usage (EXIT_FAILURE);
        }