jpf-indent revision 166124
1166124Srafan#!/bin/sh 2166124Srafan#**************************************************************************** 3166124Srafan#* Copyright (c) 2004-2005,2006 Thomas E. Dickey * 4166124Srafan#* * 5166124Srafan#* Permission is hereby granted, free of charge, to any person obtaining a * 6166124Srafan#* copy of this software and associated documentation files (the * 7166124Srafan#* "Software"), to deal in the Software without restriction, including * 8166124Srafan#* without limitation the rights to use, copy, modify, merge, publish, * 9166124Srafan#* distribute, distribute with modifications, sublicense, and/or sell * 10166124Srafan#* copies of the Software, and to permit persons to whom the Software is * 11166124Srafan#* furnished to do so, subject to the following conditions: * 12166124Srafan#* * 13166124Srafan#* The above copyright notice and this permission notice shall be included * 14166124Srafan#* in all copies or substantial portions of the Software. * 15166124Srafan#* * 16166124Srafan#* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 17166124Srafan#* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 18166124Srafan#* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 19166124Srafan#* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 20166124Srafan#* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 21166124Srafan#* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 22166124Srafan#* THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 23166124Srafan#* * 24166124Srafan#* Except as contained in this notice, the name(s) of the above copyright * 25166124Srafan#* holders shall not be used in advertising or otherwise to promote the * 26166124Srafan#* sale, use or other dealings in this Software without prior written * 27166124Srafan#* authorization. * 28166124Srafan#****************************************************************************/ 29166124Srafan# $Id: jpf-indent,v 1.6 2006/02/18 17:07:15 tom Exp $ 30166124Srafan# indent ncurses source written by Juergen Pfeifer 31166124SrafanNOOP=no 32166124SrafanOPTS=' 33166124Srafan-npro 34166124Srafan--blank-lines-after-declarations 35166124Srafan--blank-lines-after-procedures 36166124Srafan--brace-indent2 37166124Srafan--braces-after-if-line 38166124Srafan--continue-at-parentheses 39166124Srafan--indent-level2 40166124Srafan--line-length80 41166124Srafan--no-space-after-casts 42166124Srafan--no-space-after-function-call-names 43166124Srafan--parameter-indentation4 44166124Srafan--swallow-optional-blank-lines 45166124Srafan--tab-size8 46166124Srafan 47166124Srafan-T FIELD 48166124Srafan-T FIELDTYPE 49166124Srafan-T FIELD_CELL 50166124Srafan-T FORM 51166124Srafan-T NCURSES_INLINE 52166124Srafan-T RegExp_Arg 53166124Srafan-T TypeArgument 54166124Srafan-T WINDOW 55166124Srafan-T attr_t 56166124Srafan-T bool 57166124Srafan-T cchar_t 58166124Srafan-T chtype 59166124Srafan-T enumARG 60166124Srafan-T va_list 61166124Srafan-T wchar_t 62166124Srafan' 63166124Srafanfor name in $* 64166124Srafando 65166124Srafan case $name in 66166124Srafan -v|-n) 67166124Srafan NOOP=yes 68166124Srafan OPTS="$OPTS -v" 69166124Srafan ;; 70166124Srafan -*) 71166124Srafan OPTS="$OPTS $name" 72166124Srafan ;; 73166124Srafan *.[ch]) 74166124Srafan save="${name}".a$$ 75166124Srafan test="${name}".b$$ 76166124Srafan rm -f "$save" "$test" 77166124Srafan mv "$name" "$save" 78166124Srafan sed \ 79166124Srafan -e '/MODULE_ID(/s/)$/);/' \ 80166124Srafan -e 's,\<GCC_NORETURN;,;//GCC_NORETURN;,' \ 81166124Srafan -e 's,\<GCC_PRINTFLIKE(,;//GCC_PRINTFLIKE(,' \ 82166124Srafan -e 's,\<GCC_SCANFLIKE(,;//GCC_SCANFLIKE(,' \ 83166124Srafan -e 's,\(\<NCURSES_EXPORT_VAR\>\),//\1,' \ 84166124Srafan "$save" >"$test" 85166124Srafan cp "$test" "$name" 86166124Srafan chmod u+w "$name" 87166124Srafan # ${INDENT_PROG-indent} --version 88166124Srafan ${INDENT_PROG-indent} -npro $OPTS "$name" 89166124Srafan sed \ 90166124Srafan -e '/MODULE_ID(/s/);$/)/' \ 91166124Srafan -e 's,;[ ]*//GCC_NORETURN;, GCC_NORETURN;,' \ 92166124Srafan -e 's,;[ ]*//GCC_PRINTFLIKE(, GCC_PRINTFLIKE(,' \ 93166124Srafan -e 's,;[ ]*//GCC_SCANFLIKE(, GCC_SCANFLIKE(,' \ 94166124Srafan -e 's,//\(\<NCURSES_EXPORT_VAR\>\),\1,' \ 95166124Srafan "$name" >"$test" 96166124Srafan mv "$test" "$name" 97166124Srafan rm -f "${name}~" 98166124Srafan if test $NOOP = yes ; then 99166124Srafan if (cmp -s "$name" "$save" ) then 100166124Srafan echo "** no change: $name" 101166124Srafan else 102166124Srafan diff -u "$save" "$name" 103166124Srafan fi 104166124Srafan rm -f "$name" 105166124Srafan mv "$save" "$name" 106166124Srafan elif ( cmp -s "$name" "$save" ) ; then 107166124Srafan echo "** unchanged $name" 108166124Srafan rm -f "${name}" 109166124Srafan mv "$save" "$name" 110166124Srafan else 111166124Srafan echo "** updated $name" 112166124Srafan rm -f "$save" 113166124Srafan fi 114166124Srafan ;; 115166124Srafan *) 116166124Srafan echo "** ignored: $name" 117166124Srafan ;; 118166124Srafan esac 119166124Srafandone 120