develooper Front page | perl.perl5.porters | Postings from June 2008

Re: [PATCH] stat() and -X for tied handles

Thread Previous | Thread Next
Rafael Garcia-Suarez
June 4, 2008 07:22
Re: [PATCH] stat() and -X for tied handles
Message ID:
2008/6/4 Robert Norris <>:
> Hi porters,
> Here's a patch that makes stat() and the -X file test ops work on tied
> handles. It was made against blead but applies cleanly to maint-5.10.
> It adds three methods to the tied object interface:
>  * STAT, called by stat() and most of the file test ops
>  * ISATTY, called by -t
>  * ISBINARY, called by -B and -T

That's very interesting and I shall consider it for inclusion. I'm
waiting a bit for comments from the list though (I'm not personally a
heavy user of tied filehandles.) I'll look a bit closer at the
implementation too.

BTW, I don't think that patching t/lib/Tie{In,Out}.pm was necessary:
those modules are only needed by a few tests and do not get installed
with perl.

> This is my first time poking at Perl's innards and I'm still unfamiliar
> with most of it so I'm not sure what mistakes I might have made,
> particularly with the stack macros. I think the idea is right though.
> The end of S_do_stat_maybe_tiehandle() where it pulls the values
> returned by STAT off the stack is probably wrong. Its based on the
> opposite code at the end of pp_stat(), but I don't have the ability to
> test the various possibilities.
> One bit I don't like is that pp_stat() calls S_do_stat_maybe_tiehandle()
> which then repeats most of the tests to determine if its working on a
> tied handle. Its seems to fix this properly I'd want to have a single
> function that does the all the "stat a handle" work, and then have
> pp_stat() just wrap that. If I did that though I'm not sure where
> Perl_my_stat() in doio.c fits, and I don't think we want tiehandle stuff
> in that function, so I opted to leave it for now.
> The additional three methods seemed to be the simplest interface I could
> come up with, but I don't know if it looks right - I'm bad at
> interfaces.

The Perl-level interface seems OK to me.

> This functionality is something that I really need, so I'm keen to get
> it right. All feedback very welcome.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About