fix bytes-convert-end

The `bytes-convert-end` function didn't set up a proper decoding.
Make sure that it at least does nothing for encodings where
there's nothing to do.
This commit is contained in:
Matthew Flatt 2017-06-20 14:58:20 -06:00
parent a915433b02
commit d4742a0618
2 changed files with 12 additions and 1 deletions

View File

@ -996,6 +996,17 @@
(let-values ([(s2 n2 status2) (bytes-convert c2 s)])
(bytes->string/utf-8 s2)))))
;; Check that `bytes-convert-end` does nothing for UTF-8 and UTF-16 conversion:
(let ([c (bytes-open-converter "platform-UTF-16" "platform-UTF-8")])
(test-values '(#"" complete)
(lambda () (bytes-convert-end c))))
(let ([c (bytes-open-converter "platform-UTF-8" "platform-UTF-16")])
(test-values '(#"" complete)
(lambda () (bytes-convert-end c))))
(let ([c (bytes-open-converter "UTF-8-permissive" "UTF-8")])
(test-values '(#"" complete)
(lambda () (bytes-convert-end c))))
(when (eq? (system-type) 'windows)
(let ([c (bytes-open-converter "platform-UTF-8-permissive" "platform-UTF-16")])
;; Check that we use all 6 bytes of #"\355\240\200\355\260\200" or none

View File

@ -4696,7 +4696,7 @@ static Scheme_Object *convert_one(const char *who, int opos, int argc, Scheme_Ob
scheme_get_substring_indices(who, argv[1], argc, argv, 2, 3, &istart, &ifinish);
} else {
istart = 0;
ifinish = 4; /* This is really a guess about how much space we need for a shift terminator */
ifinish = 0;
}
if (argc > opos) {