From: Nick Ing-Simmons Date: Mon, 11 Feb 2002 11:59:18 +0000 (+0000) Subject: Patch up the failing multi-byte write case, and un-skip X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=25f7d9d365e0d370c3b5dfc8fdfd572718a96a04;p=p5sagit%2Fp5-mst-13.2.git Patch up the failing multi-byte write case, and un-skip the test. p4raw-id: //depot/perlio@14639 --- diff --git a/ext/Encode/Encode.xs b/ext/Encode/Encode.xs index 4d6c6ac..4e36a49 100644 --- a/ext/Encode/Encode.xs +++ b/ext/Encode/Encode.xs @@ -328,6 +328,11 @@ PerlIOEncode_flush(pTHX_ PerlIO * f) if (PerlIO_flush(PerlIONext(f)) != 0) { code = -1; } + if (SvCUR(e->bufsv)) { + /* Did not all translate */ + e->base.ptr = e->base.buf+SvCUR(e->bufsv); + return code; + } } else if (PerlIOBase(f)->flags & PERLIO_F_RDBUF) { /* read case */ @@ -384,6 +389,9 @@ PerlIOEncode_close(pTHX_ PerlIO * f) PerlIOEncode *e = PerlIOSelf(f, PerlIOEncode); IV code = PerlIOBase_close(aTHX_ f); if (e->bufsv) { + if (e->base.buf && e->base.ptr > e->base.buf) { + Perl_croak(aTHX_ "Close with partial character"); + } SvREFCNT_dec(e->bufsv); e->bufsv = Nullsv; } @@ -402,6 +410,9 @@ PerlIOEncode_tell(pTHX_ PerlIO * f) the UTF8 we have in bufefr and then ask layer below */ PerlIO_flush(f); + if (b->buf && b->ptr > b->buf) { + Perl_croak(aTHX_ "Cannot tell at partial character"); + } return PerlIO_tell(PerlIONext(f)); } @@ -470,6 +481,7 @@ Encode_XSEncoding(pTHX_ encode_t * enc) void call_failure(SV * routine, U8 * done, U8 * dest, U8 * orig) { + /* Exists for breakpointing */ } static SV * diff --git a/ext/Encode/t/Japanese.t b/ext/Encode/t/Japanese.t index d6fa824..20f5b25 100644 --- a/ext/Encode/t/Japanese.t +++ b/ext/Encode/t/Japanese.t @@ -70,7 +70,7 @@ select($out); SKIP: { - skip "Multi-byte write is broken",3; + #skip "Multi-byte write is broken",3; print "# dst :encoding test\n"; open(my $src,"<:utf8",$ref) || die "Cannot open $ref:$!"; ok(defined($src) || fileno($src));