Assemble '*' repeated argument list in order. Also implement '@' counter.
authorRob Landley <rob@landley.net>
Tue, 17 Jun 2008 00:27:35 +0000 (19:27 -0500)
committerRob Landley <rob@landley.net>
Tue, 17 Jun 2008 00:27:35 +0000 (19:27 -0500)
lib/args.c

index 6103bb0..ee915b4 100644 (file)
@@ -121,15 +121,14 @@ static int gotflag(struct getoptflagstate *gof)
                        error_exit("Missing argument");
                if (type == ':') *(opt->arg) = (long)gof->arg;
                else if (type == '*') {
-                       struct arg_list *temp, **list;
+                       struct arg_list **list;
+
                        list = (struct arg_list **)opt->arg;
-                       temp = xmalloc(sizeof(struct arg_list));
-                       temp->arg = gof->arg;
-                       temp->next = *list;
-                       *list = temp;
+                       while (*list) list=&((*list)->next);
+                       *list = xzalloc(sizeof(struct arg_list));
+                       (*list)->arg = gof->arg;
                } else if (type == '#') *(opt->arg) = atolx((char *)gof->arg);
-               else if (type == '@') {
-               }
+               else if (type == '@') ++*(opt->arg);
 
                gof->arg = "";
        }