Sync up with r21-2-17-1999-07-05-18.
[chise/xemacs-chise.git] / src / file-coding.c
index 081f851..eef4f69 100644 (file)
@@ -25,6 +25,7 @@ Boston, MA 02111-1307, USA.  */
 
 #include <config.h>
 #include "lisp.h"
+
 #include "buffer.h"
 #include "elhash.h"
 #include "insdel.h"
@@ -55,7 +56,7 @@ int coding_category_by_priority[CODING_CATEGORY_LAST + 1];
 
 Lisp_Object Qcoding_system_p;
 
-Lisp_Object Qno_conversion, Qccl, Qiso2022;
+Lisp_Object Qraw_text, Qno_conversion, Qccl, Qiso2022;
 /* Qinternal in general.c */
 
 Lisp_Object Qmnemonic, Qeol_type;
@@ -244,10 +245,46 @@ static Lisp_Object mark_coding_system (Lisp_Object, void (*) (Lisp_Object));
 static void print_coding_system (Lisp_Object, Lisp_Object, int);
 static void finalize_coding_system (void *header, int for_disksave);
 
+#ifdef MULE
+static const struct lrecord_description ccs_description_1[] = {
+  { XD_LISP_OBJECT, offsetof(charset_conversion_spec, from_charset), 2 },
+  { XD_END }
+};
+
+static const struct struct_description ccs_description = {
+  sizeof(charset_conversion_spec),
+  ccs_description_1
+};
+  
+static const struct lrecord_description ccsd_description_1[] = {
+  XD_DYNARR_DESC(charset_conversion_spec_dynarr, &ccs_description),
+  { XD_END }
+};
+
+static const struct struct_description ccsd_description = {
+  sizeof(charset_conversion_spec_dynarr),
+  ccsd_description_1
+};
+#endif
+
+static const struct lrecord_description coding_system_description[] = {
+  { XD_LISP_OBJECT, offsetof(struct Lisp_Coding_System, name), 2 },
+  { XD_LISP_OBJECT, offsetof(struct Lisp_Coding_System, mnemonic), 3 },
+  { XD_LISP_OBJECT, offsetof(struct Lisp_Coding_System, eol_lf), 3 },
+#ifdef MULE
+  { XD_LISP_OBJECT, offsetof(struct Lisp_Coding_System, iso2022.initial_charset), 4 },
+  { XD_STRUCT_PTR,  offsetof(struct Lisp_Coding_System, iso2022.input_conv),  1, &ccsd_description },
+  { XD_STRUCT_PTR,  offsetof(struct Lisp_Coding_System, iso2022.output_conv), 1, &ccsd_description },
+  { XD_LISP_OBJECT, offsetof(struct Lisp_Coding_System, ccl.decode), 2 },
+#endif
+  { XD_END }
+};
+
 DEFINE_LRECORD_IMPLEMENTATION ("coding-system", coding_system,
                               mark_coding_system, print_coding_system,
                               finalize_coding_system,
-                              0, 0, struct Lisp_Coding_System);
+                              0, 0, coding_system_description,
+                              struct Lisp_Coding_System);
 
 static Lisp_Object
 mark_coding_system (Lisp_Object obj, void (*markobj) (Lisp_Object))
@@ -1531,7 +1568,7 @@ coding_system_from_mask (int mask)
            }
        }
       if (NILP (retval))
-       retval = Fget_coding_system (Qno_conversion);
+       retval = Fget_coding_system (Qraw_text);
       return retval;
     }
   else
@@ -1553,7 +1590,7 @@ coding_system_from_mask (int mask)
       if (cat >= 0)
        return coding_category_system[cat];
       else
-       return Fget_coding_system (Qno_conversion);
+       return Fget_coding_system (Qraw_text);
     }
 }
 
