[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Emacs-diffs] emacs-25 223b3f0: Improve regex to not trigger stack o
From: |
Stefan Monnier |
Subject: |
Re: [Emacs-diffs] emacs-25 223b3f0: Improve regex to not trigger stack overflow |
Date: |
Sun, 13 Dec 2015 15:21:13 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.1.50 (gnu/linux) |
> - "\\[[^][]*\\<label[[:space:]]*=[[:space:]]*{?\\(?1:[^],}]+\\)}?")
> +
> "\\[[^][]\\{0,2000\\}\\<label[[:space:]]*=[[:space:]]*{?\\(?1:[^],}]+\\)}?")
BTW, if you don't like the arbitrary limit, you can probably "fix" the
problem (or at least reduce the stack usage enough that it doesn't show
up any more in practice) by replacing "[^][]*" with something like
"\\(?:[^[],]*,\\)*[ \t]*".
The difference is that in "[^[],]*,", the "*" repetition will be done
without any need to record state for eventual backtracking (because
the "," is mutually exclusive with the "[^[],]", and the regexp matcher
includes a special optimization for that case since it's common and
very useful).
Stefan
- Re: [Emacs-diffs] emacs-25 223b3f0: Improve regex to not trigger stack overflow,
Stefan Monnier <=