phil@osiris.UUCP (Philip Kos) (11/21/85)
I'm looking for a way to do partial preprocessing of C programs. What I'm talking about is selectively #defining one (or more) preprocessor variables or macros in the source code and expanding it (them) while leaving all others untouched. I want any occurrences of the variables or macros in the source code (and particularly #if/#ifdef code) to be expanded. Is there a way to do this using cpp that I've been missing? If not, could m4 do something like this? (It would have to imitate the Reiser cpp to perform correctly, so I have my doubts about m4...) If none of the preprocessors can handle it, is there a program anywhere which implements this function? We have something here on our Pyramid called 'unifdef', which is located in /usr/ucb and seems to be from Berkeley (according to the sccs header). I can't find any documentation on it, though. If this *is* an official BSD distribution-type command, could somebody please explain to me how it works (or at least what it does) - I don't really have the time to figure it out empirically. If I get no leads from this posting, I may well write something like this myself (whenever I manage to find the time!!). If I do, would anybody else out there be interested in a copy? Phil Kos "Woo!" The Johns Hopkins Hospital - Trent Phlooog Baltimore, MD ...!gamma!cp1 v ...!decvax!decuac -> !aplvax!osiris!phil <- ...!unc!brl-bmd ^ ...!allegra!umcp-cs
larryv@chinet.UUCP (Larry W. Virden) (11/26/85)
Along similar lines to the partial preprocessor (which was posted in the not too distant past...) I would like to find a "de-processor"... That is, a program which could be given a series of defines and would make substitions within the text appropriately, as an inverse to a preprocessor. Thus, if I said: #define MAXLEN 256 occurances of 256 would be replaced with MAXLEN ... If I said #define ADD(x,y) ((x) + (y)) Then a = b + c; would be replaced with a = ADD(b,c); This type of program has its various uses. P.S. Does anyone have an EASY to use filter which performs standard "regular expression" replacements within a file? I know that some UNIX systems have SED(1) - I am looking for something much simpler to use: replace 'a[B-Z]' 'A&' < file1 > file2 or something similar. Thanks -- Larry W. Virden A user of the Free Access chinet board... ...!chinet!larryv