changeset 1760:0240ff815597

[xemacs-hg @ 2003-10-22 14:16:58 by james] Fix Cygwin problem with resolving symbolic links to absolute pathnames.
author james
date Wed, 22 Oct 2003 14:17:00 +0000
parents a14f3af8e6fb
children db7c7e251153
files src/ChangeLog src/realpath.c
diffstat 2 files changed, 20 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Tue Oct 21 23:49:42 2003 +0000
+++ b/src/ChangeLog	Wed Oct 22 14:17:00 2003 +0000
@@ -1,3 +1,8 @@
+2003-10-16  Jerry James  <james@xemacs.org>
+
+	* realpath.c (qxe_realpath): When a symbolic link to an absolute
+	pathname is found, really start over.
+
 2003-10-21  Stephen J. Turnbull  <stephen@xemacs.org>
 
 	* bytecode.c (execute_optimized_program):
--- a/src/realpath.c	Tue Oct 21 23:49:42 2003 +0000
+++ b/src/realpath.c	Wed Oct 22 14:17:00 2003 +0000
@@ -180,6 +180,8 @@
   int abslen = abs_start (path);
 #endif
 
+ restart:
+
   /* Make a copy of the source path since we may need to modify it. */
   qxestrcpy (copy_path, path);
   path = copy_path;
@@ -320,13 +322,19 @@
 	  /* Note: readlink doesn't add the null byte. */
 	  link_path[n] = '\0';
 	  
-	  if (abs_start (link_path) > 0)
-	    /* Start over for an absolute symlink. */
-	    new_path = resolved_path + abs_start (link_path) - 1;
-	  else
-	    /* Otherwise back up over this component. */
-	    for (--new_path; !IS_DIRECTORY_SEP (*new_path); --new_path)
-	      assert (new_path > resolved_path);
+	  abslen = abs_start (link_path);
+	  if (abslen > 0)
+	    {
+	      /* Start over for an absolute symlink. */
+	      new_path = resolved_path;
+	      qxestrcat (link_path, path);
+	      path = link_path;
+	      goto restart;
+	    }
+
+	  /* Otherwise back up over this component. */
+	  for (--new_path; !IS_DIRECTORY_SEP (*new_path); --new_path)
+	    assert (new_path > resolved_path);
 
 	  /* Safe sex check. */
 	  if (qxestrlen (path) + n >= PATH_MAX)