help-gengetopt
[Top][All Lists]
Advanced

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

[help-gengetopt]patch to allow for long option with no short option


From: Person or Persons Unknown
Subject: [help-gengetopt]patch to allow for long option with no short option
Date: Tue, 10 Oct 2000 20:18:59 -0400

                                          Evening, Tuesday 10, October 2000

Here is a patch to gengetopt which will allow it to handle long options
with no associated short options.  This is done by handling a special short
option '-'.  This is a patch against v2.1 of gengetopt.

diff -Naur gengetopt-2.1/src/gengetopt.c gengetopt/src/gengetopt.c
--- gengetopt-2.1/src/gengetopt.c       Sun Jul 23 13:51:58 2000
+++ gengetopt/src/gengetopt.c   Wed Oct  4 22:28:28 2000
@@ -171,7 +171,9 @@
        for (n = gengetopt_options; n != NULL; n = n->next)
        {
                if (!strcmp (n->long_opt, long_opt)) return 2;
-               if (n->short_opt == short_opt) return 3;
+        if (short_opt
+            && n->short_opt == short_opt)
+            return 3;
        }
 
        n = malloc (sizeof (struct gengetopt_option));
@@ -190,7 +192,7 @@
                return 1;
        }
        
-       n->short_opt = short_opt;
+       n->short_opt = ((short_opt == '-') ? 0 : short_opt);
        n->type = type;
        n->flagstat = flagstat;
         n->required = required;
diff -Naur gengetopt-2.1/src/gm.c gengetopt/src/gm.c
--- gengetopt-2.1/src/gm.c      Wed Sep 20 17:14:56 2000
+++ gengetopt/src/gm.c  Wed Oct  4 21:54:45 2000
@@ -71,6 +71,76 @@
   return output_file;
 }
 
+static void
+do_check_option_given (struct gengetopt_option *opt)
+{
+       switch (opt->type) {
+       case ARG_NO:
+        check_option_given (opt->var_arg, opt->long_opt, opt->short_opt);
+        break;
+       case ARG_FLAG:
+        indent ();
+        printf ("%s->%s_flag = !(%s->%s_flag);\n",
+                ARGS_STRUCT,
+                opt->var_arg,
+                ARGS_STRUCT,
+                               opt->var_arg);
+        break;
+       case ARG_STRING:
+        check_option_given (opt->var_arg, opt->long_opt, opt->short_opt);
+        indent ();
+        printf ("%s->%s_arg = gengetopt_strdup (optarg);\n",
+                               ARGS_STRUCT, opt->var_arg);
+        break;
+       case ARG_INT:
+        check_option_given (opt->var_arg, opt->long_opt, opt->short_opt);
+        indent ();
+        printf ("%s->%s_arg = atoi (optarg);\n",
+                               ARGS_STRUCT, opt->var_arg);
+        break;
+       case ARG_SHORT:
+        check_option_given (opt->var_arg, opt->long_opt, opt->short_opt);
+        indent ();
+        printf ("%s->%s_arg = (short)atoi (optarg);\n",
+                               ARGS_STRUCT, opt->var_arg);
+        break;
+       case ARG_LONG:
+        check_option_given (opt->var_arg, opt->long_opt, opt->short_opt);
+        indent ();
+        printf ("%s->%s_arg = atol (optarg);\n", 
+                ARGS_STRUCT, opt->var_arg);
+        break;
+       case ARG_FLOAT:
+        check_option_given (opt->var_arg, opt->long_opt, opt->short_opt);
+        indent ();
+        printf ("%s->%s_arg = (float)strtod (optarg, NULL);\n",
+                               ARGS_STRUCT, opt->var_arg);
+        break;
+       case ARG_DOUBLE:
+        check_option_given (opt->var_arg, opt->long_opt, opt->short_opt);
+        indent ();
+        printf ("%s->%s_arg = strtod (optarg, NULL);\n",
+                               ARGS_STRUCT, opt->var_arg);
+        break;
+       case ARG_LONGDOUBLE:
+        check_option_given (opt->var_arg, opt->long_opt, opt->short_opt);
+        indent ();
+        printf ("%s->%s_arg = (long double) strtod (optarg, NULL);\n",
+                               ARGS_STRUCT, opt->var_arg);
+        break;
+       case ARG_LONGLONG:
+        check_option_given (opt->var_arg, opt->long_opt, opt->short_opt);
+        indent ();
+        printf ("%s->%s_arg = (long long)atol (optarg);\n",
+                               ARGS_STRUCT, opt->var_arg);
+        break;
+       default:
+        fprintf (stderr, "gengetopt: bug found in %s:%d\n", __FILE__,
+                 __LINE__);
+        abort ();
+       }
+}
+
 int
 generate_cmdline_parser (char *function_name, short unamed_options,
                          char *filename, char *header_ext, char *c_ext,
@@ -80,6 +150,7 @@
   struct gengetopt_option * opt;
   char *comment_string ;
   int i ;
+  int first_time = 1;
 
   FILE *output_file ;
 
@@ -179,12 +250,12 @@
                   abort ();
                }
                 indent ();
