(Fdefine_coding_system_internal): Fix previous change.
[bpt/emacs.git] / src / coding.c
index 982aaac..76b61e3 100644 (file)
@@ -401,12 +401,6 @@ Lisp_Object Vdefault_process_coding_system;
 /* Char table for translating Quail and self-inserting input.  */
 Lisp_Object Vtranslation_table_for_input;
 
-/* Global flag to tell that we can't call post-read-conversion and
-   pre-write-conversion functions.  Usually the value is zero, but it
-   is set to 1 temporarily while such functions are running.  This is
-   to avoid infinite recursive call.  */
-static int inhibit_pre_post_conversion;
-
 /* Two special coding systems.  */
 Lisp_Object Vsjis_coding_system;
 Lisp_Object Vbig5_coding_system;
@@ -972,7 +966,7 @@ coding_alloc_by_making_gap (coding, bytes)
 static unsigned char *
 alloc_destination (coding, nbytes, dst)
      struct coding_system *coding;
-     int nbytes;
+     EMACS_INT nbytes;
      unsigned char *dst;
 {
   EMACS_INT offset = dst - coding->destination;
@@ -2063,6 +2057,11 @@ encode_coding_emacs_mule (coding)
   int preferred_charset_id = -1;
 
   CODING_GET_INFO (coding, attrs, eol_type, charset_list);
+  if (! EQ (charset_list, Vemacs_mule_charset_list))
+    {
+      CODING_ATTR_CHARSET_LIST (attrs)
+       = charset_list = Vemacs_mule_charset_list;
+    }
 
   while (charbuf < charbuf_end)
     {
@@ -2131,9 +2130,10 @@ encode_coding_emacs_mule (coding)
          if (leading_codes[1])
            EMIT_ONE_BYTE (leading_codes[1]);
          if (dimension == 1)
-           EMIT_ONE_BYTE (code);
+           EMIT_ONE_BYTE (code | 0x80);
          else
            {
+             code |= 0x8080;
              EMIT_ONE_BYTE (code >> 8);
              EMIT_ONE_BYTE (code & 0xFF);
            }
@@ -5018,12 +5018,11 @@ Lisp_Object
 coding_inherit_eol_type (coding_system, parent)
      Lisp_Object coding_system, parent;
 {
-  Lisp_Object spec, attrs, eol_type;
+  Lisp_Object spec, eol_type;
 
   if (NILP (coding_system))
     coding_system = Qraw_text;
   spec = CODING_SYSTEM_SPEC (coding_system);
-  attrs = AREF (spec, 0);
   eol_type = AREF (spec, 2);
   if (VECTORP (eol_type)
       && ! NILP (parent))
@@ -5371,7 +5370,7 @@ detect_coding (coding)
       && ! EQ (coding_type, Qccl))
     {
       int eol_seen = detect_eol (coding->source, coding->src_bytes,
-                                XINT (CODING_ATTR_CATEGORY (attrs)));
+                                (enum coding_category) XINT (CODING_ATTR_CATEGORY (attrs)));
 
       if (eol_seen != EOL_SEEN_NONE)
        adjust_coding_eol_type (coding, eol_seen);
@@ -6026,14 +6025,19 @@ consume_chars (coding)
   /* Note: composition handling is not yet implemented.  */
   coding->common_flags &= ~CODING_ANNOTATE_COMPOSITION_MASK;
 
-  if (coding->common_flags & CODING_ANNOTATE_COMPOSITION_MASK)
-    stop = stop_composition = pos;
-  else
-    stop = stop_composition = end_pos;
-  if (coding->common_flags & CODING_ANNOTATE_CHARSET_MASK)
-    stop = stop_charset = pos;
+  if (NILP (coding->src_object))
+    stop = stop_composition = stop_charset = end_pos;
   else
-    stop_charset = end_pos;
+    {
+      if (coding->common_flags & CODING_ANNOTATE_COMPOSITION_MASK)
+       stop = stop_composition = pos;
+      else
+       stop = stop_composition = end_pos;
+      if (coding->common_flags & CODING_ANNOTATE_CHARSET_MASK)
+       stop = stop_charset = pos;
+      else
+       stop_charset = end_pos;
+    }
 
   /* Compensate for CRLF and annotation.  */
   buf_end -= 1 + MAX_ANNOTATION_LENGTH;
@@ -8103,7 +8107,6 @@ usage: (define-coding-system-internal ...)  */)
 
   if (EQ (coding_type, Qcharset))
     {
-      Lisp_Object list;
       /* Generate a lisp vector of 256 elements.  Each element is nil,
         integer, or a list of charset IDs.
 
@@ -8115,25 +8118,10 @@ usage: (define-coding-system-internal ...)  */)
 
         If Nth element is a list of charset IDs, N is the first byte
         of one of them.  The list is sorted by dimensions of the
-        charsets.  A charset of smaller dimension comes firtst.
-      */
-      for (list = Qnil, tail = charset_list; CONSP (tail); tail = XCDR (tail))
-       {
-         struct charset *charset = CHARSET_FROM_ID (XFASTINT (XCAR (tail)));
-
-         if (charset->method == CHARSET_METHOD_SUPERSET)
-           {
-             val = CHARSET_SUPERSET (charset);
-             for (; CONSP (val); val = XCDR (val))
-               list = Fcons (XCAR (XCAR (val)), list);
-           }
-         else
-           list = Fcons (XCAR (tail), list);
-       }
-
+        charsets.  A charset of smaller dimension comes firtst. */
       val = Fmake_vector (make_number (256), Qnil);
 
-      for (tail = Fnreverse (list); CONSP (tail); tail = XCDR (tail))
+      for (tail = charset_list; CONSP (tail); tail = XCDR (tail))
        {
          struct charset *charset = CHARSET_FROM_ID (XFASTINT (XCAR (tail)));
          int dim = CHARSET_DIMENSION (charset);
@@ -8488,8 +8476,7 @@ usage: (define-coding-system-internal ...)  */)
                         make_number (nargs)));
 }
 
