summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKenichi Handa <handa@m17n.org>1998-02-04 11:23:28 +0000
committerKenichi Handa <handa@m17n.org>1998-02-04 11:23:28 +0000
commitf26d85ca3d108190358486c80636ede1eb8831aa (patch)
treec2b093439ece16ddb8cf60fa8e86edf7f48b51e5 /src
parent1dee9b8f5752fc782fa7d1fd9b8523f0c67539d4 (diff)
downloademacs-f26d85ca3d108190358486c80636ede1eb8831aa.tar.gz
(Fsubst_char_in_region): Handle character-base
position and byte-base position correctly. (Fstring_to_char): Give byte size to STRING_CHAR.
Diffstat (limited to 'src')
-rw-r--r--src/editfns.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/editfns.c b/src/editfns.c
index b588d413d4b..e5b9d54344e 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -146,7 +146,7 @@ A multibyte character is handled correctly.")
CHECK_STRING (string, 0);
p = XSTRING (string);
if (p->size)
- XSETFASTINT (val, STRING_CHAR (p->data, p->size));
+ XSETFASTINT (val, STRING_CHAR (p->data, p->size_byte));
else
XSETFASTINT (val, 0);
return val;
@@ -1741,7 +1741,7 @@ Both characters must have the same length of multi-byte form.")
(start, end, fromchar, tochar, noundo)
Lisp_Object start, end, fromchar, tochar, noundo;
{
- register int pos, stop, i, len, end_byte;
+ register int pos, pos_byte, stop, i, len, end_byte;
int changed = 0;
unsigned char fromwork[4], *fromstr, towork[4], *tostr, *p;
int count = specpdl_ptr - specpdl;
@@ -1763,7 +1763,8 @@ Both characters must have the same length of multi-byte form.")
towork[0] = XFASTINT (tochar), tostr = towork;
}
- pos = CHAR_TO_BYTE (XINT (start));
+ pos = XINT (start);
+ pos_byte = CHAR_TO_BYTE (pos);
stop = CHAR_TO_BYTE (XINT (end));
end_byte = stop;
@@ -1782,17 +1783,16 @@ Both characters must have the same length of multi-byte form.")
current_buffer->filename = Qnil;
}
- if (pos < GPT_BYTE)
+ if (pos_byte < GPT_BYTE)
stop = min (stop, GPT_BYTE);
- p = BYTE_POS_ADDR (pos);
while (1)
{
- if (pos >= stop)
+ if (pos_byte >= stop)
{
- if (pos >= end_byte) break;
+ if (pos_byte >= end_byte) break;
stop = end_byte;
- p = BYTE_POS_ADDR (pos);
}
+ p = BYTE_POS_ADDR (pos_byte);
if (p[0] == fromstr[0]
&& (len == 1
|| (p[1] == fromstr[1]
@@ -1815,17 +1815,17 @@ Both characters must have the same length of multi-byte form.")
}
if (NILP (noundo))
- record_change (pos, len);
+ record_change (pos, 1);
for (i = 0; i < len; i++) *p++ = tostr[i];
- pos += len;
+ pos++;
+ pos_byte += len;
}
- else
- pos++, p++;
+ INC_BOTH (pos, pos_byte);
}
if (changed)
signal_after_change (XINT (start),
- stop - XINT (start), stop - XINT (start));
+ XINT (end) - XINT (start), XINT (end) - XINT (start));
unbind_to (count, Qnil);
return Qnil;