From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#47408: [PATCH] Etags support for Mercury -- fix explicit tags for existentially-quantified procedures Date: Thu, 17 Jun 2021 13:50:09 +0300 Message-ID: <83y2b8zrxa.fsf@gnu.org> References: <46bb9128-8bf5-e24c-2172-1cbb4202ee1d@gmail.com> <83lf7c5t6z.fsf@gnu.org> <46a10b9f-91d7-63c4-1513-0af4743e0940@gmail.com> <83eed45omq.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4700"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 47408@debbugs.gnu.org To: fabrice nicol Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Jun 17 12:51:11 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ltpc6-00013B-Ry for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 17 Jun 2021 12:51:10 +0200 Original-Received: from localhost ([::1]:59208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltpc5-0007Wl-TQ for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 17 Jun 2021 06:51:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:42738) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltpby-0007UM-E3 for bug-gnu-emacs@gnu.org; Thu, 17 Jun 2021 06:51:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42325) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltpby-0004vx-5g for bug-gnu-emacs@gnu.org; Thu, 17 Jun 2021 06:51:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ltpby-00032x-17 for bug-gnu-emacs@gnu.org; Thu, 17 Jun 2021 06:51:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 17 Jun 2021 10:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 47408 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 47408-submit@debbugs.gnu.org id=B47408.162392702911560 (code B ref 47408); Thu, 17 Jun 2021 10:51:01 +0000 Original-Received: (at 47408) by debbugs.gnu.org; 17 Jun 2021 10:50:29 +0000 Original-Received: from localhost ([127.0.0.1]:53871 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ltpbQ-00030N-SU for submit@debbugs.gnu.org; Thu, 17 Jun 2021 06:50:29 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:44900) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ltpbO-0002zB-Ge for 47408@debbugs.gnu.org; Thu, 17 Jun 2021 06:50:27 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:57958) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltpbI-0004N6-5D; Thu, 17 Jun 2021 06:50:20 -0400 Original-Received: from 84.94.185.95.cable.012.net.il ([84.94.185.95]:4905 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltpb4-0005Nl-SS; Thu, 17 Jun 2021 06:50:20 -0400 In-Reply-To: (message from fabrice nicol on Mon, 14 Jun 2021 20:52:54 +0200) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:208660 Archived-At: > Cc: 47408@debbugs.gnu.org, pot@gnu.org > From: fabrice nicol > 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?