[RFC] Mechanism for ordering options with getopt32

Mats Erik Andersson mats.andersson64 at comhem.se
Sat Apr 14 22:49:32 UTC 2007


Hello good folks,

let me show a proof of concept for a minimal
implementation to register the order in which
getopt32 parses options.

The difference file contains all additions
necessary, but should serve as a starting point 
for discussions, nothing more. I have tested
this against the getopt32-modified hexdump.c
that I proposed last week. The mechanism works
but requires code in the applet.

In the attached code I deliberately used an
upper limit of 15 recordable options (including
multiplicities). A major drawback, which causes
overhead in my hexdump, is that it is, inside the
code of getopt32, easily possible to catch the
on-flag of a used option, but it is really the
position within the option string that is relevant.
Thus any applet must de facto calculate a 
2-logarithm of the flag to recover a usable index.
The same problem would remain, should one record
the one letter symbol of the option instead of
its on-flag.

Feel free to ask me more, or simply to ignore
this request for comments. The idea and concept
to let getopt32 remember the ordering, originates
from a comment Denis Vlasenko made to my proposed
rewrite of hexdump.c.

Regards,    Mats E Andersson
-------------- next part --------------
A non-text attachment was scrubbed...
Name: order_for_getopt32.diff
Type: text/x-patch
Size: 1736 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20070415/fd62cc9e/attachment-0002.bin 


More information about the busybox mailing list