aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/editfns.c b/src/editfns.c
index 51b62c4bafa..0be7c4a702f 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -490,20 +490,26 @@ See also `gap-position'.")
490} 490}
491 491
492DEFUN ("position-bytes", Fposition_bytes, Sposition_bytes, 1, 1, 0, 492DEFUN ("position-bytes", Fposition_bytes, Sposition_bytes, 1, 1, 0,
493 "Return the byte position for character position POSITION.") 493 "Return the byte position for character position POSITION.\n\
494If POSITION is out of range, the value is nil.")
494 (position) 495 (position)
495 Lisp_Object position; 496 Lisp_Object position;
496{ 497{
497 CHECK_NUMBER_COERCE_MARKER (position, 1); 498 CHECK_NUMBER_COERCE_MARKER (position, 1);
499 if (XINT (position) < BEG || XINT (position) > Z)
500 return Qnil;
498 return make_number (CHAR_TO_BYTE (XINT (position))); 501 return make_number (CHAR_TO_BYTE (XINT (position)));
499} 502}
500 503
501DEFUN ("byte-to-position", Fbyte_to_position, Sbyte_to_position, 1, 1, 0, 504DEFUN ("byte-to-position", Fbyte_to_position, Sbyte_to_position, 1, 1, 0,
502 "Return the character position for byte position BYTEPOS.") 505 "Return the character position for byte position BYTEPOS.\n\
506If BYTEPOS is out of range, the value is nil.")
503 (bytepos) 507 (bytepos)
504 Lisp_Object bytepos; 508 Lisp_Object bytepos;
505{ 509{
506 CHECK_NUMBER (bytepos, 1); 510 CHECK_NUMBER (bytepos, 1);
511 if (XINT (bytepos) < BEG_BYTE || XINT (bytepos) > Z_BYTE)
512 return Qnil;
507 return make_number (BYTE_TO_CHAR (XINT (bytepos))); 513 return make_number (BYTE_TO_CHAR (XINT (bytepos)));
508} 514}
509 515