# HG changeset patch # User Kenichi Handa # Date 904306959 0 # Node ID 1c8e0e09aea1e03672f9548b62fd0c9fd9874391 # Parent f7e486faa1adf0665fd5ffa1a5122bf8f760de9d (Fposition_bytes): If the arg POSITION is out of range, return nil. (Fbyte_to_position): If the arg BYTEPOS is out of range, return nil. diff -r f7e486faa1ad -r 1c8e0e09aea1 src/editfns.c --- a/src/editfns.c Fri Aug 28 12:22:39 1998 +0000 +++ b/src/editfns.c Fri Aug 28 12:22:39 1998 +0000 @@ -490,20 +490,26 @@ } DEFUN ("position-bytes", Fposition_bytes, Sposition_bytes, 1, 1, 0, - "Return the byte position for character position POSITION.") + "Return the byte position for character position POSITION.\n\ +If POSITION is out of range, the value is nil.") (position) Lisp_Object position; { CHECK_NUMBER_COERCE_MARKER (position, 1); + if (XINT (position) < BEG || XINT (position) > Z) + return Qnil; return make_number (CHAR_TO_BYTE (XINT (position))); } DEFUN ("byte-to-position", Fbyte_to_position, Sbyte_to_position, 1, 1, 0, - "Return the character position for byte position BYTEPOS.") + "Return the character position for byte position BYTEPOS.\n\ +If BYTEPOS is out of range, the value is nil.") (bytepos) Lisp_Object bytepos; { CHECK_NUMBER (bytepos, 1); + if (XINT (bytepos) < BEG_BYTE || XINT (bytepos) > Z_BYTE) + return Qnil; return make_number (BYTE_TO_CHAR (XINT (bytepos))); }