diff options
| author | Kenichi Handa | 1998-08-28 12:22:39 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-08-28 12:22:39 +0000 |
| commit | fcf9683ed539fe4ecd926349a1cae3dc84378afa (patch) | |
| tree | a25c3d1e27dda6f18da054420f9413e3a578e944 /src | |
| parent | 9b6a601f87535e51228a8febf2d0a37752ac3feb (diff) | |
| download | emacs-fcf9683ed539fe4ecd926349a1cae3dc84378afa.tar.gz emacs-fcf9683ed539fe4ecd926349a1cae3dc84378afa.zip | |
(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.
Diffstat (limited to 'src')
| -rw-r--r-- | src/editfns.c | 10 |
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 | ||
| 492 | DEFUN ("position-bytes", Fposition_bytes, Sposition_bytes, 1, 1, 0, | 492 | DEFUN ("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\ |
| 494 | If 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 | ||
| 501 | DEFUN ("byte-to-position", Fbyte_to_position, Sbyte_to_position, 1, 1, 0, | 504 | DEFUN ("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\ |
| 506 | If 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 | ||