From 476e47cabac35f1724d3be437c07e97ca00a399a Mon Sep 17 00:00:00 2001 From: Kenichi Handa Date: Mon, 27 Feb 2006 00:54:28 +0000 Subject: [PATCH] (Faset): On setting a character bigger than 255 in a unibyte string, signal an error instead of make the string multibyte. --- src/data.c | 36 +++--------------------------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/src/data.c b/src/data.c index a4d865f681e..8e7f5d20542 100644 --- a/src/data.c +++ b/src/data.c @@ -2094,39 +2094,9 @@ bool-vector. IDX starts at 0. */) 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;