changeset 29724:caf7f927357c

(CCL_WRITE_CHAR): Convert NL according to ccl->eol_type. (setup_ccl_program): Initialize ccl->eol_type to CODING_EOL_LF.
author Kenichi Handa <handa@m17n.org>
date Mon, 19 Jun 2000 05:16:57 +0000
parents 9d85d8264c59
children 2bc397e9b09a
files src/ccl.c
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/ccl.c	Mon Jun 19 05:15:51 2000 +0000
+++ b/src/ccl.c	Mon Jun 19 05:16:57 2000 +0000
@@ -669,11 +669,22 @@
 #define CCL_WRITE_CHAR(ch)					\
   do {								\
     int bytes = SINGLE_BYTE_CHAR_P (ch) ? 1: CHAR_BYTES (ch);	\
+    if (ch == '\n' && ccl->eol_type == CODING_EOL_CRLF)		\
+      bytes++;							\
     if (!dst)							\
       CCL_INVALID_CMD;						\
     else if (dst + bytes <= (dst_bytes ? dst_end : src))	\
       {								\
-	if (bytes == 1)						\
+	if (ch == '\n')						\
+	  {							\
+	    if (ccl->eol_type == CODING_EOL_CRLF)		\
+	      *dst++ = '\r', *dst++ = '\n';			\
+	    else if (ccl->eol_type == CODING_EOL_CR)		\
+	      *dst++ = '\r';					\
+	    else						\
+	      *dst++ = '\n';					\
+	  }							\
+	else if (bytes == 1)					\
 	  *dst++ = (ch);					\
 	else							\
 	  dst += CHAR_STRING (ch, dst);				\
@@ -1755,6 +1766,7 @@
   ccl->private_state = 0;
   ccl->status = 0;
   ccl->stack_idx = 0;
+  ccl->eol_type = CODING_EOL_LF;
   return 0;
 }