summaryrefslogtreecommitdiffstats
path: root/ast/cexpand
blob: b40957ae021e25a87b82ab00a5c622596a0ac04a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/tcsh
#+

#  Name:
#    cexpand

#  Purpose:
#    Expand a C source file using the C pre-processor and re-format it
#    into a readable form. The output is written to a file with the same
#    base-name as the input file, but with a file type of ".cpp".

#  Usage:
#    % cexpand fred.c

#-

if( "$1" == "" ) then
   echo "Usage: cexpand <file.c>"
   exit
endif

set file = `basename $1 .c`
cpp -CC -P $file.c -DTHREAD_SAFE -DHAVE_CONFIG_H -I. -I.. -I/star/include > aaxx
indent aaxx -kr -o bbxx
cat bbxx | sed -e 's#/\*#\n/\*#g' > ccxx
cat ccxx | cexpand.pl > ddxx
indent ddxx -kr -o $file.cpp
rm aaxx bbxx ccxx ddxx

echo "Output in $file.cpp"
echo ""