-               printf ("int %s_given ;\t/* Wheter %s was given.  */\n",
+               printf ("int %s_given ;\t/* Whether %s was given.  */\n",
                        opt->var_arg, opt->long_opt);
     } else {
       /* for NO_ARG options we simply create a "given" */
       indent ();
-      printf ("int %s_given ;\t/* Wheter %s was given.  */\n",
+      printf ("int %s_given ;\t/* Whether %s was given.  */\n",
               opt->var_arg, opt->long_opt);
     }
 
@@ -319,10 +390,13 @@
                case ARG_DOUBLE:
                case ARG_LONGDOUBLE:
                case ARG_LONGLONG:
-               case ARG_STRING: printf ("-%c%s|--%s=%s ",
-                                       opt->short_opt, arg_names[opt->type],
-                                       opt->long_opt, arg_names[opt->type]);
-                                break;
+               case ARG_STRING: 
+               if (opt->short_opt)
+            {
+                printf ("-%c%s|", opt->short_opt, arg_names[opt->type]);
+            }
+            printf ("--%s=%s ", opt->long_opt, arg_names[opt->type]);
+                  break;
                default: fprintf (stderr, "gengetopt: bug found in %s:%d!!\n",
                                  __FILE__, __LINE__);
                         abort ();
@@ -331,9 +405,14 @@
        if (!opt->required)
                switch (opt->type) {
                case ARG_NO:
-               case ARG_FLAG: printf ("[-%c|--%s] ",
-                                       opt->short_opt, opt->long_opt);
-                              break;
+               case ARG_FLAG: 
+            printf ("[");
+            if (opt->short_opt)
+            {
+                printf ("-%c|", opt->short_opt, opt->long_opt);
+            }
+            printf ("--%s] ", opt->long_opt);
+            break;
                case ARG_INT:
                case ARG_SHORT:
                case ARG_LONG:
@@ -341,10 +420,13 @@
                case ARG_DOUBLE:
                case ARG_LONGDOUBLE:
                case ARG_LONGLONG:
-               case ARG_STRING: printf ("[-%c%s|--%s=%s] ",
-                                       opt->short_opt, arg_names[opt->type],
-                                       opt->long_opt, arg_names[opt->type]);
-                                break;
+               case ARG_STRING: 
+               if (opt->short_opt)
+            {
+                printf ("-%c%s", opt->short_opt, arg_names[opt->type]);
+           }
+           printf ("--%s=%s ", opt->long_opt, arg_names[opt->type]);
+                  break;
                default: fprintf (stderr, "gengetopt: bug found in %s:%d!!\n",
                                  __FILE__, __LINE__);
                         abort ();
@@ -378,24 +460,33 @@
   foropt
        if (opt->type == ARG_FLAG || opt->type == ARG_NO)
        {
-               printf ("   -%c", opt->short_opt);
+        if (opt->short_opt) printf ("   -%c", opt->short_opt);
+        else                printf ("      ");
                for (w = 2; w < max_short; w++) printf (" ");
                printf ("  --%s", opt->long_opt);
                for (w = 2+gengetopt_strlen(opt->long_opt); w < max_long; w++)
                        printf (" ");
                printf ("  %s", opt->desc);
                if (opt->type == ARG_FLAG)
-                 {
+           {
                    if (opt->flagstat)
-                       printf (" (default=on)");
-                    else
+                printf (" (default=on)");
+            else
                       printf (" (default=off)");
-                  }
+        }
                printf ("\\n\\\n");
        }
        else
        {
-               printf ("   -%c%s", opt->short_opt, arg_names[opt->type]);
+               if (opt->short_opt)
+            printf ("   -%c%s", opt->short_opt, arg_names[opt->type]);
+        else
+        {
+            int type_len = gengetopt_strlen(arg_names[opt->type]);
+
+            printf ("      ");
+            for (w = 1; w < type_len; w++) printf (" ");
+        }
                for (w = 2+gengetopt_strlen(arg_names[opt->type]); w < 
max_short; w++)
                        printf (" ");
                printf ("  --%s=%s", opt->long_opt, arg_names[opt->type]);
@@ -508,9 +599,11 @@
   foropt
     {
       indent ();
-      printf ("{ \"%s\",\t%d, NULL, \'%c\' },\n", opt->long_opt,
-               (opt->type == ARG_NO || opt->type == ARG_FLAG ? 0 : 1),
-               opt->short_opt);
+      printf ("{ \"%s\",\t%d, NULL, ", opt->long_opt,
+                         (opt->type == ARG_NO || opt->type == ARG_FLAG ? 0 : 
1));
+      if (opt->short_opt) printf ("\'%c\'", opt->short_opt);
+      else printf ("0");
+      printf ("},\n");
     }
 
   indent ();
@@ -524,8 +617,9 @@
   printf ("c = getopt_long (argc, argv, \"");
 
   foropt
-       printf ("%c%s", opt->short_opt,
-               (opt->type == ARG_NO || opt->type == ARG_FLAG ? "" : ":"));
+    if (opt->short_opt)
+           printf ("%c%s", opt->short_opt,
+                       (opt->type == ARG_NO || opt->type == ARG_FLAG ? "" : 
":"));
 
   printf ("\", long_options, &option_index);\n\n");
 
@@ -565,85 +659,49 @@
 
 
   foropt {
-       if (opt->short_opt == 'h' || opt->short_opt == 'V') continue;
+    if (opt->short_opt == 'h' || opt->short_opt == 'V') continue;
 
-        printf ("\n");
-        indent ();
-       printf ("case '%c':\t/* %s.  */\n", opt->short_opt,
-               opt->desc);
+    printf ("\n");
+    indent ();
+    if (opt->short_opt)
+    {
+        printf ("case '%c':\t/* %s.  */\n", opt->short_opt,
+                opt->desc);
         inc_indent ();
-       switch (opt->type) {
-       case ARG_NO:
-          check_option_given (opt->var_arg, opt->long_opt, opt->short_opt);
-         break;
-       case ARG_FLAG:
-          indent ();
-                       printf ("%s->%s_flag = !(%s->%s_flag);\n",
-                                ARGS_STRUCT,
-                                opt->var_arg,
-                                ARGS_STRUCT,
-                               opt->var_arg);
-                       break;
-       case ARG_STRING:
-                       check_option_given (opt->var_arg, opt->long_opt, 
opt->short_opt);
-                        indent ();
-                       printf ("%s->%s_arg = gengetopt_strdup (optarg);\n",
-                               ARGS_STRUCT, opt->var_arg);
-                       break;
-       case ARG_INT:
-                       check_option_given (opt->var_arg, opt->long_opt, 
opt->short_opt);
-                        indent ();
-                       printf ("%s->%s_arg = atoi (optarg);\n",
-                               ARGS_STRUCT, opt->var_arg);
-                       break;
-       case ARG_SHORT:
-                       check_option_given (opt->var_arg, opt->long_opt, 
opt->short_opt);
-                        indent ();
-                       printf ("%s->%s_arg = (short)atoi (optarg);\n",
-                               ARGS_STRUCT, opt->var_arg);
-                       break;
-       case ARG_LONG:
-                       check_option_given (opt->var_arg, opt->long_opt, 
opt->short_opt);
-                       indent ();
-                        printf ("%s->%s_arg = atol (optarg);\n", 
-                                ARGS_STRUCT, opt->var_arg);
-                       break;
-       case ARG_FLOAT:
-                       check_option_given (opt->var_arg, opt->long_opt, 
opt->short_opt);
-                        indent ();
-                       printf ("%s->%s_arg = (float)strtod (optarg, NULL);\n",
-                               ARGS_STRUCT, opt->var_arg);
-                       break;
-       case ARG_DOUBLE:
-                       check_option_given (opt->var_arg, opt->long_opt, 
opt->short_opt);
-                        indent ();
-                       printf ("%s->%s_arg = strtod (optarg, NULL);\n",
-                               ARGS_STRUCT, opt->var_arg);
-                       break;
-       case ARG_LONGDOUBLE:
-                       check_option_given (opt->var_arg, opt->long_opt, 
opt->short_opt);
-                        indent ();
-                       printf ("%s->%s_arg = (long double) strtod (optarg, 
NULL);\n",
-                               ARGS_STRUCT, opt->var_arg);
-                       break;
-       case ARG_LONGLONG:
-                       check_option_given (opt->var_arg, opt->long_opt, 
opt->short_opt);
-                        indent ();
-                       printf ("%s->%s_arg = (long long)atol (optarg);\n",
-                               ARGS_STRUCT, opt->var_arg);
-                       break;
-       default:
-                       fprintf (stderr, "gengetopt: bug found in %s:%d\n", 
__FILE__,
-                               __LINE__);
-                       abort ();
-       }
+        do_check_option_given (opt);
         indent ();
-       printf ("break;\n");
+        printf ("break;\n");
         dec_indent ();
+    }
   }
 
   printf ("\n");
   indent ();
+  printf ("case 0:\t/* Long option with no short option */\n");
+  inc_indent();
+  foropt 
+      if (!opt->short_opt)
+      {
+          indent();
+          printf ("/* %s.  */\n", opt->desc);
+          indent();
+          printf ("%sif (strcmp (long_option[option_index].name, "
+                  "\"%s\") == 0)\n",
+                  ((first_time == 0) ? "else " : ""),
+                  opt->long_opt);
+          first_time = 0;
+          indent();
+          printf ("{\n");
+          inc_indent();
+          do_check_option_given (opt);
+        dec_indent();
+        indent ();
+        printf ("}\n");
+        
+      }
+
+  printf ("\n");
+  indent ();
   printf ("case '?':\t/* Invalid option.  */\n");
   inc_indent ();
   indent ();
@@ -680,7 +738,10 @@
         printf ("{\n"); 
         inc_indent ();
         indent ();
-        printf ("fprintf (stderr, \"%%s: `--%s' (`-%c') option required!\\n\", 
PACKAGE);\n", opt->long_opt, opt->short_opt);
+        if (opt->short_opt)
+            printf ("fprintf (stderr, \"%%s: `--%s' (`-%c') option 
required!\\n\", PACKAGE);\n", opt->long_opt, opt->short_opt);
+        else
+            printf ("fprintf (stderr, \"%%s: `--%s' option required!\\n\", 
PACKAGE);\n", opt->long_opt);
         indent ();
         printf ("missing_required_options = 1;\n");
         dec_indent ();
@@ -769,7 +830,10 @@
   printf ("{\n");
   inc_indent ();
   indent ();
-  printf ("fprintf (stderr, \"%%s: `--%s' (`-%c') option given more than 
once\\n\", PACKAGE);\n", long_opt, short_opt);
+  if (short_opt)
+      printf ("fprintf (stderr, \"%%s: `--%s' (`-%c') option given more than 
once\\n\", PACKAGE);\n", long_opt, short_opt);
+  else 
+      printf ("fprintf (stderr, \"%%s: `--%s' option given more than 
once\\n\", PACKAGE);\n", long_opt);
   indent ();
   printf ("clear_args ();\n");
   indent ();
diff -Naur gengetopt-2.1/src/parser.c gengetopt/src/parser.c
--- gengetopt-2.1/src/parser.c  Sat Aug  5 12:51:39 2000
+++ gengetopt/src/parser.c      Wed Oct  4 22:31:57 2000
@@ -1,20 +1,21 @@
 
 /*  A Bison parser, made from parser.y
-    by GNU Bison version 1.28  */
+ by  GNU Bison version 1.25
+  */
 
 #define YYBISON 1  /* Identify Bison output.  */
 
-#define        TOK_PACKAGE     257
-#define        TOK_VERSION     258
-#define        TOK_OPTION      259
-#define        TOK_YES 260
-#define        TOK_NO  261
-#define        TOK_FLAG        262
-#define        TOK_ONOFF       263
-#define        TOK_STRING      264
-#define        TOK_STRING_WITH_SPACES  265
-#define        TOK_CHAR        266
-#define        TOK_ARGTYPE     267
+#define        TOK_PACKAGE     258
+#define        TOK_VERSION     259
+#define        TOK_OPTION      260
+#define        TOK_YES 261
+#define        TOK_NO  262
+#define        TOK_FLAG        263
+#define        TOK_ONOFF       264
+#define        TOK_STRING      265
+#define        TOK_STRING_WITH_SPACES  266
+#define        TOK_CHAR        267
+#define        TOK_ARGTYPE     268
 
 #line 7 "parser.y"
 
@@ -58,7 +59,7 @@
 #define        YYFLAG          -32768
 #define        YYNTBASE        15
 
-#define YYTRANSLATE(x) ((unsigned)(x) <= 267 ? yytranslate[x] : 20)
+#define YYTRANSLATE(x) ((unsigned)(x) <= 268 ? yytranslate[x] : 20)
 
 static const char yytranslate[] = {     0,
      2,     2,     2,     2,     2,     2,     2,     2,     2,    14,
@@ -86,8 +87,8 @@
      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
-     7,     8,     9,    10,    11,    12,    13
+     2,     2,     2,     2,     2,     1,     2,     3,     4,     5,
+     6,     7,     8,     9,    10,    11,    12,    13
 };
 
 #if YYDEBUG != 0
@@ -167,8 +168,7 @@
      7,    10,    10,    14,    14,     9,    12,     0
 };
 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
-#line 3 "//usr/lib/bison.simple"
-/* This file comes from bison-1.28.  */
+#line 3 "/usr/lib/bison.simple"
 
 /* Skeleton output parser for bison,
    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
@@ -185,66 +185,46 @@
 
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
-   Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
 
 /* As a special exception, when this file is copied by Bison into a
    Bison output file, you may use that output file without restriction.
    This special exception was added by the Free Software Foundation
    in version 1.24 of Bison.  */
 
-/* This is the parser code that is written into each bison parser
-  when the %semantic_parser declaration is not specified in the grammar.
-  It was written by Richard Stallman by simplifying the hairy parser
-  used when %semantic_parser is specified.  */
-
-#ifndef YYSTACK_USE_ALLOCA
-#ifdef alloca
-#define YYSTACK_USE_ALLOCA
-#else /* alloca not defined */
+#ifndef alloca
 #ifdef __GNUC__
-#define YYSTACK_USE_ALLOCA
 #define alloca __builtin_alloca
 #else /* not GNU C.  */
-#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined 
(__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
-#define YYSTACK_USE_ALLOCA
+#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined 
(__sparc) || defined (__sgi)
 #include <alloca.h>
 #else /* not sparc */
-/* We think this test detects Watcom and Microsoft C.  */
-/* This used to test MSDOS, but that is a bad idea
-   since that symbol is in the user namespace.  */
-#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
-#if 0 /* No need for malloc.h, which pollutes the namespace;
-        instead, just don't use alloca.  */
+#if defined (MSDOS) && !defined (__TURBOC__)
 #include <malloc.h>
-#endif
 #else /* not MSDOS, or __TURBOC__ */
 #if defined(_AIX)
-/* I don't know what this was needed for, but it pollutes the namespace.
-   So I turned it off.   rms, 2 May 1997.  */
-/* #include <malloc.h>  */
+#include <malloc.h>
  #pragma alloca
-#define YYSTACK_USE_ALLOCA
-#else /* not MSDOS, or __TURBOC__, or _AIX */
-#if 0
-#ifdef __hpux /* address@hidden says this works for HPUX 9.05 and up,
-                and on HPUX 10.  Eventually we can turn this on.  */
-#define YYSTACK_USE_ALLOCA
-#define alloca __builtin_alloca
+#else /* not MSDOS, __TURBOC__, or _AIX */
+#ifdef __hpux
+#ifdef __cplusplus
+extern "C" {
+void *alloca (unsigned int);
+};
+#else /* not __cplusplus */
+void *alloca ();
+#endif /* not __cplusplus */
 #endif /* __hpux */
-#endif
 #endif /* not _AIX */
 #endif /* not MSDOS, or __TURBOC__ */
-#endif /* not sparc */
-#endif /* not GNU C */
-#endif /* alloca not defined */
-#endif /* YYSTACK_USE_ALLOCA not defined */
+#endif /* not sparc.  */
+#endif /* not GNU C.  */
+#endif /* alloca not defined.  */
 
-#ifdef YYSTACK_USE_ALLOCA
-#define YYSTACK_ALLOC alloca
-#else
-#define YYSTACK_ALLOC malloc
-#endif
+/* This is the parser code that is written into each bison parser
+  when the %semantic_parser declaration is not specified in the grammar.
+  It was written by Richard Stallman by simplifying the hairy parser
+  used when %semantic_parser is specified.  */
 
 /* Note: there must be only one dollar sign in this file.
    It is replaced by the list of actions, each action
@@ -254,8 +234,8 @@
 #define yyclearin      (yychar = YYEMPTY)
 #define YYEMPTY                -2
 #define YYEOF          0
-#define YYACCEPT       goto yyacceptlab
-#define YYABORT        goto yyabortlab
+#define YYACCEPT       return(0)
+#define YYABORT        return(1)
 #define YYERROR                goto yyerrlab1
 /* Like YYERROR except do call yyerror.
    This remains here temporarily to ease the
@@ -336,12 +316,12 @@
 #ifndef YYMAXDEPTH
 #define YYMAXDEPTH 10000
 #endif
-
-/* Define __yy_memcpy.  Note that the size argument
-   should be passed with type unsigned int, because that is what the non-GCC
-   definitions require.  With GCC, __builtin_memcpy takes an arg
-   of type size_t, but it can handle unsigned int.  */
 
+/* Prevent warning if -Wstrict-prototypes.  */
+#ifdef __GNUC__
+int yyparse (void);
+#endif
+
 #if __GNUC__ > 1               /* GNU C and GNU C++ define this.  */
 #define __yy_memcpy(TO,FROM,COUNT)     __builtin_memcpy(TO,FROM,COUNT)
 #else                          /* not GNU C or C++ */
@@ -353,7 +333,7 @@
 __yy_memcpy (to, from, count)
      char *to;
      char *from;
-     unsigned int count;
+     int count;
 {
   register char *f = from;
   register char *t = to;
@@ -368,10 +348,10 @@
 /* This is the most reliable way to avoid incompatibilities
    in available built-in functions on various systems.  */
 static void
-__yy_memcpy (char *to, char *from, unsigned int count)
+__yy_memcpy (char *to, char *from, int count)
 {
-  register char *t = to;
   register char *f = from;
+  register char *t = to;
   register int i = count;
 
   while (i-- > 0)
@@ -381,7 +361,7 @@
 #endif
 #endif
 
-#line 217 "//usr/lib/bison.simple"
+#line 196 "/usr/lib/bison.simple"
 
 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
    into yyparse.  The argument should have type void *.
@@ -402,15 +382,6 @@
 #define YYPARSE_PARAM_DECL
 #endif /* not YYPARSE_PARAM */
 
-/* Prevent warning if -Wstrict-prototypes.  */
-#ifdef __GNUC__
-#ifdef YYPARSE_PARAM
-int yyparse (void *);
-#else
-int yyparse (void);
-#endif
-#endif
-
 int
 yyparse(YYPARSE_PARAM_ARG)
      YYPARSE_PARAM_DECL
@@ -439,7 +410,6 @@
 #endif
 
   int yystacksize = YYINITDEPTH;
-  int yyfree_stacks = 0;
 
 #ifdef YYPURE
   int yychar;
@@ -524,32 +494,18 @@
       if (yystacksize >= YYMAXDEPTH)
        {
          yyerror("parser stack overflow");
-         if (yyfree_stacks)
-           {
-             free (yyss);
-             free (yyvs);
-#ifdef YYLSP_NEEDED
-             free (yyls);
-#endif
-           }
          return 2;
        }
       yystacksize *= 2;
       if (yystacksize > YYMAXDEPTH)
        yystacksize = YYMAXDEPTH;
-#ifndef YYSTACK_USE_ALLOCA
-      yyfree_stacks = 1;
-#endif
-      yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
-      __yy_memcpy ((char *)yyss, (char *)yyss1,
-                  size * (unsigned int) sizeof (*yyssp));
-      yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
-      __yy_memcpy ((char *)yyvs, (char *)yyvs1,
-                  size * (unsigned int) sizeof (*yyvsp));
-#ifdef YYLSP_NEEDED
-      yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
-      __yy_memcpy ((char *)yyls, (char *)yyls1,
-                  size * (unsigned int) sizeof (*yylsp));
+      yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
+      __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
+      yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
+      __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
+#ifdef YYLSP_NEEDED
+      yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
+      __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
 #endif
 #endif /* no yyoverflow */
 
@@ -747,7 +703,7 @@
     break;}
 }
    /* the action file gets copied in in place of this dollarsign */
-#line 543 "//usr/lib/bison.simple"
+#line 498 "/usr/lib/bison.simple"
 
   yyvsp -= yylen;
   yyssp -= yylen;
@@ -942,30 +898,6 @@
 
   yystate = yyn;
   goto yynewstate;
-
- yyacceptlab:
-  /* YYACCEPT comes here.  */
-  if (yyfree_stacks)
-    {
-      free (yyss);
-      free (yyvs);
-#ifdef YYLSP_NEEDED
-      free (yyls);
-#endif
-    }
-  return 0;
-
- yyabortlab:
-  /* YYABORT comes here.  */
-  if (yyfree_stacks)
-    {
-      free (yyss);
-      free (yyvs);
-#ifdef YYLSP_NEEDED
-      free (yyls);
-#endif
-    }
-  return 1;
 }
 #line 93 "parser.y"
 
diff -Naur gengetopt-2.1/src/parser.h gengetopt/src/parser.h
--- gengetopt-2.1/src/parser.h  Sat Aug  5 12:51:39 2000
+++ gengetopt/src/parser.h      Wed Oct  4 22:31:57 2000
@@ -4,17 +4,17 @@
 int argtype;
 int bool;
 } YYSTYPE;
