unhelpful error message: unknown option ""

View: New views
3 Messages — Rating Filter:   Alert me  

unhelpful error message: unknown option ""

by John Hein :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

After updating from 2.2.6 to 2.2.9, I had a problem with the
--no-parameter-indentation option I was using.

As it turns out, it was removed in favor of using
just --parameter-indentation0.  The documentation was not
updated.  That's a different bug.

When I tried to use 2.2.9 for the first time, I got this:

% indent -npro -nip
indent: unknown option ""
% indent -npro --no-parameter-indentation
indent: unknown option ""

That's not a very useful error message.  It looks like somewhere
between 2.2.6 & 2.2.9, it was broken due to a new way that long/short
options are parsed.

Note that it was broken in a different way in 2.2.6 (didn't print the
same # of dashes used on the command line - or didn't strip them
correctly), but at least it was more useful.

Anyway, here's a patch to fix the error message.


--- args.c.orig Sun Nov 10 14:02:48 2002
+++ args.c Wed Nov  2 12:24:15 2005
@@ -714,7 +714,7 @@
 
     if (!found)
     {
-        fprintf (stderr, _("indent: unknown option \"%s\"\n"), option - 1);
+        fprintf (stderr, _("indent: unknown option \"%s\"\n"), option);
         exit (invocation_error);
     }
     else


_______________________________________________
Bug-indent mailing list
Bug-indent@...
http://lists.gnu.org/mailman/listinfo/bug-indent

Re: unhelpful error message: unknown option ""

by John Hein :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

John E Hein wrote at 12:34 -0700 on Nov  2, 2005:
 > After updating from 2.2.6 to 2.2.9, I had a problem with the
 > --no-parameter-indentation option I was using.
 >
 > As it turns out, it was removed in favor of using
 > just --parameter-indentation0.  The documentation was not
 > updated.  That's a different bug.

Sorry that part was a hasty guess.  So it hasn't been removed.

It turns out there is another bug, but it's the option table setup for
"nip" if BERKELEY_DEFAULTS [*] is defined.  It's missing the extra NUL
in the p_obj field.

This causes the loop in the PRO_SETTINGS case of the p_type switch in
set_options() to overrun a buffer and walk off into uncharted memory
recursively calling set_options again until it sees a double NUL in
the random memory or exits for other reasons.  In my case, it always
seems to die with "unknown option" before it gets too far.

I am running the FreeBSD port (defines BERKELEY_DEFAULTS), which is
why I noticed.

[*] The mostly duplicated initialization of the opts table with and
without BERKELEY_DEFAULTS is a design bug, IMO.

Here's a new and improved patch that includes a fix for this and the
fix for the previously reported error message bug...

--- args.c.orig Sun Nov 10 14:02:48 2002
+++ args.c Wed Nov  2 13:29:11 2005
@@ -230,7 +230,7 @@
     {"npcs",    PRO_BOOL,                           false,      OFF, &settings.proc_calls_space,                 &exp_pcs},
     {"nlps",    PRO_BOOL,                           false,      OFF, &settings.leave_preproc_space,              &exp_lps},
     {"nlp",     PRO_BOOL,                            true,      OFF, &settings.lineup_to_parens,                 &exp_lp},
-    {"nip",     PRO_SETTINGS,                           0, ONOFF_NA, (int *) "-ip0",                             &exp_nip},
+    {"nip",     PRO_SETTINGS,                           0, ONOFF_NA, (int *) "-ip0\0",                             &exp_nip},
     {"nhnl",    PRO_BOOL,                            true,      OFF, &settings.honour_newlines,                  &exp_hnl},
     {"nfca",    PRO_BOOL,                            true,      OFF, &settings.format_comments,                  &exp_fca},
     {"nfc1",    PRO_BOOL,                            true,      OFF, &settings.format_col1_comments,             &exp_fc1},
@@ -714,7 +714,7 @@
 
     if (!found)
     {
-        fprintf (stderr, _("indent: unknown option \"%s\"\n"), option - 1);
+        fprintf (stderr, _("indent: unknown option \"%s\"\n"), option);
         exit (invocation_error);
     }
     else



_______________________________________________
Bug-indent mailing list
Bug-indent@...
http://lists.gnu.org/mailman/listinfo/bug-indent

[patch] -nip fails with BERKELEY_DEFAULTS (still a problem with 2.2.10)

by John Hein :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

1) fix 'indent -npro -nip' when compiled with BERKELEY_DEFAULTS

   symptom:
    command line: unknown option "nhnl"

   Note that the "nhnl" above is just luck due to layout by the compiler.  It
   could be random garbage.

   explanation: PRO_SETTINGS lists need to be terminated with two nulls.


2) fix error message for args prefixed with '--', like 'indent -npro --no-such-arg'

   symptom:
    command line: unknown option "-no-such-arg"

   explanation: the error message uses 'option - 1' instead of 'option - option_length'
    and -- options have option_length == 2.


Note: These bugs were mentioned in the thread shown below, but the
original patch has been refreshed for 2.2.10 and the second hunk was
wrong in the original - new patch attached...

http://lists.gnu.org/archive/html/bug-indent/2005-11/msg00001.html


1) fix 'indent -npro -nip' when compiled with BERKELEY_DEFAULTS

   symptom:
    command line: unknown option "nhnl"

   Note that the "nhnl" above is just luck due to layout by the compiler.  It
   could be random garbage.

   explanation: PRO_SETTINGS lists need to be terminated with two nulls.

2) fix error message for args prefixed with '--', like 'indent -npro --no-such-arg'

   symptom:
    command line: unknown option "-no-such-arg"

   explanation: the error message uses 'option - 1' instead of 'option - option_length'
    and -- options have option_length == 2.

--- args.c.orig 2008-03-11 12:50:42.000000000 -0600
+++ args.c 2009-02-15 10:55:04.000000000 -0700
@@ -282,7 +282,7 @@
     {"npcs",    PRO_BOOL,                           false,      OFF, &settings.proc_calls_space,                 &exp_pcs},
     {"nlps",    PRO_BOOL,                           false,      OFF, &settings.leave_preproc_space,              &exp_lps},
     {"nlp",     PRO_BOOL,                            true,      OFF, &settings.lineup_to_parens,                 &exp_lp},
-    {"nip",     PRO_SETTINGS,                           0, ONOFF_NA, (int *) "-ip0",                             &exp_nip},
+    {"nip",     PRO_SETTINGS,                           0, ONOFF_NA, (int *) "-ip0\0",                           &exp_nip},
     {"nhnl",    PRO_BOOL,                            true,      OFF, &settings.honour_newlines,                  &exp_hnl},
     {"nfca",    PRO_BOOL,                            true,      OFF, &settings.format_comments,                  &exp_fca},
     {"nfc1",    PRO_BOOL,                            true,      OFF, &settings.format_col1_comments,             &exp_fc1},
@@ -798,7 +798,8 @@
 
     if (!found)
     {
-        DieError(invocation_error, _("%s: unknown option \"%s\"\n"), option_source, option - 1);
+        DieError(invocation_error, _("%s: unknown option \"%s\"\n"),
+            option_source, option - option_length);
     }
     else
     {

_______________________________________________
bug-indent mailing list
bug-indent@...
http://lists.gnu.org/mailman/listinfo/bug-indent