3 # Copyright (C) 2008 - 2014 Steve Youngs
5 # Author: Steve Youngs <steve@sxemacs.org>
6 # Maintainer: Steve Youngs <steve@sxemacs.org>
7 # Created: <2008-03-10>
8 # Time-stamp: <Monday Mar 3, 2014 17:24:16 steve>
10 # Keywords: utils package-management
12 # This file is part of pkgusr.
14 # Redistribution and use in source and binary forms, with or without
15 # modification, are permitted provided that the following conditions
18 # 1. Redistributions of source code must retain the above copyright
19 # notice, this list of conditions and the following disclaimer.
21 # 2. Redistributions in binary form must reproduce the above copyright
22 # notice, this list of conditions and the following disclaimer in the
23 # documentation and/or other materials provided with the distribution.
25 # 3. Neither the name of the author nor the names of any contributors
26 # may be used to endorse or promote products derived from this
27 # software without specific prior written permission.
29 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
30 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
32 # DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
33 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
34 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
35 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
36 # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
37 # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
38 # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
39 # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 # This script is used to locate headers that declare symbol. symbol
44 # being the thing you are searching for. This is good for those
45 # "unknown reference" errors.
51 if [ $# -lt 1 -o "$1" = "--help" -o "$1" = "--usage" -o "$1" = "-h" ]; then
53 echo 1>&2 'USAGE: ${ourname} <symbol_regexp>'
55 echo 1>&2 ' Find headers that declare symbol matching <symbol_regexp>.'
57 echo 1>&2 ' See grep(1), '"'REGULAR EXPRESSIONS'"' for the syntax of regexps'
58 echo 1>&2 ' used by this script.'
64 # These are the directories we search. If you have other header directories
65 # such as /usr/local/include, /opt/include, add them here.
66 header_dirs=(/usr/include /usr/X11R6/include)
68 ## bastard header directories...
71 # /usr/X11R6/include \
78 all_headers=$(find -H -L ${header_dirs[*]} -type f -name "*.h" -print)
80 ### FIXME: This is totally brain dead, it'll match on shit you don't
82 # A possible solution might be to use etags in some way.
83 for header in ${all_headers} ; do
84 grep -E -l --mmap --colour ${sym} ${header} 2>/dev/null
87 ## header-symbol-search ends here