[PATCH 1/2] libtool: replace : with $PATH_SEPARATOR

KO Myung-Hun <[email protected]> Sun, 15 Oct 2023 02:04:22 +0900
Newsgroups gmane.comp.gnu.libtool.patches
Message-ID <[email protected]>
Some OSes such as OS/2, uses ';' as a path separator. So using
$PATH_SEPARATOR instead of hard-coded ':' is more proper.

* build-aux-ltmain.in: replace : with $PATH_SEPARATOR.
* m4/libtool.m4: Likewise.
---
 build-aux/ltmain.in | 76 ++++++++++++++++++++++-----------------------
 m4/libtool.m4       | 16 +++++-----
 2 files changed, 46 insertions(+), 46 deletions(-)

diff --git a/build-aux/ltmain.in b/build-aux/ltmain.in
index 3b76bd08..cd38be04 100644
--- a/build-aux/ltmain.in
+++ b/build-aux/ltmain.in
@@ -733,8 +733,8 @@ func_resolve_sysroot ()
 # store the result into func_replace_sysroot_result.
 func_replace_sysroot ()
 {
-  case $lt_sysroot:$1 in
-  ?*:"$lt_sysroot"*)
+  case "$lt_sysroot$PATH_SEPARATOR$1" in
+  ?*"$PATH_SEPARATOR$lt_sysroot"*)
     func_stripname "$lt_sysroot" '' "$1"
     func_replace_sysroot_result='='$func_stripname_result
     ;;
@@ -2006,7 +2006,7 @@ func_mode_execute ()
       if eval "test -z \"\$$shlibpath_var\""; then
 	eval "$shlibpath_var=\"\$dir\""
       else
-	eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+	eval "$shlibpath_var=\"\$dir\$PATH_SEPARATOR\$$shlibpath_var\""
       fi
     done
 
@@ -3578,7 +3578,7 @@ func_exec_program ()
 	if test -n "$dllsearchpath"; then
 	  $ECHO "\
     # Add the dll search path components to the executable PATH
-    PATH=$dllsearchpath:\$PATH
+    PATH=\"$dllsearchpath$PATH_SEPARATOR\$PATH\"
 "
 	fi
 
@@ -3590,7 +3590,7 @@ func_exec_program ()
 
     # Some systems cannot cope with colon-terminated $shlibpath_var
     # The second colon is a workaround for a bug in BeOS R4 sed
-    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
+    $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/$PATH_SEPARATOR$PATH_SEPARATOR*\$//'\`
 
     export $shlibpath_var
 "
@@ -3801,7 +3801,7 @@ EOF
 	    fi
 
 	    if test -n "$dllsearchpath"; then
-              func_to_host_path "$dllsearchpath:"
+              func_to_host_path "$dllsearchpath$PATH_SEPARATOR"
 	      cat <<EOF
 const char * EXE_PATH_VARNAME = "PATH";
 const char * EXE_PATH_VALUE   = "$func_to_host_path_result";
@@ -5107,15 +5107,15 @@ func_mode_link ()
 	case $host in
 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
 	  testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
-	  case :$dllsearchpath: in
-	  *":$dir:"*) ;;
-	  ::) dllsearchpath=$dir;;
-	  *) func_append dllsearchpath ":$dir";;
+	  case "$PATH_SEPARATOR$dllsearchpath$PATH_SEPARATOR" in
+	  *"$PATH_SEPARATOR$dir$PATH_SEPARATOR"*) ;;
+	  "$PATH_SEPARATOR$PATH_SEPARATOR") dllsearchpath=$dir;;
+	  *) func_append dllsearchpath "$PATH_SEPARATOR$dir";;
 	  esac
-	  case :$dllsearchpath: in
-	  *":$testbindir:"*) ;;
-	  ::) dllsearchpath=$testbindir;;
-	  *) func_append dllsearchpath ":$testbindir";;
+	  case "$PATH_SEPARATOR$dllsearchpath$PATH_SEPARATOR" in
+	  *"$PATH_SEPARATOR$testbindir$PATH_SEPARATOR"*) ;;
+	  "$PATH_SEPARATOR$PATH_SEPARATOR") dllsearchpath=$testbindir;;
+	  *) func_append dllsearchpath "$PATH_SEPARATOR$testbindir";;
 	  esac
 	  ;;
 	esac
@@ -5592,7 +5592,7 @@ func_mode_link ()
 
     if test -n "$shlibpath_var"; then
       # get the directories listed in $shlibpath_var
-      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
+      eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/$PATH_SEPARATOR/ /g\'\`
     else
       shlib_search_path=
     fi
@@ -6223,9 +6223,9 @@ func_mode_link ()
 	    # We need to hardcode the library path
 	    if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
 	      # Make sure the rpath contains only unique directories.
-	      case $temp_rpath: in
-	      *"$absdir:"*) ;;
-	      *) func_append temp_rpath "$absdir:" ;;
+	      case "$temp_rpath$PATH_SEPARATOR" in
+	      *"$absdir$PATH_SEPARATOR"*) ;;
+	      *) func_append temp_rpath "$absdir$PATH_SEPARATOR" ;;
 	      esac
 	    fi
 
@@ -6450,9 +6450,9 @@ func_mode_link ()
 	    fi
 
 	    if test -n "$add_shlibpath"; then
-	      case :$compile_shlibpath: in
-	      *":$add_shlibpath:"*) ;;
-	      *) func_append compile_shlibpath "$add_shlibpath:" ;;
+	      case "$PATH_SEPARATOR$compile_shlibpath$PATH_SEPARATOR" in
+	      *"$PATH_SEPARATOR$add_shlibpath$PATH_SEPARATOR"*) ;;
+	      *) func_append compile_shlibpath "$add_shlibpath$PATH_SEPARATOR" ;;
 	      esac
 	    fi
 	    if test prog = "$linkmode"; then
