# HG changeset patch
# User Aidan Kehoe <kehoea@parhasard.net>
# Date 1252688047 -3600
# Node ID 7e54adf407a1aea20e3782043fa35bd3ffe75a3b
# Parent  02b7c71890410472b1e3acab50f4b8341a02555e
Fix a bug with Unicode error sequences and very short input strings.

src/ChangeLog addition:

2009-09-11  Aidan Kehoe  <kehoea@parhasard.net>

	* unicode.c (unicode_convert):
	Fix a bug with error sequences and very short input strings.

tests/ChangeLog addition:

2009-09-11  Aidan Kehoe  <kehoea@parhasard.net>

	* automated/mule-tests.el (featurep):
	Check that a Unicode bug with very short inputs has been fixed.

diff -r 02b7c7189041 -r 7e54adf407a1 src/ChangeLog
--- a/src/ChangeLog	Sun Sep 06 23:47:12 2009 +0100
+++ b/src/ChangeLog	Fri Sep 11 17:54:07 2009 +0100
@@ -1,3 +1,8 @@
+2009-09-11  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* unicode.c (unicode_convert): 
+	Fix a bug with error sequences and very short input strings.
+
 2009-08-31  Aidan Kehoe  <kehoea@parhasard.net>
 
 	* eval.c (For, Fand): 
diff -r 02b7c7189041 -r 7e54adf407a1 src/unicode.c
--- a/src/unicode.c	Sun Sep 06 23:47:12 2009 +0100
+++ b/src/unicode.c	Fri Sep 11 17:54:07 2009 +0100
@@ -2221,7 +2221,7 @@
 
 	}
 
-      if (str->eof && ch)
+      if (str->eof && counter)
         {
           switch (type)
             {
@@ -2277,6 +2277,7 @@
               break;
             }
           ch = 0;
+          counter = 0;
         }
 
       data->counter = counter;
diff -r 02b7c7189041 -r 7e54adf407a1 tests/ChangeLog
--- a/tests/ChangeLog	Sun Sep 06 23:47:12 2009 +0100
+++ b/tests/ChangeLog	Fri Sep 11 17:54:07 2009 +0100
@@ -1,3 +1,8 @@
+2009-09-11  Aidan Kehoe  <kehoea@parhasard.net>
+
+	* automated/mule-tests.el (featurep): 
+	Check that a Unicode bug with very short inputs has been fixed.
+
 2009-09-02  Jerry James  <james@xemacs.org>
 
 	* reproduce-crashes.el (12): New bug.
diff -r 02b7c7189041 -r 7e54adf407a1 tests/automated/mule-tests.el
--- a/tests/automated/mule-tests.el	Sun Sep 06 23:47:12 2009 +0100
+++ b/tests/automated/mule-tests.el	Fri Sep 11 17:54:07 2009 +0100
@@ -757,4 +757,11 @@
      do (unless (get-range-table i exceptions)
           (read (format (if (> i #xFFFF) #r"?\U%08X" #r"?\u%04X") i)))
      finally return t))
+  (loop
+    for i from #x00 to #xff
+    do (Assert
+        (= 1 (length (decode-coding-string (format "%c" i) 'utf-8-unix)))
+        (format 
+         "checking Unicode coding systems behave well with short input, %02X"
+         i)))
   )