-#define        TOK_PACKAGE     257
-#define        TOK_VERSION     258
-#define        TOK_OPTION      259
-#define        TOK_YES 260
-#define        TOK_NO  261
-#define        TOK_FLAG        262
-#define        TOK_ONOFF       263
-#define        TOK_STRING      264
-#define        TOK_STRING_WITH_SPACES  265
-#define        TOK_CHAR        266
-#define        TOK_ARGTYPE     267
+#define        TOK_PACKAGE     258
+#define        TOK_VERSION     259
+#define        TOK_OPTION      260
+#define        TOK_YES 261
+#define        TOK_NO  262
+#define        TOK_FLAG        263
+#define        TOK_ONOFF       264
+#define        TOK_STRING      265
+#define        TOK_STRING_WITH_SPACES  266
+#define        TOK_CHAR        267
+#define        TOK_ARGTYPE     268
 
 
 extern YYSTYPE yylval;
diff -Naur gengetopt-2.1/src/scanner.c gengetopt/src/scanner.c
--- gengetopt-2.1/src/scanner.c Sat Aug  5 12:51:40 2000
+++ gengetopt/src/scanner.c     Wed Oct  4 22:32:01 2000
@@ -303,16 +303,16 @@
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    4,    1,    5,    6,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    7,    7,    1,    8,    8,    8,
-        8,    8,    8,    8,    8,    8,    8,    1,    1,    1,
-        1,    1,    1,    1,    9,   10,   11,   12,   13,   14,
-       15,   16,   17,    8,   18,   19,    8,   20,   21,   22,
-        8,   23,   24,   25,   26,   27,    8,    8,   28,    8,
-        1,    1,    1,    1,    1,    1,    9,   10,   11,   12,
-
-       13,   14,   15,   16,   17,    8,   18,   19,    8,   20,
-       21,   22,    8,   23,   24,   25,   26,   27,    8,    8,
-       28,    8,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    7,    8,    1,    9,    9,    9,
+        9,    9,    9,    9,    9,    9,    9,    1,    1,    1,
+        1,    1,    1,    1,   10,   11,   12,   13,   14,   15,
+       16,   17,   18,    9,   19,   20,    9,   21,   22,   23,
+        9,   24,   25,   26,   27,   28,    9,    9,   29,    9,
+        1,    1,    1,    1,    1,    1,   10,   11,   12,   13,
+
+       14,   15,   16,   17,   18,    9,   19,   20,    9,   21,
+       22,   23,    9,   24,   25,   26,   27,   28,    9,    9,
+       29,    9,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -329,24 +329,24 @@
         1,    1,    1,    1,    1
     } ;
 
