Paul Nasrat c4acc0
--- tools/debugedit.c.jj	2007-03-14 14:11:04.000000000 +0100
Paul Nasrat c4acc0
+++ tools/debugedit.c	2007-03-14 15:39:34.000000000 +0100
Paul Nasrat c4acc0
@@ -372,38 +372,43 @@ canonicalize_path (const char *s, char *
Paul Nasrat c4acc0
       if (s[0] == '.' && (s[1] == 0 || IS_DIR_SEPARATOR (s[1])))
Paul Nasrat c4acc0
 	{
Paul Nasrat c4acc0
 	  s ++;
Paul Nasrat c4acc0
-	  if (*s)
Paul Nasrat c4acc0
-	    s++;
Paul Nasrat c4acc0
-	  else if (d > droot)
Paul Nasrat c4acc0
+	  if (!*s && d > droot)
Paul Nasrat c4acc0
 	    d--;
Paul Nasrat c4acc0
 	}
Paul Nasrat c4acc0
 
Paul Nasrat c4acc0
       else if (s[0] == '.' && s[1] == '.'
Paul Nasrat c4acc0
 	       && (s[2] == 0 || IS_DIR_SEPARATOR (s[2])))
Paul Nasrat c4acc0
 	{
Paul Nasrat c4acc0
-	  char *pre = d-1; /* includes slash */
Paul Nasrat c4acc0
+	  char *pre = d - 1; /* includes slash */
Paul Nasrat c4acc0
 	  while (droot < pre && IS_DIR_SEPARATOR (*pre))
Paul Nasrat c4acc0
 	    pre--;
Paul Nasrat c4acc0
 	  if (droot <= pre && ! IS_DIR_SEPARATOR (*pre))
Paul Nasrat c4acc0
 	    {
Paul Nasrat c4acc0
-	      d = pre;
Paul Nasrat c4acc0
-	      while (droot < d && ! IS_DIR_SEPARATOR (*d))
Paul Nasrat c4acc0
-		d--;
Paul Nasrat c4acc0
-	      /* d now points to the slash */
Paul Nasrat c4acc0
-	      if (droot < d)
Paul Nasrat c4acc0
-		d++;
Paul Nasrat c4acc0
-	      s += 2;
Paul Nasrat c4acc0
-	      if (*s)
Paul Nasrat c4acc0
-		s++;
Paul Nasrat c4acc0
-	      else if (d > droot)
Paul Nasrat c4acc0
-		d--;
Paul Nasrat c4acc0
+	      while (droot < pre && ! IS_DIR_SEPARATOR (*pre))
Paul Nasrat c4acc0
+		pre--;
Paul Nasrat c4acc0
+	      /* pre now points to the slash */
Paul Nasrat c4acc0
+	      if (droot < pre)
Paul Nasrat c4acc0
+		pre++;
Paul Nasrat c4acc0
+	      if (pre + 3 == d && pre[0] == '.' && pre[1] == '.')
Paul Nasrat c4acc0
+		{
Paul Nasrat c4acc0
+		  *d++ = *s++;
Paul Nasrat c4acc0
+		  *d++ = *s++;
Paul Nasrat c4acc0
+		}
Paul Nasrat c4acc0
+	      else
Paul Nasrat c4acc0
+		{
Paul Nasrat c4acc0
+		  d = pre;
Paul Nasrat c4acc0
+		  s += 2;
Paul Nasrat c4acc0
+		  if (*s)
Paul Nasrat c4acc0
+		    while (IS_DIR_SEPARATOR (*s))
Paul Nasrat c4acc0
+		      s++;
Paul Nasrat c4acc0
+		  else if (d > droot)
Paul Nasrat c4acc0
+		    d--;
Paul Nasrat c4acc0
+		}
Paul Nasrat c4acc0
 	    }
Paul Nasrat c4acc0
 	  else
Paul Nasrat c4acc0
 	    {
Paul Nasrat c4acc0
 	      *d++ = *s++;
Paul Nasrat c4acc0
 	      *d++ = *s++;
Paul Nasrat c4acc0
-	      if (*s)
Paul Nasrat c4acc0
-		*d++ = *s++;
Paul Nasrat c4acc0
 	    }
Paul Nasrat c4acc0
 	}
Paul Nasrat c4acc0