comparison src/editfns.c @ 21200:ea520c42a342

(Fchar_after, Fchar_before): Properly check arg type and whether in range, for all cases. (Fsave_excursion): Doc fix.
author Richard M. Stallman <rms@gnu.org>
date Tue, 17 Mar 1998 07:25:54 +0000
parents 90bdbe2754c8
children ef954087e7b9
comparison
equal deleted inserted replaced
21199:7da9a3e9d3c8 21200:ea520c42a342
378 DEFUN ("save-excursion", Fsave_excursion, Ssave_excursion, 0, UNEVALLED, 0, 378 DEFUN ("save-excursion", Fsave_excursion, Ssave_excursion, 0, UNEVALLED, 0,
379 "Save point, mark, and current buffer; execute BODY; restore those things.\n\ 379 "Save point, mark, and current buffer; execute BODY; restore those things.\n\
380 Executes BODY just like `progn'.\n\ 380 Executes BODY just like `progn'.\n\
381 The values of point, mark and the current buffer are restored\n\ 381 The values of point, mark and the current buffer are restored\n\
382 even in case of abnormal exit (throw or error).\n\ 382 even in case of abnormal exit (throw or error).\n\
383 The state of activation of the mark is also restored.") 383 The state of activation of the mark is also restored.\n\
384 \n\
385 This construct does not save `deactivate-mark', and therefore\n\
386 functions that change the buffer will still cause deactivation\n\
387 of 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 {
387 register Lisp_Object val; 392 register Lisp_Object val;
388 int count = specpdl_ptr - specpdl; 393 int count = specpdl_ptr - specpdl;
553 { 558 {
554 register int pos_byte; 559 register int pos_byte;
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
569 if (pos_byte < BEGV_BYTE || pos_byte >= ZV_BYTE)
570 return Qnil;
571 578
572 return make_number (FETCH_CHAR (pos_byte)); 579 return make_number (FETCH_CHAR (pos_byte));
573 } 580 }
574 581
575 DEFUN ("char-before", Fchar_before, Schar_before, 0, 1, 0, 582 DEFUN ("char-before", Fchar_before, Schar_before, 0, 1, 0,
586 register int pos_byte; 593 register int pos_byte;
587 594
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);
607
608 if (pos <= BEGV || pos > ZV)
609 return Qnil;
597 610
598 pos_byte = CHAR_TO_BYTE (XINT (pos)); 611 pos_byte = CHAR_TO_BYTE (XINT (pos));
599 } 612 }
600 613
601 if (!NILP (current_buffer->enable_multibyte_characters)) 614 if (!NILP (current_buffer->enable_multibyte_characters))