jpf-indent 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #!/bin/sh
  2. #****************************************************************************
  3. #* Copyright (c) 2004-2005,2006 Thomas E. Dickey *
  4. #* *
  5. #* Permission is hereby granted, free of charge, to any person obtaining a *
  6. #* copy of this software and associated documentation files (the *
  7. #* "Software"), to deal in the Software without restriction, including *
  8. #* without limitation the rights to use, copy, modify, merge, publish, *
  9. #* distribute, distribute with modifications, sublicense, and/or sell *
  10. #* copies of the Software, and to permit persons to whom the Software is *
  11. #* furnished to do so, subject to the following conditions: *
  12. #* *
  13. #* The above copyright notice and this permission notice shall be included *
  14. #* in all copies or substantial portions of the Software. *
  15. #* *
  16. #* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
  17. #* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
  18. #* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
  19. #* IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
  20. #* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
  21. #* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
  22. #* THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
  23. #* *
  24. #* Except as contained in this notice, the name(s) of the above copyright *
  25. #* holders shall not be used in advertising or otherwise to promote the *
  26. #* sale, use or other dealings in this Software without prior written *
  27. #* authorization. *
  28. #****************************************************************************/
  29. # $Id: jpf-indent,v 1.6 2006/02/18 17:07:15 tom Exp $
  30. # indent ncurses source written by Juergen Pfeifer
  31. NOOP=no
  32. OPTS='
  33. -npro
  34. --blank-lines-after-declarations
  35. --blank-lines-after-procedures
  36. --brace-indent2
  37. --braces-after-if-line
  38. --continue-at-parentheses
  39. --indent-level2
  40. --line-length80
  41. --no-space-after-casts
  42. --no-space-after-function-call-names
  43. --parameter-indentation4
  44. --swallow-optional-blank-lines
  45. --tab-size8
  46. -T FIELD
  47. -T FIELDTYPE
  48. -T FIELD_CELL
  49. -T FORM
  50. -T NCURSES_INLINE
  51. -T RegExp_Arg
  52. -T TypeArgument
  53. -T WINDOW
  54. -T attr_t
  55. -T bool
  56. -T cchar_t
  57. -T chtype
  58. -T enumARG
  59. -T va_list
  60. -T wchar_t
  61. '
  62. for name in $*
  63. do
  64. case $name in
  65. -v|-n)
  66. NOOP=yes
  67. OPTS="$OPTS -v"
  68. ;;
  69. -*)
  70. OPTS="$OPTS $name"
  71. ;;
  72. *.[ch])
  73. save="${name}".a$$
  74. test="${name}".b$$
  75. rm -f "$save" "$test"
  76. mv "$name" "$save"
  77. sed \
  78. -e '/MODULE_ID(/s/)$/);/' \
  79. -e 's,\<GCC_NORETURN;,;//GCC_NORETURN;,' \
  80. -e 's,\<GCC_PRINTFLIKE(,;//GCC_PRINTFLIKE(,' \
  81. -e 's,\<GCC_SCANFLIKE(,;//GCC_SCANFLIKE(,' \
  82. -e 's,\(\<NCURSES_EXPORT_VAR\>\),//\1,' \
  83. "$save" >"$test"
  84. cp "$test" "$name"
  85. chmod u+w "$name"
  86. # ${INDENT_PROG-indent} --version
  87. ${INDENT_PROG-indent} -npro $OPTS "$name"
  88. sed \
  89. -e '/MODULE_ID(/s/);$/)/' \
  90. -e 's,;[ ]*//GCC_NORETURN;, GCC_NORETURN;,' \
  91. -e 's,;[ ]*//GCC_PRINTFLIKE(, GCC_PRINTFLIKE(,' \
  92. -e 's,;[ ]*//GCC_SCANFLIKE(, GCC_SCANFLIKE(,' \
  93. -e 's,//\(\<NCURSES_EXPORT_VAR\>\),\1,' \
  94. "$name" >"$test"
  95. mv "$test" "$name"
  96. rm -f "${name}~"
  97. if test $NOOP = yes ; then
  98. if (cmp -s "$name" "$save" ) then
  99. echo "** no change: $name"
  100. else
  101. diff -u "$save" "$name"
  102. fi
  103. rm -f "$name"
  104. mv "$save" "$name"
  105. elif ( cmp -s "$name" "$save" ) ; then
  106. echo "** unchanged $name"
  107. rm -f "${name}"
  108. mv "$save" "$name"
  109. else
  110. echo "** updated $name"
  111. rm -f "$save"
  112. fi
  113. ;;
  114. *)
  115. echo "** ignored: $name"
  116. ;;
  117. esac
  118. done