Bizarre Bourne Shell

ado at elsie.UUCP ado at elsie.UUCP
Fri May 18 12:53:19 AEST 1984


sdccsu3!hardy--
>	I will not even comment on those brain-damaged individuals who insist
>	upon "improving" the C language with macros like IF, THEN, ELSE . . . .

CS-Arthur!avr--
>	But I will. It's done in 'adb', too, which I'm doing something with,
>	and its a royal pain - looks ugly as BabaYaga, too. UGH!

Rather than bemoaning the situation, perhaps the thing to do is overcome it.
The shell file below may be a start on doing so.  If, on a 4.1bsd system,
you name it "reborn" and then use the command
	reborn filename
where "filename" is the name of a Bourne-style C program,
a "more-traditional" version of the source code is written to the standard
output.

The script below is a quick hack, so expect the worst--little testing was done.
Surely a more portable and otherwise improved version can be created.
Is doing so worth it?  Is anyone up to it?
----------------SHELL SCRIPT STARTS AT THE NEXT LINE-----------------------
: The superfluous cat below makes up for the fact that cb gives a bogus
: exit status on some systems.
ex - $1 << 'THIS IS WHAT TO LOOK FOR' | tr -d "\015" | cb | cat
g/\<LOCAL\>/s//static/g
g/\<PROC\>/s//extern/g
g/\<TYPE\>/s//typedef/g
g/\<STRUCT\>/s//typedef struct/g
g/\<UNION\>/s//typedef union/g
g/\<REG\>/s//register/g
g/\<IF\>/s//if(/g
g/\<THEN\>/s//){/g
g/\<ELSE\>/s//} else {/g
g/\<ELIF\>/s//} else if (/g
g/\<FI\>/s//;}/g
g/\<BEGIN\>/s//{/g
g/\<END\>/s//}/g
g/\<SWITCH\>/s//switch(/g
g/\<IN\>/s//){/g
g/\<ENDSW\>/s//}/g
g/\<FOR\>/s//for(/g
g/\<WHILE\>/s//while(/g
g/\<DO\>/s//){/g
g/\<OD\>/s//;}/g
g/\<REP\>/s//do{/g
g/\<PER\>/s//}while(/g
g/\<DONE\>/s//);/g
g/\<LOOP\>/s//for(;;){/g
g/\<POOL\>/s//}/g
g/\<SKIP\>/s//;/g
g/\<DIV\>/s//\//g
g/\<REM\>/s//%/g
g/\<NEQ\>/s//^/g
g/\<ANDF\>/s//\&\&/g
g/\<ORF\>/s//||/g
g/^	*){/.-1j
g/){/s//&\
/
1,$p
q!
'THIS IS WHAT TO LOOK FOR'
exit
--
UNIX is an AT&T Bell Laboratories trademark.
--
	...decvax!allegra!umcp-cs!elsie!ado	(301) 496-5688



More information about the Comp.unix.wizards mailing list