[comp.lang.c++] Alternate +i option to CC

mikem@otc.oz (Mike Mowbray) (10/26/87)

Here's a small mod to the way the CC script handles the +i option.
It is intended to make the ..c code more readable.

Where CC has:

	if test "$PLUSI"	#leave ..c's lying around
	...

use the following instead:

	if test "$PLUSI"	#leave ..c's lying around
	then
					#remove #line's from the ..c's for sdb
		for f in $C
		do
			echo "Beautifying $f"
			sed "/^#/d" $f | cb -s -j | postcb > temp$$
			mv temp$$ $f
		done
	fi

Where "postcb" is just the following shell script:

    sed  -e 's/\([A-Za-z_0-9(]\) *( */\1(/g
	     s/ *)/)/g
	     s/ *\*)/\*)/g
	     s/ *;/;/g
	     s/ *,/,/g
	     s/ *\. */\./g
	     s/ *-> */->/g
	     s/ *\[/\[/g
	     s/ *\]/\]/g
	     s/\([	 ]\)for(/\1for (/g
	     s/\([	 ]\)if(/\1if (/g
	     s/\([	 ]\)while(/\1while (/g
	     s/\([	 ]\)switch(/\1switch (/g
	     s/\([	 ]\)return(/\1return (/g
	     s/	/    /g'

Note that for bsd systems the -j option to cb may not work, so the result will be less good.

Later on, where __ctdt.c is removed you may also wish to include the following:

				if test "$PLUSI" != 1
				then
					rm __ctdt.c
				fi
    ........

    if	test "$R" 
    then
	    if test ! "$PLUSI"
	    then
		    rm $C
	    fi
    fi

Running this version of the +i option can take a while, but you'd only use
it occasionally to see what was going on.


			Mike Mowbray
		    Systems Development
			|||| OTC ||

    ACSnet:  mikem@otc.oz	UUCP:  {uunet,mcvax}!otc.oz!mikem 
     Phone:  +61 2 287 4104	Snail:  GPO Box 7000, Sydney 2001, Australia