#!/users/fdc/bin/wermit + # # ifdef2 # # ifdef is a simple tool to check big C source files for # #if/#ifdef/#ifndef..#endif # structure, handy for finding mismatches. # ifdef2 also includes #define and #undef in the result. # # F. da Cruz, Columbia University, October 2009, November 2022 # 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 :#define* :#undef* display break :default continue } } fclose \%c exit