Speaking of getopt, what do commercial products use these days for parsing command-line options? getopt is GPL; is there a similar library with a zlib-style license?
>>19 getopt isn't ``GPL''. As a concept it's part of POSIX, and there are many different implementations under many licenses.
The GNU version does have some GNU-specific extensions (getopt_long and getopt_long_only), and obviously that library is licensed under the GPL. Is that what you were thinking of?
As far as I know, commercial products don't parse command line options at all, and just stick a giant configuration GUI in front of it, or get options from XML.
Name:
Anonymous2009-12-22 0:43
>>21
Ah I see. I didn't realize it was in POSIX. Googling "free getopt" brought me to, fittingly enough, freegetopt.sourceforge.net .
>>25
GNU also supports long options, which makes parsing a bit less straightforward, and has a few extra functions in there.
Also, like two thirds of that is comments.
Name:
Anonymous2009-12-22 8:09
>>27
So you're off not by a factor of 60 at least, but only by factor of 30 or so? Read the source, there are not so many comments really.
Whatever, I dare you to write your own POSIX-compliant getopt implementation. That would be a "few" minutes well-spent, homosexual!
>>28 So you
I don't know who you think you're talking to. POSIX getopt is really straightforward, though. Even /prog/ should be able to write an implementation.
Here's my C to Brainfuck compiler, written in perl:
foreach(<>){
s/++ptr;/>/;
s/--ptr;/</;
s/++\*ptr;/+/;
s/--\*ptr;/-/;
s/putchar\(\*ptr\);/./;
s/putchar\(\*ptr\);/,/;
s/while \(\*ptr\) {/[/;
s/}/]/;
print;
}
It doesn't quite support the whole C standard, though.
All I can say to this is lol. This is basically the exact experience that I have had with the post-secondary institutions within the United States. I can honestly say that for the majority that professors and the institution wish to stifle creativity and independent thought. The narrow minded answers they want completely disregard the plethora of other choices that would reveal the correct answer. Whether or not the story is true, this is the attitude of the American educational institute, for those that think outside the box continue to. Revolutionist, non-conventionalist, and the blatant disregard for normalcy are the fundamentals to continuing our species in the area of science.
Name:
Anonymous2009-12-25 7:26
>>51
is right. I ran the code and it cut my fucking dick off!