GNU bug report logs - #11216
23.4; parenthesis matching breaks on certain complex expressions

Previous Next

Package: emacs;

Reported by: Nathan Trapuzzano <nbtrap <at> nbtrap.com>

Date: Wed, 11 Apr 2012 00:21:01 UTC

Severity: minor

Tags: notabug

Found in version 23.4

Done: Stefan Kangas <stefan <at> marxist.se>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 11216 in the body.
You can then email your comments to 11216 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#11216; Package emacs. (Wed, 11 Apr 2012 00:21:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Nathan Trapuzzano <nbtrap <at> nbtrap.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 11 Apr 2012 00:21:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 23.4; parenthesis matching breaks on certain complex expressions
Date: Tue, 10 Apr 2012 20:18:47 -0400
[Message part 1 (text/plain, inline)]
Here's a complex regular expression that breaks parenthesis matching
(and yes, that's a real regular expression generated from a real perl
program).


M[?+]?(?:-(?:[\x01-\x7f]*[\x00\x80-\xff]+))?[\x02-\x19\x22-\x27\x28-\x2e\x30-\x3c\x3e-\x40\x5b\x5d-\x7b\x7d-\xff]*H[?+]?(?:-(?:[\x01-\x7f]*[\x00\x80-\xff]+))?[\x02-\x19\x22-\x27\x28-\x2e\x30-\x3c\x3e-\x40\x5b\x5d-\x7b\x7d-\xff]*\=[?+]?(?:-(?:[\x01-\x7f]*[\x00\x80-\xff]+))?[\x02-\x19\x22-\x27\x28-\x2e\x30-\x3c\x3e-\x40\x5b\x5d-\x7b\x7d-\xff]*N[?+]?(?:-(?:[\x01-\x7f]*[\x00\x80-\xff]+))?[\x02-\x19\x22-\x27\x28-\x2e\x30-\x3c\x3e-\x40\x5b\x5d-\x7b\x7d-\xff]*I[\=\/\\]?[?+]?(?:-(?:[\x01-\x7f]*[\x00\x80-\xff]+))?[\x02-\x19\x22-\x27\x28-\x2e\x30-\x3c\x3e-\x40\x5b\x5d-\x7b\x7d-\xff]*N(?![\x21\x27\x2a\x2d\x2f\x3d\x41-\x5a\x5c\x61-\x7a\x7c]) (?<!S\d)(?<!\-\ [@"]\d\ [\x80-\xff])(?<!\-[\x80-\xff][\x80-\xff])(?<!\-[\x80-\xff])(?<![\x27-\x29\x2f\x3d\x41-\x5a\x7c]\*)(?<![\x27-\x29\x2f\x3d\x41-\x5a\x7c])(?:A\)[\/\\]|\*\)[\/\\]A[\=\/\\]?)[?+]?(?:-(?:[\x01-\x7f]*[\x00\x80-\xff]+))?[\x02-\x19\x22-\x27\x28-\x2e\x30-\x3c\x3e-\x40\x5b\x5d-\x7b\x7d-\xff]*[?+]?(?:-(?:[\x01-\x7f]*[\x00\x80-\xff]+))?[\x02-\x19\x22-\x27\x28-\x2e\x30-\x3c\x3e-\x40\x5b\x5d-\x7b\x7d-\xff]*E[\=\/\\]?[?+]?(?:-(?:[\x01-\x7f]*[\x00\x80-\xff]+))?[\x02-\x19\x22-\x27\x28-\x2e\x30-\x3c\x3e-\x40\x5b\x5d-\x7b\x7d-\xff]*I[\=\/\\]?[?+]?(?:-(?:[\x01-\x7f]*[\x00\x80-\xff]+))?[\x02-\x19\x22-\x27\x28-\x2e\x30-\x3c\x3e-\x40\x5b\x5d-\x7b\x7d-\xff]*D[?+]?(?:-(?:[\x01-\x7f]*[\x00\x80-\xff]+))?[\x02-\x19\x22-\x27\x28-\x2e\x30-\x3c\x3e-\x40\x5b\x5d-\x7b\x7d-\xff]*E[\=\/\\]?(?![\x21\x27\x2a\x2d\x2f\x3d\x41-\x5a\x5c\x61-\x7a\x7c]) (?<!S\d)(?<!\-\ [@"]\d\ [\x80-\xff])(?<!\-[\x80-\xff][\x80-\xff])(?<!\-[\x80-\xff])(?<![\x27-\x29\x2f\x3d\x41-\x5a\x7c]\*)(?<![\x27-\x29\x2f\x3d\x41-\x5a\x7c])Q[?+]?(?:-(?:[\x01-\x7f]*[\x00\x80-\xff]+))?[\x02-\x19\x22-\x27\x28-\x2e\x30-\x3c\x3e-\x40\x5b\x5d-\x7b\x7d-\xff]*E[?+]?(?:-(?:[\x01-\x7f]*[\x00\x80-\xff]+))?[\x02-\x19\x22-\x27\x28-\x2e\x30-\x3c\x3e-\x40\x5b\x5d-\x7b\x7d-\xff]*A[?+]?(?:-(?:[\x01-\x7f]*[\x00\x80-\xff]+))?[\x02-\x19\x22-\x27\x28-\x2e\x30-\x3c\x3e-\x40\x5b\x5d-\x7b\x7d-\xff]*[\/\\]

