emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: c-mode imenu: Stack overflow in regexp matcher


From: Stefan Monnier
Subject: Re: c-mode imenu: Stack overflow in regexp matcher
Date: Wed, 07 Feb 2007 10:44:11 -0500
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.93 (gnu/linux)

>>> This will do it:
>> 
>>> (goto-char (point-max))
>>> (re-search-backward "^\\<[^()]*[^[:alnum:]_:<>~]")
>> 
>>> It matches the whole of etc/splash.xpm from "static char..." right
>>> through to the end, some 60000 odd characters later.
>> 
>> Good, thanks.  Then now we have to find someone who knows what the regexp is
>> supposed to match, so as to figure out how to rewrite it.

> progmodes/cc-menus.el:

> (defvar cc-imenu-c++-generic-expression
>         ...

>     ;; General function name regexp
>     (nil
>      ,(concat
>        "^\\<"                                 ; line MUST start with word char
>        "[^()]*"                               ; no parentheses before
>        "[^" c-alnum "_:<>~]"                  ; match any non-identifier char
>        "\\([" c-alpha "_][" c-alnum "_:<>~]*\\)" ; match function name
>        "\\([ \t\n]\\|\\\\\n\\)*("           ; see above, BUT the arg list
>        "\\([ \t\n]\\|\\\\\n\\)*\\([^ \t\n(*][^)]*\\)?)" ; must not start
>        "\\([ \t\n]\\|\\\\\n\\)*[^ \t\n;(]"    ; with an asterisk or 
> parentheses
>        ) 1)

Yes, I saw that, but it's still not clear to me what's going on here.
E.g. the "match any non-identifier char" can match a parenthesis, is
that correct?

I guess a quick fix is to replace [^()] by [^()\n].


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]