?X: empty string with an error status if the file could not be located.
?X:
?MAKE:Findhdr: grep test tr rm +usrinc awk cat startsh \
- cppstdin cppminus +cppflags
+ cppstdin cppminus +cppflags osname
?MAKE: -pick add $@ %<
?LINT:define fieldn
?S:fieldn:
?S:.
?V:fieldn
?F:./findhdr !fieldn
-?T:cline pos wanted name awkprg usrincdir status cppfilter
+?T:cline pos wanted name awkprg usrincdir status cppfilter testaccess
: determine filename position in cpp output
echo " "
echo "Computing filename position in cpp output for #include directives..." >&4
+case "$osname" in
+vos) testaccess=-e ;;
+*) testaccess=-r ;;
+esac
echo '#include <stdio.h>' > foo.c
$cat >fieldn <<EOF
$startsh
pos=1
set \$cline
while $test \$# -gt 0; do
- if $test -r \`echo \$1 | $tr -d '"'\`; then
+ if $test $testaccess \`echo \$1 | $tr -d '"'\`; then
echo "\$pos"
exit 0
fi
esac
echo "Your cpp writes the filename in the $pos field of the line."
+case "$osname" in
+vos) cppfilter="tr '\\\\>' '/' |" ;; # path component separator is >
+os2) cppfilter="sed -e 's|\\\\\\\\|/|g' |" ;; # path component separator is \
+*) cppfilter='' ;;
+esac
?X: To locate a header file, we cannot simply check for $usrinc/file.h, since
?X: some machine have the headers in weird places and our only hope is that
?X: the C pre-processor will know how to find those headers. Thank you NexT!
done
awkprg='{ print \$$fieldn }'
echo "#include <\$wanted>" > foo\$\$.c
-case "$osname" in
-vos) cppfilter="tr '\\\\>' '/'" ;; # path component separator is >
-*) cppfilter="cat" ;;
-esac
$cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
-$cppfilter | $grep "^[ ]*#.*\$wanted" | \
+$cppfilter $grep "^[ ]*#.*\$wanted" | \
while read cline; do
name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
case "\$name" in