An interview with Larry Wall (LinuxVoice)
An interview with Larry Wall (LinuxVoice)
Posted Jul 17, 2015 16:21 UTC (Fri) by rsidd (subscriber, #2582)In reply to: An interview with Larry Wall (LinuxVoice) by nevets
Parent article: An interview with Larry Wall (LinuxVoice)
Nice! Speaking of incomprehensible symbols, take a look at the getopt()-style macros in the FreeBSD chat.c from earlier years (sadly, they got rid of it circa 2008 in favour of "standard" getopt; sadly, also, lwn doesn't seem to accept the PRE tag, which precludes me from cut-pasting without much tediousness).
Posted Jul 19, 2015 10:52 UTC (Sun)
by pr1268 (guest, #24648)
[Link] (1 responses)
Here are the getopt() macros (going off-topic)
/*************** Micro getopt() *********************************************/
#define OPTION(c,v) (_O&2&&**v?*(*v)++:!c||_O&4?0:(!(_O&1)&& \
(--c,++v),_O=4,c&&**v=='-'&&v[0][1]?*++*v=='-'\
&&!v[0][1]?(--c,++v,0):(_O=2,*(*v)++):0))
#define OPTARG(c,v) (_O&2?**v||(++v,--c)?(_O=1,--c,*v++): \
(_O=4,(char*)0):(char*)0)
#define ARG(c,v) (c?(--c,*v++):(char*)0)
God help whoever had to update/maintain that mess. I consider myself a fairly knowledgeable C programmer, but even that code makes me cringe...
Posted Jul 19, 2015 13:15 UTC (Sun)
by lsl (subscriber, #86508)
[Link]
There's also a variant (from the Inferno operating system) that supports arbitrary UTF8-encoded Unicode codepoints as flag characters:
Here are the getopt() macros (going off-topic)
https://bitbucket.org/inferno-os/inferno-os/src/tip/inclu...