changeset 32806:9502d0a5b2ad

(decode_coding_emacs_mule): If coding->eol_type is CR or CRLF, decode EOLs.
author Eli Zaretskii <eliz@gnu.org>
date Tue, 24 Oct 2000 09:04:35 +0000
parents 112b31ea0526
children 7d91ceb03536
files src/coding.c
diffstat 1 files changed, 40 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/coding.c	Tue Oct 24 08:27:34 2000 +0000
+++ b/src/coding.c	Tue Oct 24 09:04:35 2000 +0000
@@ -614,7 +614,45 @@
       unsigned char tmp[MAX_MULTIBYTE_LENGTH], *p;
       int bytes;
 
-      if (UNIBYTE_STR_AS_MULTIBYTE_P (src, src_end - src, bytes))
+      if (*src == '\r')
+	{
+	  int c;
+
+	  src++;
+	  if (coding->eol_type == CODING_EOL_CR)
+	    c = '\n';
+	  else if (coding->eol_type == CODING_EOL_CRLF)
+	    {
+	      ONE_MORE_BYTE (c);
+	      if (c != '\n')
+		{
+		  if (coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL)
+		    {
+		      coding->result = CODING_FINISH_INCONSISTENT_EOL;
+		      goto label_end_of_loop;
+		    }
+		  src--;
+		  c = '\r';
+		}
+	    }
+	  *dst++ = c;
+	  coding->produced_char++;
+	  continue;
+	}
+      else if (*src == '\n')
+	{
+	  if ((coding->eol_type == CODING_EOL_CR
+	       || coding->eol_type == CODING_EOL_CRLF)
+	      && coding->mode & CODING_MODE_INHIBIT_INCONSISTENT_EOL)
+	    {
+	      coding->result = CODING_FINISH_INCONSISTENT_EOL;
+	      goto label_end_of_loop;
+	    }
+	  *dst++ = *src++;
+	  coding->produced_char++;
+	  continue;
+	}
+      else if (UNIBYTE_STR_AS_MULTIBYTE_P (src, src_end - src, bytes))
 	{
 	  p = src;
 	  src += bytes;
@@ -633,6 +671,7 @@
       while (bytes--) *dst++ = *p++;
       coding->produced_char++;
     }
+ label_end_of_loop:
   coding->consumed = coding->consumed_char = src_base - source;
   coding->produced = dst - destination;
 }