bug-findutils
[Top][All Lists]
Advanced

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

Re: [PATCH] Error message clarification


From: James Youngman
Subject: Re: [PATCH] Error message clarification
Date: Sat, 31 Mar 2007 19:14:24 +0100

On 3/31/07, address@hidden <address@hidden> wrote:
When a predicate is not syntactically correct, the find parser
will currently say:

  "invalid predicate `%s'"

which IMO obscures the fact that the predicate NAME may be alright, but
the number or format of parameters didn't match.

How about this patch, which gives a more specific error?


$ cvs -z3 diff -upN find/tree.c
Index: find/tree.c
===================================================================
RCS file: /cvsroot/findutils/findutils/find/tree.c,v
retrieving revision 1.29
diff -u -p -r1.29 tree.c
--- find/tree.c 7 Mar 2007 23:18:38 -0000       1.29
+++ find/tree.c 31 Mar 2007 18:13:24 -0000
@@ -1337,19 +1337,26 @@ build_expression_tree(int argc, char *ar
      oldi = i;
      if (!(*(parse_entry->parser_func)) (parse_entry, argv, &i))
       {
-         if (oldi == i)
+         if (argv[i])
           {
-             error (1, 0, _("invalid predicate `%s'"),
-                    predicate_name);
+             if ( (ARG_SPECIAL_PARSE == parse_entry->type) && (i == oldi) )
+               {
+                 /* The special parse function spat out the
+                  * predicate.  It must be invalid, or not tasty.
+                  */
+                 error (1, 0, _("invalid predicate `%s'"),
+                        argv[i], predicate_name);
+               }
+             else
+               {
+                 error (1, 0, _("invalid argument `%s' to `%s'"),
+                        argv[i], predicate_name);
+               }
           }
         else
           {
-             if (argv[i] == NULL)
-               /* Command line option requires an argument */
-               error (1, 0, _("missing argument to `%s'"), predicate_name);
-             else
-               error (1, 0, _("invalid argument `%s' to `%s'"),
-                      argv[i], predicate_name);
+             /* Command line option requires an argument */
+             error (1, 0, _("missing argument to `%s'"), predicate_name);
           }
       }
      else




reply via email to

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