Macro parameters getting substituted into strings
Karl Heuer
karl at haddock.ISC.COM
Wed Mar 30 07:53:29 AEST 1988
In article <8035 at elsie.UUCP> ado at 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 at haddock.isc.com), The Walking Lint
(Actually I prefer ((c)^0x40), but that's irrelevant to this article.)
More information about the Comp.lang.c
mailing list