diff options
Diffstat (limited to 'devtools')
-rwxr-xr-x | devtools/find-type-definition | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/devtools/find-type-definition b/devtools/find-type-definition index 9523e7c..2a99b78 100755 --- a/devtools/find-type-definition +++ b/devtools/find-type-definition @@ -4,6 +4,19 @@ type="$1" shift 1 -grep -r '\(define\s\+\(__kernel_\)\?'"$type"'\s\|typedef\s.*\s\(__kernel_\)\?'"$type"'\b\)' "$@" \ -| sed 's/^\([^:]*\):/\x1b[35m\1\x1b[m /' \ -| sed 's/\(__kernel_\)\?'"$type"'/\x1b[1;31m&\x1b[m/g' +e="$(printf '\033\n')" + +pattern1='define[[:space:]]\{1,\}\(__kernel_\)\{0,1\}'"$type"'[[:space:]]' +pattern2='typedef[[:space:]].*[[:space:]]\(__kernel_\)\{0,1\}'"$type"'\([^A-Za-z0-9_]\|$\)' + +pattern='\('"${pattern1}"'\|'"${pattern2}"'\)' + +find "$@" | while read f; do + if test -L "$f" || test -d "$f"; then + continue + fi + fe="$(printf '%s\n' "$f" | sed 's/\([\[*.]\|\/\|\]\)/\\&/g')" + sed -n '/^.*'"$pattern.*"'$/p' < "$f" \ + | sed 's/\(__kernel_\)\{0,1\}'"$type/$e"'[1;31m&'"$e"'[m/g' \ + | sed "s/^/$e[35m$fe$e[m /" +done |