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

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

Thread Next
From:
Robert Norris
Date:
June 4, 2008 03:26
Subject:
[PATCH] stat() and -X for tied handles
Message ID:
20080604102619.GA6717@plastic.home
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

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.

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

Cheers,
Rob.

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About