diff options
| author | Dmitry Antipov | 2014-06-25 16:11:08 +0400 |
|---|---|---|
| committer | Dmitry Antipov | 2014-06-25 16:11:08 +0400 |
| commit | 51e12e8e9411e5d050c36ef6d8777445a5497972 (patch) | |
| tree | 3473f0b720f0c6bcb4d8f42d9bf230675c46087d /src/coding.c | |
| parent | 5697ca55cb79817a6704c344cc76d866ee2e1699 (diff) | |
| download | emacs-51e12e8e9411e5d050c36ef6d8777445a5497972.tar.gz emacs-51e12e8e9411e5d050c36ef6d8777445a5497972.zip | |
Consistently use validate_subarray to verify substring.
* fns.c (validate_substring): Not static any more. Adjust to
use ptrdiff_t, not EMACS_INT, becase string and vector limits
can't exceed ptrdiff_t even if EMACS_INT is wider.
* lisp.h (validate_subarray): Add prototype.
* coding.c (Fundecodable_char_position):
* composite.c (Fcomposition_get_gstring, Fcompose_string_internal):
Use validate_subarray. Adjust comment to mention substring.
Diffstat (limited to 'src/coding.c')
| -rw-r--r-- | src/coding.c | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/coding.c b/src/coding.c index 16dc37a3f20..79f116fc618 100644 --- a/src/coding.c +++ b/src/coding.c | |||
| @@ -9091,8 +9091,7 @@ DEFUN ("find-coding-systems-region-internal", | |||
| 9091 | 9091 | ||
| 9092 | DEFUN ("unencodable-char-position", Funencodable_char_position, | 9092 | DEFUN ("unencodable-char-position", Funencodable_char_position, |
| 9093 | Sunencodable_char_position, 3, 5, 0, | 9093 | Sunencodable_char_position, 3, 5, 0, |
| 9094 | doc: /* | 9094 | doc: /* Return position of first un-encodable character in a region. |
| 9095 | Return position of first un-encodable character in a region. | ||
| 9096 | START and END specify the region and CODING-SYSTEM specifies the | 9095 | START and END specify the region and CODING-SYSTEM specifies the |
| 9097 | encoding to check. Return nil if CODING-SYSTEM does encode the region. | 9096 | encoding to check. Return nil if CODING-SYSTEM does encode the region. |
| 9098 | 9097 | ||
| @@ -9102,8 +9101,9 @@ list of positions. | |||
| 9102 | 9101 | ||
| 9103 | If optional 5th argument STRING is non-nil, it is a string to search | 9102 | If optional 5th argument STRING is non-nil, it is a string to search |
| 9104 | for un-encodable characters. In that case, START and END are indexes | 9103 | for un-encodable characters. In that case, START and END are indexes |
| 9105 | to the string. */) | 9104 | to the string and treated as in `substring'. */) |
| 9106 | (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, Lisp_Object count, Lisp_Object string) | 9105 | (Lisp_Object start, Lisp_Object end, Lisp_Object coding_system, |
| 9106 | Lisp_Object count, Lisp_Object string) | ||
| 9107 | { | 9107 | { |
| 9108 | EMACS_INT n; | 9108 | EMACS_INT n; |
| 9109 | struct coding_system coding; | 9109 | struct coding_system coding; |
| @@ -9140,12 +9140,7 @@ to the string. */) | |||
| 9140 | else | 9140 | else |
| 9141 | { | 9141 | { |
| 9142 | CHECK_STRING (string); | 9142 | CHECK_STRING (string); |
| 9143 | CHECK_NATNUM (start); | 9143 | validate_subarray (string, start, end, SCHARS (string), &from, &to); |
| 9144 | CHECK_NATNUM (end); | ||
| 9145 | if (! (XINT (start) <= XINT (end) && XINT (end) <= SCHARS (string))) | ||
| 9146 | args_out_of_range_3 (string, start, end); | ||
| 9147 | from = XINT (start); | ||
| 9148 | to = XINT (end); | ||
| 9149 | if (! STRING_MULTIBYTE (string)) | 9144 | if (! STRING_MULTIBYTE (string)) |
| 9150 | return Qnil; | 9145 | return Qnil; |
| 9151 | p = SDATA (string) + string_char_to_byte (string, from); | 9146 | p = SDATA (string) + string_char_to_byte (string, from); |