From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (list@euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.5/8.7.3/2) with ESMTP id RAA24603 for ; Tue, 2 Jul 1996 17:36:50 +1000 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id DAA21097; Tue, 2 Jul 1996 03:25:24 -0400 (EDT) Resent-Date: Tue, 2 Jul 1996 03:25:24 -0400 (EDT) From: Zefram Message-Id: <1822.199607020724@stone.dcs.warwick.ac.uk> Subject: Sick macros (was: Action, not words (Re: bug (?) in 3.0-pre1)) To: schaefer@nbn.com Date: Tue, 2 Jul 1996 08:24:37 +0100 (BST) Cc: hzoli@cs.elte.hu, zsh-workers@math.gatech.edu In-Reply-To: <960630145016.ZM12277@candle.brasslantern.com> from "Bart Schaefer" at Jun 30, 96 02:50:13 pm X-Loop: zefram@dcs.warwick.ac.uk X-Stardate: [-31]7746.54 X-US-Congress: Moronic fuckers MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"2IPX62.0.Z95.axCsn"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/1501 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu Bart wrote: >2. Introduce macros for heapalloc/permalloc that start with an open > brace, and a macro for lastalloc that ends with a close brace, so > it's syntatically required that every heapalloc/permalloc have a > matching lastalloc. As this introduces a new block context, use a > block-local variable in heapalloc/permalloc to remember the state > of the useheap global, and test the block-local in lastalloc to > reset the global state appropriately. Probably a good idea, but as these macros now introduce new syntax let's make them *look* like syntax, rather than function calls. The 3.0-pre2-test patch contains: :+ # define heapalloc() do { \ :+ int nonlocal_useheap = useheap; \ :+ global_heapalloc() I recommend changing heapalloc() to heapalloc, and similarly removing the parentheses for permalloc and lastalloc. :+ # define lastalloc_return \ :+ if (nonlocal_useheap) global_heapalloc(); \ :+ else global_permalloc(); \ :+ return This won't work as the body of an if or while. The following is always safe: #define lastalloc_return \ if( (nonlocal_useheap ? global_heapalloc() : global_permalloc()) , 0 ) \ ; \ else \ return On a related point, I've been meaning to clean up execerr() in exec.c for a while: exec.c contains: $#define execerr() { if (forked) _exit(1); \ $ closemnodes(mfds); lastval = 1; return; } This should be #define execerr \ do { \ if(forked) _exit(1); \ closemnodes(mfds); \ lastval = 1; \ return; \ } while(0) It should then be invoked as "execerr;", rather than "execerr()" (whereas it's currently *actually* being invoked as "execerr();"). YYERROR and YYERRORV in parse.c have a similar problem (they need do ... while(0) bracketing -- and this actually affected me when producing a recent patch). -zefram