aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKenichi Handa <[email protected]>1998-08-07 05:04:36 +0000
committerKenichi Handa <[email protected]>1998-08-07 05:04:36 +0000
commit76d7b82914fdf9278d1ce23c1f3e51a8ae7d99bc (patch)
tree452cac5e90c88ab12c2ac7230ede834b940a9791
parent38b62842a11aefbdb1cf572de04e5ee3d0957868 (diff)
(multibyte_char_to_unibyte): New function.
(charset_id_internal): Avoid initializer for Lisp_Object. (init_charset_once): Likewise.
-rw-r--r--src/charset.c43
1 files changed, 41 insertions, 2 deletions
diff --git a/src/charset.c b/src/charset.c
index b158bf85df..e43492a67a 100644
--- a/src/charset.c
+++ b/src/charset.c
@@ -342,6 +342,43 @@ unibyte_char_to_multibyte (c)
}
return c;
}
+
+
+/* Convert the multibyte character C to unibyte 8-bit character based
+ on Vnonascii_translation_table or nonascii_insert_offset. If
+ REV_TBL is non-nil, it should be a reverse table of
+ Vnonascii_translation_table, i.e. what given by:
+ Fchar_table_extra_slot (Vnonascii_translation_table, make_number (0)) */
+
+int
+multibyte_char_to_unibyte (c, rev_tbl)
+ int c;
+ Lisp_Object rev_tbl;
+{
+ if (!SINGLE_BYTE_CHAR_P (c))
+ {
+ int c_save = c;
+
+ if (! CHAR_TABLE_P (rev_tbl)
+ && CHAR_TABLE_P (Vnonascii_translation_table))
+ rev_tbl = Fchar_table_extra_slot (Vnonascii_translation_table,
+ make_number (0));
+ if (CHAR_TABLE_P (rev_tbl))
+ {
+ Lisp_Object temp;
+ temp = Faref (rev_tbl, make_number (c));
+ if (INTEGERP (temp))
+ c = XINT (temp);
+ }
+ else if (nonascii_insert_offset > 0)
+ c -= nonascii_insert_offset;
+ if (c < 128 || c >= 256)
+ c = (c_save & 0177) + 0200;
+ }
+
+ return c;
+}
+
/* Update the table Vcharset_table with the given arguments (see the
document of `define-charset' for the meaning of each argument).
@@ -1648,8 +1685,9 @@ int
charset_id_internal (charset_name)
char *charset_name;
{
- Lisp_Object val = Fget (intern (charset_name), Qcharset);
+ Lisp_Object val;
+ val= Fget (intern (charset_name), Qcharset);
if (!VECTORP (val))
error ("Charset %s is not defined", charset_name);
@@ -1724,8 +1762,9 @@ init_charset_once ()
WIDTH_BY_CHAR_HEAD (LEADING_CODE_PRIVATE_22) = 2;
{
- Lisp_Object val = Qnil;
+ Lisp_Object val;
+ val = Qnil;
for (i = 0x81; i < 0x90; i++)
val = Fcons (make_number ((i - 0x70) << 7), val);
for (; i < 0x9A; i++)