]> git.pond.sub.org Git - empserver/blob - src/scripts/indent-emp
client: Unbreak standalone build
[empserver] / src / scripts / indent-emp
1 #!/bin/sh -e
2
3 # indent needs to know type names do to a proper job.
4 # Type names located with grep typedef, then extracted by hand:
5 types="coord empth_rwlock_t empth_t i_type"
6
7 opts="-kr -cdw -cp8 -ncs -psl -ss"
8 for t in $types
9 do opts="$opts -T $t"
10 done
11
12 # Quote `The `indent' Manual', Edition 2.2.8, section Bugs:
13 #
14 #   Comments of the form /*UPPERCASE*/ are not treated as comment but
15 #   as an identifier, causing them to be joined with the next
16 #   line. This renders comments of this type useless, unless they are
17 #   embedded in the code to begin with.
18 #
19 # Therefore, we have to pre- and postprocess with sed.  Without this
20 # bug, a simple find | xargs indent would do.
21
22 for i
23 do
24   if sed 's#/\*\([A-Z][A-Z]*\)\*/#/* @@@\1@@@ */#g' <$i | indent $opts | sed 's#/\* @@@\([A-Z][A-Z]*\)@@@ \*/#/*\1*/#g' >$$
25   then mv $$ $i
26   else rm -f $i; exit 1;
27   fi
28 done