bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#47408: [PATCH] Etags support for Mercury -- fix explicit tags for ex


From: Eli Zaretskii
Subject: bug#47408: [PATCH] Etags support for Mercury -- fix explicit tags for existentially-quantified procedures
Date: Thu, 17 Jun 2021 13:50:09 +0300

> Cc: 47408@debbugs.gnu.org, pot@gnu.org
> From: fabrice nicol <fabrnicol@gmail.com>
> Date: Mon, 14 Jun 2021 20:52:54 +0200
> 
> Agreed. (But you may have more systematically explicit tags because of 
> this condition 2.)
> 
> The attached patch was tested, builds and runs OK. Replaces the former 
> one, is you stick to the option of modifying 's' by reference rather 
> than creating a copy.

Thanks.  I confirm that this works, but I have 2 follow-up issues with
this patch:

1. It adds tags for some identifiers that AFAUI are actually
   keywords, and shouldn't be in the TAGS tables.  Examples:
   "interface" (e.g., on line 146 of accumulator.m) and
   "implementation" (e.g., on line 166).  I guess this is unintended?
   If so, how to fix it?

2. It always produces "explicitly named" tags, which I think is
   unnecessary.  AFAICT, this is related to the following snippet from
   mercury_pr:

> +      /* Left-trim type definitions.  */
> +
> +      while (pos > namelength + offset
> +          && c_isspace (s[pos - namelength - offset]))
> +     --offset;
> +
> +      /* There is no need to correct namelength or call notinname.  */
> +      s[pos - offset - 1] = '\0';
> +
> +      make_tag (s + pos - namelength - offset, namelength, true, s, pos, 
> lineno, linecharno);
> +      return pos;

   I don't understand why you need to overwrite s[pos - offset -1]
   with the null byte: the same effect could be obtained by adjusting
   the POS argument passed to make_tag.  Also, you in effect chop off
   the last character of NAME, but don't adjust NAMELENGTH
   accordingly.  These factors together cause make_tag to decide that
   an explicitly-named tag is in order, because name[namelength-1] is
   a null byte, which is rejected as being "not-a-name" character.

   To fix this second issue, I propose the change below, which should
   be applied on top of your patches:

diff --git a/lib-src/etags.c b/lib-src/etags.c
index 370e825..2b0288e 100644
--- a/lib-src/etags.c
+++ b/lib-src/etags.c
@@ -6585,10 +6585,8 @@ mercury_pr (char *s, char *last, ptrdiff_t lastlen)
             && c_isspace (s[pos - namelength - offset]))
        --offset;
 
-      /* There is no need to correct namelength or call notinname.  */
-      s[pos - offset - 1] = '\0';
-
-      make_tag (s + pos - namelength - offset, namelength, true, s, pos, 
lineno, linecharno);
+      make_tag (s + pos - namelength - offset, namelength - 1, true,
+               s, pos - offset - 1, lineno, linecharno);
       return pos;
     }
 
I've verified that etags after this change still produces the correct
TAGS file, including for the file univ.m you sent up-thread.

Do you agree with the changes I propose?  If not, could you please
explain what I miss here?





reply via email to

[Prev in Thread] Current Thread [Next in Thread]