Matching gets messed up with the open parenthesis immediately following
the first (?<!S\d). I suspect this is due to the opening double-quote
about 10 characters later.

I noticed that the behavior of show-paren-mode changes depending on the
major mode. For example, the behavior described above happens in
fundamental mode, whereas when I switch to text mode, quotation marks
are ignored. However, switching to text mode also causes paren-matching
to ignore back-slashes and thus escaped parentheses/brackets. I think
the best fix would be to enable customization of show-paren-mode so
that the user can specify which characters should be ignored when
matching parentheses.

I've also attached a file containing the regexp in question in case the long line gets broken up over mail transmission.
[regexp.txt (text/plain, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11216; Package emacs. (Wed, 11 Apr 2012 07:11:01 GMT) Full text and rfc822 format available.

Message #8 received at 11216 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
Cc: 11216 <at> debbugs.gnu.org
Subject: Re: bug#11216: 23.4;
	parenthesis matching breaks on certain complex expressions
Date: Wed, 11 Apr 2012 09:09:21 +0200
Nathan Trapuzzano <nbtrap <at> nbtrap.com> writes:

> Matching gets messed up with the open parenthesis immediately following
> the first (?<!S\d). I suspect this is due to the opening double-quote
> about 10 characters later.

No, it's because < has open paren syntax, but there is no matching
close paren.  This is not a bug.  You need to use a suitable syntax
table that doesn't make < a paren syntax.

Andreas.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11216; Package emacs. (Thu, 12 Apr 2012 02:10:02 GMT) Full text and rfc822 format available.

Message #11 received at 11216 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Nathan Trapuzzano <nbtrap <at> nbtrap.com>
Cc: 11216 <at> debbugs.gnu.org
Subject: Re: bug#11216: 23.4;
	parenthesis matching breaks on certain complex expressions
Date: Wed, 11 Apr 2012 22:08:39 -0400
> Here's a complex regular expression that breaks parenthesis matching
> (and yes, that's a real regular expression generated from a real perl
> program).
[...]
> I think the best fix would be to enable customization of
> show-paren-mode so that the user can specify which characters should
> be ignored when matching parentheses.

show-paren-mode is customized by the major-mode, so all you have to do
is use the right major mode.  E.g. perl-mode.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#11216; Package emacs. (Fri, 01 Nov 2019 20:12:02 GMT) Full text and rfc822 format available.

Message #14 received at 11216 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefan <at> marxist.se>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: Nathan Trapuzzano <nbtrap <at> nbtrap.com>, 11216 <at> debbugs.gnu.org
Subject: Re: bug#11216: 23.4; parenthesis matching breaks on certain complex
 expressions
Date: Fri, 01 Nov 2019 21:11:27 +0100
tags 11216 + notabug
close 11216
thanks

Andreas Schwab <schwab <at> linux-m68k.org> writes:

> Nathan Trapuzzano <nbtrap <at> nbtrap.com> writes:
>
>> Matching gets messed up with the open parenthesis immediately following
>> the first (?<!S\d). I suspect this is due to the opening double-quote
>> about 10 characters later.
>
> No, it's because < has open paren syntax, but there is no matching
> close paren.  This is not a bug.  You need to use a suitable syntax
> table that doesn't make < a paren syntax.

With the above explanaition, I'm closing this as notabug.

Please reopen if this is incorrect.

Best regards,
Stefan Kangas




Added tag(s) notabug. Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Fri, 01 Nov 2019 20:12:03 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 11216 <at> debbugs.gnu.org and Nathan Trapuzzano <nbtrap <at> nbtrap.com> Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Fri, 01 Nov 2019 20:12:03 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 30 Nov 2019 12:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 138 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.