diff options
author | Richard M. Stallman <rms@gnu.org> | 1997-08-20 22:28:40 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 1997-08-20 22:28:40 +0000 |
commit | 811ed31743ebffc6f5cd897e70a428b7f0eaa4c4 (patch) | |
tree | 41db8b3645ff7504f43e8240fdb12e13bff3e0b0 /src/charset.c | |
parent | a978628f9246f8d27079072b7e7733edb96ea851 (diff) | |
download | emacs-811ed31743ebffc6f5cd897e70a428b7f0eaa4c4.tar.gz |
(Fchars_in_region): Fix gap handling.
Diffstat (limited to 'src/charset.c')
-rw-r--r-- | src/charset.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/src/charset.c b/src/charset.c index 94468b55581..edfab057549 100644 --- a/src/charset.c +++ b/src/charset.c @@ -897,8 +897,8 @@ character.") DEFUN ("chars-in-region", Fchars_in_region, Schars_in_region, 2, 2, 0, "Return number of characters between BEG and END.\n\ -When using multibyte characters, this is not the necessarily same as\n\ -(- END BEG); that subtraction gives you the number of bytes, which\n\ +When using multibyte characters, this is not the necessarily same\n\ +as (- END BEG); that subtraction gives you the number of bytes, which\n\ may be more than the number of characters.") (beg, end) Lisp_Object beg, end; @@ -911,25 +911,30 @@ may be more than the number of characters.") validate_region (&beg, &end); from = min (XFASTINT (beg), XFASTINT (end)); - stop = to = max (XFASTINT (beg), XFASTINT (end)); + to = max (XFASTINT (beg), XFASTINT (end)); p = POS_ADDR (from); - endp = POS_ADDR (stop); - if (from < GPT && GPT < to) - stop = GPT; + if (from < GPT && GPT <= to) + { + stop = GPT; + endp = GPT_ADDR; + } + else + { + stop = to; + endp = POS_ADDR (stop); + } while (1) { if (p == endp) { - if (stop == GPT) - { - p = POS_ADDR (stop); - stop = to; - endp = POS_ADDR (stop); - } - else + if (stop == to) break; + + p = POS_ADDR (stop); + stop = to; + endp = POS_ADDR (stop); } if (*p == LEADING_CODE_COMPOSITION) |