PageRenderTime 1246ms CodeModel.GetById 33ms RepoModel.GetById 1ms app.codeStats 0ms

/deps/ncurses/test/listused.sh

https://github.com/jsjohnst/node-ncurses
Shell | 182 lines | 133 code | 6 blank | 43 comment | 21 complexity | c05054a03dc48b85527a6f8092e9b68c MD5 | raw file
  1. #!/bin/sh
  2. ##############################################################################
  3. # Copyright (c) 2003,2006 Free Software Foundation, Inc. #
  4. # #
  5. # Permission is hereby granted, free of charge, to any person obtaining a #
  6. # copy of this software and associated documentation files (the "Software"), #
  7. # to deal in the Software without restriction, including without limitation #
  8. # the rights to use, copy, modify, merge, publish, distribute, distribute #
  9. # with modifications, sublicense, and/or sell copies of the Software, and to #
  10. # permit persons to whom the Software is furnished to do so, subject to the #
  11. # following conditions: #
  12. # #
  13. # The above copyright notice and this permission notice shall be included in #
  14. # all copies or substantial portions of the Software. #
  15. # #
  16. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
  17. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
  18. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
  19. # THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
  20. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
  21. # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
  22. # 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 sale, #
  26. # use or other dealings in this Software without prior written #
  27. # authorization. #
  28. ##############################################################################
  29. # $Id: listused.sh,v 1.7 2006/06/03 16:39:37 tom Exp $
  30. # A very simple script to list entrypoints that are used by either a test
  31. # program, or within the libraries. This relies on the output format of 'nm',
  32. # and assumes that the libraries are configured with TRACE defined, and using
  33. # these options:
  34. # --disable-macros
  35. # --enable-widec
  36. # Static libraries are used, to provide some filtering based on internal usage
  37. # of the different symbols.
  38. # keep the sorting independent of locale:
  39. if test "${LANGUAGE+set}" = set; then LANGUAGE=C; export LANGUAGE; fi
  40. if test "${LANG+set}" = set; then LANG=C; export LANG; fi
  41. if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
  42. if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
  43. if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
  44. if test "${LC_COLLATE+set}" = set; then LC_COLLATE=C; export LC_COLLATE; fi
  45. NM_OPTS=
  46. if test ! -d ../objects ; then
  47. echo "? need objects to run this script"
  48. exit 1
  49. elif test ! -d ../lib ; then
  50. echo "? need libraries to run this script"
  51. exit 1
  52. fi
  53. PROGS=
  54. for name in `(echo "test:";sort modules; echo "progs:";sort ../progs/modules) |sed -e 's/[ ].*//' -e '/^[#@]/d'`
  55. do
  56. case $name in
  57. *:)
  58. PROGS="$PROGS $name"
  59. ;;
  60. *)
  61. NAME=../objects/${name}.o
  62. if test -f $NAME
  63. then
  64. PROGS="$PROGS $NAME"
  65. fi
  66. ;;
  67. esac
  68. done
  69. # For each library -
  70. for lib in ../lib/*.a
  71. do
  72. LIB=`basename $lib .a`
  73. case $LIB in
  74. *_*|*+*)
  75. continue
  76. ;;
  77. esac
  78. tmp=`echo $LIB|sed -e 's/w$//'`
  79. echo
  80. echo "${tmp}:"
  81. echo $tmp |sed -e 's/./-/g'
  82. # Construct a list of public externals provided by the library.
  83. WANT=`nm $NM_OPTS $lib |\
  84. sed -e 's/^[^ ]*//' \
  85. -e 's/^ *//' \
  86. -e '/^[ a-z] /d' \
  87. -e '/:$/d' \
  88. -e '/^$/d' \
  89. -e '/^U /d' \
  90. -e 's/^[A-Z] //' \
  91. -e '/^_/d' |\
  92. sort -u`
  93. # List programs which use that external.
  94. for name in $WANT
  95. do
  96. HAVE=
  97. tags=
  98. last=
  99. for prog in $PROGS
  100. do
  101. case $prog in
  102. *:)
  103. tags=$prog
  104. ;;
  105. *)
  106. TEST=`nm $NM_OPTS $prog |\
  107. sed -e 's/^[^ ]*//' \
  108. -e 's/^ *//' \
  109. -e '/^[ a-z] /d' \
  110. -e '/:$/d' \
  111. -e '/^$/d' \
  112. -e 's/^[A-Z] //' \
  113. -e '/^_/d' \
  114. -e 's/^'${name}'$/_/' \
  115. -e '/^[^_]/d'`
  116. if test -n "$TEST"
  117. then
  118. have=`basename $prog .o`
  119. if test -n "$HAVE"
  120. then
  121. if test "$last" = "$tags"
  122. then
  123. HAVE="$HAVE $have"
  124. else
  125. HAVE="$HAVE $tags $have"
  126. fi
  127. else
  128. HAVE="$tags $have"
  129. fi
  130. last="$tags"
  131. fi
  132. ;;
  133. esac
  134. done
  135. # if we did not find a program using it directly, see if it
  136. # is used within a library.
  137. if test -z "$HAVE"
  138. then
  139. for tmp in ../lib/*.a
  140. do
  141. case $tmp in
  142. *_*|*+*)
  143. continue
  144. ;;
  145. esac
  146. TEST=`nm $NM_OPTS $tmp |\
  147. sed -e 's/^[^ ]*//' \
  148. -e 's/^ *//' \
  149. -e '/^[ a-z] /d' \
  150. -e '/:$/d' \
  151. -e '/^$/d' \
  152. -e '/^[A-TV-Z] /d' \
  153. -e 's/^[A-Z] //' \
  154. -e '/^_/d' \
  155. -e 's/^'${name}'$/_/' \
  156. -e '/^[^_]/d'`
  157. if test -n "$TEST"
  158. then
  159. tmp=`basename $tmp .a |sed -e 's/w$//'`
  160. HAVE=`echo $tmp | sed -e 's/lib/lib: /'`
  161. break
  162. fi
  163. done
  164. fi
  165. test -z "$HAVE" && HAVE="-"
  166. lenn=`expr 39 - length $name`
  167. lenn=`expr $lenn / 8`
  168. tabs=
  169. while test $lenn != 0
  170. do
  171. tabs="${tabs} "
  172. lenn=`expr $lenn - 1`
  173. done
  174. echo "${name}${tabs}${HAVE}"
  175. done
  176. done