[comp.windows.x] using cpp to process shell scripts

ejh@SEI.CMU.EDU (erik) (07/13/90)

mephisto!prism!rhoward@rutgers.edu..(Robert.L..Howard) writes:

>When using cpp to process the source to a script file, cpp always
>puts a blank line in the output for everytime it encounters a
>#directive or a /*comment*/.  (This is SunOS 4.1)  Is this normal
>behavior?  If so, why?  It really makes the resulting shell script 
>messy with all those blank lines...

Yes, this is normal behavior. Remember that cpp is the *C* preprocessor, and,
as such, is set up to help you with C. The reason it does this is so that,
when you have errors, the line numbers are correct.

(BTW, I presume you meant whole line comments: cpp replaces everything
between /* and */ with spaces.)

I agree with you that it makes the scripts messy. I don't like it when
#ifdef foo
do-one-thing
#else
do-the-other-thing
#endif

turns into (if foo is not defined)
<blank line>
do-the-other-thing
<blank line>

It makes my Makefile look messy if I have commands both before and after this
clause. I don't know about m4, but does anyone have a cpp-like thing that
doesn't keep line numbers. (Yeah, I know: it makes debugging tough, but I
could always use regular cpp for that).

Erik Hardy (erik@sei.cmu.edu)
SEI/User Interface Project

yaccity yacc (don't awk back)

guy@auspex.auspex.com (Guy Harris) (07/15/90)

>I don't know about m4, but does anyone have a cpp-like thing that
>doesn't keep line numbers. (Yeah, I know: it makes debugging tough, but I
>could always use regular cpp for that).

You could try grabbing the DECUS "cpp", which is in the "mit/util/cpp"
directory in the X11R4 source, and whacking on that as necessary....