Mercurial > emacs
comparison src/fns.c @ 23424:982f97638a8e
(clear_string_char_byte_cache): New function.
(Ffillarray): Handle multibyte string correctly.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Mon, 12 Oct 1998 12:00:44 +0000 |
parents | 1abc842b1ca7 |
children | fa66133ad026 |
comparison
equal
deleted
inserted
replaced
23423:4817632d3428 | 23424:982f97638a8e |
---|---|
786 | 786 |
787 static Lisp_Object string_char_byte_cache_string; | 787 static Lisp_Object string_char_byte_cache_string; |
788 static int string_char_byte_cache_charpos; | 788 static int string_char_byte_cache_charpos; |
789 static int string_char_byte_cache_bytepos; | 789 static int string_char_byte_cache_bytepos; |
790 | 790 |
791 void | |
792 clear_string_char_byte_cache () | |
793 { | |
794 string_char_byte_cache_string = Qnil; | |
795 } | |
796 | |
791 /* Return the character index corresponding to CHAR_INDEX in STRING. */ | 797 /* Return the character index corresponding to CHAR_INDEX in STRING. */ |
792 | 798 |
793 int | 799 int |
794 string_char_to_byte (string, char_index) | 800 string_char_to_byte (string, char_index) |
795 Lisp_Object string; | 801 Lisp_Object string; |
1780 { | 1786 { |
1781 register unsigned char *p = XSTRING (array)->data; | 1787 register unsigned char *p = XSTRING (array)->data; |
1782 CHECK_NUMBER (item, 1); | 1788 CHECK_NUMBER (item, 1); |
1783 charval = XINT (item); | 1789 charval = XINT (item); |
1784 size = XSTRING (array)->size; | 1790 size = XSTRING (array)->size; |
1785 for (index = 0; index < size; index++) | 1791 if (STRING_MULTIBYTE (array)) |
1786 p[index] = charval; | 1792 { |
1793 unsigned char workbuf[4], *str; | |
1794 int len = CHAR_STRING (charval, workbuf, str); | |
1795 int size_byte = STRING_BYTES (XSTRING (array)); | |
1796 unsigned char *p1 = p, *endp = p + size_byte; | |
1797 int this_len, i; | |
1798 | |
1799 for (i = 0; i < size; i++) | |
1800 { | |
1801 this_len = MULTIBYTE_FORM_LENGTH (p1, endp - p1); | |
1802 if (len != this_len) | |
1803 error ("Attempt to change byte length of a string"); | |
1804 } | |
1805 for (i = 0; i < size_byte; i++) | |
1806 *p++ = str[i % len]; | |
1807 } | |
1808 else | |
1809 for (index = 0; index < size; index++) | |
1810 p[index] = charval; | |
1787 } | 1811 } |
1788 else if (BOOL_VECTOR_P (array)) | 1812 else if (BOOL_VECTOR_P (array)) |
1789 { | 1813 { |
1790 register unsigned char *p = XBOOL_VECTOR (array)->data; | 1814 register unsigned char *p = XBOOL_VECTOR (array)->data; |
1791 int size_in_chars | 1815 int size_in_chars |