]> granicus.if.org Git - flex/commitdiff
parse multiple short concatenated options; patch submitted by Petr Machata <pmachata...
authorWill Estes <wlestes@users.sourceforge.net>
Sat, 12 May 2007 13:11:57 +0000 (13:11 +0000)
committerWill Estes <wlestes@users.sourceforge.net>
Sat, 12 May 2007 13:11:57 +0000 (13:11 +0000)
scanopt.c

index cc7f63198122e0fb42c5267319c468e750fdfb19..2c8d59319dbf184a2f7191b0c8647de1fc44a0e0 100644 (file)
--- a/scanopt.c
+++ b/scanopt.c
@@ -789,12 +789,12 @@ int     scanopt (svoid, arg, optindex)
                }
 
                optarg = pstart + 1;
-               arglen = 0;
-               while (optarg[arglen])
-                       arglen++;
-
-               if (arglen == 0)
+               if (!*optarg) {
                        optarg = NULL;
+                       arglen = 0;
+               }
+               else
+                       arglen = strlen (optarg);
        }
 
        /* At this point, we have a long or short option matched at opt_offset into
@@ -812,13 +812,16 @@ int     scanopt (svoid, arg, optindex)
 
        /* case: no args allowed */
        if (auxp->flags & ARG_NONE) {
-               if (optarg) {
+               if (optarg && !is_short) {
                        scanopt_err (s, opt_offset, is_short, errcode =
                                     SCANOPT_ERR_ARG_NOT_ALLOWED);
                        INC_INDEX (s, 1);
                        return errcode;
                }
-               INC_INDEX (s, 1);
+               else if (!optarg)
+                       INC_INDEX (s, 1);
+               else
+                       s->subscript++;
                return optp->r_val;
        }