-static yyconst int yy_meta[29] =
+static yyconst int yy_meta[30] =
     {   0,
-        1,    1,    2,    3,    3,    1,    3,    4,    4,    4,
+        1,    1,    2,    3,    3,    1,    3,    3,    4,    4,
         4,    4,    4,    4,    4,    4,    4,    4,    4,    4,
-        4,    4,    4,    4,    4,    4,    4,    4
+        4,    4,    4,    4,    4,    4,    4,    4,    4
     } ;
 
 static yyconst short int yy_base[90] =
     {   0,
-        0,    0,  104,  105,   27,  105,    0,    0,  105,   82,
-       83,   81,   79,   78,   16,   89,   16,   84,   83,   31,
-       35,    0,   69,   25,   69,   73,  105,   78,  105,   66,
-       79,   68,   65,   64,   62,   80,  105,   38,   74,   68,
-       73,  105,   66,  105,   63,   61,   55,   60,   52,  105,
-      105,   56,  105,   49,   25,   52,   63,   46,   50,   52,
-       55,  105,   46,   45,   45,   49,  105,   48,   41,  105,
-       35,   40,  105,   46,  105,   38,   47,   41,  105,  105,
-       36,  105,   35,  105,  105,   41,   46,   48,   50
+        0,    0,  105,  106,   28,  106,    0,    0,  106,   82,
+       83,   81,   79,   78,   16,   89,   16,   84,   83,   32,
+       36,    0,   69,   25,   69,   73,  106,   78,  106,   66,
+       79,   68,   65,   64,   62,   81,  106,   39,   74,   68,
+       73,  106,   66,  106,   63,   61,   55,   60,   52,  106,
+      106,   56,  106,   49,   25,   52,   63,   46,   50,   52,
+       55,  106,   46,   45,   45,   49,  106,   48,   41,  106,
+       35,   40,  106,   46,  106,   38,   47,   41,  106,  106,
+       36,  106,   35,  106,  106,   42,   47,   49,   51
     } ;
 
 static yyconst short int yy_def[90] =
