]> git.pond.sub.org Git - empserver/blob - src/scripts/indent-emp
0982593b8bd4110326e90c41b80dcc8a60b64b18
[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="bit_fdmask bit_mask caddr_t coord ef_fileinit emp_sig_t empth_sem_t empth_t intp iop_t iovec_t loc_Sem_t loc_Thread_t natid plate_e pointer qsort_func_t s_char stkalign_t u_char u_int u_short vf_ptr voidfunc"
6 opts="-kr -cdw -cp8 -ncs -psl -nsob -ss"
7 for t in $types
8 do opts="$opts -T $t"
9 done
10
11 # Quote The indent Manual, Edition 2.2.8, section Bugs:
12 #
13 #   Comments of the form /*UPPERCASE*/ are not treated as comment but
14 #   as an identifier, causing them to be joined with the next
15 #   line. This renders comments of this type useless, unless they are
16 #   embedded in the code to begin with.
17 #
18 # Therefore, we have to pre- and postprocess with sed.  Without this
19 # bug, a simple find | xargs indent would do.
20
21 for i in `find -name \*.[ch]`
22 do
23   if sed 's#/\*\([A-Z][A-Z]*\)\*/#/* @@@\1@@@ */#g' <$i | indent $opts | sed 's#/\* @@@\([A-Z][A-Z]*\)@@@ \*/#/*\1*/#g' >$$
24   then mv $$ $i
25   else rm -f $i; exit 1;
26   fi
27 done