guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 06/07: Fix iconv encoding of long strings


From: Andy Wingo
Subject: [Guile-commits] 06/07: Fix iconv encoding of long strings
Date: Sun, 7 Aug 2016 21:24:31 +0000 (UTC)

wingo pushed a commit to branch stable-2.0
in repository guile.

commit 681acfd8ba3dea9b933ef594dafc7288b4d59320
Author: Andy Wingo <address@hidden>
Date:   Sun Aug 7 23:20:00 2016 +0200

    Fix iconv encoding of long strings
    
    * libguile/print.c (display_string_using_iconv): If the encoding the
      full utf8 buffer would overflow the output buffer, just keep trucking
      instead of erroring.  Fixes #22667.
    * test-suite/tests/iconv.test ("round-trip"): Add some tests.
---
 libguile/print.c            |    6 +++++-
 test-suite/tests/iconv.test |   13 +++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/libguile/print.c b/libguile/print.c
index 86e0a03..a5b2a84 100644
--- a/libguile/print.c
+++ b/libguile/print.c
@@ -1034,7 +1034,11 @@ display_string_using_iconv (const void *str, int 
narrow_p, size_t len,
 
              printed++;
            }
-         else
+         else if (errno_save == E2BIG)
+            /* No space in output buffer for this input.  Keep
+               trucking.  */
+            continue;
+          else
            /* Something bad happened that we can't handle: bail out.  */
            break;
        }
diff --git a/test-suite/tests/iconv.test b/test-suite/tests/iconv.test
index 9083cd2..647761f 100644
--- a/test-suite/tests/iconv.test
+++ b/test-suite/tests/iconv.test
@@ -118,3 +118,16 @@
       (equal? (make-string (string-length s) #\?)
               (bytevector->string (string->bytevector s "ascii" 'substitute)
                                   "ascii")))))
+
+(with-test-prefix "round-trip"
+  (define (pass-if-round-trip str encoding)
+    (pass-if-equal str str
+      (bytevector->string (string->bytevector str encoding) encoding)))
+
+  (pass-if-round-trip (make-string 128 #\a) "UTF-8")
+  (pass-if-round-trip (make-string 128 #\a) "UTF-16")
+  (pass-if-round-trip (make-string 128 #\a) "UTF-32")
+
+  (pass-if-round-trip (make-string 129 #\a) "UTF-8")
+  (pass-if-round-trip (make-string 129 #\a) "UTF-16")
+  (pass-if-round-trip (make-string 129 #\a) "UTF-32"))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]