@@ -362,42 +362,42 @@
        85,   85,   85,   85,    0,   85,   85,   85,   85
     } ;
 
-static yyconst short int yy_nxt[134] =
+static yyconst short int yy_nxt[136] =
     {   0,
-        4,    5,    6,    5,    7,    8,    4,    9,    9,    9,
-        9,   10,    9,   11,    9,    9,   12,    9,   13,   14,
-       15,   16,    9,   17,    9,    9,   18,   19,   20,   28,
-       20,   32,   20,   40,   20,   29,   63,   30,   36,   37,
-       33,   36,   37,   64,   21,   41,   22,   84,   22,   22,
-       38,   38,   36,   36,   83,   82,   81,   80,   79,   78,
-       77,   76,   75,   74,   73,   72,   71,   70,   69,   68,
-       67,   66,   65,   62,   61,   60,   59,   58,   57,   56,
-       55,   54,   53,   52,   51,   50,   49,   48,   47,   46,
-       45,   44,   43,   42,   39,   35,   34,   31,   27,   26,
+        4,    5,    6,    5,    7,    8,    9,    4,    9,    9,
+        9,    9,   10,    9,   11,    9,    9,   12,    9,   13,
+       14,   15,   16,    9,   17,    9,    9,   18,   19,   20,
+       28,   20,   32,   20,   40,   20,   29,   63,   30,   36,
+       37,   33,   36,   37,   64,   21,   41,   22,   84,   22,
+       22,   38,   38,   36,   36,   83,   82,   81,   80,   79,
+       78,   77,   76,   75,   74,   73,   72,   71,   70,   69,
+       68,   67,   66,   65,   62,   61,   60,   59,   58,   57,
+       56,   55,   54,   53,   52,   51,   50,   49,   48,   47,
+       46,   45,   44,   43,   42,   39,   35,   34,   31,   27,
 
-       25,   24,   23,   85,    3,   85,   85,   85,   85,   85,
+       26,   25,   24,   23,   85,    3,   85,   85,   85,   85,
        85,   85,   85,   85,   85,   85,   85,   85,   85,   85,
        85,   85,   85,   85,   85,   85,   85,   85,   85,   85,
-       85,   85,   85
+       85,   85,   85,   85,   85
     } ;
 
