gdb_indent.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #!/bin/sh
  2. # Try to find a GNU indent. There could be a BSD indent in front of a
  3. # GNU gindent so when indent is found, keep looking.
  4. # Make certain that the script is not running in an internationalized
  5. # environment.
  6. LANG=c ; export LANG
  7. LC_ALL=c ; export LC_ALL
  8. gindent=
  9. indent=
  10. paths=`echo $PATH | sed \
  11. -e 's/::/:.:/g' \
  12. -e 's/^:/.:/' \
  13. -e 's/:$/:./' \
  14. -e 's/:/ /g'`
  15. for path in $paths
  16. do
  17. if test ! -n "${gindent}" -a -x ${path}/gindent
  18. then
  19. gindent=${path}/gindent
  20. break
  21. elif test ! -n "${indent}" -a -x ${path}/indent
  22. then
  23. indent=${path}/indent
  24. fi
  25. done
  26. if test -n "${gindent}"
  27. then
  28. indent=${gindent}
  29. elif test -n "${indent}"
  30. then
  31. :
  32. else
  33. echo "Indent not found" 1>&2
  34. fi
  35. # Check that the indent found is both GNU and a reasonable version.
  36. # Different indent versions give different indentation.
  37. m1=2
  38. m2=2
  39. m3=9
  40. version=`${indent} --version 2>/dev/null < /dev/null`
  41. case "${version}" in
  42. *GNU* ) ;;
  43. * ) echo "error: GNU indent $m1.$m2.$m3 expected" 1>&2 ; exit 1;;
  44. esac
  45. v1=`echo "${version}" | sed 's/^.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)$/\1/'`
  46. v2=`echo "${version}" | sed 's/^.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)$/\2/'`
  47. v3=`echo "${version}" | sed 's/^.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)$/\3/'`
  48. if test $m1 -ne $v1 -o $m2 -ne $v2 -o $m3 -gt $v3
  49. then
  50. echo "error: Must be GNU indent version $m1.$m2.$m3 or later" 1>&2
  51. exit 1
  52. fi
  53. if test $m3 -ne $v3
  54. then
  55. echo "warning: GNU indent version $m1.$m2.$m3 recommended" 1>&2
  56. fi
  57. # Check that we're in the GDB source directory
  58. case `pwd` in
  59. */gdb ) ;;
  60. */sim/* ) ;;
  61. * ) echo "Not in GDB directory" 1>&2 ; exit 1 ;;
  62. esac
  63. # Run indent per GDB specs
  64. types="\
  65. -T FILE \
  66. -T bfd -T asection -T pid_t \
  67. -T prgregset_t -T fpregset_t -T gregset_t -T sigset_t \
  68. -T td_thrhandle_t -T td_event_msg_t -T td_thr_events_t \
  69. -T td_notify_t -T td_thr_iter_f -T td_thrinfo_t \
  70. -T caddr_t \
  71. `cat *.h | sed -n \
  72. -e 's/^.*[^a-z0-9_]\([a-z0-9_]*_ftype\).*$/-T \1/p' \
  73. -e 's/^.*[^a-z0-9_]\([a-z0-9_]*_func\).*$/-T \1/p' \
  74. -e 's/^typedef.*[^a-zA-Z0-9_]\([a-zA-Z0-9_]*[a-zA-Z0-9_]\);$/-T \1/p' \
  75. | sort -u`"
  76. ${indent} ${types} "$@"