groff
[Top][All Lists]
Advanced

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

Re: [Groff] (no subject)


From: Werner LEMBERG
Subject: Re: [Groff] (no subject)
Date: Fri, 17 Mar 2000 11:31:02 GMT

> I tried to use the GNU standard option names, but the following names
> might be discutable:
> [...]

Please look at the following `patch' (it isn't a real patch since I've
simply inserted/removed lines without adjusting the diff headers).

I've changed some option names.  Please comment.


    Werner

--- groff.cc.orig       Thu Mar 16 00:21:32 2000
+++ groff.cc    Thu Mar 16 00:51:50 2000
@@ -25,6 +25,7 @@
 #include <stdlib.h>
 #include <signal.h>
 #include <errno.h>
 
 #include "lib.h"
 #include "assert.h"
@@ -109,19 +110,78 @@
   int iflag = 0;
   int Xflag = 0;
   int safer_flag = 1;
-  int opt;
+
+  int opt, longopt_index;
+  static struct option long_options[] = {
+    /* Long options with a corresponding short option are internally
+       replaced by their short equivalent. */
+    {"ascii", 0, NULL, 'a'},
+    {"debug", 0, NULL, 'b'},
+    {"compat", 0, NULL, 'C'},
+    {"define-string", 1, NULL, 'd'},
+    {"eqn", 0, NULL, 'e'},
+    {"ignore-errors", 0, NULL, 'E'},
+    {"font-family", 1, NULL, 'f'},
+    {"font-dir", 1, NULL, 'F'},
+    {"grn", 0, NULL, 'g'},
+    {"help", 0, NULL, 'h'},
+    {"append-stdin", 0, NULL, 'i'},
+    {"soelim-dir", 1, NULL, 'I'},
+    {"print", 0, NULL, 'l'},
+    {"print-arg", 1, NULL, 'L'},
+    {"macro-package", 1, NULL, 'm'},
+    {"macro-dir", 1, NULL, 'M'},
+    {"first-page-number", 1, NULL, 'n'},
+    {"no-eqn-newlines", 0, NULL, 'N'},
+    {"output-pages", 1, NULL, 'o'},
+    {"pic", 0, NULL, 'p'},
+    {"device-arg", 1, NULL, 'P'},
+    {"set-register", 1, NULL, 'r'},
+    {"refer", 0, NULL, 'R'},
+    {"soelim", 0, NULL, 's'},
+    {"safer", 0, NULL, 'S'},
+    {"tbl", 0, NULL, 't'},
+    {"device", 1, NULL, 'T'},
+    {"unsafe", 0, NULL, 'U'},
+    {"version", 0, NULL, 'v'},
+    {"to-stdout", 0, NULL, 'V'},
+    {"warning", 1, NULL, 'w'},
+    {"no-warning", 1, NULL, 'W'},
+    {"xditview", 0, NULL, 'X'},
+    {"no-output", 0, NULL, 'z'},
+    {"no-device", 0, NULL, 'Z'},
+
+    /* last element must be all 0 */
+    {NULL, 0, NULL, 0}
+  }; 
+
   const char *command_prefix = getenv("GROFF_COMMAND_PREFIX");
   if (!command_prefix)
     command_prefix = PROG_PREFIX;
   commands[TROFF_INDEX].set_name(command_prefix, "troff");
-  while ((opt = getopt(argc, argv,
-                      "abCd:eEf:F:ghiI:lL:m:M:n:No:pP:r:RsStT:UvVw:W:XzZ"))
+
+  while ((opt = getopt_long(argc, argv,
+                            "abCd:eEf:F:ghiI:lL:m:M:n:No:"
+                            "pP:r:RsStT:UvVw:W:XzZ",
+                            long_options, &longopt_index))
         != EOF) {
     char buf[3];
     buf[0] = '-';
     buf[1] = opt;
     buf[2] = '\0';
     switch (opt) {
+    case 0:
+      /* handle long options without a corresponding
+         single-character option */
+      break;
     case 'i':
       iflag = 1;
       break;


reply via email to

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