From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: [BUG] Regexp compiler, problem with character classes Date: Mon, 18 Sep 2006 09:03:47 -0400 Message-ID: References: <87fyeu5937.fsf@stupidchicken.com> <87eju9z67y.fsf@stupidchicken.com> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1158584671 23899 80.91.229.2 (18 Sep 2006 13:04:31 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 18 Sep 2006 13:04:31 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Sep 18 15:04:29 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GPIn8-0002ax-9t for ged-emacs-devel@m.gmane.org; Mon, 18 Sep 2006 15:04:07 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GPIn7-0002vG-RG for ged-emacs-devel@m.gmane.org; Mon, 18 Sep 2006 09:04:05 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GPImu-0002q3-Dl for emacs-devel@gnu.org; Mon, 18 Sep 2006 09:03:52 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GPIms-0002lO-0G for emacs-devel@gnu.org; Mon, 18 Sep 2006 09:03:51 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GPImr-0002l1-Pj for emacs-devel@gnu.org; Mon, 18 Sep 2006 09:03:49 -0400 Original-Received: from [209.226.175.184] (helo=tomts22-srv.bellnexxia.net) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GPIph-00064Z-Gy for emacs-devel@gnu.org; Mon, 18 Sep 2006 09:06:45 -0400 Original-Received: from localhost ([70.55.143.90]) by tomts22-srv.bellnexxia.net (InterMail vM.5.01.06.13 201-253-122-130-113-20050324) with ESMTP id <20060918130347.VHBD10262.tomts22-srv.bellnexxia.net@localhost>; Mon, 18 Sep 2006 09:03:47 -0400 Original-Received: by localhost (Postfix, from userid 20848) id 71F2185B5; Mon, 18 Sep 2006 09:03:47 -0400 (EDT) Original-To: Chong Yidong In-Reply-To: <87eju9z67y.fsf@stupidchicken.com> (Chong Yidong's message of "Mon\, 18 Sep 2006 08\:53\:21 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:59962 Archived-At: >>>> 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 > Emacs-devel@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-devel