unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* next-single-property-change
@ 2006-09-12 15:27 Richard Stallman
  2006-09-12 16:51 ` next-single-property-change Chong Yidong
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Stallman @ 2006-09-12 15:27 UTC (permalink / raw)


Would someone please install this change and ack?


From: Stefan Monnier <monnier@iro.umontreal.ca>
Date: Fri, 08 Sep 2006 17:29:32 -0400
In-Reply-To: <E1GLmz7-0003pb-Tk@fencepost.gnu.org> (Richard Stallman's message of "Fri, 08 Sep 2006 16:29:57 -0400")
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on monty-python
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=SUBJ_HAS_SPACES,
	UPPERCASE_25_50 autolearn=no version=3.0.4

> 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));
 }
 \f
 /* Callers note, this can GC when OBJECT is a buffer (or nil).  */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: next-single-property-change
  2006-09-12 15:27 next-single-property-change Richard Stallman
@ 2006-09-12 16:51 ` Chong Yidong
  2006-09-12 18:34   ` next-single-property-change Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Chong Yidong @ 2006-09-12 16:51 UTC (permalink / raw)
  Cc: emacs-devel

Richard Stallman <rms@gnu.org> writes:

> Would someone please install this change and ack?

Done.  (I updated FOR-RELEASE too).

> From: Stefan Monnier <monnier@iro.umontreal.ca>
> 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));
>  }
>  \f
>  /* Callers note, this can GC when OBJECT is a buffer (or nil).  */

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: next-single-property-change
  2006-09-12 16:51 ` next-single-property-change Chong Yidong
@ 2006-09-12 18:34   ` Stefan Monnier
  0 siblings, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2006-09-12 18:34 UTC (permalink / raw)
  Cc: rms, emacs-devel

> Done.  (I updated FOR-RELEASE too).

Thanks,


        Stefan

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-09-12 18:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-12 15:27 next-single-property-change Richard Stallman
2006-09-12 16:51 ` next-single-property-change Chong Yidong
2006-09-12 18:34   ` next-single-property-change Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).