-static yyconst short int yy_chk[134] =
+static yyconst short int yy_chk[136] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    5,   15,
-        5,   17,   20,   24,   20,   15,   55,   15,   21,   21,
-       17,   38,   38,   55,   86,   24,   87,   83,   87,   87,
-       88,   88,   89,   89,   81,   78,   77,   76,   74,   72,
-       71,   69,   68,   66,   65,   64,   63,   61,   60,   59,
-       58,   57,   56,   54,   52,   49,   48,   47,   46,   45,
-       43,   41,   40,   39,   36,   35,   34,   33,   32,   31,
-       30,   28,   26,   25,   23,   19,   18,   16,   14,   13,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    5,
+       15,    5,   17,   20,   24,   20,   15,   55,   15,   21,
+       21,   17,   38,   38,   55,   86,   24,   87,   83,   87,
+       87,   88,   88,   89,   89,   81,   78,   77,   76,   74,
+       72,   71,   69,   68,   66,   65,   64,   63,   61,   60,
+       59,   58,   57,   56,   54,   52,   49,   48,   47,   46,
+       45,   43,   41,   40,   39,   36,   35,   34,   33,   32,
+       31,   30,   28,   26,   25,   23,   19,   18,   16,   14,
 
-       12,   11,   10,    3,   85,   85,   85,   85,   85,   85,
+       13,   12,   11,   10,    3,   85,   85,   85,   85,   85,
        85,   85,   85,   85,   85,   85,   85,   85,   85,   85,
        85,   85,   85,   85,   85,   85,   85,   85,   85,   85,
