changeset 110849:49bb2cbec1ea

coding.c (complement_process_encoding_system): Fix previous change.
author Kenichi Handa <handa@m17n.org>
date Fri, 08 Oct 2010 11:23:52 +0900
parents 4492ee76e918 (current diff) 79354404ff53 (diff)
children 8cb2627c2b87
files
diffstat 2 files changed, 37 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/src/ChangeLog	Wed Oct 06 19:16:02 2010 -0700
+++ b/src/ChangeLog	Fri Oct 08 11:23:52 2010 +0900
@@ -1,3 +1,13 @@
+2010-10-08  Kenichi Handa  <handa@m17n.org>
+
+	* coding.c (complement_process_encoding_system): Fix previous
+	change.
+
+2010-10-04  Kenichi Handa  <handa@m17n.org>
+
+	* coding.c (complement_process_encoding_system): Fix previous
+	change.
+
 2010-10-03  Michael Albinus  <michael.albinus@gmx.de>
 
 	* dbusbind.c (syms_of_dbusbind): Move putenv call ...
--- a/src/coding.c	Wed Oct 06 19:16:02 2010 -0700
+++ b/src/coding.c	Fri Oct 08 11:23:52 2010 +0900
@@ -6122,50 +6122,33 @@
 complement_process_encoding_system (coding_system)
      Lisp_Object coding_system;
 {
-  Lisp_Object spec, attrs, coding_type, eol_type;
-
-  if (NILP (coding_system))
-    coding_system = Qundecided;
-  spec = CODING_SYSTEM_SPEC (coding_system);
-  attrs = AREF (spec, 0);
-  coding_type = CODING_ATTR_TYPE (attrs);
-  eol_type = AREF (spec, 2);
-
-  if (EQ (coding_type, Qundecided))
-    {
-      /* We must decide the text-conversion part ar first.  */
-      if (CONSP (Vdefault_process_coding_system))
-	{
-	  coding_system = XCDR (Vdefault_process_coding_system);
-	  if (! NILP (coding_system))
-	    {
-	      spec = CODING_SYSTEM_SPEC (coding_system);
-	      attrs = AREF (spec, 0);
-	      coding_type = CODING_ATTR_TYPE (attrs);
-	      eol_type = AREF (spec, 2);
-	    }
-	}
-      if (EQ (coding_type, Qundecided))
-	{
-	  coding_system = preferred_coding_system ();
-	  spec = CODING_SYSTEM_SPEC (coding_system);
-	  attrs = AREF (spec, 0);
-	  coding_type = CODING_ATTR_TYPE (attrs);
-	  eol_type = AREF (spec, 2);
-	}
-      if (EQ (coding_type, Qundecided))
-	{
-	  coding_system = Qraw_text;
-	  coding_type = Qraw_text;
-	  eol_type = Qnil;
-	}
-    }
-  if (NILP (eol_type) || VECTORP (eol_type))
-    {
-      /* We must decide the eol-conversion part.  */      
-      coding_system = coding_inherit_eol_type (coding_system, coding_system);
-    }
-
+  Lisp_Object coding_base = Qnil, eol_base = Qnil;
+  Lisp_Object spec, attrs;
+  int i;
+
+  for (i = 0; i < 3; i++)
+    {
+      if (i == 1)
+	coding_system = CDR_SAFE (Vdefault_process_coding_system);
+      else if (i == 2)
+	coding_system = preferred_coding_system ();
+      spec = CODING_SYSTEM_SPEC (coding_system);
+      if (NILP (spec))
+	continue;
+      attrs = AREF (spec, 0);
+      if (NILP (coding_base) && ! EQ (CODING_ATTR_TYPE (attrs), Qundecided))
+	coding_base = CODING_ATTR_BASE_NAME (attrs);
+      if (NILP (eol_base) && ! VECTORP (AREF (spec, 2)))
+	eol_base = coding_system;
+      if (! NILP (coding_base) && ! NILP (eol_base))
+	break;
+    }
+
+  if (i > 0)
+    /* The original CODING_SYSTEM didn't specify text-conversion or
+       eol-conversion.  Be sure that we return a fully complemented
+       coding system.  */
+    coding_system = coding_inherit_eol_type (coding_base, eol_base);
   return coding_system;
 }