This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Subject: optimize matching -g still enables -DDEBUGING
[metaconfig.git] / U / modified / Findhdr.U
index 6cc2940..28e181d 100644 (file)
@@ -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 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
@@ -53,7 +57,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
@@ -74,6 +78,11 @@ case $fieldn in
 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!
@@ -91,12 +100,8 @@ do
 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