Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 17 Jan 2000 20:05:52 -0500 (EST)
From:      John Baldwin <jhb@FreeBSD.org>
To:        chat@FreeBSD.org
Subject:   For any sick-in-the-head C programmers
Message-ID:  <200001180105.UAA01109@server.baldwin.cx>

next in thread | raw e-mail | index | archive | help
This code was "discovered" in src/usr.bin/chat/chat.c during -Wall fixups. 
Please, go grab a trashcan before you read this so you don't mess up your
keyboard:

From line 142 and following:

/*************** 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 OPTONLYARG(c,v) (_O&2&&**v?(_O=1,--c,*v++):(char*)0)
#define ARG(c,v)        (c?(--c,*v++):(char*)0)

static int _O = 0;              /* Internal state */
/*************** Micro getopt() *********************************************/

-- 

John Baldwin <jhb@FreeBSD.org> -- http://www.FreeBSD.org/~jhb/
PGP Key: http://www.cslab.vt.edu/~jobaldwi/pgpkey.asc
"Power Users Use the Power to Serve!"  -  http://www.FreeBSD.org/


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-chat" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200001180105.UAA01109>