]> Savannah Git Hosting - gnulib.git/commitdiff
relocatable: Fix that /@unixroot prefix is not working on OS/2 kLIBC
authorKO Myung-Hun <komh78@gmail.com>
Thu, 1 Dec 2016 10:52:44 +0000 (19:52 +0900)
committerPádraig Brady <P@draigBrady.com>
Thu, 1 Dec 2016 11:36:13 +0000 (11:36 +0000)
OS/2 kLIBC has a feature to rewrite some path components. For example,
'/@unixroot' is replaced with a value of $UNIXROOT if it is.

So prepending a drive letter to the path starting with '/' makes the
path starting with '/@unixroot' to 'x:/@unixroot' which is unexpected.

This will breaks the behavior of some programs depending on /@unixroot
prefix.

* lib/relocatable.c (relocate): Do not touch pathname if it is started
with '/@unixroot'.

ChangeLog
lib/relocatable.c

index 6eaaf7f455cded558a33d75ed5aed69413f4b71c..6b4d0d5c9781bcca1bf31bc7fbd22c9331ce1cb7 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2016-12-01  KO Myung-Hun  <komh78@gmail.com>
+
+       relocatable: Fix that /@unixroot prefix is not working on OS/2 kLIBC
+       * lib/relocatable.c (relocate): Do not touch pathname if it is started
+       with '/@unixroot'.
+
 2016-12-01  KO Myung-Hun  <komh78@gmail.com>
 
        sys_socket: typedef sa_family_t correctly on OS/2 kLIBC
index 60cb54ac7e17c2a1dd58dcab72b27402623fe2a8..401f3e0e45dbe57b62f0fb88a0cc9bf1b9024543 100644 (file)
@@ -539,6 +539,18 @@ relocate (const char *pathname)
     }
 
 #ifdef __EMX__
+# ifdef __KLIBC__
+#  undef strncmp
+
+  if (pathname && strncmp (pathname, "/@unixroot", 10) == 0
+      && (pathname[10] == '\0' || pathname[10] == '/' || pathname[10] == '\\'))
+    {
+      /* kLIBC itself processes /@unixroot prefix */
+
+      return pathname;
+    }
+  else
+# endif
   if (pathname && ISSLASH (pathname[0]))
     {
       const char *unixroot = getenv ("UNIXROOT");