diff options
| author | Kenichi Handa | 1998-12-22 06:06:48 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-12-22 06:06:48 +0000 |
| commit | e6e114f23121e6e0305c32b8ee4b3eedde186c9f (patch) | |
| tree | f21b4e3fdb8a3f5087ec3bbbef32e02726377121 /src | |
| parent | 9a4d01d85c90edb9b0e6360a34558b0ae1d6e21b (diff) | |
| download | emacs-e6e114f23121e6e0305c32b8ee4b3eedde186c9f.tar.gz emacs-e6e114f23121e6e0305c32b8ee4b3eedde186c9f.zip | |
(Fcharset_after): Check range. If POS is out of
range, return nil.
Diffstat (limited to 'src')
| -rw-r--r-- | src/charset.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/charset.c b/src/charset.c index 0b3d4266c8d..cbf8fe02375 100644 --- a/src/charset.c +++ b/src/charset.c | |||
| @@ -1006,7 +1006,8 @@ DEFUN ("char-charset", Fchar_charset, Schar_charset, 1, 1, 0, | |||
| 1006 | 1006 | ||
| 1007 | DEFUN ("charset-after", Fcharset_after, Scharset_after, 0, 1, 0, | 1007 | DEFUN ("charset-after", Fcharset_after, Scharset_after, 0, 1, 0, |
| 1008 | "Return charset of a character in current buffer at position POS.\n\ | 1008 | "Return charset of a character in current buffer at position POS.\n\ |
| 1009 | If POS is nil, it defauls to the current point.") | 1009 | If POS is nil, it defauls to the current point.\n\ |
| 1010 | If POS is out of range, the value is nil.") | ||
| 1010 | (pos) | 1011 | (pos) |
| 1011 | Lisp_Object pos; | 1012 | Lisp_Object pos; |
| 1012 | { | 1013 | { |
| @@ -1016,10 +1017,16 @@ If POS is nil, it defauls to the current point.") | |||
| 1016 | if (NILP (pos)) | 1017 | if (NILP (pos)) |
| 1017 | pos_byte = PT_BYTE; | 1018 | pos_byte = PT_BYTE; |
| 1018 | else if (MARKERP (pos)) | 1019 | else if (MARKERP (pos)) |
| 1019 | pos_byte = marker_byte_position (pos); | 1020 | { |
| 1021 | pos_byte = marker_byte_position (pos); | ||
| 1022 | if (pos_byte < BEGV_BYTE || pos_byte >= ZV_BYTE) | ||
| 1023 | return Qnil; | ||
| 1024 | } | ||
| 1020 | else | 1025 | else |
| 1021 | { | 1026 | { |
| 1022 | CHECK_NUMBER (pos, 0); | 1027 | CHECK_NUMBER (pos, 0); |
| 1028 | if (XINT (pos) < BEGV || XINT (pos) >= ZV) | ||
| 1029 | return Qnil; | ||
| 1023 | pos_byte = CHAR_TO_BYTE (XINT (pos)); | 1030 | pos_byte = CHAR_TO_BYTE (XINT (pos)); |
| 1024 | } | 1031 | } |
| 1025 | p = BYTE_POS_ADDR (pos_byte); | 1032 | p = BYTE_POS_ADDR (pos_byte); |