-       85,   85,   85
+       85,   85,   85,   85,   85
     } ;
 
 static yy_state_type yy_last_accepting_state;
@@ -569,7 +569,7 @@
 YY_DECL
        {
        register yy_state_type yy_current_state;
-       register char *yy_cp = NULL, *yy_bp = NULL;
+       register char *yy_cp, *yy_bp;
        register int yy_act;
 
 #line 13 "scanner.l"
@@ -632,7 +632,7 @@
                        yy_current_state = yy_nxt[yy_base[yy_current_state] + 
(unsigned int) yy_c];
                        ++yy_cp;
                        }
-               while ( yy_base[yy_current_state] != 105 );
+               while ( yy_base[yy_current_state] != 106 );
 
 yy_find_action:
                yy_act = yy_accept[yy_current_state];
@@ -747,7 +747,7 @@
 YY_RULE_SETUP
 #line 33 "scanner.l"
 {
-                               /* if you add or remove simbols, change 
canonize_vars
+                               /* if you add or remove symbols, change 
canonize_vars
                                   function */
                                yytext [strlen(yytext) - 1] = 0;
                                yylval.str = yytext + 1;
@@ -758,7 +758,7 @@
 YY_RULE_SETUP
 #line 40 "scanner.l"
 {
-                               /* if you add or remove simbols, change 
canonize_vars
+                               /* if you add or remove symbols, change 
canonize_vars
                                   function */
                                yytext [strlen(yytext) - 1] = 0;
                                yylval.str = yytext + 1;
diff -Naur gengetopt-2.1/src/scanner.l gengetopt/src/scanner.l
--- gengetopt-2.1/src/scanner.l Sat Jul  1 09:58:45 2000
+++ gengetopt/src/scanner.l     Wed Oct  4 22:21:20 2000
@@ -29,16 +29,16 @@
 [Oo][Nn]                                  yylval.bool = 1; return TOK_ONOFF;
 [Oo][Ff][Ff]                              yylval.bool = 0; return TOK_ONOFF;
 
-[[:alnum:]]                    yylval.chr = yytext[0]; return TOK_CHAR;
+[[:alnum:]-]                   yylval.chr = yytext[0]; return TOK_CHAR;
 \"[[:alnum:]][[:alnum:].-]*\"  {
-                               /* if you add or remove simbols, change 
canonize_vars
+                               /* if you add or remove symbols, change 
canonize_vars
                                   function */
                                yytext [strlen(yytext) - 1] = 0;
                                yylval.str = yytext + 1;
                                return TOK_STRING;
                                }
 \"[[:alnum:]][[:alnum:]. -]*\" {
-                               /* if you add or remove simbols, change 
canonize_vars
+                               /* if you add or remove symbols, change 
canonize_vars
                                   function */
                                yytext [strlen(yytext) - 1] = 0;
                                yylval.str = yytext + 1;



reply via email to

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