Subject: bug#32: Bug in etags ".." code

From: Tom Tromey <[email-masked]>
Date: Sun, 02 Mar 2008 17:02:48 -0700

I ran etags like this:

etags ./eval.c -o $(pwd)//.retags.d/Q

Note the double "/".

The resulting tags file contains this line:

../../eval.c,567

But this is wrong, there should be only a single "..".

I think relative_filename needs to handle the situation where multiple
"/"s appear consecutively.  The appended patch worked for me.

Tom

*** etags.c	07 Feb 2008 19:34:52 -0700	3.82
--- etags.c	02 Mar 2008 17:01:30 -0700	
***************
*** 6792,6799 ****
  
    /* Build a sequence of "../" strings for the resulting relative file name. */
    i = 0;
    while ((dp = etags_strchr (dp + 1, '/')) != NULL)
!     i += 1;
    res = xnew (3*i + strlen (fp + 1) + 1, char);
    res[0] = '\0';
    while (i-- > 0)
--- 6792,6805 ----
  
    /* Build a sequence of "../" strings for the resulting relative file name. */
    i = 0;
+   while (*dp == '/')
+     ++dp;
    while ((dp = etags_strchr (dp + 1, '/')) != NULL)
!     {
!       i += 1;
!       while (*dp == '/')
! 	++dp;
!     }
    res = xnew (3*i + strlen (fp + 1) + 1, char);
    res[0] = '\0';
    while (i-- > 0)