changeset 35587:7e767148cfdc

(decode_coding): Set a flag for inhibiting inconsistent eol. (code_convert_region): Always set saved_coding_symbol. (decode_coding_string): Likewise. Update coding->symbol when we encounter a inconsistent eol by the same way as code_convert_region.
author Kenichi Handa <handa@m17n.org>
date Fri, 26 Jan 2001 06:10:21 +0000
parents 6c84d7800dd2
children 31904bdf4350
files src/coding.c
diffstat 1 files changed, 22 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/src/coding.c	Fri Jan 26 06:07:48 2001 +0000
+++ b/src/coding.c	Fri Jan 26 06:10:21 2001 +0000
@@ -4679,7 +4679,12 @@
 
   if (coding->eol_type == CODING_EOL_UNDECIDED
       && coding->type != coding_type_ccl)
-    detect_eol (coding, source, src_bytes);
+    {
+      detect_eol (coding, source, src_bytes);
+      /* We had better recover the original eol format if we
+	 encounter an inconsitent eol format while decoding.  */
+      coding->mode |= CODING_MODE_INHIBIT_INCONSISTENT_EOL;
+    }
 
   coding->produced = coding->produced_char = 0;
   coding->consumed = coding->consumed_char = 0;
@@ -5304,7 +5309,7 @@
   int multibyte_p = !NILP (current_buffer->enable_multibyte_characters);
 
   deletion = Qnil;
-  saved_coding_symbol = Qnil;
+  saved_coding_symbol = coding->symbol;
 
   if (from < PT && PT < to)
     {
@@ -5356,7 +5361,6 @@
       if (coding->eol_type == CODING_EOL_UNDECIDED
 	  && coding->type != coding_type_ccl)
 	{
-	  saved_coding_symbol = coding->symbol;
 	  detect_eol (coding, BYTE_POS_ADDR (from_byte), len_byte);
 	  if (coding->eol_type == CODING_EOL_UNDECIDED)
 	    coding->eol_type = CODING_EOL_LF;
@@ -5794,7 +5798,7 @@
   from = 0;
   to_byte = STRING_BYTES (XSTRING (str));
 
-  saved_coding_symbol = Qnil;
+  saved_coding_symbol = coding->symbol;
   coding->src_multibyte = STRING_MULTIBYTE (str);
   coding->dst_multibyte = 1;
   if (CODING_REQUIRE_DETECTION (coding))
@@ -5883,6 +5887,8 @@
 	extend_conversion_buffer (&buf);
       else if (result == CODING_FINISH_INCONSISTENT_EOL)
 	{
+	  Lisp_Object eol_type;
+
 	  /* Recover the original EOL format.  */
 	  if (coding->eol_type == CODING_EOL_CR)
 	    {
@@ -5906,8 +5912,19 @@
 	      produced += num_eol;
 	      produced_char += num_eol;
 	    } 
+	  /* Suppress eol-format conversion in the further conversion.  */
 	  coding->eol_type = CODING_EOL_LF;
-	  coding->symbol = saved_coding_symbol;
+
+	  /* Set the coding system symbol to that for Unix-like EOL.  */
+	  eol_type = Fget (saved_coding_symbol, Qeol_type);
+	  if (VECTORP (eol_type)
+	      && XVECTOR (eol_type)->size == 3
+	      && SYMBOLP (XVECTOR (eol_type)->contents[CODING_EOL_LF]))
+	    coding->symbol = XVECTOR (eol_type)->contents[CODING_EOL_LF];
+	  else
+	    coding->symbol = saved_coding_symbol;
+
+
 	}
     }