changeset 47791:1a71f916ad2f

(code_convert_region): When we need more GAP for conversion, pay attention to the case that coding->produced is not greater than coding->consumed.
author Kenichi Handa <handa@m17n.org>
date Tue, 08 Oct 2002 00:57:59 +0000
parents 2eb1a25294ab
children 8753fa3673f5
files src/coding.c
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/coding.c	Mon Oct 07 22:51:03 2002 +0000
+++ b/src/coding.c	Tue Oct 08 00:57:59 2002 +0000
@@ -5696,9 +5696,19 @@
 		REQUIRE + LEN_BYTE = LEN_BYTE * (NEW / ORIG)
 		REQUIRE = LEN_BYTE * (NEW - ORIG) / ORIG
 	     Here, we are sure that NEW >= ORIG.  */
-	  float ratio = coding->produced - coding->consumed;
-	  ratio /= coding->consumed;
-	  require = len_byte * ratio;
+	  float ratio;
+
+	  if (coding->produced <= coding->consumed)
+	    {
+	      /* This happens because of CCL-based coding system with
+		 eol-type CRLF.  */
+	      require = 0;
+	    }
+	  else
+	    {
+	      ratio = (coding->produced - coding->consumed) / coding->consumed;
+	      require = len_byte * ratio;
+	    }
 	  first = 0;
 	}
       if ((src - dst) < (require + 2000))