@@ -2116,7 +2153,8 @@ mule_decode (Lstream *decoding, CONST unsigned char *src,
       decode_coding_utf8 (decoding, src, dst, n);
       break;
     case CODESYS_CCL:
-      ccl_driver (&str->ccl, src, dst, n, 0);
+      str->ccl.last_block = str->flags & CODING_STATE_END;
+      ccl_driver (&str->ccl, src, dst, n, 0, CCL_MODE_DECODING);
       break;
     case CODESYS_ISO2022:
       decode_coding_iso2022 (decoding, src, dst, n);
@@ -2528,7 +2566,8 @@ mule_encode (Lstream *encoding, CONST unsigned char *src,
       encode_coding_utf8 (encoding, src, dst, n);
       break;
     case CODESYS_CCL:
-      ccl_driver (&str->ccl, src, dst, n, 0);
+      str->ccl.last_block = str->flags & CODING_STATE_END;
+      ccl_driver (&str->ccl, src, dst, n, 0, CCL_MODE_ENCODING);
       break;
     case CODESYS_ISO2022:
       encode_coding_iso2022 (encoding, src, dst, n);
@@ -5403,7 +5442,7 @@ convert_from_external_format (CONST Extbyte *ptr,
 /************************************************************************/
 
 void
-syms_of_mule_coding (void)
+syms_of_file_coding (void)
 {
   defsymbol (&Qbuffer_file_coding_system, "buffer-file-coding-system");
   deferror (&Qcoding_system_error, "coding-system-error",
@@ -5447,6 +5486,7 @@ syms_of_mule_coding (void)
 #endif /* MULE */
   defsymbol (&Qcoding_system_p, "coding-system-p");
   defsymbol (&Qno_conversion, "no-conversion");
+  defsymbol (&Qraw_text, "raw-text");
 #ifdef MULE
   defsymbol (&Qbig5, "big5");
   defsymbol (&Qshift_jis, "shift-jis");
@@ -5515,7 +5555,7 @@ syms_of_mule_coding (void)
 }
 
 void
-lstream_type_create_mule_coding (void)
+lstream_type_create_file_coding (void)
 {
   LSTREAM_HAS_METHOD (decoding, reader);
   LSTREAM_HAS_METHOD (decoding, writer);
@@ -5535,7 +5575,7 @@ lstream_type_create_mule_coding (void)
 }
 
 void
-vars_of_mule_coding (void)
+vars_of_file_coding (void)
 {
   int i;
 
@@ -5597,7 +5637,7 @@ Setting this to nil does not do anything.
 }
 
 void
-complex_vars_of_mule_coding (void)
+complex_vars_of_file_coding (void)
 {
   staticpro (&Vcoding_system_hash_table);
   Vcoding_system_hash_table =
@@ -5643,15 +5683,22 @@ complex_vars_of_mule_coding (void)
   DEFINE_CODESYS_PROP (CODESYS_PROP_CCL,     Qdecode);
 #endif /* MULE */
   /* Need to create this here or we're really screwed. */
-  Fmake_coding_system (Qno_conversion, Qno_conversion, build_string ("No conversion"),
-                      list2 (Qmnemonic, build_string ("Noconv")));
+  Fmake_coding_system
+    (Qraw_text, Qno_conversion,
+     build_string ("Raw text, which means it converts only line-break-codes."),
+     list2 (Qmnemonic, build_string ("Raw")));
+
+  Fmake_coding_system
+    (Qbinary, Qno_conversion,
+     build_string ("Binary, which means it does not convert anything."),
+     list4 (Qeol_type, Qlf,
+           Qmnemonic, build_string ("Binary")));
 
-  Fcopy_coding_system (Fcoding_system_property (Qno_conversion, Qeol_lf),
-                      Qbinary);
+  Fdefine_coding_system_alias (Qno_conversion, Qraw_text);
 
   /* Need this for bootstrapping */
   coding_category_system[CODING_CATEGORY_NO_CONVERSION] =
-    Fget_coding_system (Qno_conversion);
+    Fget_coding_system (Qraw_text);
 
 #ifdef MULE
   {