From 712d0374f725449c00a309f873a315b09e685c7b Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Mon, 29 Mar 2004 09:26:31 +0000
Subject: [PATCH] =?UTF-8?q?fix=20to=20figure=20out=20the=20"real"=20window?=
 =?UTF-8?q?s=20path=20when=20built=20and=20run=20with=20mingw=20Andr=E9s?=
 =?UTF-8?q?=20Garc=EDa=20helped=20out!?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 tests/runtests.pl | 47 +++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 43 insertions(+), 4 deletions(-)

diff --git a/tests/runtests.pl b/tests/runtests.pl
index ad37504d10..b02b9f4497 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -659,12 +659,51 @@ sub checkcurl {
 
         if($_ =~ /^curl/) {
             $curl = $_;
-
             $curl =~ s/^(.*)(libcurl.*)/$1/g;
             $libcurl = $2;
-
-           if ($curl =~ /win32/)
-           {
+            if($curl =~ /mingw32/) {
+                # This is a windows minw32 build, we need to translate the
+                # given path to the "actual" windows path.
+
+                my @m = `mount`;
+                my $matchlen;
+                my $bestmatch;
+                my $mount;
+
+# example mount output:
+# C:\DOCUME~1\Temp on /tmp type user (binmode,noumount)
+# c:\ActiveState\perl on /perl type user (binmode)
+# C:\msys\1.0\bin on /usr/bin type user (binmode,cygexec,noumount)
+# C:\msys\1.0\bin on /bin type user (binmode,cygexec,noumount)
+
+                foreach $mount (@m) {
+                    if( $mount =~ /(.*) on ([^ ]*) type /) {
+                        my ($mingw, $real)=($2, $1);
+                        if($pwd =~ /^$mingw/) {
+                            # the path we got from pwd starts with the path
+                            # we found on this line in the mount output
+
+                            my $len = length($real);
+                            if($len > $matchlen) {
+                                # we remember the match that is the longest
+                                $matchlen = $len;
+                                $bestmatch = $real;
+                            }
+                        }
+                    }
+                }
+                if(!$matchlen) {
+                    print "Serious error, can't find our \"real\" path!\n";
+                }
+                else {
+                    # now prepend the prefix from the mount command to build
+                    # our "actual path"
+                    $pwd = "$bestmatch$pwd";
+                }
+                $pwd =~ s#\\#/#g;
+            }
+            elsif ($curl =~ /win32/)
+            {
                # Native Windows builds don't understand the
                # output of cygwin's pwd.  It will be
                # something like /cygdrive/c/<some path>.
-- 
GitLab