From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Re: next-single-property-change Date: Tue, 12 Sep 2006 12:51:57 -0400 Message-ID: <87zmd5gh8y.fsf@stupidchicken.com> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1158079868 13849 80.91.229.2 (12 Sep 2006 16:51:08 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Tue, 12 Sep 2006 16:51:08 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Sep 12 18:51:07 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 1GNBSy-0001QS-AV for ged-emacs-devel@m.gmane.org; Tue, 12 Sep 2006 18:50:35 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GNBSx-0000dh-T7 for ged-emacs-devel@m.gmane.org; Tue, 12 Sep 2006 12:50:32 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1GNBSa-0000Yf-1m for emacs-devel@gnu.org; Tue, 12 Sep 2006 12:50:08 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1GNBSZ-0000YG-7h for emacs-devel@gnu.org; Tue, 12 Sep 2006 12:50:07 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GNBSZ-0000Y8-1w for emacs-devel@gnu.org; Tue, 12 Sep 2006 12:50:07 -0400 Original-Received: from [18.19.1.138] (helo=cyd) by monty-python.gnu.org with esmtp (Exim 4.52) id 1GNBU4-0007wJ-H3; Tue, 12 Sep 2006 12:51:40 -0400 Original-Received: by cyd (Postfix, from userid 1000) id 5B83E4EB5C; Tue, 12 Sep 2006 12:51:57 -0400 (EDT) Original-To: rms@gnu.org In-Reply-To: (Richard Stallman's message of "Tue\, 12 Sep 2006 11\:27\:38 -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:59740 Archived-At: Richard Stallman writes: > Would someone please install this change and ack? Done. (I updated FOR-RELEASE too). > From: Stefan Monnier > Date: Fri, 08 Sep 2006 17:29:32 -0400 > >> Would someone please fix this and DTRT? > >> The docsting of next-single-property-change promises that it will >> never return a value equal to the position given, but it does if the >> buffer is narrowed and the next property change occurs after the >> narrowed region. Test case: > > I believe the patch below corrects this problem (for related functions as > well). Can you confirm? > > > Stefan > > > --- orig/src/textprop.c > +++ mod/src/textprop.c > @@ -1001,17 +1001,16 @@ > && (NILP (limit) || next->position < XFASTINT (limit))) > next = next_interval (next); > > - if (NULL_INTERVAL_P (next)) > - return limit; > - if (NILP (limit)) > - XSETFASTINT (limit, (STRINGP (object) > - ? SCHARS (object) > - : BUF_ZV (XBUFFER (object)))); > - if (!(next->position < XFASTINT (limit))) > + if (NULL_INTERVAL_P (next) > + || (next->position > + >= (INTEGERP (limit) > + ? XFASTINT (limit) > + : (STRINGP (object) > + ? SCHARS (object) > + : BUF_ZV (XBUFFER (object)))))) > return limit; > - > - XSETFASTINT (position, next->position); > - return position; > + else > + return make_number (next->position); > } > > /* Return 1 if there's a change in some property between BEG and END. */ > @@ -1083,16 +1082,16 @@ > && (NILP (limit) || next->position < XFASTINT (limit))) > next = next_interval (next); > > - if (NULL_INTERVAL_P (next)) > - return limit; > - if (NILP (limit)) > - XSETFASTINT (limit, (STRINGP (object) > - ? SCHARS (object) > - : BUF_ZV (XBUFFER (object)))); > - if (!(next->position < XFASTINT (limit))) > + if (NULL_INTERVAL_P (next) > + || (next->position > + >= (INTEGERP (limit) > + ? XFASTINT (limit) > + : (STRINGP (object) > + ? SCHARS (object) > + : BUF_ZV (XBUFFER (object)))))) > return limit; > - > - return make_number (next->position); > + else > + return make_number (next->position); > } > > DEFUN ("previous-property-change", Fprevious_property_change, > @@ -1132,14 +1131,15 @@ > && (NILP (limit) > || (previous->position + LENGTH (previous) > XFASTINT (limit)))) > previous = previous_interval (previous); > - if (NULL_INTERVAL_P (previous)) > - return limit; > - if (NILP (limit)) > - XSETFASTINT (limit, (STRINGP (object) ? 0 : BUF_BEGV (XBUFFER (object)))); > - if (!(previous->position + LENGTH (previous) > XFASTINT (limit))) > - return limit; > > - return make_number (previous->position + LENGTH (previous)); > + if (NULL_INTERVAL_P (previous) > + || (previous->position + LENGTH (previous) > + <= (INTEGERP (limit) > + ? XFASTINT (limit) > + : (STRINGP (object) ? 0 : BUF_BEGV (XBUFFER (object)))))) > + return limit; > + else > + return make_number (previous->position + LENGTH (previous)); > } > > DEFUN ("previous-single-property-change", Fprevious_single_property_change, > @@ -1184,14 +1184,15 @@ > && (NILP (limit) > || (previous->position + LENGTH (previous) > XFASTINT (limit)))) > previous = previous_interval (previous); > - if (NULL_INTERVAL_P (previous)) > - return limit; > - if (NILP (limit)) > - XSETFASTINT (limit, (STRINGP (object) ? 0 : BUF_BEGV (XBUFFER (object)))); > - if (!(previous->position + LENGTH (previous) > XFASTINT (limit))) > - return limit; > > - return make_number (previous->position + LENGTH (previous)); > + if (NULL_INTERVAL_P (previous) > + || (previous->position + LENGTH (previous) > + <= (INTEGERP (limit) > + ? XFASTINT (limit) > + : (STRINGP (object) ? 0 : BUF_BEGV (XBUFFER (object)))))) > + return limit; > + else > + return make_number (previous->position + LENGTH (previous)); > } > > /* Callers note, this can GC when OBJECT is a buffer (or nil). */