From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Philipp Stephani Newsgroups: gmane.emacs.bugs Subject: bug#29343: 27.0.50; Match data doesn't contain elements for non-matched subgroups Date: Sat, 16 Dec 2017 14:29:12 +0000 Message-ID: References: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a11481742818646056075f1e9" X-Trace: blaine.gmane.org 1513434610 14094 195.159.176.226 (16 Dec 2017 14:30:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 16 Dec 2017 14:30:10 +0000 (UTC) To: 29343@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Dec 16 15:30:06 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQDTZ-0003Oq-3q for geb-bug-gnu-emacs@m.gmane.org; Sat, 16 Dec 2017 15:30:05 +0100 Original-Received: from localhost ([::1]:50930 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQDTg-0004ux-BK for geb-bug-gnu-emacs@m.gmane.org; Sat, 16 Dec 2017 09:30:12 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59807) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eQDTa-0004un-GP for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2017 09:30:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eQDTX-0002jr-BG for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2017 09:30:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:56083) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eQDTX-0002j5-6n for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2017 09:30:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eQDTW-0000Ff-Qi for bug-gnu-emacs@gnu.org; Sat, 16 Dec 2017 09:30:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Philipp Stephani Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 16 Dec 2017 14:30:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 29343 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 29343-submit@debbugs.gnu.org id=B29343.1513434569894 (code B ref 29343); Sat, 16 Dec 2017 14:30:02 +0000 Original-Received: (at 29343) by debbugs.gnu.org; 16 Dec 2017 14:29:29 +0000 Original-Received: from localhost ([127.0.0.1]:36531 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQDSz-0000EM-Ld for submit@debbugs.gnu.org; Sat, 16 Dec 2017 09:29:29 -0500 Original-Received: from mail-qt0-f180.google.com ([209.85.216.180]:33996) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eQDSy-0000EB-LW for 29343@debbugs.gnu.org; Sat, 16 Dec 2017 09:29:28 -0500 Original-Received: by mail-qt0-f180.google.com with SMTP id 33so15415603qtv.1 for <29343@debbugs.gnu.org>; Sat, 16 Dec 2017 06:29:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=KUu90OE0NAedt4fj5qgPfzi11V+t+2ojgbNGjYNHnzE=; b=ui9TnbFMH74D8S/4YzyGXTBTfRJk2MNwJQeyUgAQP+mZu07gffIMb2kMszu4DuAhs4 9GG/kCOQwYxUfRE0hP+QDtsZh0AGm4FzhZHbOBoc7M963P5hDrNWRQ8ok4X0oVe1BexO dq5vy4SUjpMWlKsSx7O4egyMk/gk2eqx+6OYnNvyj/Lqt0F7QhGVZbxKO0iA2S8scJUB uauKa3JKNdRtNhnMuBYTirgG9EtNb7UTWXeCWTzi10RcP/TUDCt/OTWhpgukNkD68yj8 eaRBJ0O17DdoRjX3sAHNly1bjmG81k9gVw+Et2Gp9uA6WqEh2yifK97LGs7KFAChb2H2 eweA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=KUu90OE0NAedt4fj5qgPfzi11V+t+2ojgbNGjYNHnzE=; b=tXQTlySuZqkduAlp7FCrEjoriUZBG5Sy8v2hyxReXL799oYT27IcB2YWbpkruRIPH0 5EpfsGQZ5dn9diV5ultvtQKVzd2aXpZuEj4KAc+5FDTXOmzbMLvygljNIECi1dk+mw+i FqeY3Hmc4cUsvR8/A4PVcCvk6KyjkNCCJhCyPkIdDmj4msycgptdpnNED2so8drSzTQL 19XTgTp4p8hdXDNtxIna9GDxIdl5zyyNgFQLYnvvbPLEzIRxfG76lrzo/mkThstvRioh LPdTbzKAiDaNlMMyfYtYwq32TftFs1YfsOze2MbJB0WyOcUBjNwtsX3ICfkqiXLEdZcW f8nA== X-Gm-Message-State: AKGB3mKW2kR92s+aNUu/4nuIAkXfMluimd2awsJohZz3ImiouIW0G16e L0IcGSR3neoUcpg5MLAxwF2w7J5L7lmGUqNeGPvF7A== X-Google-Smtp-Source: ACJfBovfgJzSpRrRNxD0ZC/pNiib/XGyNi5fTCu3kQsKEXstNTiv491K3sTmmR+MOLXgThklUM+I7AetgrqA9sWNG0c= X-Received: by 10.200.23.20 with SMTP id w20mr4384488qtj.210.1513434562789; Sat, 16 Dec 2017 06:29:22 -0800 (PST) In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:141157 Archived-At: --001a11481742818646056075f1e9 Content-Type: text/plain; charset="UTF-8" Philipp Stephani schrieb am Fr., 17. Nov. 2017 um 21:12 Uhr: > > $ emacs -Q -batch -eval '(progn (string-match "^\\(a\\)?\\(b\\)\\(c\\)?$" > "b") (print (match-data)))' > (0 1 nil nil 0 1) > > Note that neither the `a` nor the `c` group matched, but there are > entries for `a` in `match-data`, but not for `c`. This makes working > with the match data unnecessarily hard because its length depends on > whether certain optional groups have matched or not. I haven't seen any > discussion about this behavior in either the manual or the docstring. I > think the match data in this case should be (0 1 nil nil 0 1 nil nil). > > It turns out that this is harder than I expected, because the information about the number of groups in the pattern isn't stored anywhere, and search_regs.num_regs may be different from the group count. If it turns out too hard to fix, the behavior should at least be documented. --001a11481742818646056075f1e9 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


Philip= p Stephani <p.stephani2@gmail.c= om> schrieb am Fr., 17. Nov. 2017 um 21:12=C2=A0Uhr:

$ emacs -Q -batch -eval '(progn (string-match "^\\(a\\)?\\(b\\)\\(= c\\)?$" "b") (print (match-data)))'
(0 1 nil nil 0 1)

Note that neither the `a` nor the `c` group matched, but there are
entries for `a` in `match-data`, but not for `c`.=C2=A0 This makes working<= br> with the match data unnecessarily hard because its length depends on
whether certain optional groups have matched or not.=C2=A0 I haven't se= en any
discussion about this behavior in either the manual or the docstring.=C2=A0= I
think the match data in this case should be (0 1 nil nil 0 1 nil nil).


It turns out that this is harder than I ex= pected, because the information about the number of groups in the pattern i= sn't stored anywhere, and search_regs.num_regs may be different from th= e group count. If it turns out too hard to fix, the behavior should at leas= t be documented.
--001a11481742818646056075f1e9--