aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa2006-02-27 00:54:28 +0000
committerKenichi Handa2006-02-27 00:54:28 +0000
commit476e47cabac35f1724d3be437c07e97ca00a399a (patch)
tree38a999aa536a7a184ec064c473be47e49127d6de
parenta6c05016ac9ce84cdff34608b36d5677e9843068 (diff)
downloademacs-476e47cabac35f1724d3be437c07e97ca00a399a.tar.gz
emacs-476e47cabac35f1724d3be437c07e97ca00a399a.zip
(Faset): On setting a character bigger than 255 in a
unibyte string, signal an error instead of make the string multibyte.
-rw-r--r--src/data.c36
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;