diff options
| author | Kenichi Handa | 2002-08-20 07:21:58 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2002-08-20 07:21:58 +0000 |
| commit | 6d2b9b27d80425adca59b7a79805e4d0aa204100 (patch) | |
| tree | 9f813a357e02b150d00b92c53a26e3934de7335c /src | |
| parent | 10be8e931bd9e6ac6e90dfe9efe8f1e44de9abea (diff) | |
| download | emacs-6d2b9b27d80425adca59b7a79805e4d0aa204100.tar.gz emacs-6d2b9b27d80425adca59b7a79805e4d0aa204100.zip | |
(Fexpand_abbrev): Fix for the multibyte case.
Diffstat (limited to 'src')
| -rw-r--r-- | src/abbrev.c | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/abbrev.c b/src/abbrev.c index fc3f304d3fb..64989b40553 100644 --- a/src/abbrev.c +++ b/src/abbrev.c | |||
| @@ -237,12 +237,13 @@ Returns the abbrev symbol, if expansion took place. */) | |||
| 237 | { | 237 | { |
| 238 | register char *buffer, *p; | 238 | register char *buffer, *p; |
| 239 | int wordstart, wordend; | 239 | int wordstart, wordend; |
| 240 | register int wordstart_byte, wordend_byte, idx; | 240 | register int wordstart_byte, wordend_byte, idx, idx_byte; |
| 241 | int whitecnt; | 241 | int whitecnt; |
| 242 | int uccount = 0, lccount = 0; | 242 | int uccount = 0, lccount = 0; |
| 243 | register Lisp_Object sym; | 243 | register Lisp_Object sym; |
| 244 | Lisp_Object expansion, hook, tem; | 244 | Lisp_Object expansion, hook, tem; |
| 245 | Lisp_Object value; | 245 | Lisp_Object value; |
| 246 | int multibyte = ! NILP (current_buffer->enable_multibyte_characters); | ||
| 246 | 247 | ||
| 247 | value = Qnil; | 248 | value = Qnil; |
| 248 | 249 | ||
| @@ -288,26 +289,38 @@ Returns the abbrev symbol, if expansion took place. */) | |||
| 288 | 289 | ||
| 289 | p = buffer = (char *) alloca (wordend_byte - wordstart_byte); | 290 | p = buffer = (char *) alloca (wordend_byte - wordstart_byte); |
| 290 | 291 | ||
| 291 | for (idx = wordstart_byte; idx < wordend_byte; idx++) | 292 | for (idx = wordstart, idx_byte = wordstart_byte; idx < wordend;) |
| 292 | { | 293 | { |
| 293 | /* ??? This loop needs to go by characters! */ | 294 | register int c; |
| 294 | register int c = FETCH_BYTE (idx); | 295 | |
| 296 | FETCH_CHAR_ADVANCE (c, idx, idx_byte); | ||
| 297 | if (! multibyte) | ||
| 298 | { | ||
| 299 | MAKE_CHAR_MULTIBYTE (c); | ||
| 300 | } | ||
| 301 | |||
| 295 | if (UPPERCASEP (c)) | 302 | if (UPPERCASEP (c)) |
| 296 | c = DOWNCASE (c), uccount++; | 303 | c = DOWNCASE (c), uccount++; |
| 297 | else if (! NOCASEP (c)) | 304 | else if (! NOCASEP (c)) |
| 298 | lccount++; | 305 | lccount++; |
| 299 | *p++ = c; | 306 | if (multibyte) |
| 307 | CHAR_STRING_ADVANCE (c, p); | ||
| 308 | else | ||
| 309 | { | ||
| 310 | MAKE_CHAR_UNIBYTE (c); | ||
| 311 | *p++ = c; | ||
| 312 | } | ||
| 300 | } | 313 | } |
| 301 | 314 | ||
| 302 | if (VECTORP (current_buffer->abbrev_table)) | 315 | if (VECTORP (current_buffer->abbrev_table)) |
| 303 | sym = oblookup (current_buffer->abbrev_table, buffer, | 316 | sym = oblookup (current_buffer->abbrev_table, buffer, |
| 304 | wordend - wordstart, wordend_byte - wordstart_byte); | 317 | wordend - wordstart, p - buffer); |
| 305 | else | 318 | else |
| 306 | XSETFASTINT (sym, 0); | 319 | XSETFASTINT (sym, 0); |
| 307 | 320 | ||
| 308 | if (INTEGERP (sym) || NILP (SYMBOL_VALUE (sym))) | 321 | if (INTEGERP (sym) || NILP (SYMBOL_VALUE (sym))) |
| 309 | sym = oblookup (Vglobal_abbrev_table, buffer, | 322 | sym = oblookup (Vglobal_abbrev_table, buffer, |
| 310 | wordend - wordstart, wordend_byte - wordstart_byte); | 323 | wordend - wordstart, p - buffer); |
| 311 | if (INTEGERP (sym) || NILP (SYMBOL_VALUE (sym))) | 324 | if (INTEGERP (sym) || NILP (SYMBOL_VALUE (sym))) |
| 312 | return value; | 325 | return value; |
| 313 | 326 | ||