about summary refs log tree commit diff
path: root/argp/argp-parse.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1998-09-07 13:47:26 +0000
committerUlrich Drepper <drepper@redhat.com>1998-09-07 13:47:26 +0000
commit94b78bb204a9606254c1088a4bb6fa00859a9d82 (patch)
treeb674ea60e2de891aeaeaf66a9f487c98f9de79a5 /argp/argp-parse.c
parentcf9f9a168619810ef2bd1b67f9f1db53bd235dc4 (diff)
downloadglibc-94b78bb204a9606254c1088a4bb6fa00859a9d82.tar.gz
glibc-94b78bb204a9606254c1088a4bb6fa00859a9d82.tar.xz
glibc-94b78bb204a9606254c1088a4bb6fa00859a9d82.zip
Update.
	* argp/argp-help.c: Likewise.
	* argp/argp-parse.c: Likewise.
Diffstat (limited to 'argp/argp-parse.c')
-rw-r--r--argp/argp-parse.c100
1 files changed, 53 insertions, 47 deletions
diff --git a/argp/argp-parse.c b/argp/argp-parse.c
index e2ddd6d361..e59f614a05 100644
--- a/argp/argp-parse.c
+++ b/argp/argp-parse.c
@@ -605,39 +605,43 @@ parser_finalize (struct parser *parser,
     err = 0;
 
   if (! err)
-    if (parser->state.next == parser->state.argc)
-      /* We successfully parsed all arguments!  Call all the parsers again,
-	 just a few more times... */
-      {
-	for (group = parser->groups;
-	     group < parser->egroup && (!err || err==EBADKEY);
-	     group++)
-	  if (group->args_processed == 0)
-	    err = group_parse (group, &parser->state, ARGP_KEY_NO_ARGS, 0);
-	for (group = parser->groups;
-	     group < parser->egroup && (!err || err==EBADKEY);
-	     group++)
-	  err = group_parse (group, &parser->state, ARGP_KEY_END, 0);
-
-	if (err == EBADKEY)
-	  err = 0;		/* Some parser didn't understand.  */
-
-	/* Tell the user that all arguments are parsed.  */
-	if (end_index)
-	  *end_index = parser->state.next;
-      }
-    else if (end_index)
-      /* Return any remaining arguments to the user.  */
-      *end_index = parser->state.next;
-    else
-      /* No way to return the remaining arguments, they must be bogus. */
-      {
-	if (!(parser->state.flags & ARGP_NO_ERRS) && parser->state.err_stream)
-	  fprintf (parser->state.err_stream,
-		   dgettext (parser->argp->argp_domain,
-			     "%s: Too many arguments\n"), parser->state.name);
-	err = EBADKEY;
-      }
+    {
+      if (parser->state.next == parser->state.argc)
+	/* We successfully parsed all arguments!  Call all the parsers again,
+	   just a few more times... */
+	{
+	  for (group = parser->groups;
+	       group < parser->egroup && (!err || err==EBADKEY);
+	       group++)
+	    if (group->args_processed == 0)
+	      err = group_parse (group, &parser->state, ARGP_KEY_NO_ARGS, 0);
+	  for (group = parser->groups;
+	       group < parser->egroup && (!err || err==EBADKEY);
+	       group++)
+	    err = group_parse (group, &parser->state, ARGP_KEY_END, 0);
+
+	  if (err == EBADKEY)
+	    err = 0;		/* Some parser didn't understand.  */
+
+	  /* Tell the user that all arguments are parsed.  */
+	  if (end_index)
+	    *end_index = parser->state.next;
+	}
+      else if (end_index)
+	/* Return any remaining arguments to the user.  */
+	*end_index = parser->state.next;
+      else
+	/* No way to return the remaining arguments, they must be bogus. */
+	{
+	  if (!(parser->state.flags & ARGP_NO_ERRS)
+	      && parser->state.err_stream)
+	    fprintf (parser->state.err_stream,
+		     dgettext (parser->argp->argp_domain,
+			       "%s: Too many arguments\n"),
+		     parser->state.name);
+	  err = EBADKEY;
+	}
+    }
 
   /* Okay, we're all done, with either an error or success; call the parsers
      to indicate which one.  */
@@ -849,20 +853,22 @@ parser_parse_next (struct parser *parser, int *arg_ebadkey)
     opt = KEY_END;
 
   if (opt == KEY_END)
-    /* We're past what getopt considers the options.  */
-    if (parser->state.next >= parser->state.argc
-	|| (parser->state.flags & ARGP_NO_ARGS))
-      /* Indicate that we're done.  */
-      {
-	*arg_ebadkey = 1;
-	return EBADKEY;
-      }
-    else
-      /* A non-option arg; simulate what getopt might have done.  */
-      {
-	opt = KEY_ARG;
-	optarg = parser->state.argv[parser->state.next++];
-      }
+    {
+      /* We're past what getopt considers the options.  */
+      if (parser->state.next >= parser->state.argc
+	  || (parser->state.flags & ARGP_NO_ARGS))
+	/* Indicate that we're done.  */
+	{
+	  *arg_ebadkey = 1;
+	  return EBADKEY;
+	}
+      else
+	/* A non-option arg; simulate what getopt might have done.  */
+	{
+	  opt = KEY_ARG;
+	  optarg = parser->state.argv[parser->state.next++];
+	}
+    }
 
   if (opt == KEY_ARG)
     /* A non-option argument; try each parser in turn.  */