diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/data.c | 36 |
1 files 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. */) | |||
| 2094 | args_out_of_range (array, idx); | 2094 | args_out_of_range (array, idx); |
| 2095 | CHECK_NUMBER (newelt); | 2095 | CHECK_NUMBER (newelt); |
| 2096 | 2096 | ||
| 2097 | if (XINT (newelt) < 0 || ASCII_CHAR_P (XINT (newelt)) | 2097 | if (XINT (newelt) >= 0 && ! SINGLE_BYTE_CHAR_P (XINT (newelt))) |
| 2098 | || CHAR_BYTE8_P (XINT (newelt))) | 2098 | args_out_of_range (array, newelt); |
| 2099 | SSET (array, idxval, XINT (newelt)); | 2099 | SSET (array, idxval, XINT (newelt)); |
| 2100 | else | ||
| 2101 | { | ||
| 2102 | /* We must relocate the string data while converting it to | ||
| 2103 | multibyte. */ | ||
| 2104 | int idxval_byte, prev_bytes, new_bytes; | ||
| 2105 | unsigned char workbuf[MAX_MULTIBYTE_LENGTH], *p0 = workbuf, *p1; | ||
| 2106 | unsigned char *origstr = SDATA (array), *str; | ||
| 2107 | int nchars, nbytes; | ||
| 2108 | USE_SAFE_ALLOCA; | ||
| 2109 | |||
| 2110 | nchars = SCHARS (array); | ||
| 2111 | nbytes = idxval_byte = count_size_as_multibyte (origstr, idxval); | ||
| 2112 | nbytes += count_size_as_multibyte (origstr + idxval, | ||
| 2113 | nchars - idxval); | ||
| 2114 | SAFE_ALLOCA (str, unsigned char *, nbytes); | ||
| 2115 | copy_text (SDATA (array), str, nchars, 0, 1); | ||
| 2116 | PARSE_MULTIBYTE_SEQ (str + idxval_byte, nbytes - idxval_byte, | ||
| 2117 | prev_bytes); | ||
| 2118 | new_bytes = CHAR_STRING (XINT (newelt), p0); | ||
| 2119 | allocate_string_data (XSTRING (array), nchars, | ||
| 2120 | nbytes + new_bytes - prev_bytes); | ||
| 2121 | bcopy (str, SDATA (array), idxval_byte); | ||
| 2122 | p1 = SDATA (array) + idxval_byte; | ||
| 2123 | while (new_bytes--) | ||
| 2124 | *p1++ = *p0++; | ||
| 2125 | bcopy (str + idxval_byte + prev_bytes, p1, | ||
| 2126 | nbytes - (idxval_byte + prev_bytes)); | ||
| 2127 | SAFE_FREE (); | ||
| 2128 | clear_string_char_byte_cache (); | ||
| 2129 | } | ||
| 2130 | } | 2100 | } |
| 2131 | 2101 | ||
| 2132 | return newelt; | 2102 | return newelt; |