From: Nick Ing-Simmons Date: Tue, 16 Oct 2001 19:11:30 +0000 (+0000) Subject: PerlIOXxxx_dups for all but Win32 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9f16d962dace601f24c23063432e8a8eb01bfa4a;p=p5sagit%2Fp5-mst-13.2.git PerlIOXxxx_dups for all but Win32 p4raw-id: //depot/perlio@12462 --- diff --git a/ext/Encode/Encode.xs b/ext/Encode/Encode.xs index e01959c..87e8913 100644 --- a/ext/Encode/Encode.xs +++ b/ext/Encode/Encode.xs @@ -328,8 +328,16 @@ PerlIOEncode_tell(PerlIO *f) PerlIO * PerlIOEncode_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *params) { - /* FIXME - Almost certainly needs more work */ - return PerlIOBase_dup(aTHX_ f, o, params); + if ((f = PerlIOBase_dup(aTHX_ f, o, params))) + { + PerlIOEncode *fe = PerlIOSelf(f,PerlIOEncode); + PerlIOEncode *oe = PerlIOSelf(o,PerlIOEncode); + if (oe->enc) + { + fe->enc = PerlIO_sv_dup(aTHX_ oe->enc, params); + } + } + return f; } PerlIO_funcs PerlIO_encode = { diff --git a/ext/PerlIO/Scalar/Scalar.xs b/ext/PerlIO/Scalar/Scalar.xs index 9fd6a2f..3bd37de 100644 --- a/ext/PerlIO/Scalar/Scalar.xs +++ b/ext/PerlIO/Scalar/Scalar.xs @@ -239,8 +239,14 @@ PerlIOScalar_open(pTHX_ PerlIO_funcs *self, PerlIO_list_t *layers, IV n, const c PerlIO * PerlIOScalar_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param) { - /* FIXME - Needs more work */ - return PerlIOBase_dup(aTHX_ f, o, param); + if ((f = PerlIOBase_dup(aTHX_ f, o, param))) + { + PerlIOScalar *fs = PerlIOSelf(f,PerlIOScalar); + PerlIOScalar *os = PerlIOSelf(o,PerlIOScalar); + /* var has been set by implicit push */ + fs->posn = os->posn; + } + return f; } PerlIO_funcs PerlIO_scalar = { diff --git a/ext/PerlIO/Via/Via.xs b/ext/PerlIO/Via/Via.xs index 2e029db..adf0abf 100644 --- a/ext/PerlIO/Via/Via.xs +++ b/ext/PerlIO/Via/Via.xs @@ -13,7 +13,6 @@ typedef struct SV * obj; SV * var; SSize_t cnt; - Off_t posn; IO * io; SV * fh; CV *PUSHED; @@ -270,7 +269,7 @@ PerlIOVia_seek(PerlIO *f, Off_t offset, int whence) dTHX; PerlIOVia *s = PerlIOSelf(f,PerlIOVia); SV *offsv = sv_2mortal(newSViv(offset)); - SV *whsv = sv_2mortal(newSViv(offset)); + SV *whsv = sv_2mortal(newSViv(whence)); SV *result = PerlIOVia_method(aTHX_ f,MYMethod(SEEK),G_SCALAR,offsv,whsv,Nullsv); return (result) ? SvIV(result) : -1; } @@ -281,7 +280,7 @@ PerlIOVia_tell(PerlIO *f) dTHX; PerlIOVia *s = PerlIOSelf(f,PerlIOVia); SV *result = PerlIOVia_method(aTHX_ f,MYMethod(TELL),G_SCALAR,Nullsv); - return (result) ? (Off_t) SvIV(result) : s->posn; + return (result) ? (Off_t) SvIV(result) : (Off_t) -1; } SSize_t @@ -494,8 +493,13 @@ PerlIOVia_eof(PerlIO *f) PerlIO * PerlIOVia_dup(pTHX_ PerlIO *f, PerlIO *o, CLONE_PARAMS *param) { - /* FIXME - Needs more work */ - return PerlIOBase_dup(aTHX_ f, o, param); + if ((f = PerlIOBase_dup(aTHX_ f, o, param))) + { + /* Most of the fields will lazily set them selves up as needed + stash and obj have been set up by the implied push + */ + } + return f; } PerlIO_funcs PerlIO_object = {