1126261Smlaier#!/bin/sh
2145836Smlaier#****************************************************************************
3126258Smlaier#* Copyright (c) 2004-2005,2006 Thomas E. Dickey                            *
4126258Smlaier#*                                                                          *
5126258Smlaier#* Permission is hereby granted, free of charge, to any person obtaining a  *
6126258Smlaier#* copy of this software and associated documentation files (the            *
7126258Smlaier#* "Software"), to deal in the Software without restriction, including      *
8126258Smlaier#* without limitation the rights to use, copy, modify, merge, publish,      *
9126258Smlaier#* distribute, distribute with modifications, sublicense, and/or sell       *
10126258Smlaier#* copies of the Software, and to permit persons to whom the Software is    *
11126258Smlaier#* furnished to do so, subject to the following conditions:                 *
12126258Smlaier#*                                                                          *
13126258Smlaier#* The above copyright notice and this permission notice shall be included  *
14126258Smlaier#* in all copies or substantial portions of the Software.                   *
15126258Smlaier#*                                                                          *
16126258Smlaier#* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
17126258Smlaier#* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
18126258Smlaier#* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
19126258Smlaier#* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
20126258Smlaier#* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
21126258Smlaier#* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
22126258Smlaier#* THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
23126258Smlaier#*                                                                          *
24126258Smlaier#* Except as contained in this notice, the name(s) of the above copyright   *
25126258Smlaier#* holders shall not be used in advertising or otherwise to promote the     *
26126258Smlaier#* sale, use or other dealings in this Software without prior written       *
27126258Smlaier#* authorization.                                                           *
28126258Smlaier#****************************************************************************/
29126258Smlaier# $Id: jpf-indent,v 1.6 2006/02/18 17:07:15 tom Exp $
30127145Smlaier# indent ncurses source written by Juergen Pfeifer
31126261SmlaierNOOP=no
32126261SmlaierOPTS='
33126261Smlaier-npro
34126261Smlaier--blank-lines-after-declarations
35127145Smlaier--blank-lines-after-procedures
36126258Smlaier--brace-indent2
37126258Smlaier--braces-after-if-line
38126261Smlaier--continue-at-parentheses
39126261Smlaier--indent-level2
40126261Smlaier--line-length80
41127145Smlaier--no-space-after-casts
42127145Smlaier--no-space-after-function-call-names
43126261Smlaier--parameter-indentation4
44126258Smlaier--swallow-optional-blank-lines
45126258Smlaier--tab-size8
46130613Smlaier
47126258Smlaier-T FIELD
48126258Smlaier-T FIELDTYPE
49126258Smlaier-T FIELD_CELL
50126258Smlaier-T FORM
51145836Smlaier-T NCURSES_INLINE
52127145Smlaier-T RegExp_Arg 
53145836Smlaier-T TypeArgument 
54126261Smlaier-T WINDOW
55129907Smlaier-T attr_t
56126261Smlaier-T bool
57130613Smlaier-T cchar_t
58130613Smlaier-T chtype
59148015Smlaier-T enumARG
60126261Smlaier-T va_list
61126258Smlaier-T wchar_t 
62126258Smlaier'
63126261Smlaierfor name in $*
64126258Smlaierdo
65126258Smlaier	case $name in
66130933Sbrooks	-v|-n)
67130933Sbrooks		NOOP=yes
68130933Sbrooks		OPTS="$OPTS -v"
69126258Smlaier		;;
70126258Smlaier	-*)
71126258Smlaier		OPTS="$OPTS $name"
72145836Smlaier		;;
73145836Smlaier	*.[ch])
74126258Smlaier		save="${name}".a$$
75126258Smlaier		test="${name}".b$$
76126258Smlaier		rm -f "$save" "$test"
77130613Smlaier		mv "$name" "$save"
78126258Smlaier		sed \
79130613Smlaier			-e '/MODULE_ID(/s/)$/);/' \
80130613Smlaier			-e 's,\<GCC_NORETURN;,;//GCC_NORETURN;,' \
81126258Smlaier			-e 's,\<GCC_PRINTFLIKE(,;//GCC_PRINTFLIKE(,' \
82126258Smlaier			-e 's,\<GCC_SCANFLIKE(,;//GCC_SCANFLIKE(,' \
83126258Smlaier			-e 's,\(\<NCURSES_EXPORT_VAR\>\),//\1,' \
84126258Smlaier			"$save" >"$test"
85126258Smlaier		cp "$test" "$name"
86126258Smlaier		chmod u+w "$name"
87126258Smlaier		# ${INDENT_PROG-indent} --version
88126258Smlaier		${INDENT_PROG-indent} -npro $OPTS "$name"
89126258Smlaier		sed \
90145836Smlaier			-e '/MODULE_ID(/s/);$/)/' \
91145836Smlaier			-e 's,;[ 	]*//GCC_NORETURN;, GCC_NORETURN;,' \
92145836Smlaier			-e 's,;[ 	]*//GCC_PRINTFLIKE(, GCC_PRINTFLIKE(,' \
93145836Smlaier			-e 's,;[ 	]*//GCC_SCANFLIKE(, GCC_SCANFLIKE(,' \
94145836Smlaier			-e 's,//\(\<NCURSES_EXPORT_VAR\>\),\1,' \
95145836Smlaier			"$name" >"$test"
96145836Smlaier		mv "$test" "$name"
97145836Smlaier		rm -f "${name}~"
98145836Smlaier		if test $NOOP = yes ; then
99145836Smlaier			if (cmp -s "$name" "$save" ) then
100145836Smlaier				echo "** no change: $name"
101145836Smlaier			else
102126258Smlaier				diff -u "$save" "$name"
103126258Smlaier			fi
104126258Smlaier			rm -f "$name"
105127145Smlaier			mv "$save" "$name"
106127145Smlaier		elif ( cmp -s "$name" "$save" ) ; then
107126261Smlaier			echo "** unchanged $name"
108126261Smlaier			rm -f "${name}"
109126258Smlaier			mv "$save" "$name"
110126258Smlaier		else
111126258Smlaier			echo "** updated $name"
112126258Smlaier			rm -f "$save"
113126258Smlaier		fi
114126258Smlaier		;;
115126258Smlaier	*)
116126258Smlaier		echo "** ignored:   $name"
117126258Smlaier		;;
118126258Smlaier	esac
119127145Smlaierdone
120130613Smlaier