From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: fabrice nicol Newsgroups: gmane.emacs.bugs Subject: bug#47408: [PATCH] Etags support for Mercury -- fix explicit tags for existentially-quantified procedures Date: Mon, 14 Jun 2021 19:10:53 +0200 Message-ID: <46a10b9f-91d7-63c4-1513-0af4743e0940@gmail.com> References: <46bb9128-8bf5-e24c-2172-1cbb4202ee1d@gmail.com> <83lf7c5t6z.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23279"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.2 Cc: 47408@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jun 14 19:10:10 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 1lsq6E-0005sm-AT for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 14 Jun 2021 19:10:10 +0200 Original-Received: from localhost ([::1]:57994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lsq6C-0000FU-ET for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 14 Jun 2021 13:10:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44808) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lsq67-0000FM-14 for bug-gnu-emacs@gnu.org; Mon, 14 Jun 2021 13:10:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:36197) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lsq66-0006GN-PF for bug-gnu-emacs@gnu.org; Mon, 14 Jun 2021 13:10:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lsq66-0002aD-G2 for bug-gnu-emacs@gnu.org; Mon, 14 Jun 2021 13:10:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: fabrice nicol Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 14 Jun 2021 17:10:02 +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.16236905889905 (code B ref 47408); Mon, 14 Jun 2021 17:10:02 +0000 Original-Received: (at 47408) by debbugs.gnu.org; 14 Jun 2021 17:09:48 +0000 Original-Received: from localhost ([127.0.0.1]:47743 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lsq5s-0002Zh-BR for submit@debbugs.gnu.org; Mon, 14 Jun 2021 13:09:48 -0400 Original-Received: from mail-wr1-f50.google.com ([209.85.221.50]:46064) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lsq5r-0002ZU-AA for 47408@debbugs.gnu.org; Mon, 14 Jun 2021 13:09:47 -0400 Original-Received: by mail-wr1-f50.google.com with SMTP id z8so15332090wrp.12 for <47408@debbugs.gnu.org>; Mon, 14 Jun 2021 10:09:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=GNjyejysL4DeYUnJ2c61KteY9JlykMcYE9AGBjZq558=; b=F/qxl8bKyhQjt3bnRoS7rme5YUK2Ug1FExpSkoY28LbLcFpJJ14tv4Zrl42NsAqYCQ elB3s6nZUlxjjt4qrKKBB7xbIpRa2f0UBcbPsZhWZlXHdHHHlVxNKGdp04uV25MdoeAK VBs3qA6p+MSi2kMufxeT+SyCdHwP8GIUK3IQDYln101ZZIAfxQXJRMLIVnyefcdXT9Bv o8re1x40sg2qOItm2dHFjzvNdBl3akbKRiQkNqoS9X6lEkXJL0LjyJj/T1G5gsdbfNle MNIFupFSUccUR1WLREan/DEGZvH5zjGn8A9dLX09tF4OdgVfqg4Ba8TGVi7LwkeqgOg4 nb1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=GNjyejysL4DeYUnJ2c61KteY9JlykMcYE9AGBjZq558=; b=YeEJ0uxHtlGBSJWAadAb/86WysjkHj0zFfJr2ednB/diIX+gVrauIJxxAxlfjGMNVz ueATJNZ5hFAsJyWUlJOhsp/e+Tx+BBJid8r6ojE7ShlJhZRiNWLAb38xw2e1V8hUC5uw a/AORHR2WwMP7kM+9rtKAiUyVvw9eJRBrJg1k0MKB1VerJuY79UFbpY/qXpjUj5Q0FYp uZUFGbM/3WJSMZkdrvqYffka8ctE5GyyjrqoeA1vZeI0UANUOxZXuRkXsKvr+Peno76h OAaQlUhlgcQy4v5kbZe857s1/HmeC7x4XcFlBsKC2GRwk94bfZeQ9127YEY8Yulu4266 VC2g== X-Gm-Message-State: AOAM533eh7qLhiYkSMxIRpiYZqmSYtBIjYUcJNiwGT7RcL/BPgXbuXjW SELZbfJcSiWNHVZ0T5WLxeg= X-Google-Smtp-Source: ABdhPJyha1w8/y8cFIE/cBGFZTDwfnlwq4uu1aACav9t6Hq9GNq17Uwl7Dk5fJDEOOchIhOHkfFNWg== X-Received: by 2002:a05:6000:18ca:: with SMTP id w10mr12244282wrq.55.1623690581334; Mon, 14 Jun 2021 10:09:41 -0700 (PDT) Original-Received: from ?IPv6:2a01:cb1d:88b9:5c00:7b73:7901:965e:8523? ([2a01:cb1d:88b9:5c00:7b73:7901:965e:8523]) by smtp.gmail.com with ESMTPSA id f14sm71568wmq.10.2021.06.14.10.09.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Jun 2021 10:09:41 -0700 (PDT) In-Reply-To: <83lf7c5t6z.fsf@gnu.org> Content-Language: en-US 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:208512 Archived-At: Yes, I'm afraid that you missed something there this time around. If you take a look at other languages that implement explicit tags (like Fortran) you will see that there are buffers coming in to avoid having 'name' and 'linestart' (1st and 4th arguments to 'make_tag') share a same string pointer (here 's'). This is explained in the header comment to 'make_tag': " 2. LINESTART contains name as either a rightmost, or rightmost but  *     one character, substring;" which is a bit of a convoluted constraint: better protect oneself and bufferize from the ground up. In most cases (though perhaps with occasional exceptions), if I followed your suggestion, 'name' would be a substring with aon offset of  at least +2 bytes from start of string s. When I applied you suggestion and tested, the TAGS base was as expected accordingly: wrong. Fabrice >> 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?