Subject: bug#47408: Etags support for Mercury [v0.5]

From: Eli Zaretskii <[email-masked]>
Date: Thu, 10 Jun 2021 22:15:11 +0300

> Date: Thu, 10 Jun 2021 20:20:45 +0300
> From: Eli Zaretskii <[email-masked]>
> Cc: [email-masked]
> 
> It should have been the job of mercury_pr to find the identifier
> itself within the line whose pointer it accepts as S, and pass only
> that to make_tag as NAME/NAMELEN arguments.  I made a step in that
> direction, but it turns out I didn't go far enough.  Feel free to
> propose improvements to the code I installed so as to identify the
> name of the identifier and nothing else, as other callers of make_tag
> do.
> 
> > The issue seems to be located at the patch line below:
> > 
> > 
> > + char *name = skip_non_spaces (s + len0);
> 
> The only problem with the above line is that it assumes there's only
> one non-space "word" before the identifier proper, whereas the example
> you show makes it clear there could be more than one.  Which means the
> code might need to repeatedly skip these non-identifier words until we
> exhaust them all.  I will look into fixing that (but I really prefer
> that you do it in my stead, as I don't know enough about the Mercury's
> syntax).

I think one way of solving this would be for mercury_decl to return
more information to the caller than it currently does.  That function
already performs the necessary analysis of the line, and knows where
the real identifier is located within that line.  But it doesn't
return that information to the caller.  If it could return the pointer
to the beginning of the identifier and the length of the identifier,
it would allow mercury_pr to call make_tag correctly without doing
again what mercury_decl already did.

If you agree with this analysis, I'd be grateful if you could submit a
patch along these lines.  TIA.