[vox-tech] writing free getopt, ran into a dilemma...

Mark K. Kim vox-tech@lists.lugod.org
Sat, 30 Mar 2002 19:33:35 -0800 (PST)


I tried using increment_optind() technique as Micah suggested, but I found
some technical limitation.  I couldn't find any way to do it without
allocating memory in heap, and I couldn't free it safely without breaking
compatibility.

After reading Mike's [very detailed] posts :), I decided permuting argv[]
is not a bad idea.  So I implemented getopt() using the permuting
technique.

I'd appreciate it if anybody could check it out and give me a feedback.
You can download the file from:

   http://www.cbreak.org/tmp/

I've implemented *EVERYTHING* :)  The "-" and the "+" and the ":" and the
"::" and the "POSIXLY_CORRECT", and the "--".  At least, I *think* that's
everything.  Please let me know if you find any bugs, incompatibilities,
or anything else.

Thanks!

-Mark

--
Mark K. Kim
http://www.cbreak.org/
PGP key available upon request.