François Pinard <pin...@iro.umontreal.ca> writes:

> Nick Dokos <ndo...@gmail.com> writes:
>
>> you can leave org out of the picture altogether: create an empty
>> buffer, insert 33333 x's by hand, go to the beginning and evaluate
>
>>    (looking-at ".*foo")
>
>> As Stefan says in the thread you pointed out, it's a limitation of the
>> emacs regexp engine.
>
> Yes, I got this from his article.  However, it seems that "[^\nf]*foo"
> would succeed, avoiding the stack explosion.  So, it is possible to
> rework the regexpes around the limitation.
>
> Surely not a fun job to do for Org regexpes, I know.  Maybe not worth
> doing as very long lines are unusual, yet maybe worth doing nevertheless
> for Org files because long lines are still possible.  The fact is that I
> was hit by this problem in the Org buffers generated by org-grep.
>

It would be better to reimplement the regexp engine using e.g. an NDFA.
IIRC, it requires constant stack but it limits the regexps allowed. See
e.g.

        http://swtch.com/~rsc/regexp/regexp1.html

It might make sense to pair the NDFA with a backtracker. The pattern
compiler could then choose which one to use based on the regexp.

-- 
Nick


Reply via email to