diff options
| author | Kenichi Handa | 2002-07-22 06:35:00 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2002-07-22 06:35:00 +0000 |
| commit | dbbb237db83ab63c51ce5816e2f08d813361ae82 (patch) | |
| tree | 7c23ed2e8322f17928ce89e25f98e85dd10d5883 /src | |
| parent | b5c7dbe655f5d2f00ea53a6c1fcfb9e5bd740fb3 (diff) | |
| download | emacs-dbbb237db83ab63c51ce5816e2f08d813361ae82.tar.gz emacs-dbbb237db83ab63c51ce5816e2f08d813361ae82.zip | |
(charset_ordered_list_tick): New variable.
(Fdefine_charset_internal): Increment charset_ordered_list_tick.
(Funify_charset): New optional arg DEUNIFY. If it is non-nil,
deunify intead of unify a charset.
(string_xstring_p): Add `const' to local variables.
(find_charsets_in_text): Add `const' to arguemnts and local
variables.
(encode_char): Adjusted for the change of Funify_charset. Fix
detecting of invalid code.
(Fset_charset_priority): Increment charset_ordered_list_tick.
Diffstat (limited to 'src')
| -rw-r--r-- | src/charset.c | 84 |
1 files changed, 54 insertions, 30 deletions
diff --git a/src/charset.c b/src/charset.c index 4a64b4e36c1..c4ec97b2a65 100644 --- a/src/charset.c +++ b/src/charset.c | |||
| @@ -107,6 +107,11 @@ int charset_primary; | |||
| 107 | /* List of charsets ordered by the priority. */ | 107 | /* List of charsets ordered by the priority. */ |
| 108 | Lisp_Object Vcharset_ordered_list; | 108 | Lisp_Object Vcharset_ordered_list; |
| 109 | 109 | ||
| 110 | /* Incremented everytime we change Vcharset_ordered_list. This is | ||
| 111 | unsigned short so that it fits in Lisp_Int and never match with | ||
| 112 | -1. */ | ||
| 113 | unsigned short charset_ordered_list_tick; | ||
| 114 | |||
| 110 | /* List of iso-2022 charsets. */ | 115 | /* List of iso-2022 charsets. */ |
| 111 | Lisp_Object Viso_2022_charset_list; | 116 | Lisp_Object Viso_2022_charset_list; |
| 112 | 117 | ||
| @@ -1055,6 +1060,7 @@ usage: (define-charset-internal ...) */) | |||
| 1055 | Vcharset_list = Fcons (args[charset_arg_name], Vcharset_list); | 1060 | Vcharset_list = Fcons (args[charset_arg_name], Vcharset_list); |
| 1056 | Vcharset_ordered_list = nconc2 (Vcharset_ordered_list, | 1061 | Vcharset_ordered_list = nconc2 (Vcharset_ordered_list, |
| 1057 | Fcons (make_number (id), Qnil)); | 1062 | Fcons (make_number (id), Qnil)); |
| 1063 | charset_ordered_list_tick++; | ||
| 1058 | } | 1064 | } |
| 1059 | 1065 | ||
| 1060 | return Qnil; | 1066 | return Qnil; |
| @@ -1124,12 +1130,18 @@ DEFUN ("set-charset-plist", Fset_charset_plist, Sset_charset_plist, 2, 2, 0, | |||
| 1124 | } | 1130 | } |
| 1125 | 1131 | ||
| 1126 | 1132 | ||
| 1127 | DEFUN ("unify-charset", Funify_charset, Sunify_charset, 1, 2, 0, | 1133 | DEFUN ("unify-charset", Funify_charset, Sunify_charset, 1, 3, 0, |
| 1128 | doc: /* Unify characters of CHARSET with Unicode. | 1134 | doc: /* Unify characters of CHARSET with Unicode. |
| 1129 | This means reading the relevant file and installing the table defined | 1135 | This means reading the relevant file and installing the table defined |
| 1130 | by CHARSET's `:unify-map' property. */) | 1136 | by CHARSET's `:unify-map' property. |
| 1131 | (charset, unify_map) | 1137 | |
| 1132 | Lisp_Object charset, unify_map; | 1138 | Optional second arg UNIFY-MAP a file name string or vector that has |
| 1139 | the same meaning of the `:unify-map' attribute of the function | ||
| 1140 | `define-charset' (which see). | ||
| 1141 | |||
| 1142 | Optional third argument DEUNIFY, if non-nil, means to de-unify CHARSET. */) | ||
| 1143 | (charset, unify_map, deunify) | ||
| 1144 | Lisp_Object charset, unify_map, deunify; | ||
| 1133 | { | 1145 | { |
| 1134 | int id; | 1146 | int id; |
| 1135 | struct charset *cs; | 1147 | struct charset *cs; |
| @@ -1138,21 +1150,38 @@ by CHARSET's `:unify-map' property. */) | |||
| 1138 | cs = CHARSET_FROM_ID (id); | 1150 | cs = CHARSET_FROM_ID (id); |
| 1139 | if (CHARSET_METHOD (cs) == CHARSET_METHOD_MAP_DEFERRED) | 1151 | if (CHARSET_METHOD (cs) == CHARSET_METHOD_MAP_DEFERRED) |
| 1140 | load_charset (cs); | 1152 | load_charset (cs); |
| 1141 | if (CHARSET_UNIFIED_P (cs) | 1153 | if (NILP (deunify) |
| 1142 | && CHAR_TABLE_P (CHARSET_DEUNIFIER (cs))) | 1154 | ? CHARSET_UNIFIED_P (cs) && ! NILP (CHARSET_DEUNIFIER (cs)) |
| 1155 | : ! CHARSET_UNIFIED_P (cs)) | ||
| 1143 | return Qnil; | 1156 | return Qnil; |
| 1157 | |||
| 1144 | CHARSET_UNIFIED_P (cs) = 0; | 1158 | CHARSET_UNIFIED_P (cs) = 0; |
| 1145 | if (NILP (unify_map)) | 1159 | if (NILP (deunify)) |
| 1146 | unify_map = CHARSET_UNIFY_MAP (cs); | 1160 | { |
| 1147 | if (STRINGP (unify_map)) | 1161 | if (CHARSET_METHOD (cs) != CHARSET_METHOD_OFFSET) |
| 1148 | load_charset_map_from_file (cs, unify_map, 2); | 1162 | error ("Can't unify charset: %s", XSYMBOL (charset)->name->data); |
| 1149 | else if (VECTORP (unify_map)) | 1163 | if (NILP (unify_map)) |
| 1150 | load_charset_map_from_vector (cs, unify_map, 2); | 1164 | unify_map = CHARSET_UNIFY_MAP (cs); |
| 1151 | else if (NILP (unify_map)) | 1165 | if (STRINGP (unify_map)) |
| 1152 | error ("No unify-map for charset"); | 1166 | load_charset_map_from_file (cs, unify_map, 2); |
| 1153 | else | 1167 | else if (VECTORP (unify_map)) |
| 1154 | error ("Bad unify-map arg"); | 1168 | load_charset_map_from_vector (cs, unify_map, 2); |
| 1155 | CHARSET_UNIFIED_P (cs) = 1; | 1169 | else if (NILP (unify_map)) |
| 1170 | error ("No unify-map for charset"); | ||
| 1171 | else | ||
| 1172 | error ("Bad unify-map arg"); | ||
| 1173 | CHARSET_UNIFIED_P (cs) = 1; | ||
| 1174 | } | ||
| 1175 | else if (CHAR_TABLE_P (Vchar_unify_table)) | ||
| 1176 | { | ||
| 1177 | int min_code = CHARSET_MIN_CODE (cs); | ||
| 1178 | int max_code = CHARSET_MAX_CODE (cs); | ||
| 1179 | int min_char = DECODE_CHAR (cs, min_code); | ||
| 1180 | int max_char = DECODE_CHAR (cs, max_code); | ||
| 1181 | |||
| 1182 | char_table_set_range (Vchar_unify_table, min_char, max_char, Qnil); | ||
| 1183 | } | ||
| 1184 | |||
| 1156 | return Qnil; | 1185 | return Qnil; |
| 1157 | } | 1186 | } |
| 1158 | 1187 | ||
| @@ -1235,8 +1264,8 @@ int | |||
| 1235 | string_xstring_p (string) | 1264 | string_xstring_p (string) |
| 1236 | Lisp_Object string; | 1265 | Lisp_Object string; |
| 1237 | { | 1266 | { |
| 1238 | unsigned char *p = XSTRING (string)->data; | 1267 | const unsigned char *p = XSTRING (string)->data; |
| 1239 | unsigned char *endp = p + STRING_BYTES (XSTRING (string)); | 1268 | const unsigned char *endp = p + STRING_BYTES (XSTRING (string)); |
| 1240 | struct charset *charset; | 1269 | struct charset *charset; |
| 1241 | 1270 | ||
| 1242 | if (XSTRING (string)->size == STRING_BYTES (XSTRING (string))) | 1271 | if (XSTRING (string)->size == STRING_BYTES (XSTRING (string))) |
| @@ -1265,11 +1294,11 @@ string_xstring_p (string) | |||
| 1265 | 1294 | ||
| 1266 | static void | 1295 | static void |
| 1267 | find_charsets_in_text (ptr, nchars, nbytes, charsets, table) | 1296 | find_charsets_in_text (ptr, nchars, nbytes, charsets, table) |
| 1268 | unsigned char *ptr; | 1297 | const unsigned char *ptr; |
| 1269 | int nchars, nbytes; | 1298 | int nchars, nbytes; |
| 1270 | Lisp_Object charsets, table; | 1299 | Lisp_Object charsets, table; |
| 1271 | { | 1300 | { |
| 1272 | unsigned char *pend = ptr + nbytes; | 1301 | const unsigned char *pend = ptr + nbytes; |
| 1273 | int ncharsets = ASIZE (charsets); | 1302 | int ncharsets = ASIZE (charsets); |
| 1274 | 1303 | ||
| 1275 | if (nchars == nbytes) | 1304 | if (nchars == nbytes) |
| @@ -1490,7 +1519,7 @@ encode_char (charset, c) | |||
| 1490 | deunifier = CHARSET_DEUNIFIER (charset); | 1519 | deunifier = CHARSET_DEUNIFIER (charset); |
| 1491 | if (! CHAR_TABLE_P (deunifier)) | 1520 | if (! CHAR_TABLE_P (deunifier)) |
| 1492 | { | 1521 | { |
| 1493 | Funify_charset (CHARSET_NAME (charset), Qnil); | 1522 | Funify_charset (CHARSET_NAME (charset), Qnil, Qnil); |
| 1494 | deunifier = CHARSET_DEUNIFIER (charset); | 1523 | deunifier = CHARSET_DEUNIFIER (charset); |
| 1495 | } | 1524 | } |
| 1496 | deunified = CHAR_TABLE_REF (deunifier, c); | 1525 | deunified = CHAR_TABLE_REF (deunifier, c); |
| @@ -1530,14 +1559,8 @@ encode_char (charset, c) | |||
| 1530 | struct charset *this_charset = CHARSET_FROM_ID (id); | 1559 | struct charset *this_charset = CHARSET_FROM_ID (id); |
| 1531 | 1560 | ||
| 1532 | code = ENCODE_CHAR (this_charset, c); | 1561 | code = ENCODE_CHAR (this_charset, c); |
| 1533 | if (code != CHARSET_INVALID_CODE (this_charset) | 1562 | if (code != CHARSET_INVALID_CODE (this_charset)) |
| 1534 | && (code_offset < 0 || code >= code_offset)) | 1563 | return code + code_offset; |
| 1535 | { | ||
| 1536 | code += code_offset; | ||
| 1537 | if (code >= charset->min_code && code <= charset->max_code | ||
| 1538 | && CODE_POINT_TO_INDEX (charset, code) >= 0) | ||
| 1539 | return code; | ||
| 1540 | } | ||
| 1541 | } | 1564 | } |
| 1542 | return CHARSET_INVALID_CODE (charset); | 1565 | return CHARSET_INVALID_CODE (charset); |
| 1543 | } | 1566 | } |
| @@ -1904,6 +1927,7 @@ usage: (set-charset-priority &rest charsets) */) | |||
| 1904 | arglist[0] = Fnreverse (new_head); | 1927 | arglist[0] = Fnreverse (new_head); |
| 1905 | arglist[1] = old_list; | 1928 | arglist[1] = old_list; |
| 1906 | Vcharset_ordered_list = Fnconc (2, arglist); | 1929 | Vcharset_ordered_list = Fnconc (2, arglist); |
| 1930 | charset_ordered_list_tick++; | ||
| 1907 | return Qnil; | 1931 | return Qnil; |
| 1908 | } | 1932 | } |
| 1909 | 1933 | ||