aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa2002-08-20 07:07:19 +0000
committerKenichi Handa2002-08-20 07:07:19 +0000
commit530e07516732a573289aef2fb699e769b7b0b79b (patch)
tree71a03de0b859fd18db7d6a7a3c2213463ba16ef0 /src
parent9bbe03417aa03458ff9136c08a4a8cf68332ad06 (diff)
downloademacs-530e07516732a573289aef2fb699e769b7b0b79b.tar.gz
emacs-530e07516732a573289aef2fb699e769b7b0b79b.zip
(Fexpand_abbrev): Fix for the multibyte case.
Diffstat (limited to 'src')
-rw-r--r--src/abbrev.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/src/abbrev.c b/src/abbrev.c
index 6e973e9c307..2939b138d3f 100644
--- a/src/abbrev.c
+++ b/src/abbrev.c
@@ -238,12 +238,13 @@ Returns the abbrev symbol, if expansion took place. */)
238{ 238{
239 register char *buffer, *p; 239 register char *buffer, *p;
240 int wordstart, wordend; 240 int wordstart, wordend;
241 register int wordstart_byte, wordend_byte, idx; 241 register int wordstart_byte, wordend_byte, idx, idx_byte;
242 int whitecnt; 242 int whitecnt;
243 int uccount = 0, lccount = 0; 243 int uccount = 0, lccount = 0;
244 register Lisp_Object sym; 244 register Lisp_Object sym;
245 Lisp_Object expansion, hook, tem; 245 Lisp_Object expansion, hook, tem;
246 Lisp_Object value; 246 Lisp_Object value;
247 int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
247 248
248 value = Qnil; 249 value = Qnil;
249 250
@@ -289,26 +290,39 @@ Returns the abbrev symbol, if expansion took place. */)
289 290
290 p = buffer = (char *) alloca (wordend_byte - wordstart_byte); 291 p = buffer = (char *) alloca (wordend_byte - wordstart_byte);
291 292
292 for (idx = wordstart_byte; idx < wordend_byte; idx++) 293 for (idx = wordstart, idx_byte = wordstart_byte; idx < wordend; )
293 { 294 {
294 /* ??? This loop needs to go by characters! */ 295 register int c;
295 register int c = FETCH_BYTE (idx); 296
297 if (multibyte)
298 {
299 FETCH_CHAR_ADVANCE (c, idx, idx_byte);
300 }
301 else
302 {
303 c = FETCH_BYTE (idx_byte);
304 idx++, idx_byte++;
305 }
306
296 if (UPPERCASEP (c)) 307 if (UPPERCASEP (c))
297 c = DOWNCASE (c), uccount++; 308 c = DOWNCASE (c), uccount++;
298 else if (! NOCASEP (c)) 309 else if (! NOCASEP (c))
299 lccount++; 310 lccount++;
300 *p++ = c; 311 if (multibyte)
312 p += CHAR_STRING (c, p);
313 else
314 *p++ = c;
301 } 315 }
302 316
303 if (VECTORP (current_buffer->abbrev_table)) 317 if (VECTORP (current_buffer->abbrev_table))
304 sym = oblookup (current_buffer->abbrev_table, buffer, 318 sym = oblookup (current_buffer->abbrev_table, buffer,
305 wordend - wordstart, wordend_byte - wordstart_byte); 319 wordend - wordstart, p - buffer);
306 else 320 else
307 XSETFASTINT (sym, 0); 321 XSETFASTINT (sym, 0);
308 322
309 if (INTEGERP (sym) || NILP (SYMBOL_VALUE (sym))) 323 if (INTEGERP (sym) || NILP (SYMBOL_VALUE (sym)))
310 sym = oblookup (Vglobal_abbrev_table, buffer, 324 sym = oblookup (Vglobal_abbrev_table, buffer,
311 wordend - wordstart, wordend_byte - wordstart_byte); 325 wordend - wordstart, p - buffer);
312 if (INTEGERP (sym) || NILP (SYMBOL_VALUE (sym))) 326 if (INTEGERP (sym) || NILP (SYMBOL_VALUE (sym)))
313 return value; 327 return value;
314 328