Mercurial > emacs
comparison src/charset.c @ 88948:1ff7f42f40ad
(charset_eight_bit, Qeight_bit_control): New
variables.
(charset_8_bit__control, charset_8_bit_graphic,
Qeight_bit_control, Qeight_bit_graphic): These variables deleted.
(define_charset_internal): New function.
(syms_of_charset): Call define_charset_internal for pre-defined
charsets.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Wed, 31 Jul 2002 07:07:59 +0000 |
parents | cd7645c9842b |
children | afdff51dae58 |
comparison
equal
deleted
inserted
replaced
88947:894b8bce3208 | 88948:1ff7f42f40ad |
---|---|
67 | 67 |
68 Lisp_Object Qcharsetp; | 68 Lisp_Object Qcharsetp; |
69 | 69 |
70 /* Special charset symbols. */ | 70 /* Special charset symbols. */ |
71 Lisp_Object Qascii; | 71 Lisp_Object Qascii; |
72 Lisp_Object Qeight_bit_control; | 72 Lisp_Object Qeight_bit; |
73 Lisp_Object Qeight_bit_graphic; | |
74 Lisp_Object Qiso_8859_1; | 73 Lisp_Object Qiso_8859_1; |
75 Lisp_Object Qunicode; | 74 Lisp_Object Qunicode; |
76 | 75 |
77 /* The corresponding charsets. */ | 76 /* The corresponding charsets. */ |
78 int charset_ascii; | 77 int charset_ascii; |
79 int charset_8_bit_control; | 78 int charset_eight_bit; |
80 int charset_8_bit_graphic; | |
81 int charset_iso_8859_1; | 79 int charset_iso_8859_1; |
82 int charset_unicode; | 80 int charset_unicode; |
83 | 81 |
84 /* The other special charsets. */ | 82 /* The other special charsets. */ |
85 int charset_jisx0201_roman; | 83 int charset_jisx0201_roman; |
1014 { | 1012 { |
1015 charset.hash_index = hash_put (hash_table, args[charset_arg_name], attrs, | 1013 charset.hash_index = hash_put (hash_table, args[charset_arg_name], attrs, |
1016 hash_code); | 1014 hash_code); |
1017 if (charset_table_used == charset_table_size) | 1015 if (charset_table_used == charset_table_size) |
1018 { | 1016 { |
1019 charset_table_size += 256; | 1017 struct charset *new_table |
1020 charset_table | 1018 = (struct charset *) xmalloc (sizeof (struct charset) |
1021 = ((struct charset *) | 1019 * (charset_table_size + 16)); |
1022 xrealloc (charset_table, | 1020 bcopy (charset_table, new_table, |
1023 sizeof (struct charset) * charset_table_size)); | 1021 sizeof (struct charset) * charset_table_size); |
1022 charset_table_size += 16; | |
1023 charset_table = new_table; | |
1024 } | 1024 } |
1025 id = charset_table_used++; | 1025 id = charset_table_used++; |
1026 new_definition_p = 1; | 1026 new_definition_p = 1; |
1027 } | 1027 } |
1028 | 1028 |
1063 charset_ordered_list_tick++; | 1063 charset_ordered_list_tick++; |
1064 } | 1064 } |
1065 | 1065 |
1066 return Qnil; | 1066 return Qnil; |
1067 } | 1067 } |
1068 | |
1069 | |
1070 /* Same as Fdefine_charset_internal but arguments are more convenient | |
1071 to call from C (typically in syms_of_charset). This can define a | |
1072 charset of `offset' method only. Return the ID of the new | |
1073 charset. */ | |
1074 | |
1075 static int | |
1076 define_charset_internal (name, dimension, code_space, min_code, max_code, | |
1077 iso_final, iso_revision, emacs_mule_id, | |
1078 ascii_compatible, supprementary, | |
1079 code_offset) | |
1080 Lisp_Object name; | |
1081 int dimension; | |
1082 unsigned char *code_space; | |
1083 unsigned min_code, max_code; | |
1084 int iso_final, iso_revision, emacs_mule_id; | |
1085 int ascii_compatible, supprementary; | |
1086 int code_offset; | |
1087 { | |
1088 Lisp_Object args[charset_arg_max]; | |
1089 Lisp_Object plist[14]; | |
1090 Lisp_Object val; | |
1091 int i; | |
1092 | |
1093 args[charset_arg_name] = name; | |
1094 args[charset_arg_dimension] = make_number (dimension); | |
1095 val = Fmake_vector (make_number (8), make_number (0)); | |
1096 for (i = 0; i < 8; i++) | |
1097 ASET (val, i, make_number (code_space[i])); | |
1098 args[charset_arg_code_space] = val; | |
1099 args[charset_arg_min_code] = make_number (min_code); | |
1100 args[charset_arg_max_code] = make_number (max_code); | |
1101 args[charset_arg_iso_final] | |
1102 = (iso_final < 0 ? Qnil : make_number (iso_final)); | |
1103 args[charset_arg_iso_revision] = make_number (iso_revision); | |
1104 args[charset_arg_emacs_mule_id] | |
1105 = (emacs_mule_id < 0 ? Qnil : make_number (emacs_mule_id)); | |
1106 args[charset_arg_ascii_compatible_p] = ascii_compatible ? Qt : Qnil; | |
1107 args[charset_arg_supplementary_p] = supprementary ? Qt : Qnil; | |
1108 args[charset_arg_invalid_code] = Qnil; | |
1109 args[charset_arg_code_offset] = make_number (code_offset); | |
1110 args[charset_arg_map] = Qnil; | |
1111 args[charset_arg_subset] = Qnil; | |
1112 args[charset_arg_superset] = Qnil; | |
1113 args[charset_arg_unify_map] = Qnil; | |
1114 | |
1115 plist[0] = intern (":name"); | |
1116 plist[1] = args[charset_arg_name]; | |
1117 plist[2] = intern (":dimension"); | |
1118 plist[3] = args[charset_arg_dimension]; | |
1119 plist[4] = intern (":code-space"); | |
1120 plist[5] = args[charset_arg_code_space]; | |
1121 plist[6] = intern (":iso-final-char"); | |
1122 plist[7] = args[charset_arg_iso_final]; | |
1123 plist[8] = intern (":emacs-mule-id"); | |
1124 plist[9] = args[charset_arg_emacs_mule_id]; | |
1125 plist[10] = intern (":ascii-compatible-p"); | |
1126 plist[11] = args[charset_arg_ascii_compatible_p]; | |
1127 plist[12] = intern (":code-offset"); | |
1128 plist[13] = args[charset_arg_code_offset]; | |
1129 | |
1130 args[charset_arg_plist] = Flist (14, plist); | |
1131 Fdefine_charset_internal (charset_arg_max, args); | |
1132 | |
1133 return XINT (CHARSET_SYMBOL_ID (name)); | |
1134 } | |
1135 | |
1068 | 1136 |
1069 DEFUN ("define-charset-alias", Fdefine_charset_alias, | 1137 DEFUN ("define-charset-alias", Fdefine_charset_alias, |
1070 Sdefine_charset_alias, 2, 2, 0, | 1138 Sdefine_charset_alias, 2, 2, 0, |
1071 doc: /* Define ALIAS as an alias for charset CHARSET. */) | 1139 doc: /* Define ALIAS as an alias for charset CHARSET. */) |
1072 (alias, charset) | 1140 (alias, charset) |
1982 | 2050 |
1983 DEFSYM (Qcharsetp, "charsetp"); | 2051 DEFSYM (Qcharsetp, "charsetp"); |
1984 | 2052 |
1985 DEFSYM (Qascii, "ascii"); | 2053 DEFSYM (Qascii, "ascii"); |
1986 DEFSYM (Qunicode, "unicode"); | 2054 DEFSYM (Qunicode, "unicode"); |
1987 DEFSYM (Qeight_bit_control, "eight-bit-control"); | 2055 DEFSYM (Qeight_bit, "eight-bit"); |
1988 DEFSYM (Qeight_bit_graphic, "eight-bit-graphic"); | |
1989 DEFSYM (Qiso_8859_1, "iso-8859-1"); | 2056 DEFSYM (Qiso_8859_1, "iso-8859-1"); |
1990 | 2057 |
1991 DEFSYM (Qgl, "gl"); | 2058 DEFSYM (Qgl, "gl"); |
1992 DEFSYM (Qgr, "gr"); | 2059 DEFSYM (Qgr, "gr"); |
1993 | 2060 |
2045 | 2112 |
2046 DEFVAR_LISP ("charset-list", &Vcharset_list, | 2113 DEFVAR_LISP ("charset-list", &Vcharset_list, |
2047 doc: /* List of all charsets ever defined. */); | 2114 doc: /* List of all charsets ever defined. */); |
2048 Vcharset_list = Qnil; | 2115 Vcharset_list = Qnil; |
2049 | 2116 |
2050 /* Make the prerequisite charset `ascii' and `unicode'. */ | 2117 charset_ascii |
2051 { | 2118 = define_charset_internal (Qascii, 1, "\x00\x7F\x00\x00\x00\x00", |
2052 Lisp_Object args[charset_arg_max]; | 2119 0, 127, 'B', -1, 0, 1, 0, 0); |
2053 Lisp_Object plist[14]; | 2120 charset_unicode |
2054 Lisp_Object val; | 2121 = define_charset_internal (Qunicode, 3, "\x00\x7F\x00\x7F\x00\x10", |
2055 | 2122 0, MAX_UNICODE_CHAR, -1, 0, -1, 1, 0, 0); |
2056 plist[0] = intern (":name"); | 2123 charset_eight_bit |
2057 plist[2] = intern (":dimension"); | 2124 = define_charset_internal (Qeight_bit, 1, "\x80\xFF\x00\x00\x00\x00", |
2058 plist[4] = intern (":code-space"); | 2125 128, 255, -1, 0, -1, 0, 0, |
2059 plist[6] = intern (":iso-final-char"); | 2126 MAX_5_BYTE_CHAR + 1); |
2060 plist[8] = intern (":emacs-mule-id"); | |
2061 plist[10] = intern (":ascii-compatible-p"); | |
2062 plist[12] = intern (":code-offset"); | |
2063 | |
2064 args[charset_arg_name] = Qascii; | |
2065 args[charset_arg_dimension] = make_number (1); | |
2066 val = Fmake_vector (make_number (8), make_number (0)); | |
2067 ASET (val, 1, make_number (127)); | |
2068 args[charset_arg_code_space] = val; | |
2069 args[charset_arg_min_code] = Qnil; | |
2070 args[charset_arg_max_code] = Qnil; | |
2071 args[charset_arg_iso_final] = make_number ('B'); | |
2072 args[charset_arg_iso_revision] = Qnil; | |
2073 args[charset_arg_emacs_mule_id] = make_number (0); | |
2074 args[charset_arg_ascii_compatible_p] = Qt; | |
2075 args[charset_arg_supplementary_p] = Qnil; | |
2076 args[charset_arg_invalid_code] = Qnil; | |
2077 args[charset_arg_code_offset] = make_number (0); | |
2078 args[charset_arg_map] = Qnil; | |
2079 args[charset_arg_subset] = Qnil; | |
2080 args[charset_arg_superset] = Qnil; | |
2081 args[charset_arg_unify_map] = Qnil; | |
2082 /* The actual plist is set by mule-conf.el. */ | |
2083 plist[1] = args[charset_arg_name]; | |
2084 plist[3] = args[charset_arg_dimension]; | |
2085 plist[5] = args[charset_arg_code_space]; | |
2086 plist[7] = args[charset_arg_iso_final]; | |
2087 plist[9] = args[charset_arg_emacs_mule_id]; | |
2088 plist[11] = args[charset_arg_ascii_compatible_p]; | |
2089 plist[13] = args[charset_arg_code_offset]; | |
2090 args[charset_arg_plist] = Flist (14, plist); | |
2091 Fdefine_charset_internal (charset_arg_max, args); | |
2092 charset_ascii = XINT (CHARSET_SYMBOL_ID (Qascii)); | |
2093 | |
2094 args[charset_arg_name] = Qunicode; | |
2095 args[charset_arg_dimension] = make_number (3); | |
2096 val = Fmake_vector (make_number (8), make_number (0)); | |
2097 ASET (val, 1, make_number (255)); | |
2098 ASET (val, 3, make_number (255)); | |
2099 ASET (val, 5, make_number (16)); | |
2100 args[charset_arg_code_space] = val; | |
2101 args[charset_arg_min_code] = Qnil; | |
2102 args[charset_arg_max_code] = Qnil; | |
2103 args[charset_arg_iso_final] = Qnil; | |
2104 args[charset_arg_iso_revision] = Qnil; | |
2105 args[charset_arg_emacs_mule_id] = Qnil; | |
2106 args[charset_arg_ascii_compatible_p] = Qt; | |
2107 args[charset_arg_supplementary_p] = Qnil; | |
2108 args[charset_arg_invalid_code] = Qnil; | |
2109 args[charset_arg_code_offset] = make_number (0); | |
2110 args[charset_arg_map] = Qnil; | |
2111 args[charset_arg_subset] = Qnil; | |
2112 args[charset_arg_superset] = Qnil; | |
2113 args[charset_arg_unify_map] = Qnil; | |
2114 /* The actual plist is set by mule-conf.el. */ | |
2115 plist[1] = args[charset_arg_name]; | |
2116 plist[3] = args[charset_arg_dimension]; | |
2117 plist[5] = args[charset_arg_code_space]; | |
2118 plist[7] = args[charset_arg_iso_final]; | |
2119 plist[9] = args[charset_arg_emacs_mule_id]; | |
2120 plist[11] = args[charset_arg_ascii_compatible_p]; | |
2121 plist[13] = args[charset_arg_code_offset]; | |
2122 args[charset_arg_plist] = Flist (14, plist); | |
2123 Fdefine_charset_internal (charset_arg_max, args); | |
2124 charset_unicode = XINT (CHARSET_SYMBOL_ID (Qunicode)); | |
2125 } | |
2126 } | 2127 } |
2127 | 2128 |
2128 #endif /* emacs */ | 2129 #endif /* emacs */ |