changeset 89279:1fd77c471ee6

(decode_coding_utf_8): When eol_type is Qdos, handle the case that the last byte is '\r' correctly. (decode_coding_emacs_mule): Likewise. (decode_coding_iso_2022): Likewise. (decode_coding_sjis): Likewise. (decode_coding_big5): Likewise. (decode_coding_charset): Likewise. (produce_chars): Likewise. (decode_coding): Flushing out the unprocessed data correctly. (decode_coding_gap): Set CODING_MODE_LAST_BLOCK bit of coding->mode.
author Kenichi Handa <handa@m17n.org>
date Wed, 06 Nov 2002 00:10:42 +0000
parents de07830a2cc4
children 90cfc2d753b5
files src/coding.c
diffstat 1 files changed, 36 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/coding.c	Wed Nov 06 00:10:18 2002 +0000
+++ b/src/coding.c	Wed Nov 06 00:10:42 2002 +0000
@@ -1126,7 +1126,10 @@
 	      if (EQ (eol_type, Qdos))
 		{
 		  if (src == src_end)
-		    goto no_more_source;
+		    {
+		      coding->result = CODING_RESULT_INSUFFICIENT_SRC;
+		      goto no_more_source;
+		    }
 		  if (*src == '\n')
 		    ONE_MORE_BYTE (c);
 		}
@@ -1917,7 +1920,10 @@
 	      if (EQ (eol_type, Qdos))
 		{
 		  if (src == src_end)
-		    goto no_more_source;
+		    {
+		      coding->result = CODING_RESULT_INSUFFICIENT_SRC;
+		      goto no_more_source;
+		    }
 		  if (*src == '\n')
 		    ONE_MORE_BYTE (c);
 		}
@@ -2784,7 +2790,7 @@
 
       ONE_MORE_BYTE (c1);
 
-      /* We produce no character or one character.  */
+      /* We produce at most one character.  */
       switch (iso_code_class [c1])
 	{
 	case ISO_0x20_or_0x7F:
@@ -2841,7 +2847,10 @@
 	      if (EQ (eol_type, Qdos))
 		{
 		  if (src == src_end)
-		    goto no_more_source;
+		    {
+		      coding->result = CODING_RESULT_INSUFFICIENT_SRC;
+		      goto no_more_source;
+		    }		      
 		  if (*src == '\n')
 		    ONE_MORE_BYTE (c1);
 		}
@@ -3796,7 +3805,10 @@
 	  if (EQ (eol_type, Qdos))
 	    {
 	      if (src == src_end)
-		goto no_more_source;
+		{
+		  coding->result = CODING_RESULT_INSUFFICIENT_SRC;
+		  goto no_more_source;
+		}
 	      if (*src == '\n')
 		ONE_MORE_BYTE (c);
 	    }
@@ -3885,7 +3897,10 @@
 	  if (EQ (eol_type, Qdos))
 	    {
 	      if (src == src_end)
-		goto no_more_source;
+		{
+		  coding->result = CODING_RESULT_INSUFFICIENT_SRC;
+		  goto no_more_source;
+		}
 	      if (*src == '\n')
 		ONE_MORE_BYTE (c);
 	    }
@@ -4429,8 +4444,12 @@
 	     else.  */
 	  if (EQ (eol_type, Qdos))
 	    {
-	      if (src < src_end
-		  && *src == '\n')
+	      if (src == src_end)
+		{
+		  coding->result = CODING_RESULT_INSUFFICIENT_SRC;
+		  goto no_more_source;
+		}
+	      if (*src == '\n')
 		ONE_MORE_BYTE (c);
 	    }
 	  else if (EQ (eol_type, Qmac))
@@ -5272,8 +5291,12 @@
 		    {
 		      if (EQ (eol_type, Qdos))
 			{
-			  if (src < src_end
-			      && *src == '\n')
+			  if (src == src_end)
+			    {
+			      coding->result = CODING_RESULT_INSUFFICIENT_SRC;
+			      goto no_more_source;
+			    }
+			  if (*src == '\n')
 			    c = *src++;
 			}
 		      else if (EQ (eol_type, Qmac))
@@ -5621,12 +5644,11 @@
 	  /* Flush out unprocessed data as binary chars.  We are sure
 	     that the number of data is less than the size of
 	     coding->charbuf.  */
-	  int *charbuf = coding->charbuf;
-
 	  while (nbytes-- > 0)
 	    {
 	      int c = *src++;
-	      *charbuf++ =  (c & 0x80 ? - c : c);
+
+	      coding->charbuf[coding->charbuf_used++] = (c & 0x80 ? - c : c);
 	    }
 	  produce_chars (coding);
 	}
@@ -5883,6 +5905,7 @@
   coding->dst_pos = PT;
   coding->dst_pos_byte = PT_BYTE;
   coding->dst_multibyte = ! NILP (current_buffer->enable_multibyte_characters);
+  coding->mode |= CODING_MODE_LAST_BLOCK;
 
   if (CODING_REQUIRE_DETECTION (coding))
     detect_coding (coding);