aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1998-03-17 07:25:54 +0000
committerRichard M. Stallman1998-03-17 07:25:54 +0000
commit85cac557cd0457eb6029bda3c2e90736ef04b24e (patch)
tree5671cbcda52b01d8a8b02eaad3bbab3fb87edda6
parentf405b38dd119a868fb715010129db21b46941a45 (diff)
downloademacs-85cac557cd0457eb6029bda3c2e90736ef04b24e.tar.gz
emacs-85cac557cd0457eb6029bda3c2e90736ef04b24e.zip
(Fchar_after, Fchar_before): Properly check arg type
and whether in range, for all cases. (Fsave_excursion): Doc fix.
-rw-r--r--src/editfns.c35
1 files changed, 24 insertions, 11 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 5ae0c28be6d..587e751efc7 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -380,7 +380,12 @@ DEFUN ("save-excursion", Fsave_excursion, Ssave_excursion, 0, UNEVALLED, 0,
380Executes BODY just like `progn'.\n\ 380Executes BODY just like `progn'.\n\
381The values of point, mark and the current buffer are restored\n\ 381The values of point, mark and the current buffer are restored\n\
382even in case of abnormal exit (throw or error).\n\ 382even in case of abnormal exit (throw or error).\n\
383The state of activation of the mark is also restored.") 383The state of activation of the mark is also restored.\n\
384\n\
385This construct does not save `deactivate-mark', and therefore\n\
386functions that change the buffer will still cause deactivation\n\
387of the mark at the end of the command. To prevent that, bind\n\
388`deactivate-mark' with `let'.")
384 (args) 389 (args)
385 Lisp_Object args; 390 Lisp_Object args;
386{ 391{
@@ -555,20 +560,22 @@ If `enable-multibyte-characters' is nil or POS is not at character boundary,\n\
555 register Lisp_Object val; 560 register Lisp_Object val;
556 561
557 if (NILP (pos)) 562 if (NILP (pos))
558 return make_number (FETCH_CHAR (PT_BYTE)); 563 pos_byte = PT_BYTE;
559 564 else if (MARKERP (pos))
560 if (MARKERP (pos)) 565 {
561 pos_byte = marker_byte_position (pos); 566 pos_byte = marker_byte_position (pos);
567 if (pos_byte < BEGV_BYTE || pos_byte >= ZV_BYTE)
568 return Qnil;
569 }
562 else 570 else
563 { 571 {
564 CHECK_NUMBER_COERCE_MARKER (pos, 0); 572 CHECK_NUMBER_COERCE_MARKER (pos, 0);
573 if (pos < BEGV || pos >= ZV)
574 return Qnil;
565 575
566 pos_byte = CHAR_TO_BYTE (XINT (pos)); 576 pos_byte = CHAR_TO_BYTE (XINT (pos));
567 } 577 }
568 578
569 if (pos_byte < BEGV_BYTE || pos_byte >= ZV_BYTE)
570 return Qnil;
571
572 return make_number (FETCH_CHAR (pos_byte)); 579 return make_number (FETCH_CHAR (pos_byte));
573} 580}
574 581
@@ -588,13 +595,19 @@ is returned as a character.")
588 if (NILP (pos)) 595 if (NILP (pos))
589 pos_byte = PT_BYTE; 596 pos_byte = PT_BYTE;
590 else if (MARKERP (pos)) 597 else if (MARKERP (pos))
591 pos_byte = marker_byte_position (pos); 598 {
592 else if (pos <= BEGV || pos > ZV) 599 pos_byte = marker_byte_position (pos);
593 return Qnil; 600
601 if (pos_byte <= BEGV_BYTE || pos_byte > ZV_BYTE)
602 return Qnil;
603 }
594 else 604 else
595 { 605 {
596 CHECK_NUMBER_COERCE_MARKER (pos, 0); 606 CHECK_NUMBER_COERCE_MARKER (pos, 0);
597 607
608 if (pos <= BEGV || pos > ZV)
609 return Qnil;
610
598 pos_byte = CHAR_TO_BYTE (XINT (pos)); 611 pos_byte = CHAR_TO_BYTE (XINT (pos));
599 } 612 }
600 613