GNU bug report logs - #47408
Emacs etags support for Mercury [v0.2]

Previous Next

Package: emacs;

Reported by: fabrice nicol <fabrnicol <at> gmail.com>

Date: Fri, 26 Mar 2021 08:28:02 UTC

Severity: normal

Tags: patch

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #93 received at 47408 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: fabrice nicol <fabrnicol <at> gmail.com>
Cc: 47408 <at> debbugs.gnu.org, pot <at> gnu.org
Subject: Re: [PATCH] Etags support for Mercury -- fix explicit tags for
 existentially-quantified procedures
Date: Mon, 14 Jun 2021 19:04:04 +0300
> From: fabrice nicol <fabrnicol <at> gmail.com>
> Date: Mon, 14 Jun 2021 17:10:26 +0200
> 
> I'm sending the announced patch, which enables existentially-quantified 
> procedures for both etags and ctags in Mercury etags/ctags support.
> 
> Taking advantage of this to revise my prior contribution, I fixed an 
> incidental issue (single-word declarations, which are very rare, were 
> not tagged).

Thanks.  I didn't yet try to apply and run the patch, but one aspect
of the patch caused me to raise mu brow:

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

Why do you copy the identifier's name into a newly-allocated buffer,
instead of just passing 's + pos - namelength - offset' and
'namelength' as the first 2 arguments of make_tag?  Isn't this
xnew+memcpy+free dance here redundant?  Or what did I miss?




This bug report was last modified 3 years and 338 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.