-/* Fixme: should this record the alias relationships for
-   diagnostics?  Should it update coding-system-list?  */
+
 DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias,
        Sdefine_coding_system_alias, 2, 2, 0,
        doc: /* Define ALIAS as an alias for CODING-SYSTEM.  */)
@@ -8501,6 +8488,9 @@ DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias,
   CHECK_SYMBOL (alias);
   CHECK_CODING_SYSTEM_GET_SPEC (coding_system, spec);
   aliases = AREF (spec, 1);
+  /* ALISES should be a list of length more than zero, and the first
+     element is a base coding system.  Append ALIAS at the tail of the
+     list.  */
   while (!NILP (XCDR (aliases)))
     aliases = XCDR (aliases);
   XSETCDR (aliases, Fcons (alias, Qnil));
@@ -8515,11 +8505,10 @@ DEFUN ("define-coding-system-alias", Fdefine_coding_system_alias,
       for (i = 0; i < 3; i++)
        Fdefine_coding_system_alias (AREF (subsidiaries, i),
                                     AREF (eol_type, i));
-
-      ASET (spec, 2, subsidiaries);
     }
 
   Fputhash (alias, spec, Vcoding_system_hash_table);
+  Vcoding_system_list = Fcons (alias, Vcoding_system_list);
   Vcoding_system_alist = Fcons (Fcons (Fsymbol_name (alias), Qnil),
                                Vcoding_system_alist);
 
@@ -8637,8 +8626,6 @@ init_coding_once ()
   iso_code_class[ISO_CODE_SS3] = ISO_single_shift_3;
   iso_code_class[ISO_CODE_CSI] = ISO_control_sequence_introducer;
 
-  inhibit_pre_post_conversion = 0;
-
   for (i = 0; i < 256; i++)
     {
       emacs_mule_bytes[i] = 1;