[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"))
- [Guile-commits] branch stable-2.0 updated (edd6d6e -> a3ad59b), Andy Wingo, 2016/08/07
- [Guile-commits] 04/07: Capture full path to GUILE_FOR_BUILD., Andy Wingo, 2016/08/07
- [Guile-commits] 02/07: Fix typo about pattern variables, Andy Wingo, 2016/08/07
- [Guile-commits] 05/07: Recognize nios2 as compilation target, Andy Wingo, 2016/08/07
- [Guile-commits] 03/07: Fix grammar in api-compound.texi, Andy Wingo, 2016/08/07
- [Guile-commits] 07/07: Let assv/assoc shortcircuit to assq where feasible, Andy Wingo, 2016/08/07
- [Guile-commits] 06/07: Fix iconv encoding of long strings,
Andy Wingo <=
- [Guile-commits] 01/07: Manual recommends against SRFI-10, Andy Wingo, 2016/08/07