From: Alan Mackenzie <acm@muc.de>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: Marcin Borkowski <mbork@amu.edu.pl>, 19873@debbugs.gnu.org
Subject: bug#19873: Ill-formed regular expression is constructed in forward-paragraph.
Date: Thu, 2 Dec 2021 20:45:17 +0000 [thread overview]
Message-ID: <YakwXbh40S/F7XII@ACM> (raw)
In-Reply-To: <87y25347ew.fsf@gnus.org>
Hello, Lars.
On Thu, Dec 02, 2021 at 11:39:51 +0100, Lars Ingebrigtsen wrote:
> Alan Mackenzie <acm@muc.de> writes:
> > I think this idea is workable, but you'll have to check for one or both
> > of paragraph-s{tart,eparate} starting with "[ \t]+". A good strategy
> > here might be to begin the target regexp with "^[ \t]*", then begin one
> > or both components with "[ \t]" (without the "*").
> > There may be other gotchas which I haven't thought about yet.
> > One needs a twisted mind to do this sort of thing properly, so I offer my
> > services to review your upcoming patch. ;-)
> The problem seems rather intractable to me. Is there really any way to
> examine a regexp to determine "does this in practice match [ \t]*"?
Back when the bug was new, I started writing a library to analyse a
regular expression and convert it into an equivalent well formed regular
expression. It's actually working, but is incomplete. It's currently
2757 lines long, including pretty complete unit testing. I actually
looked at it again at the start of November.
> I wonder whether instead of trying to construct a better overall regexp
> could rewrite the loop. That is, instead of searching for sp-parstart,
> search for parstart "\\|" parsep, and then check whether
> (match-beginning 0) of that comes after "^[ \t]*". Or something along
> those lines.
> But I don't know whether that'd be any faster in practice.
It strikes me as one of these things which needs to be done
systematically, which, as I said, I've already tried (and not yet given
up). The question presents itself, would the effort be better spent
improving Emacs's regexp engine?
> Do you have a test case that demonstrates the slowness? In that case I
> could try to see whether there's any alternate approach here that's
> faster.
Martin Rudalics had the original testcase. The slowness was exponential
with the number of spaces typed, I think.
> --
> (domestic pets only, the antidote for overdose, milk.)
> bloggy blog: http://lars.ingebrigtsen.no
--
Alan Mackenzie (Nuremberg, Germany).
next prev parent reply other threads:[~2021-12-02 20:45 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-15 10:31 bug#19873: Ill-formed regular expression is constructed in forward-paragraph Alan Mackenzie
2017-02-26 16:44 ` Marcin Borkowski
2017-02-26 16:57 ` Eli Zaretskii
2017-02-26 18:48 ` Marcin Borkowski
2017-03-07 16:47 ` Eli Zaretskii
2017-03-09 21:04 ` Alan Mackenzie
2021-12-02 10:39 ` Lars Ingebrigtsen
2021-12-02 10:44 ` Lars Ingebrigtsen
2021-12-02 11:17 ` Lars Ingebrigtsen
2021-12-02 20:45 ` Alan Mackenzie [this message]
2021-12-03 16:15 ` Lars Ingebrigtsen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=YakwXbh40S/F7XII@ACM \
--to=acm@muc.de \
--cc=19873@debbugs.gnu.org \
--cc=larsi@gnus.org \
--cc=mbork@amu.edu.pl \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.