Mercurial > emacs
comparison src/abbrev.c @ 89024:b09549c9663c
(Fexpand_abbrev): Fix for the multibyte case.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Tue, 20 Aug 2002 07:21:58 +0000 |
parents | aac41b50c875 |
children | 98dcb14bf34c |
comparison
equal
deleted
inserted
replaced
89023:4187f97fc0bd | 89024:b09549c9663c |
---|---|
235 Returns the abbrev symbol, if expansion took place. */) | 235 Returns the abbrev symbol, if expansion took place. */) |
236 () | 236 () |
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 |
249 Frun_hooks (1, &Qpre_abbrev_expand_hook); | 250 Frun_hooks (1, &Qpre_abbrev_expand_hook); |
250 | 251 |
286 if (wordend <= wordstart) | 287 if (wordend <= wordstart) |
287 return value; | 288 return value; |
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 |
314 if (INTERACTIVE && !EQ (minibuf_window, selected_window)) | 327 if (INTERACTIVE && !EQ (minibuf_window, selected_window)) |
315 { | 328 { |