Mercurial > emacs
changeset 90321:344d06a17979
(Faset): On setting a character bigger than 255 in a
unibyte string, signal an error instead of make the string
multibyte.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Mon, 27 Feb 2006 00:54:28 +0000 |
parents | 8a1ee48a8386 |
children | a7b705f6cbbf |
files | src/data.c |
diffstat | 1 files changed, 3 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/src/data.c Sun Feb 26 07:09:24 2006 +0000 +++ b/src/data.c Mon Feb 27 00:54:28 2006 +0000 @@ -2094,39 +2094,9 @@ args_out_of_range (array, idx); CHECK_NUMBER (newelt); - if (XINT (newelt) < 0 || ASCII_CHAR_P (XINT (newelt)) - || CHAR_BYTE8_P (XINT (newelt))) - SSET (array, idxval, XINT (newelt)); - else - { - /* We must relocate the string data while converting it to - multibyte. */ - int idxval_byte, prev_bytes, new_bytes; - unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1; - unsigned char *origstr = SDATA (array), *str; - int nchars, nbytes; - USE_SAFE_ALLOCA; - - nchars = SCHARS (array); - nbytes = idxval_byte = count_size_as_multibyte (origstr, idxval); - nbytes += count_size_as_multibyte (origstr + idxval, - nchars - idxval); - SAFE_ALLOCA (str, unsigned char *, nbytes); - copy_text (SDATA (array), str, nchars, 0, 1); - PARSE_MULTIBYTE_SEQ (str + idxval_byte, nbytes - idxval_byte, - prev_bytes); - new_bytes = CHAR_STRING (XINT (newelt), p0); - allocate_string_data (XSTRING (array), nchars, - nbytes + new_bytes - prev_bytes); - bcopy (str, SDATA (array), idxval_byte); - p1 = SDATA (array) + idxval_byte; - while (new_bytes--) - *p1++ = *p0++; - bcopy (str + idxval_byte + prev_bytes, p1, - nbytes - (idxval_byte + prev_bytes)); - SAFE_FREE (); - clear_string_char_byte_cache (); - } + if (XINT (newelt) >= 0 && ! SINGLE_BYTE_CHAR_P (XINT (newelt))) + args_out_of_range (array, newelt); + SSET (array, idxval, XINT (newelt)); } return newelt;