summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenichi Handa <handa@m17n.org>2002-08-20 07:07:19 +0000
committerKenichi Handa <handa@m17n.org>2002-08-20 07:07:19 +0000
commit530e07516732a573289aef2fb699e769b7b0b79b (patch)
tree71a03de0b859fd18db7d6a7a3c2213463ba16ef0
parent9bbe03417aa03458ff9136c08a4a8cf68332ad06 (diff)
downloademacs-530e07516732a573289aef2fb699e769b7b0b79b.tar.gz
(Fexpand_abbrev): Fix for the multibyte case.
-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. */)
{
register char *buffer, *p;
int wordstart, wordend;
- register int wordstart_byte, wordend_byte, idx;
+ register int wordstart_byte, wordend_byte, idx, idx_byte;
int whitecnt;
int uccount = 0, lccount = 0;
register Lisp_Object sym;
Lisp_Object expansion, hook, tem;
Lisp_Object value;
+ int multibyte = ! NILP (current_buffer->enable_multibyte_characters);
value = Qnil;
@@ -289,26 +290,39 @@ Returns the abbrev symbol, if expansion took place. */)
p = buffer = (char *) alloca (wordend_byte - wordstart_byte);
- for (idx = wordstart_byte; idx < wordend_byte; idx++)
+ for (idx = wordstart, idx_byte = wordstart_byte; idx < wordend; )
{
- /* ??? This loop needs to go by characters! */
- register int c = FETCH_BYTE (idx);
+ register int c;
+
+ if (multibyte)
+ {
+ FETCH_CHAR_ADVANCE (c, idx, idx_byte);
+ }
+ else
+ {
+ c = FETCH_BYTE (idx_byte);
+ idx++, idx_byte++;
+ }
+
if (UPPERCASEP (c))
c = DOWNCASE (c), uccount++;
else if (! NOCASEP (c))
lccount++;
- *p++ = c;
+ if (multibyte)
+ p += CHAR_STRING (c, p);
+ else
+ *p++ = c;
}
if (VECTORP (current_buffer->abbrev_table))
sym = oblookup (current_buffer->abbrev_table, buffer,
- wordend - wordstart, wordend_byte - wordstart_byte);
+ wordend - wordstart, p - buffer);
else
XSETFASTINT (sym, 0);
if (INTEGERP (sym) || NILP (SYMBOL_VALUE (sym)))
sym = oblookup (Vglobal_abbrev_table, buffer,
- wordend - wordstart, wordend_byte - wordstart_byte);
+ wordend - wordstart, p - buffer);
if (INTEGERP (sym) || NILP (SYMBOL_VALUE (sym)))
return value;