the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
-/* Synched up with: FSF 20.3. Not in FSF. */
-
/* Rewritten by Ben Wing <ben@xemacs.org>. */
+/* Rewritten by MORIOKA Tomohiko <tomo@m17n.org> for XEmacs UTF-2000. */
+
#include <config.h>
#ifdef UTF2000
#include <limits.h>
Lisp_Object Vcharset_latin_iso8859_9;
Lisp_Object Vcharset_japanese_jisx0208_1978;
Lisp_Object Vcharset_chinese_gb2312;
+Lisp_Object Vcharset_chinese_gb12345;
Lisp_Object Vcharset_japanese_jisx0208;
Lisp_Object Vcharset_japanese_jisx0208_1990;
Lisp_Object Vcharset_korean_ksc5601;
Lisp_Object Vcharset_ucs;
Lisp_Object Vcharset_ucs_bmp;
Lisp_Object Vcharset_ucs_cns;
+Lisp_Object Vcharset_ucs_big5;
Lisp_Object Vcharset_latin_viscii;
Lisp_Object Vcharset_latin_tcvn5712;
Lisp_Object Vcharset_latin_viscii_lower;
Lisp_Object Vcharset_latin_viscii_upper;
Lisp_Object Vcharset_chinese_big5;
+Lisp_Object Vcharset_chinese_big5_cdp;
Lisp_Object Vcharset_ideograph_gt;
Lisp_Object Vcharset_ideograph_gt_pj_1;
Lisp_Object Vcharset_ideograph_gt_pj_2;
return -1;
}
+static int
+map_over_uint8_byte_table (Lisp_Uint8_Byte_Table *ct,
+ int (*fn) (Emchar c, Lisp_Object val, void *arg),
+ void *arg, Emchar ofs, int place)
+{
+ int i, retval;
+ int unit = 1 << (8 * place);
+ Emchar c = ofs;
+ Emchar c1;
+
+ for (i = 0, retval = 0; i < 256 && retval == 0; i++)
+ {
+ if (ct->property[i] != BT_UINT8_unbound)
+ {
+ c1 = c + unit;
+ for (; c < c1 && retval == 0; c++)
+ retval = (fn) (c, UINT8_DECODE (ct->property[i]), arg);
+ }
+ else
+ c += unit;
+ }
+ return retval;
+}
#define BT_UINT16_MIN 0
#define BT_UINT16_MAX (USHRT_MAX - 3)
return -1;
}
+static int
+map_over_uint16_byte_table (Lisp_Uint16_Byte_Table *ct,
+ int (*fn) (Emchar c, Lisp_Object val, void *arg),
+ void *arg, Emchar ofs, int place)
+{
+ int i, retval;
+ int unit = 1 << (8 * place);
+ Emchar c = ofs;
+ Emchar c1;
+
+ for (i = 0, retval = 0; i < 256 && retval == 0; i++)
+ {
+ if (ct->property[i] != BT_UINT16_unbound)
+ {
+ c1 = c + unit;
+ for (; c < c1 && retval == 0; c++)
+ retval = (fn) (c, UINT16_DECODE (ct->property[i]), arg);
+ }
+ else
+ c += unit;
+ }
+ return retval;
+}
+
static Lisp_Object
mark_byte_table (Lisp_Object obj)
return -1;
}
+static int
+map_over_byte_table (Lisp_Byte_Table *ct,
+ int (*fn) (Emchar c, Lisp_Object val, void *arg),
+ void *arg, Emchar ofs, int place)
+{
+ int i, retval;
+ Lisp_Object v;
+ int unit = 1 << (8 * place);
+ Emchar c = ofs;
+
+ for (i = 0, retval = 0; i < 256 && retval == 0; i++)
+ {
+ v = ct->property[i];
+ if (UINT8_BYTE_TABLE_P (v))
+ {
+ retval
+ = map_over_uint8_byte_table (XUINT8_BYTE_TABLE(v),
+ fn, arg, c, place - 1);
+ c += unit;
+ }
+ else if (UINT16_BYTE_TABLE_P (v))
+ {
+ retval
+ = map_over_uint16_byte_table (XUINT16_BYTE_TABLE(v),
+ fn, arg, c, place - 1);
+ c += unit;
+ }
+ else if (BYTE_TABLE_P (v))
+ {
+ retval = map_over_byte_table (XBYTE_TABLE(v),
+ fn, arg, c, place - 1);
+ c += unit;
+ }
+ else if (!UNBOUNDP (v))
+ {
+ Emchar c1 = c + unit;
+
+ for (; c < c1 && retval == 0; c++)
+ retval = (fn) (c, v, arg);
+ }
+ else
+ c += unit;
+ }
+ return retval;
+}
+
Lisp_Object get_byte_table (Lisp_Object table, unsigned char idx);
Lisp_Object put_byte_table (Lisp_Object table, unsigned char idx,
= put_byte_table (table1, (unsigned char)(code >> 24), table2);
}
+/* Map FN (with client data ARG) in char table CT.
+ Mapping stops the first time FN returns non-zero, and that value
+ becomes the return value of map_char_id_table(). */
+int
+map_char_id_table (Lisp_Char_ID_Table *ct,
+ int (*fn) (Emchar c, Lisp_Object val, void *arg),
+ void *arg);
+int
+map_char_id_table (Lisp_Char_ID_Table *ct,
+ int (*fn) (Emchar c, Lisp_Object val, void *arg),
+ void *arg)
+{
+ Lisp_Object v = ct->table;
+
+ if (UINT8_BYTE_TABLE_P (v))
+ return map_over_uint8_byte_table (XUINT8_BYTE_TABLE(v), fn, arg, 0, 3);
+ else if (UINT16_BYTE_TABLE_P (v))
+ return map_over_uint16_byte_table (XUINT16_BYTE_TABLE(v), fn, arg, 0, 3);
+ else if (BYTE_TABLE_P (v))
+ return map_over_byte_table (XBYTE_TABLE(v), fn, arg, 0, 3);
+ else if (!UNBOUNDP (v))
+ {
+ int unit = 1 << 24;
+ Emchar c = 0;
+ Emchar c1 = c + unit;
+ int retval;
+
+ for (retval = 0; c < c1 && retval == 0; c++)
+ retval = (fn) (c, v, arg);
+ }
+ return 0;
+}
+
+struct slow_map_char_id_table_arg
+{
+ Lisp_Object function;
+ Lisp_Object retval;
+};
+
+static int
+slow_map_char_id_table_fun (Emchar c, Lisp_Object val, void *arg)
+{
+ struct slow_map_char_id_table_arg *closure =
+ (struct slow_map_char_id_table_arg *) arg;
+
+ closure->retval = call2 (closure->function, make_char (c), val);
+ return !NILP (closure->retval);
+}
+
Lisp_Object Vchar_attribute_hash_table;
Lisp_Object Vcharacter_composition_table;
Lisp_Object Qideograph_daikanwa;
Lisp_Object Q_decomposition;
Lisp_Object Qucs;
+Lisp_Object Qto_ucs;
Lisp_Object Q_ucs;
Lisp_Object Qcompat;
Lisp_Object Qisolated;
}
value = seq;
}
- else if (EQ (attribute, Q_ucs))
+ else if (EQ (attribute, Qto_ucs) || EQ (attribute, Q_ucs))
{
Lisp_Object ret;
Emchar c;
put_char_id_table (c, Fcons (character, ret),
Vcharacter_variant_table);
}
+#if 0
+ if (EQ (attribute, Q_ucs))
+ attribute = Qto_ucs;
+#endif
}
{
Lisp_Object table = Fgethash (attribute,
return Qnil;
}
+DEFUN ("map-char-attribute", Fmap_char_attribute, 2, 2, 0, /*
+Map FUNCTION over entries in ATTRIBUTE, calling it with two args,
+each key and value in the table.
+*/
+ (function, attribute))
+{
+ Lisp_Object ccs;
+ Lisp_Char_ID_Table *ct;
+ struct slow_map_char_id_table_arg slarg;
+ struct gcpro gcpro1, gcpro2;
+
+ if (!NILP (ccs = Ffind_charset (attribute)))
+ {
+ Lisp_Object encoding_table = XCHARSET_ENCODING_TABLE (ccs);
+
+ if (CHAR_ID_TABLE_P (encoding_table))
+ ct = XCHAR_ID_TABLE (encoding_table);
+ else
+ return Qnil;
+ }
+ else
+ {
+ Lisp_Object table = Fgethash (attribute,
+ Vchar_attribute_hash_table,
+ Qunbound);
+ if (CHAR_ID_TABLE_P (table))
+ ct = XCHAR_ID_TABLE (table);
+ else
+ return Qnil;
+ }
+ slarg.function = function;
+ slarg.retval = Qnil;
+ GCPRO2 (slarg.function, slarg.retval);
+ map_char_id_table (ct, slow_map_char_id_table_fun, &slarg);
+ UNGCPRO;
+
+ return slarg.retval;
+}
+
INLINE_HEADER int CHARSET_BYTE_SIZE (Lisp_Charset* cs);
INLINE_HEADER int
CHARSET_BYTE_SIZE (Lisp_Charset* cs)
}
rest = Fcdr (rest);
}
- if (!NILP (code = Fcdr (Fassq (Q_ucs, attributes))))
+ if ( (!NILP (code = Fcdr (Fassq (Qto_ucs, attributes)))) ||
+ (!NILP (code = Fcdr (Fassq (Q_ucs, attributes)))) )
+
{
if (!INTP (code))
signal_simple_error ("Invalid argument", attributes);
return character;
}
+DEFUN ("find-char", Ffind_char, 1, 1, 0, /*
+Retrieve the character of the given ATTRIBUTES.
+*/
+ (attributes))
+{
+ Lisp_Object rest = attributes;
+ Lisp_Object code;
+
+ while (CONSP (rest))
+ {
+ Lisp_Object cell = Fcar (rest);
+ Lisp_Object ccs;
+
+ if (!LISTP (cell))
+ signal_simple_error ("Invalid argument", attributes);
+ if (!NILP (ccs = Ffind_charset (Fcar (cell))))
+ {
+ cell = Fcdr (cell);
+ if (CONSP (cell))
+ return Fmake_char (ccs, Fcar (cell), Fcar (Fcdr (cell)));
+ else
+ return Fdecode_char (ccs, cell);
+ }
+ rest = Fcdr (rest);
+ }
+ if ( (!NILP (code = Fcdr (Fassq (Qto_ucs, attributes)))) ||
+ (!NILP (code = Fcdr (Fassq (Q_ucs, attributes)))) )
+ {
+ if (!INTP (code))
+ signal_simple_error ("Invalid argument", attributes);
+ else
+ return make_char (XINT (code) + 0x100000);
+ }
+ return Qnil;
+}
+
Lisp_Object Vutf_2000_version;
#endif
Qlatin_iso8859_9,
Qjapanese_jisx0208_1978,
Qchinese_gb2312,
+ Qchinese_gb12345,
Qjapanese_jisx0208,
Qjapanese_jisx0208_1990,
Qkorean_ksc5601,
#ifdef UTF2000
Qucs_bmp,
Qucs_cns,
+ Qucs_big5,
Qlatin_viscii,
Qlatin_tcvn5712,
Qlatin_viscii_lower,
Qvietnamese_viscii_lower,
Qvietnamese_viscii_upper,
Qchinese_big5,
+ Qchinese_big5_cdp,
Qideograph_gt,
Qideograph_gt_pj_1,
Qideograph_gt_pj_2,
{
int c1 = code_point >> 8;
int c2 = code_point & 0xFF;
- unsigned int I
- = (c1 - 0xA1) * BIG5_SAME_ROW
- + c2 - (c2 < 0x7F ? 0x40 : 0x62);
+ unsigned int I;
- if (c1 < 0xC9)
- {
- charset = Vcharset_chinese_big5_1;
- }
- else
+ if ( ( (0xA1 <= c1) && (c1 <= 0xFE) )
+ &&
+ ( ((0x40 <= c2) && (c2 <= 0x7E)) ||
+ ((0xA1 <= c2) && (c2 <= 0xFE)) ) )
{
- charset = Vcharset_chinese_big5_2;
- I -= (BIG5_SAME_ROW) * (0xC9 - 0xA1);
+ I = (c1 - 0xA1) * BIG5_SAME_ROW
+ + c2 - (c2 < 0x7F ? 0x40 : 0x62);
+
+ if (c1 < 0xC9)
+ {
+ charset = Vcharset_chinese_big5_1;
+ }
+ else
+ {
+ charset = Vcharset_chinese_big5_2;
+ I -= (BIG5_SAME_ROW) * (0xC9 - 0xA1);
+ }
+ code_point = ((I / 94 + 33) << 8) | (I % 94 + 33);
}
- code_point = ((I / 94 + 33) << 8) | (I % 94 + 33);
}
if ((final = XCHARSET_FINAL (charset)) >= '0')
{
return c & 0x7F;
}
/*
- else if ((MIN_CHAR_GREEK <= c) && (c <= MAX_CHAR_GREEK))
- {
- *charset = Vcharset_greek_iso8859_7;
- return c - MIN_CHAR_GREEK + 0x20;
- }
- else if ((MIN_CHAR_CYRILLIC <= c) && (c <= MAX_CHAR_CYRILLIC))
- {
- *charset = Vcharset_cyrillic_iso8859_5;
- return c - MIN_CHAR_CYRILLIC + 0x20;
- }
- */
else if ((MIN_CHAR_HEBREW <= c) && (c <= MAX_CHAR_HEBREW))
{
*charset = Vcharset_hebrew_iso8859_8;
return c - MIN_CHAR_HEBREW + 0x20;
}
+ */
else if ((MIN_CHAR_THAI <= c) && (c <= MAX_CHAR_THAI))
{
*charset = Vcharset_thai_tis620;
if (XCHARSET_GRAPHIC (charset) == 1)
c &= 0x7F7F7F7F;
c = DECODE_CHAR (charset, c);
- return c ? make_char (c) : Qnil;
+ return c >= 0 ? make_char (c) : Qnil;
}
DEFUN ("decode-builtin-char", Fdecode_builtin_char, 2, 2, 0, /*
c &= 0x7F7F7F7F;
#endif
c = decode_builtin_char (charset, c);
- return c ? make_char (c) : Fdecode_char (charset, code);
+ return c >= 0 ? make_char (c) : Fdecode_char (charset, code);
}
#endif
DEFSUBR (Fget_char_attribute);
DEFSUBR (Fput_char_attribute);
DEFSUBR (Fremove_char_attribute);
+ DEFSUBR (Fmap_char_attribute);
DEFSUBR (Fdefine_char);
+ DEFSUBR (Ffind_char);
DEFSUBR (Fchar_variants);
DEFSUBR (Fget_composite_char);
DEFSUBR (Fcharset_mapping_table);
defsymbol (&Qlatin_iso8859_9, "latin-iso8859-9");
defsymbol (&Qjapanese_jisx0208_1978, "japanese-jisx0208-1978");
defsymbol (&Qchinese_gb2312, "chinese-gb2312");
+ defsymbol (&Qchinese_gb12345, "chinese-gb12345");
defsymbol (&Qjapanese_jisx0208, "japanese-jisx0208");
defsymbol (&Qjapanese_jisx0208_1990, "japanese-jisx0208-1990");
defsymbol (&Qkorean_ksc5601, "korean-ksc5601");
defsymbol (&Qchinese_cns11643_1, "chinese-cns11643-1");
defsymbol (&Qchinese_cns11643_2, "chinese-cns11643-2");
#ifdef UTF2000
+ defsymbol (&Qto_ucs, "=>ucs");
defsymbol (&Q_ucs, "->ucs");
defsymbol (&Q_decomposition, "->decomposition");
defsymbol (&Qcompat, "compat");
defsymbol (&Qucs, "ucs");
defsymbol (&Qucs_bmp, "ucs-bmp");
defsymbol (&Qucs_cns, "ucs-cns");
+ defsymbol (&Qucs_big5, "ucs-big5");
defsymbol (&Qlatin_viscii, "latin-viscii");
defsymbol (&Qlatin_tcvn5712, "latin-tcvn5712");
defsymbol (&Qlatin_viscii_lower, "latin-viscii-lower");
defsymbol (&Qideograph_gt_pj_11, "ideograph-gt-pj-11");
defsymbol (&Qideograph_daikanwa, "ideograph-daikanwa");
defsymbol (&Qchinese_big5, "chinese-big5");
+ defsymbol (&Qchinese_big5_cdp, "chinese-big5-cdp");
defsymbol (&Qmojikyo, "mojikyo");
defsymbol (&Qmojikyo_2022_1, "mojikyo-2022-1");
defsymbol (&Qmojikyo_pj_1, "mojikyo-pj-1");
build_string ("ISO/IEC 10646 for CNS 11643"),
build_string (""),
Qnil, 0, 0, 0, 0);
+ staticpro (&Vcharset_ucs_big5);
+ Vcharset_ucs_big5 =
+ make_charset (LEADING_BYTE_UCS_BIG5, Qucs_big5, 256, 3,
+ 1, 2, 0, CHARSET_LEFT_TO_RIGHT,
+ build_string ("UCS for Big5"),
+ build_string ("UCS for Big5"),
+ build_string ("ISO/IEC 10646 for Big5"),
+ build_string (""),
+ Qnil, 0, 0, 0, 0);
#else
# define MIN_CHAR_THAI 0
# define MAX_CHAR_THAI 0
-# define MIN_CHAR_HEBREW 0
-# define MAX_CHAR_HEBREW 0
+ /* # define MIN_CHAR_HEBREW 0 */
+ /* # define MAX_CHAR_HEBREW 0 */
# define MIN_CHAR_HALFWIDTH_KATAKANA 0
# define MAX_CHAR_HALFWIDTH_KATAKANA 0
#endif
build_string ("ISO8859-7 (Greek)"),
build_string ("ISO8859-7 (Greek)"),
build_string ("iso8859-7"),
- Qnil,
- 0 /* MIN_CHAR_GREEK */,
- 0 /* MAX_CHAR_GREEK */, 0, 32);
+ Qnil, 0, 0, 0, 32);
staticpro (&Vcharset_arabic_iso8859_6);
Vcharset_arabic_iso8859_6 =
make_charset (LEADING_BYTE_ARABIC_ISO8859_6, Qarabic_iso8859_6, 96, 1,
build_string ("ISO8859-8 (Hebrew)"),
build_string ("ISO8859-8 (Hebrew)"),
build_string ("iso8859-8"),
- Qnil, MIN_CHAR_HEBREW, MAX_CHAR_HEBREW, 0, 32);
+ Qnil,
+ 0 /* MIN_CHAR_HEBREW */,
+ 0 /* MAX_CHAR_HEBREW */, 0, 32);
staticpro (&Vcharset_katakana_jisx0201);
Vcharset_katakana_jisx0201 =
make_charset (LEADING_BYTE_KATAKANA_JISX0201, Qkatakana_jisx0201, 94, 1,
build_string ("ISO8859-5 (Cyrillic)"),
build_string ("ISO8859-5 (Cyrillic)"),
build_string ("iso8859-5"),
- Qnil,
- 0 /* MIN_CHAR_CYRILLIC */,
- 0 /* MAX_CHAR_CYRILLIC */, 0, 32);
+ Qnil, 0, 0, 0, 32);
staticpro (&Vcharset_latin_iso8859_9);
Vcharset_latin_iso8859_9 =
make_charset (LEADING_BYTE_LATIN_ISO8859_9, Qlatin_iso8859_9, 96, 1,
build_string ("GB2312 Chinese simplified"),
build_string ("gb2312"),
Qnil, 0, 0, 0, 33);
+ staticpro (&Vcharset_chinese_gb12345);
+ Vcharset_chinese_gb12345 =
+ make_charset (LEADING_BYTE_CHINESE_GB12345, Qchinese_gb12345, 94, 2,
+ 2, 0, 0, CHARSET_LEFT_TO_RIGHT,
+ build_string ("G1"),
+ build_string ("GB 12345)"),
+ build_string ("GB 12345-1990"),
+ build_string ("GB12345\\(\\.1990\\)?-0"),
+ Qnil, 0, 0, 0, 33);
staticpro (&Vcharset_japanese_jisx0208);
Vcharset_japanese_jisx0208 =
make_charset (LEADING_BYTE_JAPANESE_JISX0208, Qjapanese_jisx0208, 94, 2,
build_string ("TCVN 5712"),
build_string ("TCVN 5712 (VSCII-2)"),
build_string ("Vietnamese TCVN 5712:1983 (VSCII-2)"),
- build_string ("tcvn5712-1"),
+ build_string ("tcvn5712\\(\\.1993\\)?-1"),
Qnil, 0, 0, 0, 32);
staticpro (&Vcharset_latin_viscii_lower);
Vcharset_latin_viscii_lower =
build_string ("Big5 Chinese traditional"),
build_string ("big5"),
Qnil, 0, 0, 0, 0);
+ staticpro (&Vcharset_chinese_big5_cdp);
+ Vcharset_chinese_big5_cdp =
+ make_charset (LEADING_BYTE_CHINESE_BIG5_CDP, Qchinese_big5_cdp, 256, 2,
+ 2, 2, 0, CHARSET_LEFT_TO_RIGHT,
+ build_string ("Big5-CDP"),
+ build_string ("Big5 + CDP extension"),
+ build_string ("Big5 with CDP extension"),
+ build_string ("big5\\.cdp-0"),
+ Qnil, 0, 0, 0, 0);
staticpro (&Vcharset_ideograph_gt);
Vcharset_ideograph_gt =
make_charset (LEADING_BYTE_GT, Qideograph_gt, 256, 3,
build_string ("GT (pseudo JIS encoding) part "#n), \
build_string ("GT 2000 (pseudo JIS encoding) part "#n), \
build_string \
- ("\\(GT2000PJ-"#n "\\|jisx0208\\.GT2000-"#n "\\)$"), \
+ ("\\(GTpj-"#n "\\|jisx0208\\.GT-"#n "\\)$"), \
Qnil, 0, 0, 0, 33);
DEF_GT_PJ (1);
DEF_GT_PJ (2);