# HG changeset patch # User Richard M. Stallman # Date 872116120 0 # Node ID 752afe97eaa4b0aecf150df84da929ce6900cac7 # Parent 39815ec1b9f8f7e9e0e0c607108f7286e8dc4623 (Fchars_in_region): Fix gap handling. diff -r 39815ec1b9f8 -r 752afe97eaa4 src/charset.c --- a/src/charset.c Wed Aug 20 17:25:25 1997 +0000 +++ b/src/charset.c Wed Aug 20 22:28:40 1997 +0000 @@ -897,8 +897,8 @@ 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 @@ 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)