[Toybox] [Patch] - long options with '-' separator

Ashwini Sharma ak.ashwini1981 at gmail.com
Wed Mar 19 03:00:38 PDT 2014


Hi Rob, List,

There are cases when the long options are of the format
abc-def. In current implementation FLAG_xxx macros are generated for
long options too. with __-__ sign in the macro, it will generate errors.

I am of the opinion that __-__ be converted to '_' for generating the
FLAG_xxx
macros and be used in the command.

This will enable the user to 'abc-def', but be handled like 'abc_def' in
code.

Use case for the same is in TAR

tar same-permissions ....

OR

tar no-same-owner ....

A patch modifying mkflags.c, to handle this is

--- a/scripts/mkflags.c 2014-03-17 02:57:38.000000000 +0530
+++ b/scripts/mkflags.c 2014-03-19 15:25:33.389610350 +0530
@@ -44,7 +44,7 @@
         blank->lopt = new;
         list = blank;
       }
-      while (*++string != ')');  // An empty longopt () would break this.
+      while (*++string != ')') if (*string == '-') *string = '_';  // An
empty longopt () would break this.
       *(string++) = 0;
       continue;
     }

Let me know your opinion on the same.

regards,
Ashwini
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20140319/1360de8a/attachment-0003.htm>


More information about the Toybox mailing list