diff options
author | Dmitry Antipov <dmantipov@yandex.ru> | 2014-06-25 16:11:08 +0400 |
---|---|---|
committer | Dmitry Antipov <dmantipov@yandex.ru> | 2014-06-25 16:11:08 +0400 |
commit | 51e12e8e9411e5d050c36ef6d8777445a5497972 (patch) | |
tree | 3473f0b720f0c6bcb4d8f42d9bf230675c46087d /src/composite.c | |
parent | 5697ca55cb79817a6704c344cc76d866ee2e1699 (diff) | |
download | emacs-51e12e8e9411e5d050c36ef6d8777445a5497972.tar.gz |
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/composite.c')
-rw-r--r-- | src/composite.c | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/src/composite.c b/src/composite.c index 5e14ad037a6..66a20759ec6 100644 --- a/src/composite.c +++ b/src/composite.c @@ -1684,9 +1684,10 @@ Otherwise (for terminal display), FONT-OBJECT must be a terminal ID, a frame, or nil for the selected frame's terminal device. If the optional 4th argument STRING is not nil, it is a string -containing the target characters between indices FROM and TO. -Otherwise FROM and TO are character positions in current buffer; -they can be in either order, and can be integers or markers. +containing the target characters between indices FROM and TO, +which are treated as in `substring'. Otherwise FROM and TO are +character positions in current buffer; they can be in either order, +and can be integers or markers. A glyph-string is a vector containing information about how to display a specific character sequence. The format is: @@ -1742,15 +1743,10 @@ should be ignored. */) } else { - CHECK_NATNUM (from); - CHECK_NATNUM (to); CHECK_STRING (string); + validate_subarray (string, from, to, SCHARS (string), &frompos, &topos); if (! STRING_MULTIBYTE (string)) error ("Attempt to shape unibyte text"); - if (! (XINT (from) <= XINT (to) && XINT (to) <= SCHARS (string))) - args_out_of_range_3 (string, from, to); - frompos = XFASTINT (from); - topos = XFASTINT (to); frombyte = string_char_to_byte (string, frompos); } @@ -1795,21 +1791,18 @@ DEFUN ("compose-string-internal", Fcompose_string_internal, Scompose_string_internal, 3, 5, 0, doc: /* Internal use only. -Compose text between indices START and END of STRING. -Optional 4th and 5th arguments are COMPONENTS and MODIFICATION-FUNC +Compose text between indices START and END of STRING, where +START and END are treated as in `substring'. Optional 4th +and 5th arguments are COMPONENTS and MODIFICATION-FUNC for the composition. See `compose-string' for more details. */) - (Lisp_Object string, Lisp_Object start, Lisp_Object end, Lisp_Object components, Lisp_Object modification_func) + (Lisp_Object string, Lisp_Object start, Lisp_Object end, + Lisp_Object components, Lisp_Object modification_func) { - CHECK_STRING (string); - CHECK_NUMBER (start); - CHECK_NUMBER (end); + ptrdiff_t from, to; - if (XINT (start) < 0 || - XINT (start) > XINT (end) - || XINT (end) > SCHARS (string)) - args_out_of_range (start, end); - - compose_text (XINT (start), XINT (end), components, modification_func, string); + CHECK_STRING (string); + validate_subarray (string, start, end, SCHARS (string), &from, &to); + compose_text (from, to, components, modification_func, string); return string; } |