In Configure, refactor the test for procselfexe into a loop.
authorNicholas Clark <nick@ccl4.org>
Tue, 27 Sep 2011 21:47:39 +0000 (23:47 +0200)
committerRicardo Signes <rjbs@cpan.org>
Wed, 21 Mar 2012 01:06:00 +0000 (21:06 -0400)
This removes code duplication, and makes it easy to add more variants.
Based on a patch from Johann 'Myrkraverk' Oskarsson.

Configure

index d9911f9..48a3650 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -16118,23 +16118,22 @@ echo " "
 procselfexe=''
 val="$undef"
 case "$d_readlink" in
-"$define")
-       if $issymlink /proc/self/exe ; then
-               $ls -l /proc/self/exe > reflect
-               if $contains /`basename $ls` reflect >/dev/null 2>&1; then
-                       echo "You have Linux-like /proc/self/exe."
-                       procselfexe='"/proc/self/exe"'
-                       val="$define"
-               fi
-       fi
-       if $issymlink /proc/curproc/file ; then
-               $ls -l /proc/curproc/file > reflect
+    "$define")
+       set Linux /proc/self/exe BSD /proc/curproc/file
+       while test $# -gt 0; do
+           type=$1; try=$2
+           shift; shift
+           if $issymlink $try; then
+               $ls -l $try > reflect
                if $contains /`basename $ls` reflect >/dev/null 2>&1; then
-                       echo "You have BSD-like /proc/curproc/file."
-                       procselfexe='"/proc/curproc/file"'
-                       val="$define"
+                   echo "You have $type-like $try."
+                   procselfexe='"'$try'"'
+                   val="$define"
+                   : This will break out of the loop
+                   set X; shift
                fi
-       fi
+           fi
+       done
        ;;
 esac
 $rm -f reflect