diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-06-06 14:43:56 +0200 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-06-11 08:48:14 +0200 |
commit | cf0c26e1e5a2c4feb57f6d36050415159796e762 (patch) | |
tree | 3212610a430db455d20a4cc9223b712d0fa267a6 /ext/IPC-Open3 | |
parent | 0689e260481390ae18db4d1043f84f46f17a2951 (diff) | |
download | perl-cf0c26e1e5a2c4feb57f6d36050415159796e762.tar.gz |
Move the autovivification emulation code to the top of IPC::Open3::_open3().
This avoids having to re-assign to the scalars $dad_wtr and $dad_rdr.
Diffstat (limited to 'ext/IPC-Open3')
-rw-r--r-- | ext/IPC-Open3/lib/IPC/Open3.pm | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/ext/IPC-Open3/lib/IPC/Open3.pm b/ext/IPC-Open3/lib/IPC/Open3.pm index 916fd84ceb..890cc7071c 100644 --- a/ext/IPC-Open3/lib/IPC/Open3.pm +++ b/ext/IPC-Open3/lib/IPC/Open3.pm @@ -199,19 +199,14 @@ use constant DO_SPAWN => $^O eq 'os2' || $^O eq 'MSWin32' || FORCE_DEBUG_SPAWN; sub _open3 { local $Me = shift; - my($dad_wtr, $dad_rdr, $dad_err, @cmd) = @_; - my($dup_wtr, $dup_rdr, $dup_err, $kidpid); - if (@cmd > 1 and $cmd[0] eq '-') { - croak "Arguments don't make sense when the command is '-'" - } # simulate autovivification of filehandles because # it's too ugly to use @_ throughout to make perl do it for us # tchrist 5-Mar-00 unless (eval { - $dad_wtr = $_[0] = gensym unless defined $dad_wtr && length $dad_wtr; - $dad_rdr = $_[1] = gensym unless defined $dad_rdr && length $dad_rdr; + $_[0] = gensym unless defined $_[0] && length $_[0]; + $_[1] = gensym unless defined $_[1] && length $_[1]; 1; }) { # must strip crud for croak to add back, or looks ugly @@ -219,6 +214,12 @@ sub _open3 { croak "$Me: $@"; } + my($dad_wtr, $dad_rdr, $dad_err, @cmd) = @_; + my($dup_wtr, $dup_rdr, $dup_err, $kidpid); + if (@cmd > 1 and $cmd[0] eq '-') { + croak "Arguments don't make sense when the command is '-'" + } + $dad_err ||= $dad_rdr; $dup_wtr = ($dad_wtr =~ s/^[<>]&//); |