]> git.eshelyaron.com Git - emacs.git/commitdiff
(relative_filename): Stop backward search at beginning
authorKarl Heuer <kwzh@gnu.org>
Tue, 12 Jan 1999 21:58:08 +0000 (21:58 +0000)
committerKarl Heuer <kwzh@gnu.org>
Tue, 12 Jan 1999 21:58:08 +0000 (21:58 +0000)
of string, since non-Unix systems can have absolute paths with no
initial slash.

lib-src/etags.c

index 22e6d35ae10378bd4af80c400df3914c0a2bb660..b838d90b636b94ee90d0082805dbc572b30b6611 100644 (file)
@@ -4714,9 +4714,10 @@ relative_filename (file, dir)
   while (*fp++ == *dp++)
     continue;
   fp--, dp--;                  /* back to the first differing char */
-  do                           /* look at the equal chars until '/' */
+  do {                         /* look at the equal chars until '/' */
+    if (fp == abs) return abs; /* first char differs, give up */
     fp--, dp--;
-  while (*fp != '/');
+  while (*fp != '/');
 
   /* Build a sequence of "../" strings for the resulting relative file name. */
   i = 0;