(decode_coding_emacs_mule): Handle insufficent source correctly.
authorKenichi Handa <handa@m17n.org>
Tue, 9 Mar 2004 12:27:26 +0000 (12:27 +0000)
committerKenichi Handa <handa@m17n.org>
Tue, 9 Mar 2004 12:27:26 +0000 (12:27 +0000)
src/ChangeLog
src/coding.c

index bb8ef04..95cec4f 100644 (file)
@@ -1,3 +1,8 @@
+2004-03-09  Kenichi Handa  <handa@etlken2>
+
+       * coding.c (decode_coding_emacs_mule): Handle insufficent source
+       correctly.
+
 2004-03-04  Richard M. Stallman  <rms@gnu.org>
 
        * s/sol2-6.h (LD_SWITCH_SYSTEM_TEMACS): New definition.
index 62c761c..76ef302 100644 (file)
@@ -1024,9 +1024,26 @@ decode_coding_emacs_mule (coding, source, destination, src_bytes, dst_bytes)
        }
       else
        {
-         bytes = CHAR_STRING (*src, tmp);
-         p = tmp;
+         int i, c;
+
+         bytes = BYTES_BY_CHAR_HEAD (*src);
          src++;
+         for (i = 1; i < bytes; i++)
+           {
+             ONE_MORE_BYTE (c);
+             if (CHAR_HEAD_P (c))
+               break;
+           }
+         if (i < bytes)
+           {
+             bytes = CHAR_STRING (*src_base, tmp);
+             p = tmp;
+             src = src_base + 1;
+           }
+         else
+           {
+             p = src_base;
+           }
        }
       if (dst + bytes >= (dst_bytes ? dst_end : src))
        {