From dc2a33bd91c55f10880e66a47f8843349303fd4c Mon Sep 17 00:00:00 2001 From: "cls%seawood.org" Date: Thu, 14 Aug 2003 21:32:11 +0000 Subject: [PATCH] Do not spawn processes when converting cygwin paths. Signficant performance enhancement. Thanks to paxunix@acm.org for the patch. Bug #206643 r=bryner sr=cls a=mkaply --- build/cygwin-wrapper | 51 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/build/cygwin-wrapper b/build/cygwin-wrapper index 3da3c508d749..2c9a1dcbbe24 100755 --- a/build/cygwin-wrapper +++ b/build/cygwin-wrapper @@ -7,17 +7,48 @@ shift if test -z "$prog"; then exit 0 fi -mountpoint=`mount -p | awk '{ if (/^\//) { print $1; exit } }'` + +mountpoint=$CYGDRIVE_MOUNT if test -z "$mountpoint"; then - print "Cannot determine cygwin mount points. Exiting" - exit 1 + mountpoint=`mount -p` + if test -z "$mountpoint"; then + print "Cannot determine cygwin mount points. Exiting" + exit 1 + fi fi -mountpoint=`echo $mountpoint | sed 's|/$||'` -if test "$prog" = "-up"; then - prog=$1 - shift - args=`echo $* | sed -e "s|-I\([a-zA-Z]\):/|-I${mountpoint}/\1/|g;"` -else - args=`echo $* | sed -e "s|${mountpoint}/\([a-zA-Z]\)/|\1:/|g;"` + +mountpoint=${mountpoint#*/} +mountpoint=/${mountpoint%%[!A-Za-z0-9_]*} +mountpoint=${mountpoint%/} + +args="" +up="" +if test "${prog}" = "-up"; then + up=1 + prog=${1} + shift fi + +for i in "${@}" +do + if test -n "${up}"; then + pathname=${i#-I[a-zA-Z]:/} + if ! test "${pathname}" = "${i}"; then + no_i=${i#-I} + driveletter=${no_i%%:*} + i=-I${mountpoint}/${driveletter}/${pathname} + fi + else + eval 'leader=${i%%'${mountpoint}'/[a-zA-Z]/*}' + if ! test "${leader}" = "${i}"; then + eval 'pathname=${i#'${leader}${mountpoint}'/[a-zA-Z]/}' + eval 'no_mountpoint=${i#'${leader}${mountpoint}'/}' + driveletter=${no_mountpoint%%/*} + i=${leader}${driveletter}:/${pathname} + fi + fi + + args="${args} ${i}" +done + exec $prog $args