changeset 72834:84ff2640fb2a

* textprop.c (Fnext_property_change, Fnext_single_property_change) (Fprevious_property_change, Fprevious_single_property_change): Avoid changing limit, so we can correctly catch the case where the property is constant up to limit.
author Chong Yidong <cyd@stupidchicken.com>
date Tue, 12 Sep 2006 16:47:26 +0000
parents 81a55a7dc3c3
children 1c517ee1ca2c
files src/ChangeLog src/textprop.c
diffstat 2 files changed, 41 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Tue Sep 12 16:43:25 2006 +0000
+++ b/src/ChangeLog	Tue Sep 12 16:47:26 2006 +0000
@@ -1,3 +1,10 @@
+2006-09-12  Chong Yidong  <cyd@stupidchicken.com>
+
+	* textprop.c (Fnext_property_change, Fnext_single_property_change)
+	(Fprevious_property_change, Fprevious_single_property_change):
+	Avoid changing limit, so we can correctly catch the case where the
+	property is constant up to limit.
+
 2006-09-12  YAMAMOTO Mitsuharu  <mituharu@math.s.chiba-u.ac.jp>
 
 	* macfns.c (mac_window) [MAC_OS_X_VERSION_MAX_ALLOWED >= 1030]:
--- a/src/textprop.c	Tue Sep 12 16:43:25 2006 +0000
+++ b/src/textprop.c	Tue Sep 12 16:47:26 2006 +0000
@@ -1001,17 +1001,16 @@
 	 && (NILP (limit) || next->position < XFASTINT (limit)))
     next = next_interval (next);
 
-  if (NULL_INTERVAL_P (next))
+  if (NULL_INTERVAL_P (next)
+      || (next->position
+	  >= (INTEGERP (limit)
+	      ? XFASTINT (limit)
+	      : (STRINGP (object)
+		 ? SCHARS (object)
+		 : BUF_ZV (XBUFFER (object))))))
     return limit;
-  if (NILP (limit))
-    XSETFASTINT (limit, (STRINGP (object)
-			 ? SCHARS (object)
-			 : BUF_ZV (XBUFFER (object))));
-  if (!(next->position < XFASTINT (limit)))
-    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))
+  if (NULL_INTERVAL_P (next)
+      || (next->position
+	  >= (INTEGERP (limit)
+	      ? XFASTINT (limit)
+	      : (STRINGP (object)
+		 ? SCHARS (object)
+		 : BUF_ZV (XBUFFER (object))))))
     return limit;
-  if (NILP (limit))
-    XSETFASTINT (limit, (STRINGP (object)
-			 ? SCHARS (object)
-			 : BUF_ZV (XBUFFER (object))));
-  if (!(next->position < XFASTINT (limit)))
-    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))
+
+  if (NULL_INTERVAL_P (previous)
+      || (previous->position + LENGTH (previous)
+	  <= (INTEGERP (limit)
+	      ? XFASTINT (limit)
+	      : (STRINGP (object) ? 0 : BUF_BEGV (XBUFFER (object))))))
     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));
+  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))
+
+  if (NULL_INTERVAL_P (previous)
+      || (previous->position + LENGTH (previous)
+	  <= (INTEGERP (limit)
+	      ? XFASTINT (limit)
+	      : (STRINGP (object) ? 0 : BUF_BEGV (XBUFFER (object))))))
     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));
+  else
+    return make_number (previous->position + LENGTH (previous));
 }
 
 /* Callers note, this can GC when OBJECT is a buffer (or nil).  */