(M40310): Separate U+925B, C1-6745 and J90-3174.
[chise/xemacs-chise.git] / src / text-coding.c
index 5d77048..affcbdd 100644 (file)
@@ -1,6 +1,7 @@
 /* Code conversion functions.
    Copyright (C) 1991, 1995 Free Software Foundation, Inc.
    Copyright (C) 1995 Sun Microsystems, Inc.
+   Copyright (C) 1999,2000 MORIOKA Tomohiko
 
 This file is part of XEmacs.
 
@@ -670,7 +671,8 @@ parse_charset_conversion_specs (charset_conversion_spec_dynarr *store_here,
        signal_simple_error ("Invalid charset conversion spec", car);
       from = Fget_charset (XCAR (car));
       to = Fget_charset (XCAR (XCDR (car)));
-      if (XCHARSET_TYPE (from) != XCHARSET_TYPE (to))
+      if ( (XCHARSET_CHARS (from) != XCHARSET_CHARS (to)) ||
+          (XCHARSET_DIMENSION (from) != XCHARSET_DIMENSION (to)) )
        signal_simple_error_2
          ("Attempted conversion between different charset types",
           from, to);
@@ -3067,13 +3069,12 @@ char_encode_shift_jis (struct encoding_stream *str, Emchar ch,
       Lisp_Object charset;
       unsigned int c1, c2, s1, s2;
 #ifdef UTF2000
-      Lisp_Object value = charset_code_point (Vcharset_latin_jisx0201, ch);
-      Lisp_Object ret = Fcar (value);
+      int code_point = charset_code_point (Vcharset_latin_jisx0201, ch);
 
-      if (INTP (ret))
+      if (code_point >= 0)
        {
          charset = Vcharset_latin_jisx0201;
-         c1 = XINT (ret);
+         c1 = code_point;
          c2 = 0;
        }
       else
@@ -4724,7 +4725,8 @@ iso2022_designate (Lisp_Object charset, unsigned char reg,
 {
   static CONST char inter94[] = "()*+";
   static CONST char inter96[] = ",-./";
-  unsigned int type;
+  unsigned short chars;
+  unsigned char dimension;
   unsigned char final;
   Lisp_Object old_charset = str->iso2022.charset[reg];
 
@@ -4732,11 +4734,13 @@ iso2022_designate (Lisp_Object charset, unsigned char reg,
   if (!CHARSETP (charset))
     /* charset might be an initial nil or t. */
     return;
-  type = XCHARSET_TYPE (charset);
+  chars = XCHARSET_CHARS (charset);
+  dimension = XCHARSET_DIMENSION (charset);
   final = XCHARSET_FINAL (charset);
   if (!str->iso2022.force_charset_on_output[reg] &&
       CHARSETP (old_charset) &&
-      XCHARSET_TYPE (old_charset) == type &&
+      XCHARSET_CHARS (old_charset) == chars &&
+      XCHARSET_DIMENSION (old_charset) == dimension &&
       XCHARSET_FINAL (old_charset) == final)
     return;
 
@@ -4760,25 +4764,29 @@ iso2022_designate (Lisp_Object charset, unsigned char reg,
   }
 
   Dynarr_add (dst, ISO_CODE_ESC);
-  switch (type)
+  switch (chars)
     {
-    case CHARSET_TYPE_94:
-      Dynarr_add (dst, inter94[reg]);
-      break;
-    case CHARSET_TYPE_96:
-      Dynarr_add (dst, inter96[reg]);
-      break;
-    case CHARSET_TYPE_94X94:
-      Dynarr_add (dst, '$');
-      if (reg != 0
-         || !(CODING_SYSTEM_ISO2022_SHORT (str->codesys))
-         || final < '@'
-         || final > 'B')
+    case 94:
+      if (dimension == 1)
        Dynarr_add (dst, inter94[reg]);
+      else
+       {
+         Dynarr_add (dst, '$');
+         if (reg != 0
+             || !(CODING_SYSTEM_ISO2022_SHORT (str->codesys))
+             || final < '@'
+             || final > 'B')
+           Dynarr_add (dst, inter94[reg]);
+       }
       break;
-    case CHARSET_TYPE_96X96:
-      Dynarr_add (dst, '$');
-      Dynarr_add (dst, inter96[reg]);
+    case 96:
+      if (dimension == 1)
+       Dynarr_add (dst, inter96[reg]);
+      else
+       {
+         Dynarr_add (dst, '$');
+         Dynarr_add (dst, inter96[reg]);
+       }
       break;
     }
   Dynarr_add (dst, final);
@@ -4876,31 +4884,25 @@ char_encode_iso2022 (struct encoding_stream *str, Emchar ch,
       reg = -1;
       for (i = 0; i < 4; i++)
        {
-         Lisp_Object code_point;
+         int code_point;
 
          if ((CHARSETP (charset = str->iso2022.charset[i])
-              && !EQ (code_point = charset_code_point (charset, ch), Qnil))
+              && ((code_point = charset_code_point (charset, ch)) >= 0))
              ||
              (CHARSETP
               (charset
                = CODING_SYSTEM_ISO2022_INITIAL_CHARSET (codesys, i))
-              && !EQ (code_point = charset_code_point (charset, ch), Qnil)))
+              && ((code_point = charset_code_point (charset, ch)) >= 0)))
            {
-             Lisp_Object ret = Fcar (code_point);
-
-             if (INTP (ret))
+             if (XCHARSET_DIMENSION (charset) == 1)
                {
-                 byte1 = XINT (ret);
-                 ret = Fcar (Fcdr (code_point));
-                 if (INTP (ret))
-                   byte2 = XINT (ret);
-                 else
-                   byte2 = 0;
+                 byte1 = code_point;
+                 byte2 = 0;
                }
-             else
+             else /* if (XCHARSET_DIMENSION (charset) == 2) */
                {
-                 byte1 = 0;
-                 byte2 = 0;
+                 byte1 = code_point >> 8;
+                 byte2 = code_point & 255;
                }
              reg = i;
              break;