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#73771: 30.0.91; etags generates broken TAGS file for multi-line regex match Date: Sun, 13 Oct 2024 15:58:44 +0300 Message-ID: <86ldystb0b.fsf@gnu.org> References: <87zfn9tmf4.fsf@ice9.digital> <86wmiduw93.fsf@gnu.org> <871q0ki8hj.fsf@tucano.isti.cnr.it> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13894"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 73771@debbugs.gnu.org, morgan@ice9.digital To: Francesco =?UTF-8?Q?Potort=C3=AC?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Oct 13 15:00:14 2024 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 1szyCj-0003Pa-Qy for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 13 Oct 2024 15:00:14 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1szyCP-000393-UT; Sun, 13 Oct 2024 08:59:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1szyCJ-000385-S8 for bug-gnu-emacs@gnu.org; Sun, 13 Oct 2024 08:59:48 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1szyCJ-0008Ka-Il for bug-gnu-emacs@gnu.org; Sun, 13 Oct 2024 08:59:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-version:References:In-Reply-To:From:Date:To:Subject; bh=fsHugbOq0q/PrtRI0w7mtPkcUlH7xvs/rG0tfZvQCmQ=; b=MRGoMWG3UFtL5nWxoE8bL+pDsFxJabQFSBroxnFx/2pCYJ5StLKsYyJHFeIwsXp7uEqA0NqYuKRX7h2ImBRfyoVhRfo8525Z1YlGyAClFNHwjZqbWHD1bF/osIygt4REVFBA/guS3bG9tcaV0vplMDz4LLLRU1LId5np8nEimyg4DIukMjTQJf+IkQ0NBVKzrfCH5CU3O9wI+7OcmAZw/83+Nq5yR8ukXKu7xyWMjUTLkzEWutqRd9lJ5tIB98XelaUQdQXXPJwArZKNFwIOHaVL7c+2TBz5++CAdBYZN0bwtz7HVNrtPmf9oka6dCbms2sJ1IymBhsx++36KKkrYQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1szyCY-0000e3-Iq for bug-gnu-emacs@gnu.org; Sun, 13 Oct 2024 09:00: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: Sun, 13 Oct 2024 13:00:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73771 X-GNU-PR-Package: emacs Original-Received: via spool by 73771-submit@debbugs.gnu.org id=B73771.17288243512363 (code B ref 73771); Sun, 13 Oct 2024 13:00:02 +0000 Original-Received: (at 73771) by debbugs.gnu.org; 13 Oct 2024 12:59:11 +0000 Original-Received: from localhost ([127.0.0.1]:50540 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1szyBi-0000c2-QZ for submit@debbugs.gnu.org; Sun, 13 Oct 2024 08:59:11 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:57004) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1szyBh-0000bn-2T for 73771@debbugs.gnu.org; Sun, 13 Oct 2024 08:59:09 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1szyBK-0008FP-Ru; Sun, 13 Oct 2024 08:58:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=fsHugbOq0q/PrtRI0w7mtPkcUlH7xvs/rG0tfZvQCmQ=; b=oqjRxitUnlBnWD1ljXwp j881TJNonfOfJKyeVAjlxsXd5f3vRPo1sx3Fbn70Gj8ZZbIjrSF1AzFw2nhszErCcA7myVefT9qcF p3mz3y5MIg46LkYs6y8bHMurX4x8xrrYKcp8IIRi2Gl9KzjY4Rd/2BHqimjTJNyoFumtj1eg+ymzK Eb04MX8QVz52Hu4T6xedEhV4fSKAF8F8lCuWPw5U2W2K9QiTKIth2jiGDEdAGXu+MHQ06GIxkTVYY RhVqfTf5+hxA+OjCUgva5bpdSjAHarRAEN/UJqHUMX/0HpPd5+xjBEEDlHTxNF5DBvI3qKAwhRZgk 6H2+U7QwX/yy9Q==; In-Reply-To: <871q0ki8hj.fsf@tucano.isti.cnr.it> (message from Francesco =?UTF-8?Q?Potort=C3=AC?= on Sun, 13 Oct 2024 12:48:40 +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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:293517 Archived-At: > From: Francesco Potort́ > Date: Sun, 13 Oct 2024 12:48:40 +0200 > Cc: 73771@debbugs.gnu.org, > Morgan Willcock > > >This is because etags always records one extra character with the > >regexp match, which is harmless, unless that extra character is a > >newline. The patch below fixes it: > > > >diff --git a/lib-src/etags.c b/lib-src/etags.c > >index a822a82..848d8ea 100644 > >--- a/lib-src/etags.c > >+++ b/lib-src/etags.c > >@@ -7420,7 +7420,7 @@ regex_tag_multiline (void) > > > > /* Force explicit tag name, if a name is there. */ > > pfnote (name, true, buffer + linecharno, > >- charno - linecharno + 1, lineno, linecharno); > >+ charno - linecharno, lineno, linecharno); > > > > if (debug) > > fprintf (stderr, "%s on %s:%"PRIdMAX": %s\n", > > > >Francesco, why does the code add one more character there? > > While I can't remember the reason, I am sure it was not done by chance. > > Sure, I may have been wrong at that time, or maybe that reason is now obsolete. To check, one should run the etags regression test and check the results. I already did. The only differences I see are in that 1 extra character, which is now no longer written to TAGS in the tests which use multi-line regexps. Note that the change is only in this single call to pfnote, from the code that is part of generating tags from multi-line regexp matches. > Off the top of my head, it may have to do with implicitly named tags that are initial substring of a different tag, but this may be a fake reconstruction of my mind, The tags we produce from regexp matches are norally explicitly named, AFAICT: /* Match occurred. Construct a tag. */ while (charno < rp->regs.end[0]) if (buffer[charno++] == '\n') lineno++, linecharno = charno; name = rp->name; if (name[0] == '\0') name = NULL; else /* make a named tag */ name = substitute (buffer, rp->name, &rp->regs); /* Force explicit tag name, if a name is there. */ pfnote (name, true, buffer + linecharno, charno - linecharno, lineno, linecharno); But if you say that we should add that offset of 1 when 'name' is NULL, I'm okay with doing that.