summaryrefslogtreecommitdiff
path: root/mcon/U/Findhdr.U
diff options
context:
space:
mode:
Diffstat (limited to 'mcon/U/Findhdr.U')
-rw-r--r--mcon/U/Findhdr.U58
1 files changed, 39 insertions, 19 deletions
diff --git a/mcon/U/Findhdr.U b/mcon/U/Findhdr.U
index 48d4d75..50f7ba7 100644
--- a/mcon/U/Findhdr.U
+++ b/mcon/U/Findhdr.U
@@ -1,12 +1,12 @@
-?RCS: $Id: Findhdr.U,v 3.0.1.2 1994/10/29 15:53:08 ram Exp $
+?RCS: $Id$
?RCS:
-?RCS: Copyright (c) 1991-1993, Raphael Manfredi
+?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
?RCS:
?RCS: You may redistribute only under the terms of the Artistic Licence,
?RCS: as specified in the README file that comes with the distribution.
?RCS: You may reuse parts of this distribution only within the terms of
?RCS: that same Artistic Licence; a copy of which may be found at the root
-?RCS: of the source tree for dist 3.0.
+?RCS: of the source tree for dist 4.0.
?RCS:
?RCS: Original Author: Thomas Neumann <tom@smart.bo.open.de>
?RCS:
@@ -28,7 +28,7 @@
?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 eunicefix osname
?MAKE: -pick add $@ %<
?LINT:define fieldn
?S:fieldn:
@@ -40,11 +40,22 @@
?S:.
?V:fieldn
?F:./findhdr !fieldn
-?T:cline pos wanted name awkprg
+?T:cline pos wanted name awkprg cppfilter testaccess status usrincdir
: determine filename position in cpp output
echo " "
echo "Computing filename position in cpp output for #include directives..." >&4
echo '#include <stdio.h>' > foo.c
+case "$osname" in
+vos)
+ testaccess=-e
+?X: VOS: path component separator is >
+ cppfilter="tr '\\\\>' '/' |"
+ ;;
+*)
+ testaccess=-r
+ cppfilter=''
+ ;;
+esac
$cat >fieldn <<EOF
$startsh
$cppstdin $cppflags $cppminus <foo.c 2>/dev/null | \
@@ -53,7 +64,7 @@ while read cline; do
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
@@ -82,25 +93,34 @@ $cat >findhdr <<EOF
$startsh
wanted=\$1
name=''
-if test -f $usrinc/\$wanted; then
- echo "$usrinc/\$wanted"
- exit 0
-fi
+for usrincdir in $usrinc; do
+ if test -f \$usrincdir/\$wanted; then
+ echo "\$usrincdir/\$wanted"
+ exit 0
+ fi
+done
awkprg='{ print \$$fieldn }'
echo "#include <\$wanted>" > foo\$\$.c
$cppstdin $cppminus $cppflags < foo\$\$.c 2>/dev/null | \
-$grep "^[ ]*#.*\$wanted" | \
+$cppfilter $grep "^[ ]*#.*\$wanted" | \
while read cline; do
name=\`echo \$cline | $awk "\$awkprg" | $tr -d '"'\`
case "\$name" in
- */\$wanted) echo "\$name"; exit 0;;
- *) name='';;
- esac;
-done;
-$rm -f foo\$\$.c;
-case "\$name" in
-'') exit 1;;
-esac
+ *[/\\\\]\$wanted) echo "\$name"; exit 1;;
+ *[\\\\/]\$wanted) echo "\$name"; exit 1;;
+ *) exit 2;;
+ esac
+done
+?X: status = 0: grep returned 0 lines, case statement not executed
+?X: status = 1: headerfile found
+?X: status = 2: while loop executed, no headerfile found
+status=\$?
+$rm -f foo\$\$.c
+if test \$status -eq 1; then
+ exit 0
+fi
+exit 1
EOF
chmod +x findhdr
+$eunicefix findhdr