home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Columbia Kermit
/
kermit.zip
/
ckscripts
/
ifdef.ksc
< prev
next >
Wrap
Text File
|
2020-01-01
|
775b
|
40 lines
#!/p/kd/fdc/solaris9/wermit +
#
# ifdef
#
# A simple tool to check big C source files for #if/#ifdef/#ifndef..#endif
# structure, handy for finding mismatches.
#
# F. da Cruz, Columbia University, October 2009
#
define display {
.\%9 ::= (\m(depth) * 2) - 2
echo "\flpad(\m(n),6). [\m(depth)] \frepeat(\32,\%9)\m(line)"
}
if not def \%1 exit 1 "usage: \%0 filename"
fopen /read \%c \%1
if fail exit 1
.depth = 0
.n = 0
while 1 {
fread /line \%c line
if fail break
incr n
.line := \fleft(\funtabify(\m(line)),40)
if < \flen(\m(line)) 6 continue
switch \m(line) {
:#if*
incr depth
display
break
:#endif*
display
decr depth
break
:default
continue
}
}
fclose \%c
exit