diff options
| author | Richard M. Stallman | 1998-01-01 02:45:12 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1998-01-01 02:45:12 +0000 |
| commit | 4c7b7eabfd2234db335dea8a045373322c07ce09 (patch) | |
| tree | c2a222dc24f7c9299acc1cbce1624b9b05490f07 /src | |
| parent | 3fa51c4e52a5dd749a31de9815f80d1d3f851e0a (diff) | |
| download | emacs-4c7b7eabfd2234db335dea8a045373322c07ce09.tar.gz emacs-4c7b7eabfd2234db335dea8a045373322c07ce09.zip | |
(casify_region): Scan in bytes and chars.
(casify_object, casify_region): Declare str, workbuf as unsigned char.
Diffstat (limited to 'src')
| -rw-r--r-- | src/casefiddle.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/casefiddle.c b/src/casefiddle.c index dfa2981eb04..2ca61ab51ec 100644 --- a/src/casefiddle.c +++ b/src/casefiddle.c | |||
| @@ -87,7 +87,7 @@ casify_object (flag, obj) | |||
| 87 | char *buf | 87 | char *buf |
| 88 | = (char *) alloca ((len - i) * MAX_LENGTH_OF_MULTI_BYTE_FORM | 88 | = (char *) alloca ((len - i) * MAX_LENGTH_OF_MULTI_BYTE_FORM |
| 89 | + i); | 89 | + i); |
| 90 | char *str, workbuf[4]; | 90 | unsigned char *str, workbuf[4]; |
| 91 | 91 | ||
| 92 | /* Copy data already handled. */ | 92 | /* Copy data already handled. */ |
| 93 | bcopy (XSTRING (obj)->data, buf, i); | 93 | bcopy (XSTRING (obj)->data, buf, i); |
| @@ -174,6 +174,7 @@ casify_region (flag, b, e) | |||
| 174 | register int inword = flag == CASE_DOWN; | 174 | register int inword = flag == CASE_DOWN; |
| 175 | register int multibyte = !NILP (current_buffer->enable_multibyte_characters); | 175 | register int multibyte = !NILP (current_buffer->enable_multibyte_characters); |
| 176 | int start, end; | 176 | int start, end; |
| 177 | int start_byte, end_byte; | ||
| 177 | Lisp_Object ch, downch, val; | 178 | Lisp_Object ch, downch, val; |
| 178 | 179 | ||
| 179 | if (EQ (b, e)) | 180 | if (EQ (b, e)) |
| @@ -189,8 +190,10 @@ casify_region (flag, b, e) | |||
| 189 | end = XFASTINT (e); | 190 | end = XFASTINT (e); |
| 190 | modify_region (current_buffer, start, end); | 191 | modify_region (current_buffer, start, end); |
| 191 | record_change (start, end - start); | 192 | record_change (start, end - start); |
| 193 | start_byte = CHAR_TO_BYTE (start); | ||
| 194 | end_byte = CHAR_TO_BYTE (end); | ||
| 192 | 195 | ||
| 193 | for (i = start; i < end; i++) | 196 | for (i = start_byte; i < end_byte; i++) |
| 194 | { | 197 | { |
| 195 | c = FETCH_BYTE (i); | 198 | c = FETCH_BYTE (i); |
| 196 | if (multibyte && c >= 0x80) | 199 | if (multibyte && c >= 0x80) |
| @@ -205,13 +208,15 @@ casify_region (flag, b, e) | |||
| 205 | if ((int) flag >= (int) CASE_CAPITALIZE) | 208 | if ((int) flag >= (int) CASE_CAPITALIZE) |
| 206 | inword = SYNTAX (c) == Sword; | 209 | inword = SYNTAX (c) == Sword; |
| 207 | } | 210 | } |
| 208 | if (i < end) | 211 | if (i < end_byte) |
| 209 | { | 212 | { |
| 210 | /* The work is not yet finished because of a multibyte character | 213 | /* The work is not yet finished because of a multibyte character |
| 211 | just encountered. */ | 214 | just encountered. */ |
| 212 | int opoint = PT, c2; | 215 | int opoint = PT; |
| 216 | int opoint_byte = PT_BYTE; | ||
| 217 | int c2; | ||
| 213 | 218 | ||
| 214 | while (i < end) | 219 | while (i < end_byte) |
| 215 | { | 220 | { |
| 216 | if ((c = FETCH_BYTE (i)) >= 0x80) | 221 | if ((c = FETCH_BYTE (i)) >= 0x80) |
| 217 | c = FETCH_MULTIBYTE_CHAR (i); | 222 | c = FETCH_MULTIBYTE_CHAR (i); |
| @@ -224,7 +229,7 @@ casify_region (flag, b, e) | |||
| 224 | if (c != c2) | 229 | if (c != c2) |
| 225 | { | 230 | { |
| 226 | int fromlen, tolen, j; | 231 | int fromlen, tolen, j; |
| 227 | char workbuf[4], *str; | 232 | unsigned char workbuf[4], *str; |
| 228 | 233 | ||
| 229 | /* Handle the most likely case */ | 234 | /* Handle the most likely case */ |
| 230 | if (c < 0400 && c2 < 0400) | 235 | if (c < 0400 && c2 < 0400) |
| @@ -245,7 +250,7 @@ casify_region (flag, b, e) | |||
| 245 | else if (tolen > fromlen) | 250 | else if (tolen > fromlen) |
| 246 | { | 251 | { |
| 247 | TEMP_SET_PT (i + fromlen); | 252 | TEMP_SET_PT (i + fromlen); |
| 248 | insert_1 (str + fromlen, tolen - fromlen, 1, 0); | 253 | insert_1 (str + fromlen, tolen - fromlen, 1, 0, 0); |
| 249 | } | 254 | } |
| 250 | #endif | 255 | #endif |
| 251 | } | 256 | } |
| @@ -254,7 +259,7 @@ casify_region (flag, b, e) | |||
| 254 | inword = SYNTAX (c2) == Sword; | 259 | inword = SYNTAX (c2) == Sword; |
| 255 | INC_POS (i); | 260 | INC_POS (i); |
| 256 | } | 261 | } |
| 257 | TEMP_SET_PT (opoint); | 262 | TEMP_SET_PT_BOTH (opoint, opoint_byte); |
| 258 | } | 263 | } |
| 259 | 264 | ||
| 260 | signal_after_change (start, end - start, end - start); | 265 | signal_after_change (start, end - start, end - start); |