comparison src/charset.c @ 20188:d4ad4463384d

(Fchars_in_string): Pay attention to enable-multibyte-characters. (Fchars_in_region): Likewise. Avoid error when the region ends in the middle of a multibyte character.
author Kenichi Handa <handa@m17n.org>
date Mon, 27 Oct 1997 04:34:26 +0000
parents 9a3343c36e83
children acb7aa0aa71f
comparison
equal deleted inserted replaced
20187:0ee26e03e911 20188:d4ad4463384d
943 unsigned char *p, *endp; 943 unsigned char *p, *endp;
944 int chars; 944 int chars;
945 945
946 CHECK_STRING (str, 0); 946 CHECK_STRING (str, 0);
947 947
948 if (NILP (current_buffer->enable_multibyte_characters))
949 return make_number (XSTRING (str)->size);
950
948 p = XSTRING (str)->data; endp = p + XSTRING (str)->size; 951 p = XSTRING (str)->data; endp = p + XSTRING (str)->size;
949 chars = 0; 952 chars = 0;
950 while (p < endp) 953 while (p < endp)
951 { 954 {
952 if (*p == LEADING_CODE_COMPOSITION) 955 if (*p == LEADING_CODE_COMPOSITION)
980 983
981 from = min (XFASTINT (beg), XFASTINT (end)); 984 from = min (XFASTINT (beg), XFASTINT (end));
982 to = max (XFASTINT (beg), XFASTINT (end)); 985 to = max (XFASTINT (beg), XFASTINT (end));
983 p = POS_ADDR (from); 986 p = POS_ADDR (from);
984 987
988 if (NILP (current_buffer->enable_multibyte_characters))
989 return make_number (to - from);
990
985 if (from < GPT && GPT <= to) 991 if (from < GPT && GPT <= to)
986 { 992 {
987 stop = GPT; 993 stop = GPT;
988 endp = GPT_ADDR; 994 endp = GPT_ADDR;
989 } 995 }
993 endp = POS_ADDR (stop); 999 endp = POS_ADDR (stop);
994 } 1000 }
995 1001
996 while (1) 1002 while (1)
997 { 1003 {
998 if (p == endp) 1004 if (p >= endp)
999 { 1005 {
1000 if (stop == to) 1006 if (stop >= to)
1001 break; 1007 break;
1002 1008
1003 p = POS_ADDR (stop); 1009 p = POS_ADDR (stop);
1004 stop = to; 1010 stop = to;
1005 endp = POS_ADDR (stop); 1011 endp = POS_ADDR (stop);