emacs-devel
[Top][All Lists]
Advanced

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

Re: [BUG] Regexp compiler, problem with character classes


From: Stefan Monnier
Subject: Re: [BUG] Regexp compiler, problem with character classes
Date: Mon, 18 Sep 2006 09:03:47 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

>>>> The easiest way to fix that bug is to make each element of the
>>>> compiled regexp cache specify the syntax table that it corresponds
>>>> to, and make modify-syntax-entry clear the cache. That way, no
>>>> change in regex.c is needed.
>>> Does this patch look OK? [...]
>> 
>> The "make each element of the compiled regexp cache specify the syntax
>> table that it corresponds to" part is still needed.
>> 
>> Here's an example:
>> 
>> $ emacs -Q
>> 
>> Evaluate in *scratch*:
>> 
>> (list
>> (string-match "x[[:space:]]" "x\n")
>> (with-temp-buffer
>> (string-match "x[[:space:]]" "x\n")))
>> 
>> => (nil nil)
>> 
>> Expected: (nil 0)

> You're right; the following additional patch should fix that.

Looks good.  But please add a comment/todo item that the syntax-table should
only be stored&checked in the (rare) case that something like [[:space:]]
is used.


        Stefan


> *** emacs/src/search.c.~1.213.~       2006-09-18 08:39:59.000000000 -0400
> --- emacs/src/search.c        2006-09-18 08:51:50.000000000 -0400
> ***************
> *** 41,47 ****
>   struct regexp_cache
>   {
>     struct regexp_cache *next;
> !   Lisp_Object regexp, whitespace_regexp;
>     struct re_pattern_buffer buf;
>     char fastmap[0400];
>     /* Nonzero means regexp was compiled to do full POSIX backtracking.  */
> --- 41,47 ----
>   struct regexp_cache
>   {
>     struct regexp_cache *next;
> !   Lisp_Object regexp, whitespace_regexp, syntax_table;
>     struct re_pattern_buffer buf;
>     char fastmap[0400];
>     /* Nonzero means regexp was compiled to do full POSIX backtracking.  */
> ***************
> *** 167,172 ****
> --- 167,173 ----
cp-> posix = posix;
cp-> buf.multibyte = multibyte;
cp-> whitespace_regexp = Vsearch_spaces_regexp;
> +   cp->syntax_table = current_buffer->syntax_table;
>     /* Doing BLOCK_INPUT here has the effect that
>        the debugger won't run if an error occurs.
>        Why is BLOCK_INPUT needed here?  */
> ***************
> *** 256,261 ****
> --- 257,263 ----
>         && EQ (cp->buf.translate, (! NILP (translate) ? translate : 
> make_number (0)))
>         && cp->posix == posix
>         && cp->buf.multibyte == multibyte
> +       && EQ (cp->syntax_table, current_buffer->syntax_table)
>         && !NILP (Fequal (cp->whitespace_regexp, Vsearch_spaces_regexp)))
>       break;
  
> ***************
> *** 3114,3121 ****
> --- 3116,3125 ----
>         searchbufs[i].buf.fastmap = searchbufs[i].fastmap;
>         searchbufs[i].regexp = Qnil;
>         searchbufs[i].whitespace_regexp = Qnil;
> +       searchbufs[i].syntax_table = Qnil;
>         staticpro (&searchbufs[i].regexp);
>         staticpro (&searchbufs[i].whitespace_regexp);
> +       staticpro (&searchbufs[i].syntax_table);
>         searchbufs[i].next = (i == REGEXP_CACHE_SIZE-1 ? 0 : 
> &searchbufs[i+1]);
>       }
>     searchbuf_head = &searchbufs[0];


> _______________________________________________
> Emacs-devel mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/emacs-devel




reply via email to

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