bison-patches
[Top][All Lists]
Advanced

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

getargs missing/extra operands nicety for Bison


From: Paul Eggert
Subject: getargs missing/extra operands nicety for Bison
Date: Mon, 21 Oct 2002 11:17:29 -0700 (PDT)

This is a little nicety that follows up on 02-usage.patch
<http://mail.gnu.org/pipermail/bison-patches/2002-October/001236.html>

2002-10-21  Paul Eggert  <address@hidden>

        * src/getargs.c (getargs): When there are too few operands, report
        the last one.  When there are too many, report the first extra
        one.  This is how diffutils does it.

--- getargs.c.~1.43.~   2002-10-19 07:36:40.000000000 -0700
+++ getargs.c   2002-10-21 11:12:43.797960000 -0700
@@ -1,5 +1,5 @@
 /* Parse command line arguments for bison.
-   Copyright 1984, 1986, 1989, 1992, 2000, 2001, 2002
+   Copyright (C) 1984, 1986, 1989, 1992, 2000, 2001, 2002
    Free Software Foundation, Inc.
 
    This file is part of Bison, the GNU Compiler Compiler.
@@ -410,11 +410,12 @@ getargs (int argc, char *argv[])
        exit (1);
       }
 
-  if (optind != argc - 1)
+  if (argc - optind != 1)
     {
-      error (0, 0,
-            (optind == argc
-             ? _("too few arguments") : _("too many arguments")));
+      if (argc - optind < 1)
+       error (0, 0, _("missing operand after `%s'"), argv[argc - 1]);
+      else
+       error (0, 0, _("extra operand `%s'"), argv[optind + 1]);
       usage (EXIT_FAILURE);
     }
 




reply via email to

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