@@ -6464,9 +6464,9 @@ func_mode_link ()
 	      if test yes != "$hardcode_direct" &&
 		 test yes != "$hardcode_minus_L" &&
 		 test yes = "$hardcode_shlibpath_var"; then
-		case :$finalize_shlibpath: in
-		*":$libdir:"*) ;;
-		*) func_append finalize_shlibpath "$libdir:" ;;
+		case "$PATH_SEPARATOR$finalize_shlibpath$PATH_SEPARATOR" in
+		*"$PATH_SEPARATOR$libdir$PATH_SEPARATOR"*) ;;
+		*) func_append finalize_shlibpath "$libdir$PATH_SEPARATOR" ;;
 		esac
 	      fi
 	    fi
@@ -6484,9 +6484,9 @@ func_mode_link ()
 	      add_dir=-L$libdir
 	      add=-l$name
 	    elif test yes = "$hardcode_shlibpath_var"; then
-	      case :$finalize_shlibpath: in
-	      *":$libdir:"*) ;;
-	      *) func_append finalize_shlibpath "$libdir:" ;;
+	      case "$PATH_SEPARATOR$finalize_shlibpath$PATH_SEPARATOR" in
+	      *"$PATH_SEPARATOR$libdir$PATH_SEPARATOR"*) ;;
+	      *) func_append finalize_shlibpath "$libdir$PATH_SEPARATOR" ;;
 	      esac
 	      add=-l$name
 	    elif test yes = "$hardcode_automatic"; then
@@ -7713,7 +7713,7 @@ EOF
 	    # We should set the runpath_var.
 	    rpath=
 	    for dir in $perm_rpath; do
-	      func_append rpath "$dir:"
+	      func_append rpath "$dir$PATH_SEPARATOR"
 	    done
 	    eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
 	  fi
@@ -8435,15 +8435,15 @@ EOF
 	case $host in
 	*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
 	  testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
-	  case :$dllsearchpath: in
-	  *":$libdir:"*) ;;
-	  ::) dllsearchpath=$libdir;;
-	  *) func_append dllsearchpath ":$libdir";;
+	  case "$PATH_SEPARATOR$dllsearchpath$PATH_SEPARATOR" in
+	  *"$PATH_SEPARATOR$libdir$PATH_SEPARATOR"*) ;;
+	  "$PATH_SEPARATOR$PATH_SEPARATOR") dllsearchpath=$libdir;;
+	  *) func_append dllsearchpath "$PATH_SEPARATOR$libdir";;
 	  esac
-	  case :$dllsearchpath: in
-	  *":$testbindir:"*) ;;
-	  ::) dllsearchpath=$testbindir;;
-	  *) func_append dllsearchpath ":$testbindir";;
+	  case "$PATH_SEPARATOR$dllsearchpath$PATH_SEPARATOR" in
+	  *"$PATH_SEPARATOR$testbindir$PATH_SEPARATOR"*) ;;
+	  "$PATH_SEPARATOR$PATH_SEPARATOR") dllsearchpath=$testbindir;;
+	  *) func_append dllsearchpath "$PATH_SEPARATOR$testbindir";;
 	  esac
 	  ;;
 	esac
@@ -8557,7 +8557,7 @@ EOF
 	  # We should set the runpath_var.
 	  rpath=
 	  for dir in $perm_rpath; do
-	    func_append rpath "$dir:"
+	    func_append rpath "$dir$PATH_SEPARATOR"
 	  done
 	  compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
 	fi
@@ -8565,7 +8565,7 @@ EOF
 	  # We should set the runpath_var.
 	  rpath=
 	  for dir in $finalize_perm_rpath; do
-	    func_append rpath "$dir:"
+	    func_append rpath "$dir$PATH_SEPARATOR"
 	  done
 	  finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
 	fi
diff --git a/m4/libtool.m4 b/m4/libtool.m4
index 79a2451e..f63b8406 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -2276,18 +2276,18 @@ func_munge_path_list ()
     case x@S|@2 in
     x)
         ;;
-    *:)
-        eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'` \@S|@@S|@1\"
+    *"$PATH_SEPARATOR")
+        eval @S|@1=\"`$ECHO @S|@2 | $SED "s/$PATH_SEPARATOR/ /g"` \@S|@@S|@1\"
         ;;
-    x:*)
-        eval @S|@1=\"\@S|@@S|@1 `$ECHO @S|@2 | $SED 's/:/ /g'`\"
+    "x$PATH_SEPARATOR"*)
+        eval @S|@1=\"\@S|@@S|@1 `$ECHO @S|@2 | $SED "s/$PATH_SEPARATOR/ /g"`\"
         ;;
-    *::*)
-        eval @S|@1=\"\@S|@@S|@1\ `$ECHO @S|@2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"
-        eval @S|@1=\"`$ECHO @S|@2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \@S|@@S|@1\"
+    *"$PATH_SEPARATOR$PATH_SEPARATOR"*)
+        eval @S|@1=\"\@S|@@S|@1\ `$ECHO @S|@2 | $SED -e "s/.*$PATH_SEPARATOR$PATH_SEPARATOR"'//" -e "s/$PATH_SEPARATOR/ /g"`\"
+        eval @S|@1=\"`$ECHO @S|@2 | $SED -e "s/$PATH_SEPARATOR$PATH_SEPARATOR.*//" -e "s/$PATH_SEPARATOR/ /g"`\ \@S|@@S|@1\"
         ;;
     *)
-        eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'`\"
+        eval @S|@1=\"`$ECHO @S|@2 | $SED "s/$PATH_SEPARATOR/ /g"`\"
         ;;
     esac
 }
-- 
2.42.0