From owner-freebsd-chat Mon Jan 17 17: 6: 2 2000 Delivered-To: freebsd-chat@freebsd.org Received: from server.baldwin.cx (jobaldwi.campus.vt.edu [198.82.67.146]) by hub.freebsd.org (Postfix) with ESMTP id 7DE7314F7E for ; Mon, 17 Jan 2000 17:05:57 -0800 (PST) (envelope-from jhb@FreeBSD.org) Received: from john.baldwin.cx (john [10.0.0.2]) by server.baldwin.cx (8.9.3/8.9.3) with ESMTP id UAA01109 for ; Mon, 17 Jan 2000 20:05:52 -0500 (EST) (envelope-from jhb@FreeBSD.org) Message-Id: <200001180105.UAA01109@server.baldwin.cx> X-Mailer: XFMail 1.4.0 on FreeBSD X-Priority: 3 (Normal) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 8bit MIME-Version: 1.0 Date: Mon, 17 Jan 2000 20:05:52 -0500 (EST) From: John Baldwin To: chat@FreeBSD.org Subject: For any sick-in-the-head C programmers Sender: owner-freebsd-chat@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org 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 -- 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