aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman2006-05-14 21:55:34 +0000
committerRichard M. Stallman2006-05-14 21:55:34 +0000
commit85cc6738ed6d07b13ad749de80e47170a1df0d7a (patch)
tree7abc2af8166d7deb5067cce3764a1c9e01d28cc1 /src
parent1b0440ed041cd311eb7e59cbe6219f7ffa26a909 (diff)
downloademacs-85cc6738ed6d07b13ad749de80e47170a1df0d7a.tar.gz
emacs-85cc6738ed6d07b13ad749de80e47170a1df0d7a.zip
(Fnext_single_char_property_change)
(Fprevious_single_char_property_change): Don't allow returning value beyond LIMIT in any cases. (Fnext_char_property_change, Fprevious_char_property_change): Doc fix.
Diffstat (limited to 'src')
-rw-r--r--src/textprop.c68
1 files changed, 44 insertions, 24 deletions
diff --git a/src/textprop.c b/src/textprop.c
index e2f9c531735..87fa6742919 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -717,10 +717,11 @@ DEFUN ("next-char-property-change", Fnext_char_property_change,
717This scans characters forward in the current buffer from POSITION till 717This scans characters forward in the current buffer from POSITION till
718it finds a change in some text property, or the beginning or end of an 718it finds a change in some text property, or the beginning or end of an
719overlay, and returns the position of that. 719overlay, and returns the position of that.
720If none is found, the function returns (point-max). 720If none is found up to (point-max), the function returns (point-max).
721 721
722If the optional second argument LIMIT is non-nil, don't search 722If the optional second argument LIMIT is non-nil, don't search
723past position LIMIT; return LIMIT if nothing is found before LIMIT. */) 723past position LIMIT; return LIMIT if nothing is found before LIMIT.
724LIMIT is a no-op if it is greater than (point-max). */)
724 (position, limit) 725 (position, limit)
725 Lisp_Object position, limit; 726 Lisp_Object position, limit;
726{ 727{
@@ -742,10 +743,11 @@ DEFUN ("previous-char-property-change", Fprevious_char_property_change,
742Scans characters backward in the current buffer from POSITION till it 743Scans characters backward in the current buffer from POSITION till it
743finds a change in some text property, or the beginning or end of an 744finds a change in some text property, or the beginning or end of an
744overlay, and returns the position of that. 745overlay, and returns the position of that.
745If none is found, the function returns (point-max). 746If none is found since (point-min), the function returns (point-min).
746 747
747If the optional second argument LIMIT is non-nil, don't search 748If the optional second argument LIMIT is non-nil, don't search
748past position LIMIT; return LIMIT if nothing is found before LIMIT. */) 749past position LIMIT; return LIMIT if nothing is found before LIMIT.
750LIMIT is a no-op if it is less than (point-min). */)
749 (position, limit) 751 (position, limit)
750 Lisp_Object position, limit; 752 Lisp_Object position, limit;
751{ 753{
@@ -771,6 +773,9 @@ If the optional third argument OBJECT is a buffer (or nil, which means
771the current buffer), POSITION is a buffer position (integer or marker). 773the current buffer), POSITION is a buffer position (integer or marker).
772If OBJECT is a string, POSITION is a 0-based index into it. 774If OBJECT is a string, POSITION is a 0-based index into it.
773 775
776In a string, scan runs to the end of the string.
777In a buffer, it runs to (point-max), and the value cannot exceed that.
778
774The property values are compared with `eq'. 779The property values are compared with `eq'.
775If the property is constant all the way to the end of OBJECT, return the 780If the property is constant all the way to the end of OBJECT, return the
776last valid position in OBJECT. 781last valid position in OBJECT.
@@ -812,22 +817,30 @@ past position LIMIT; return LIMIT if nothing is found before LIMIT. */)
812 initial_value = Fget_char_property (position, prop, object); 817 initial_value = Fget_char_property (position, prop, object);
813 818
814 if (NILP (limit)) 819 if (NILP (limit))
815 XSETFASTINT (limit, BUF_ZV (current_buffer)); 820 XSETFASTINT (limit, ZV);
816 else 821 else
817 CHECK_NUMBER_COERCE_MARKER (limit); 822 CHECK_NUMBER_COERCE_MARKER (limit);
818 823
819 for (;;) 824 if (XFASTINT (position) >= XFASTINT (limit))
820 { 825 {
821 position = Fnext_char_property_change (position, limit); 826 position = limit;
822 if (XFASTINT (position) >= XFASTINT (limit)) { 827 if (XFASTINT (position) > ZV)
823 position = limit; 828 XSETFASTINT (position, ZV);
824 break;
825 }
826
827 value = Fget_char_property (position, prop, object);
828 if (!EQ (value, initial_value))
829 break;
830 } 829 }
830 else
831 while (1)
832 {
833 position = Fnext_char_property_change (position, limit);
834 if (XFASTINT (position) >= XFASTINT (limit))
835 {
836 position = limit;
837 break;
838 }
839
840 value = Fget_char_property (position, prop, object);
841 if (!EQ (value, initial_value))
842 break;
843 }
831 844
832 unbind_to (count, Qnil); 845 unbind_to (count, Qnil);
833 } 846 }
@@ -845,6 +858,9 @@ If the optional third argument OBJECT is a buffer (or nil, which means
845the current buffer), POSITION is a buffer position (integer or marker). 858the current buffer), POSITION is a buffer position (integer or marker).
846If OBJECT is a string, POSITION is a 0-based index into it. 859If OBJECT is a string, POSITION is a 0-based index into it.
847 860
861In a string, scan runs to the start of the string.
862In a buffer, it runs to (point-min), and the value cannot be less than that.
863
848The property values are compared with `eq'. 864The property values are compared with `eq'.
849If the property is constant all the way to the start of OBJECT, return the 865If the property is constant all the way to the start of OBJECT, return the
850first valid position in OBJECT. 866first valid position in OBJECT.
@@ -883,19 +899,23 @@ back past position LIMIT; return LIMIT if nothing is found before LIMIT. */)
883 CHECK_NUMBER_COERCE_MARKER (position); 899 CHECK_NUMBER_COERCE_MARKER (position);
884 900
885 if (NILP (limit)) 901 if (NILP (limit))
886 XSETFASTINT (limit, BUF_BEGV (current_buffer)); 902 XSETFASTINT (limit, BEGV);
887 else 903 else
888 CHECK_NUMBER_COERCE_MARKER (limit); 904 CHECK_NUMBER_COERCE_MARKER (limit);
889 905
890 if (XFASTINT (position) <= XFASTINT (limit)) 906 if (XFASTINT (position) <= XFASTINT (limit))
891 position = limit; 907 {
908 position = limit;
909 if (XFASTINT (position) < BEGV)
910 XSETFASTINT (position, BEGV);
911 }
892 else 912 else
893 { 913 {
894 Lisp_Object initial_value = 914 Lisp_Object initial_value
895 Fget_char_property (make_number (XFASTINT (position) - 1), 915 = Fget_char_property (make_number (XFASTINT (position) - 1),
896 prop, object); 916 prop, object);
897 917
898 for (;;) 918 while (1)
899 { 919 {
900 position = Fprevious_char_property_change (position, limit); 920 position = Fprevious_char_property_change (position, limit);
901 921
@@ -906,9 +926,9 @@ back past position LIMIT; return LIMIT if nothing is found before LIMIT. */)
906 } 926 }
907 else 927 else
908 { 928 {
909 Lisp_Object value = 929 Lisp_Object value
910 Fget_char_property (make_number (XFASTINT (position) - 1), 930 = Fget_char_property (make_number (XFASTINT (position) - 1),
911 prop, object); 931 prop, object);
912 932
913 if (!EQ (value, initial_value)) 933 if (!EQ (value, initial_value))
914 break; 934 break;