aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRichard M. Stallman1997-08-20 22:28:40 +0000
committerRichard M. Stallman1997-08-20 22:28:40 +0000
commita8a35e617a5acf8577a56c45ea9e8cc958c056a9 (patch)
treefe165b74ead0cb27a8ac45f7e36324b5f59738b7 /src
parenteb0401dd9955b1ead664163d15fb394b007a617d (diff)
downloademacs-a8a35e617a5acf8577a56c45ea9e8cc958c056a9.tar.gz
emacs-a8a35e617a5acf8577a56c45ea9e8cc958c056a9.zip
(Fchars_in_region): Fix gap handling.
Diffstat (limited to 'src')
-rw-r--r--src/charset.c31
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.")
897 897
898DEFUN ("chars-in-region", Fchars_in_region, Schars_in_region, 2, 2, 0, 898DEFUN ("chars-in-region", Fchars_in_region, Schars_in_region, 2, 2, 0,
899 "Return number of characters between BEG and END.\n\ 899 "Return number of characters between BEG and END.\n\
900When using multibyte characters, this is not the necessarily same as\n\ 900When using multibyte characters, this is not the necessarily same\n\
901(- END BEG); that subtraction gives you the number of bytes, which\n\ 901as (- END BEG); that subtraction gives you the number of bytes, which\n\
902may be more than the number of characters.") 902may be more than the number of characters.")
903 (beg, end) 903 (beg, end)
904 Lisp_Object beg, end; 904 Lisp_Object beg, end;
@@ -911,25 +911,30 @@ may be more than the number of characters.")
911 validate_region (&beg, &end); 911 validate_region (&beg, &end);
912 912
913 from = min (XFASTINT (beg), XFASTINT (end)); 913 from = min (XFASTINT (beg), XFASTINT (end));
914 stop = to = max (XFASTINT (beg), XFASTINT (end)); 914 to = max (XFASTINT (beg), XFASTINT (end));
915 p = POS_ADDR (from); 915 p = POS_ADDR (from);
916 endp = POS_ADDR (stop);
917 916
918 if (from < GPT && GPT < to) 917 if (from < GPT && GPT <= to)
919 stop = GPT; 918 {
919 stop = GPT;
920 endp = GPT_ADDR;
921 }
922 else
923 {
924 stop = to;
925 endp = POS_ADDR (stop);
926 }
920 927
921 while (1) 928 while (1)
922 { 929 {
923 if (p == endp) 930 if (p == endp)
924 { 931 {
925 if (stop == GPT) 932 if (stop == to)
926 {
927 p = POS_ADDR (stop);
928 stop = to;
929 endp = POS_ADDR (stop);
930 }
931 else
932 break; 933 break;
934
935 p = POS_ADDR (stop);
936 stop = to;
937 endp = POS_ADDR (stop);
933 } 938 }
934 939
935 if (*p == LEADING_CODE_COMPOSITION) 940 if (*p == LEADING_CODE_COMPOSITION)