From owner-freebsd-hackers Fri Apr 26 7:23:17 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from chiark.greenend.org.uk (chiark.greenend.org.uk [212.22.195.2]) by hub.freebsd.org (Postfix) with ESMTP id 7D6BC37B400 for ; Fri, 26 Apr 2002 07:23:10 -0700 (PDT) Received: from fanf by chiark.greenend.org.uk with local (Exim 3.12 #1) id 1716cc-0006Lw-00 (Debian); Fri, 26 Apr 2002 15:22:50 +0100 Date: Fri, 26 Apr 2002 15:22:50 +0100 From: Tony Finch To: freebsd-hackers@freebsd.org Cc: dot@dotat.at Subject: improved unifdef(1) Message-ID: <20020426152250.B18410@chiark.greenend.org.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG The unifdef in the system is not suited to heavyweight tasks like (say) xterm's main.c or wu-ftpd for a number of reasons: * it has a very low limit on the number of command-line arguments that it can cope with (100) -- I've sumbitted PR#37454 about this. * it doesn't have the slightest clue about #elif * it doesn't attempt to handle #if Because I needed an unifdef with a bit more oomph and couldn't find a better one, I have done my own tune-up job on the BSD one, starting from the NetBSD sources (which seemed to have a mostly-superset of the changes made by the other BSDs). It's available from . The detailed change list is below. Note that only a very limited subset of #if expressions are understood, involving just defined(), !, &&, ||, and brackets. If anyone is interested I'd appreciate some testing, and it would be nice to get it committed eventually. Tony. -- f.a.n.finch http://dotat.at/ NORTH UTSIRE SOUTH UTSIRE: SOUTHEASTERLY VEERING WESTERLY 6 OR 7, OCCASIONALLY GALE 8 IN NORTH UTSIRE. RAIN THEN SHOWERS. MODERATE BECOMING GOOD. 2002/04/25 14:50:23 fanf import from NetBSD 2002/04/25 14:52:54 fanf revert to the CSRG copyright/sccs rubric and add $dotat$ 2002/04/25 14:55:27 fanf remove __P 2002/04/25 14:57:56 fanf remove BSS cruft 2002/04/25 14:59:59 fanf allow a reasonable number of symbols 2002/04/25 15:02:48 fanf move #endif comments to a better place 2002/04/25 15:31:28 fanf deal with -Dsym=value 2002/04/25 15:37:25 fanf sensible else if formatting 2002/04/25 15:51:42 fanf another formatting improvement 2002/04/25 16:03:16 fanf use err() 2002/04/25 16:04:55 fanf style: #include ordering; variable alignment 2002/04/25 16:05:30 fanf remove spurious fflush() 2002/04/25 16:11:54 fanf add a function that will evaluate if expressions 2002/04/25 16:12:23 fanf fix location of a { 2002/04/25 16:16:26 fanf allow whitespace before # 2002/04/25 18:10:00 fanf Initial version of #if handling. Symbol 0 is used for tracking the state of #if/#else activity. TODO: #elif, nested #if 2002/04/25 18:15:23 fanf use __RCSID for the sccs id and remove redundant #ifndef lint lines 2002/04/25 18:17:09 fanf Restore the requirement that at least one -D or -U must be present on the command line, which was broken when #if handling was added. 2002/04/25 18:45:54 fanf purge LT_OTHER since it's a synonym for LT_IF 2002/04/25 19:59:46 fanf Simplify doif()'s inif argument to just a boolean, since the IN_ELSE value isn't very different from IN_IF, and the idea doesn't work well with #elif. 2002/04/25 20:20:05 fanf Move the gall to getlin() up to doif() so that it will be able to examine the same line more than once. 2002/04/25 20:24:16 fanf Remove the inif argument to doif() entirely, since inif == (depth != 0). 2002/04/25 21:19:55 fanf remove an unnecessary variable inside doif() 2002/04/25 21:43:07 fanf Change the "unknown symbol" return value from findsym() from -1 to 0. 2002/04/25 21:44:51 fanf fix a comment to reflect the previous change 2002/04/25 23:02:51 fanf simplify error handling 2002/04/25 23:25:31 fanf simplify error line number handling 2002/04/25 23:27:40 fanf remove redundant stline variable 2002/04/25 23:46:55 fanf partial implementation of #elif and properly nesting #ifs. 2002/04/26 13:51:41 fanf Finish implementation of #elif and nesting. This version passes some initial tests. 2002/04/26 13:54:16 fanf put the newline on the #endif that replaces #elif lines To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message