aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa1999-12-15 00:02:33 +0000
committerKenichi Handa1999-12-15 00:02:33 +0000
commit66da28809c36cf4bb55711b2487a8251c3980480 (patch)
tree41984272dc4d2645bc34b90e0847e65c56e5e842 /src
parentbca78757c13cd8d0dc5c166388f8377949d73bac (diff)
downloademacs-66da28809c36cf4bb55711b2487a8251c3980480.tar.gz
emacs-66da28809c36cf4bb55711b2487a8251c3980480.zip
Include composite.h.
(casify_object): Use MAX_MULTIBYTE_LENGTH to allocate memory for a multibyte character. Adjusted for the change of CHAR_STRING. (casify_region): Likewise. Call update_compositions.
Diffstat (limited to 'src')
-rw-r--r--src/casefiddle.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/src/casefiddle.c b/src/casefiddle.c
index 113885fad69..f1fc886dd8d 100644
--- a/src/casefiddle.c
+++ b/src/casefiddle.c
@@ -25,6 +25,7 @@ Boston, MA 02111-1307, USA. */
25#include "charset.h" 25#include "charset.h"
26#include "commands.h" 26#include "commands.h"
27#include "syntax.h" 27#include "syntax.h"
28#include "composite.h"
28 29
29enum case_action {CASE_UP, CASE_DOWN, CASE_CAPITALIZE, CASE_CAPITALIZE_UP}; 30enum case_action {CASE_UP, CASE_DOWN, CASE_CAPITALIZE, CASE_CAPITALIZE_UP};
30 31
@@ -102,9 +103,7 @@ casify_object (flag, obj)
102 character just encountered. */ 103 character just encountered. */
103 int fromlen, tolen, j_byte = i; 104 int fromlen, tolen, j_byte = i;
104 char *buf 105 char *buf
105 = (char *) alloca ((len - i) * MAX_LENGTH_OF_MULTI_BYTE_FORM 106 = (char *) alloca ((len - i) * MAX_MULTIBYTE_LENGTH + i);
106 + i);
107 unsigned char *str, workbuf[4];
108 107
109 /* Copy data already handled. */ 108 /* Copy data already handled. */
110 bcopy (XSTRING (obj)->data, buf, i); 109 bcopy (XSTRING (obj)->data, buf, i);
@@ -119,10 +118,8 @@ casify_object (flag, obj)
119 else if (!UPPERCASEP (c) 118 else if (!UPPERCASEP (c)
120 && (!inword || flag != CASE_CAPITALIZE_UP)) 119 && (!inword || flag != CASE_CAPITALIZE_UP))
121 c = UPCASE1 (c); 120 c = UPCASE1 (c);
122 tolen = CHAR_STRING (c, workbuf, str);
123 bcopy (str, buf + j_byte, tolen);
124 i += fromlen; 121 i += fromlen;
125 j_byte += tolen; 122 j_byte += CHAR_STRING (c, buf + j_byte);
126 if ((int) flag >= (int) CASE_CAPITALIZE) 123 if ((int) flag >= (int) CASE_CAPITALIZE)
127 inword = SYNTAX (c) == Sword; 124 inword = SYNTAX (c) == Sword;
128 } 125 }
@@ -195,6 +192,7 @@ casify_region (flag, b, e)
195 register int multibyte = !NILP (current_buffer->enable_multibyte_characters); 192 register int multibyte = !NILP (current_buffer->enable_multibyte_characters);
196 int start, end; 193 int start, end;
197 int start_byte, end_byte; 194 int start_byte, end_byte;
195 int changed = 0;
198 196
199 if (EQ (b, e)) 197 if (EQ (b, e))
200 /* Not modifying because nothing marked */ 198 /* Not modifying because nothing marked */
@@ -212,9 +210,10 @@ casify_region (flag, b, e)
212 start_byte = CHAR_TO_BYTE (start); 210 start_byte = CHAR_TO_BYTE (start);
213 end_byte = CHAR_TO_BYTE (end); 211 end_byte = CHAR_TO_BYTE (end);
214 212
215 for (i = start_byte; i < end_byte; i++) 213 for (i = start_byte; i < end_byte; i++, start++)
216 { 214 {
217 c = FETCH_BYTE (i); 215 int c2;
216 c = c2 = FETCH_BYTE (i);
218 if (multibyte && c >= 0x80) 217 if (multibyte && c >= 0x80)
219 /* A multibyte character can't be handled in this simple loop. */ 218 /* A multibyte character can't be handled in this simple loop. */
220 break; 219 break;
@@ -224,6 +223,8 @@ casify_region (flag, b, e)
224 && (!inword || flag != CASE_CAPITALIZE_UP)) 223 && (!inword || flag != CASE_CAPITALIZE_UP))
225 c = UPCASE1 (c); 224 c = UPCASE1 (c);
226 FETCH_BYTE (i) = c; 225 FETCH_BYTE (i) = c;
226 if (c != c2)
227 changed = 1;
227 if ((int) flag >= (int) CASE_CAPITALIZE) 228 if ((int) flag >= (int) CASE_CAPITALIZE)
228 inword = SYNTAX (c) == Sword; 229 inword = SYNTAX (c) == Sword;
229 } 230 }
@@ -248,13 +249,14 @@ casify_region (flag, b, e)
248 if (c != c2) 249 if (c != c2)
249 { 250 {
250 int fromlen, tolen, j; 251 int fromlen, tolen, j;
251 unsigned char workbuf[4], *str; 252 unsigned char str[MAX_MULTIBYTE_LENGTH];
252 253
254 changed = 1;
253 /* Handle the most likely case */ 255 /* Handle the most likely case */
254 if (c < 0400 && c2 < 0400) 256 if (c < 0400 && c2 < 0400)
255 FETCH_BYTE (i) = c2; 257 FETCH_BYTE (i) = c2;
256 else if (fromlen = CHAR_STRING (c, workbuf, str), 258 else if (fromlen = CHAR_STRING (c, str),
257 tolen = CHAR_STRING (c2, workbuf, str), 259 tolen = CHAR_STRING (c2, str),
258 fromlen == tolen) 260 fromlen == tolen)
259 { 261 {
260 for (j = 0; j < tolen; ++j) 262 for (j = 0; j < tolen; ++j)
@@ -276,12 +278,17 @@ casify_region (flag, b, e)
276 } 278 }
277 if ((int) flag >= (int) CASE_CAPITALIZE) 279 if ((int) flag >= (int) CASE_CAPITALIZE)
278 inword = SYNTAX (c2) == Sword; 280 inword = SYNTAX (c2) == Sword;
279 INC_POS (i); 281 INC_BOTH (start, i);
280 } 282 }
281 TEMP_SET_PT_BOTH (opoint, opoint_byte); 283 TEMP_SET_PT_BOTH (opoint, opoint_byte);
282 } 284 }
283 285
284 signal_after_change (start, end - start, end - start); 286 start = XFASTINT (b);
287 if (changed)
288 {
289 signal_after_change (start, end - start, end - start);
290 update_compositions (start, end, CHECK_ALL);
291 }
285} 292}
286 293
287DEFUN ("upcase-region", Fupcase_region, Supcase_region, 2, 2, "r", 294DEFUN ("upcase-region", Fupcase_region, Supcase_region, 2, 2, "r",