ncurses 5.5
[ncurses.git] / misc / jpf-indent
1 #!/bin/sh
2 # $Id: jpf-indent,v 1.3 2004/05/29 19:14:45 tom Exp $
3 # indent ncurses source written by Juergen Pfeifer
4 NOOP=no
5 OPTS='
6 -npro
7 --blank-lines-after-declarations
8 --blank-lines-after-procedures
9 --brace-indent2
10 --braces-after-if-line
11 --continue-at-parentheses
12 --indent-level2
13 --line-length80
14 --no-space-after-casts
15 --no-space-after-function-call-names
16 --parameter-indentation4
17 --swallow-optional-blank-lines
18 --tab-size8
19 -T FIELD
20 -T FIELDTYPE
21 -T FIELD_CELL
22 -T FORM
23 -T INLINE
24 -T RegExp_Arg 
25 -T TypeArgument 
26 -T WINDOW
27 -T attr_t
28 -T bool
29 -T cchar_t
30 -T chtype
31 -T enumARG
32 -T va_list
33 -T wchar_t 
34 '
35 for name in $*
36 do
37         case $name in
38         -v|-n)
39                 NOOP=yes
40                 OPTS="$OPTS -v"
41                 ;;
42         -*)
43                 OPTS="$OPTS $name"
44                 ;;
45         *.[ch])
46                 save="${name}".a$$
47                 test="${name}".b$$
48                 rm -f "$save" "$test"
49                 mv "$name" "$save"
50                 sed \
51                         -e '/MODULE_ID(/s/)$/);/' \
52                         -e 's,\<GCC_NORETURN;,;//GCC_NORETURN;,' \
53                         -e 's,\(\<NCURSES_EXPORT_VAR\>\),//\1,' \
54                         "$save" >"$test"
55                 cp "$test" "$name"
56                 chmod u+w "$name"
57                 # ${INDENT_PROG-indent} --version
58                 ${INDENT_PROG-indent} $OPTS "$name"
59                 sed \
60                         -e '/MODULE_ID(/s/);$/)/' \
61                         -e 's,;[        ]*//GCC_NORETURN;, GCC_NORETURN;,' \
62                         -e 's,//\(\<NCURSES_EXPORT_VAR\>\),\1,' \
63                         "$name" >"$test"
64                 mv "$test" "$name"
65                 rm -f "${name}~"
66                 if test $NOOP = yes ; then
67                         if (cmp -s "$name" "$save" ) then
68                                 echo "** no change: $name"
69                         else
70                                 diff -u "$save" "$name"
71                         fi
72                         rm -f "$name"
73                         mv "$save" "$name"
74                 elif ( cmp -s "$name" "$save" ) ; then
75                         echo "** unchanged $name"
76                         rm -f "${name}"
77                         mv "$save" "$name"
78                 else
79                         echo "** updated $name"
80                         rm -f "$save"
81                 fi
82                 ;;
83         *)
84                 echo "** ignored:   $name"
85                 ;;
86         esac
87 done