aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/editfns.c b/src/editfns.c
index eb15566fb48..cbc1082b2cc 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -725,18 +725,23 @@ boundaries, bind `inhibit-field-text-motion' to t.
725This function does not move point. */) 725This function does not move point. */)
726 (Lisp_Object n) 726 (Lisp_Object n)
727{ 727{
728 ptrdiff_t charpos, bytepos; 728 ptrdiff_t charpos, bytepos, count;
729 729
730 if (NILP (n)) 730 if (NILP (n))
731 XSETFASTINT (n, 1); 731 count = 0;
732 else if (FIXNUMP (n))
733 count = clip_to_bounds (-BUF_BYTES_MAX, XFIXNUM (n) - 1, BUF_BYTES_MAX);
732 else 734 else
733 CHECK_FIXNUM (n); 735 {
736 CHECK_INTEGER (n);
737 count = NILP (Fnatnump (n)) ? -BUF_BYTES_MAX : BUF_BYTES_MAX;
738 }
734 739
735 scan_newline_from_point (XFIXNUM (n) - 1, &charpos, &bytepos); 740 scan_newline_from_point (count, &charpos, &bytepos);
736 741
737 /* Return END constrained to the current input field. */ 742 /* Return END constrained to the current input field. */
738 return Fconstrain_to_field (make_fixnum (charpos), make_fixnum (PT), 743 return Fconstrain_to_field (make_fixnum (charpos), make_fixnum (PT),
739 XFIXNUM (n) != 1 ? Qt : Qnil, 744 count != 0 ? Qt : Qnil,
740 Qt, Qnil); 745 Qt, Qnil);
741} 746}
742 747
@@ -763,11 +768,14 @@ This function does not move point. */)
763 ptrdiff_t orig = PT; 768 ptrdiff_t orig = PT;
764 769
765 if (NILP (n)) 770 if (NILP (n))
766 XSETFASTINT (n, 1); 771 clipped_n = 1;
772 else if (FIXNUMP (n))
773 clipped_n = clip_to_bounds (-BUF_BYTES_MAX, XFIXNUM (n), BUF_BYTES_MAX);
767 else 774 else
768 CHECK_FIXNUM (n); 775 {
769 776 CHECK_INTEGER (n);
770 clipped_n = clip_to_bounds (PTRDIFF_MIN + 1, XFIXNUM (n), PTRDIFF_MAX); 777 clipped_n = NILP (Fnatnump (n)) ? -BUF_BYTES_MAX : BUF_BYTES_MAX;
778 }
771 end_pos = find_before_next_newline (orig, 0, clipped_n - (clipped_n <= 0), 779 end_pos = find_before_next_newline (orig, 0, clipped_n - (clipped_n <= 0),
772 NULL); 780 NULL);
773 781