Mercurial > emacs
changeset 20229:328506fc1aa2
(Fsref): If IDX points an 8-bit code which is not part
of multibyte characters, return it. Pay attention to
enable-multibyte-characters.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Sat, 08 Nov 1997 03:05:44 +0000 |
parents | acb7aa0aa71f |
children | ad33fb40e5e7 |
files | src/editfns.c |
diffstat | 1 files changed, 20 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/editfns.c Sat Nov 08 03:05:44 1997 +0000 +++ b/src/editfns.c Sat Nov 08 03:05:44 1997 +0000 @@ -158,8 +158,8 @@ (str, idx) Lisp_Object str, idx; { - register int idxval, len; - register unsigned char *p; + register int idxval, len, i; + register unsigned char *p, *q; register Lisp_Object val; CHECK_STRING (str, 0); @@ -167,9 +167,25 @@ idxval = XINT (idx); if (idxval < 0 || idxval >= (len = XVECTOR (str)->size)) args_out_of_range (str, idx); + p = XSTRING (str)->data + idxval; - if (!CHAR_HEAD_P (p)) - error ("Not character boundary"); + if (!NILP (current_buffer->enable_multibyte_characters) + && !CHAR_HEAD_P (p) + && idxval > 0) + { + /* We must check if P points to a tailing byte of a multibyte + form. If so, we signal error. */ + i = idxval - 1; + q = p - 1; + while (i > 0 && *q >= 0xA0) i--, q--; + + if (*q == LEADING_CODE_COMPOSITION) + i = multibyte_form_length (XSTRING (str)->data + i, len - i); + else + i = BYTES_BY_CHAR_HEAD (*q); + if (q + i > p) + error ("Not character boundary"); + } len = XSTRING (str)->size - idxval; XSETFASTINT (val, STRING_CHAR (p, len));