]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
libtool: Forward slash escaping check on Windows
authorEvgeny Grin <k2k@narod.ru>
Fri, 4 Jul 2025 15:02:31 +0000 (18:02 +0300)
committerIleana Dumitrescu <ileanadumitrescu95@gmail.com>
Thu, 7 Aug 2025 17:20:06 +0000 (20:20 +0300)
Without cygpath, Window's 'cmd' may hang with a single slash (when transforming)
and may hang with two slashes (when not transforming).

Reported: https://savannah.gnu.org/support/index.php?110901

* build-aux/ltmain.in: Use one or two slashes with Window's command
  prompt based on cached value in lt_cv_cmd_slashes.
* m4/libtool.m4: Cache whether one or two slashes are needed with
  Window's command prompt, when cygpath is not installed in path.

build-aux/ltmain.in
m4/libtool.m4

index 06207bc8499ed7d73b4f1905f968af5c10b3927d..9c85d6603d2cca82f55f00b3c519dd5e907a0dcb 100644 (file)
@@ -1030,8 +1030,13 @@ func_convert_core_msys_to_w32 ()
   $debug_cmd
 
   # Compatibility for original MSYS
+  if test "Xone" = "X$lt_cv_cmd_slashes"; then
+  func_convert_core_msys_to_w32_result=`( cmd /c echo "$1" ) 2>/dev/null |
+    $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
+  else # Assume 'lt_cv_cmd_slashes = "two"'
   func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
     $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
+  fi
   if test "$?" -ne 0; then
       # on failure, ensure result is empty
       func_convert_core_msys_to_w32_result=
@@ -1193,7 +1198,7 @@ func_convert_file_msys_to_w32 ()
 
   func_to_host_file_result=$1
   if test -n "$1"; then
-    if test "yes" = "$cygpath_installed"; then
+    if test "Xyes" = "X$cygpath_installed"; then
       func_convert_core_msys_to_w32_with_cygpath -w "$1"
       func_to_host_file_result=$func_convert_core_msys_to_w32_with_cygpath_result
     else
@@ -1250,7 +1255,7 @@ func_convert_file_msys_to_cygwin ()
 
   func_to_host_file_result=$1
   if test -n "$1"; then
-    if test "yes" = "$cygpath_installed"; then
+    if test "Xyes" = "X$cygpath_installed"; then
       func_convert_core_msys_to_w32_with_cygpath -w "$1"
       func_cygpath -u "$func_convert_core_msys_to_w32_with_cygpath_result"
     else
@@ -1357,7 +1362,7 @@ func_convert_path_msys_to_w32 ()
     # and winepath ignores them completely.
     func_stripname : : "$1"
     func_to_host_path_tmp1=$func_stripname_result
-    if test "yes" = "$cygpath_installed"; then
+    if test "Xyes" = "X$cygpath_installed"; then
       func_convert_core_msys_to_w32_with_cygpath -w -p "$func_to_host_path_tmp1"
       func_to_host_path_result=$func_convert_core_msys_to_w32_with_cygpath_result
     else
@@ -1427,7 +1432,7 @@ func_convert_path_msys_to_cygwin ()
     # See func_convert_path_msys_to_w32:
     func_stripname : : "$1"
     func_to_host_path_tmp1=$func_stripname_result
-    if test "yes" = "$cygpath_installed"; then
+    if test "Xyes" = "X$cygpath_installed"; then
       func_convert_core_msys_to_w32_with_cygpath -w -p "$func_to_host_path_tmp1"
       func_cygpath -u -p "$func_convert_core_msys_to_w32_with_cygpath_result"
     else
index 75e666d4bb578ed13f33ab6f360731616f499293..48e47748be96988b51014318d99ce7623397adeb 100644 (file)
@@ -8717,26 +8717,39 @@ AC_MSG_RESULT([$lt_cv_to_tool_file_cmd])
 _LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd],
          [0], [convert $build files to toolchain format])dnl
 
-AC_MSG_CHECKING([whether cygpath is installed])
-AC_CACHE_VAL(lt_cv_cygpath_installed,
-[lt_cv_cygpath_installed=ignoring;
-case $host in
-  *-*-mingw* | *-*-windows* | *-*-cygwin*)
-    case $build in
-      *-*-mingw* | *-*-windows* | *-*-cygwin*)
-        cygpath --help &> /dev/null
-        _lt_result=$?
-        if test 0 = "$_lt_result"; then
-          lt_cv_cygpath_installed=yes;
-        else
-          lt_cv_cygpath_installed=no;
-        fi
-        ;;
-    esac
-    ;;
-esac
-])
-AC_MSG_RESULT([$lt_cv_cygpath_installed])
-_LT_DECL([cygpath_installed], [lt_cv_cygpath_installed],
-         [0], [whether cygpath is installed])dnl
+AS_CASE([$host],
+  [*-*-mingw* | *-*-windows* | *-*-cygwin*],
+  [AS_CASE([$build],
+    [*-*-mingw* | *-*-windows* | *-*-cygwin*],
+    [AC_MSG_CHECKING([whether cygpath is installed])
+      AC_CACHE_VAL([lt_cv_cygpath_installed],
+        [lt_cv_cygpath_installed=ignoring
+          cygpath --help &> /dev/null
+          _lt_result=$?
+          AS_IF([test 0 = "$_lt_result"],
+            [lt_cv_cygpath_installed=yes],
+            [lt_cv_cygpath_installed=no])
+        ])
+      AC_MSG_RESULT([$lt_cv_cygpath_installed])
+      _LT_DECL([cygpath_installed], [lt_cv_cygpath_installed],
+               [0], [whether cygpath is installed])dnl
+      AS_IF([test "xyes" != "x$lt_cv_cygpath_installed"],
+        [
+          AC_MSG_CHECKING([whether to use cmd with one slash or two slashes])
+          AC_CACHE_VAL([lt_cv_cmd_slashes],
+            [
+              _lt_result=`cmd /c echo one-slash works. Not checked //c echo two-slashes 2>/dev/null`
+              AS_IF([test 0 != $?],
+                [AC_MSG_ERROR([Do not know how to convert paths])])
+              AS_CASE([$_lt_result],
+                [one-slash*],[lt_cv_cmd_slashes="one"],
+                [two-slashes*],[lt_cv_cmd_slashes="two"],
+                [AC_MSG_ERROR([Do not know how to convert paths])]
+              )
+            ])
+          AC_MSG_RESULT([$lt_cv_cmd_slashes])
+        ])
+    ])
+  ]
+)dnl
 ])# _LT_PATH_CONVERSION_FUNCTIONS