diff options
| author | Kenichi Handa | 1998-10-12 12:00:44 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-10-12 12:00:44 +0000 |
| commit | 57247650fbe47e56ae4148f6db9e105d944192f6 (patch) | |
| tree | d438eeae3a7526e618536d03b13df51bb193abe7 /src | |
| parent | 76be80e02b5e9e671ae7a7407e6e886dbbf3d4f5 (diff) | |
| download | emacs-57247650fbe47e56ae4148f6db9e105d944192f6.tar.gz emacs-57247650fbe47e56ae4148f6db9e105d944192f6.zip | |
(clear_string_char_byte_cache): New function.
(Ffillarray): Handle multibyte string correctly.
Diffstat (limited to 'src')
| -rw-r--r-- | src/fns.c | 28 |
1 files changed, 26 insertions, 2 deletions
| @@ -788,6 +788,12 @@ 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 |
| @@ -1782,8 +1788,26 @@ ARRAY is a vector, string, char-table, or bool-vector.") | |||
| 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 | { |