diff options
| author | Kenichi Handa | 1998-05-22 09:44:27 +0000 |
|---|---|---|
| committer | Kenichi Handa | 1998-05-22 09:44:27 +0000 |
| commit | 537efd8df043427dfa36392683f95d1f4e89ea46 (patch) | |
| tree | 589a345a35fbc88d503c8bdefd2c31eec0daa2a3 /src | |
| parent | d74d0ca5a852af62f7ce728f35e9e7d979786653 (diff) | |
| download | emacs-537efd8df043427dfa36392683f95d1f4e89ea46.tar.gz emacs-537efd8df043427dfa36392683f95d1f4e89ea46.zip | |
Change term "character translation table" to
"translation table".
(string_to_non_ascii_char): New arg EXCLUDE_TAIL_GARBAGE. Caller
changed.
(Funibyte_char_to_multibyte): Doc-string fixed.
(syms_of_charset): Doc-string fixed.
Diffstat (limited to 'src')
| -rw-r--r-- | src/charset.c | 37 |
1 files changed, 22 insertions, 15 deletions
diff --git a/src/charset.c b/src/charset.c index 326d7f19de1..cc02d7196ad 100644 --- a/src/charset.c +++ b/src/charset.c | |||
| @@ -74,9 +74,9 @@ Lisp_Object Vcharset_symbol_table; | |||
| 74 | /* A list of charset symbols ever defined. */ | 74 | /* A list of charset symbols ever defined. */ |
| 75 | Lisp_Object Vcharset_list; | 75 | Lisp_Object Vcharset_list; |
| 76 | 76 | ||
| 77 | /* Vector of character translation table ever defined. | 77 | /* Vector of translation table ever defined. |
| 78 | ID of a character translation table is used to index this vector. */ | 78 | ID of a translation table is used to index this vector. */ |
| 79 | Lisp_Object Vcharacter_translation_table_vector; | 79 | Lisp_Object Vtranslation_table_vector; |
| 80 | 80 | ||
| 81 | /* Tables used by macros BYTES_BY_CHAR_HEAD and WIDTH_BY_CHAR_HEAD. */ | 81 | /* Tables used by macros BYTES_BY_CHAR_HEAD and WIDTH_BY_CHAR_HEAD. */ |
| 82 | int bytes_by_char_head[256]; | 82 | int bytes_by_char_head[256]; |
| @@ -168,15 +168,18 @@ non_ascii_char_to_string (c, workbuf, str) | |||
| 168 | 168 | ||
| 169 | /* Return a non-ASCII character of which multi-byte form is at STR of | 169 | /* Return a non-ASCII character of which multi-byte form is at STR of |
| 170 | length LEN. If ACTUAL_LEN is not NULL, the actual length of the | 170 | length LEN. If ACTUAL_LEN is not NULL, the actual length of the |
| 171 | character is set to the address ACTUAL_LEN. | 171 | multibyte form is set to the address ACTUAL_LEN. |
| 172 | |||
| 173 | If exclude_tail_garbage is nonzero, ACTUAL_LEN excludes gabage | ||
| 174 | bytes following the non-ASCII character. | ||
| 172 | 175 | ||
| 173 | Use macro `STRING_CHAR (STR, LEN)' instead of calling this function | 176 | Use macro `STRING_CHAR (STR, LEN)' instead of calling this function |
| 174 | directly if STR can hold an ASCII character. */ | 177 | directly if STR can hold an ASCII character. */ |
| 175 | 178 | ||
| 176 | int | 179 | int |
| 177 | string_to_non_ascii_char (str, len, actual_len) | 180 | string_to_non_ascii_char (str, len, actual_len, exclude_tail_garbage) |
| 178 | const unsigned char *str; | 181 | const unsigned char *str; |
| 179 | int len, *actual_len; | 182 | int len, *actual_len, exclude_tail_garbage; |
| 180 | { | 183 | { |
| 181 | int charset; | 184 | int charset; |
| 182 | unsigned char c1, c2; | 185 | unsigned char c1, c2; |
| @@ -195,20 +198,25 @@ string_to_non_ascii_char (str, len, actual_len) | |||
| 195 | 198 | ||
| 196 | if (cmpchar_id >= 0) | 199 | if (cmpchar_id >= 0) |
| 197 | c = MAKE_COMPOSITE_CHAR (cmpchar_id); | 200 | c = MAKE_COMPOSITE_CHAR (cmpchar_id); |
| 201 | if (exclude_tail_garbage) | ||
| 202 | bytes = cmpchar_table[cmpchar_id]->len; | ||
| 198 | } | 203 | } |
| 199 | else | 204 | else |
| 200 | { | 205 | { |
| 201 | int charset = c, c1, c2 = 0; | 206 | int charset = c, c1, c2 = 0; |
| 207 | int char_bytes = BYTES_BY_CHAR_HEAD (c); | ||
| 202 | 208 | ||
| 203 | str++; | 209 | str++; |
| 204 | if (c >= LEADING_CODE_PRIVATE_11) | 210 | if (c >= LEADING_CODE_PRIVATE_11) |
| 205 | charset = *str++; | 211 | charset = *str++; |
| 206 | if (BYTES_BY_CHAR_HEAD (c) <= bytes && CHARSET_DEFINED_P (charset)) | 212 | if (char_bytes <= bytes && CHARSET_DEFINED_P (charset)) |
| 207 | { | 213 | { |
| 208 | c1 = *str++ & 0x7f; | 214 | c1 = *str++ & 0x7f; |
| 209 | if (CHARSET_DIMENSION (charset) == 2) | 215 | if (CHARSET_DIMENSION (charset) == 2) |
| 210 | c2 = *str & 0x7F; | 216 | c2 = *str & 0x7F; |
| 211 | c = MAKE_NON_ASCII_CHAR (charset, c1, c2); | 217 | c = MAKE_NON_ASCII_CHAR (charset, c1, c2); |
| 218 | if (exclude_tail_garbage) | ||
| 219 | bytes = char_bytes; | ||
| 212 | } | 220 | } |
| 213 | } | 221 | } |
| 214 | } | 222 | } |
| @@ -273,7 +281,7 @@ split_non_ascii_string (str, len, charset, c1, c2) | |||
| 273 | return 0; | 281 | return 0; |
| 274 | } | 282 | } |
| 275 | 283 | ||
| 276 | /* Translate character C by character translation table TABLE. If C | 284 | /* Translate character C by translation table TABLE. If C |
| 277 | is negative, translate a character specified by CHARSET, C1, and C2 | 285 | is negative, translate a character specified by CHARSET, C1, and C2 |
| 278 | (C1 and C2 are code points of the character). If no translation is | 286 | (C1 and C2 are code points of the character). If no translation is |
| 279 | found in TABLE, return C. */ | 287 | found in TABLE, return C. */ |
| @@ -923,7 +931,7 @@ a valid generic character.") | |||
| 923 | DEFUN ("unibyte-char-to-multibyte", Funibyte_char_to_multibyte, | 931 | DEFUN ("unibyte-char-to-multibyte", Funibyte_char_to_multibyte, |
| 924 | Sunibyte_char_to_multibyte, 1, 1, 0, | 932 | Sunibyte_char_to_multibyte, 1, 1, 0, |
| 925 | "Convert the unibyte character CH to multibyte character.\n\ | 933 | "Convert the unibyte character CH to multibyte character.\n\ |
| 926 | The conversion is done based on `nonascii-translate-table' (which see)\n\ | 934 | The conversion is done based on `nonascii-translation-table' (which see)\n\ |
| 927 | or `nonascii-insert-offset' (which see).") | 935 | or `nonascii-insert-offset' (which see).") |
| 928 | (ch) | 936 | (ch) |
| 929 | Lisp_Object ch; | 937 | Lisp_Object ch; |
| @@ -1401,7 +1409,7 @@ str_cmpchar_id (str, len) | |||
| 1401 | /* Make `bufp' point normal multi-byte form temporally. */ | 1409 | /* Make `bufp' point normal multi-byte form temporally. */ |
| 1402 | *bufp -= 0x20; | 1410 | *bufp -= 0x20; |
| 1403 | cmpcharp->glyph[i] | 1411 | cmpcharp->glyph[i] |
| 1404 | = FAST_MAKE_GLYPH (string_to_non_ascii_char (bufp, 4, 0), 0); | 1412 | = FAST_MAKE_GLYPH (string_to_non_ascii_char (bufp, 4, 0, 0), 0); |
| 1405 | width = WIDTH_BY_CHAR_HEAD (*bufp); | 1413 | width = WIDTH_BY_CHAR_HEAD (*bufp); |
| 1406 | *bufp += 0x20; | 1414 | *bufp += 0x20; |
| 1407 | bufp += BYTES_BY_CHAR_HEAD (*bufp - 0x20); | 1415 | bufp += BYTES_BY_CHAR_HEAD (*bufp - 0x20); |
| @@ -1761,11 +1769,10 @@ syms_of_charset () | |||
| 1761 | "List of charsets ever defined."); | 1769 | "List of charsets ever defined."); |
| 1762 | Vcharset_list = Fcons (Qascii, Qnil); | 1770 | Vcharset_list = Fcons (Qascii, Qnil); |
| 1763 | 1771 | ||
| 1764 | DEFVAR_LISP ("character-translation-table-vector", | 1772 | DEFVAR_LISP ("translation-table-vector", &Vtranslation_table_vector, |
| 1765 | &Vcharacter_translation_table_vector, | ||
| 1766 | "Vector of cons cell of a symbol and translation table ever defined.\n\ | 1773 | "Vector of cons cell of a symbol and translation table ever defined.\n\ |
| 1767 | An ID of a translation table is an index of this vector."); | 1774 | An ID of a translation table is an index of this vector."); |
| 1768 | Vcharacter_translation_table_vector = Fmake_vector (make_number (16), Qnil); | 1775 | Vtranslation_table_vector = Fmake_vector (make_number (16), Qnil); |
| 1769 | 1776 | ||
| 1770 | DEFVAR_INT ("leading-code-composition", &leading_code_composition, | 1777 | DEFVAR_INT ("leading-code-composition", &leading_code_composition, |
| 1771 | "Leading-code of composite characters."); | 1778 | "Leading-code of composite characters."); |
| @@ -1795,11 +1802,11 @@ This serves to convert a Latin-1 or similar 8-bit character code\n\ | |||
| 1795 | to the corresponding Emacs multibyte character code.\n\ | 1802 | to the corresponding Emacs multibyte character code.\n\ |
| 1796 | Typically the value should be (- (make-char CHARSET 0) 128),\n\ | 1803 | Typically the value should be (- (make-char CHARSET 0) 128),\n\ |
| 1797 | for your choice of character set.\n\ | 1804 | for your choice of character set.\n\ |
| 1798 | If `nonascii-translate-table' is non-nil, it overrides this variable."); | 1805 | If `nonascii-translation-table' is non-nil, it overrides this variable."); |
| 1799 | nonascii_insert_offset = 0; | 1806 | nonascii_insert_offset = 0; |
| 1800 | 1807 | ||
| 1801 | DEFVAR_LISP ("nonascii-translation-table", &Vnonascii_translation_table, | 1808 | DEFVAR_LISP ("nonascii-translation-table", &Vnonascii_translation_table, |
| 1802 | "Character translation table to convert non-ASCII unibyte codes to multibyte.\n\ | 1809 | "Translation table to convert non-ASCII unibyte codes to multibyte.\n\ |
| 1803 | This is used for converting unibyte text to multibyte,\n\ | 1810 | This is used for converting unibyte text to multibyte,\n\ |
| 1804 | and for inserting character codes specified by number.\n\n\ | 1811 | and for inserting character codes specified by number.\n\n\ |
| 1805 | Conversion is performed only when multibyte characters are enabled,\n\ | 1812 | Conversion is performed only when multibyte characters are enabled,\n\ |