Path: utzoo!utgpu!water!watmath!clyde!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: Macro parameters getting substituted into strings Message-ID: <3222@haddock.ISC.COM> Date: 29 Mar 88 21:53:29 GMT References: <11879@brl-adm.ARPA> <4099@hoptoad.uucp> <7309@brl-smoke.ARPA> <4253@hoptoad.uucp> <8035@elsie.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 13 In article <8035@elsie.UUCP> ado@elsie.UUCP (Arthur David Olson) writes: >Here's an example (taken from "/usr/include/sys/ttychars.h") of how we coped >with the problem [of ANSI C not having a charizing operator] here at elsie... > #define LETR_a 'a' [ditto for all of 'a'..'z', 'A'..'Z'] > #define CTRL(c) ((LETR_ ## c) & 037) Since you have to edit the source file anyway, why don't you just do it right in the first place? 1,$s/CTRL(\(.\))/CTRL('\1')/g /^#define CTRL/s/.*/#define CTRL(c) ((c) & 037)/ Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint (Actually I prefer ((c)^0x40), but that's irrelevant to this article.)