#ifndef Perl_error_log
# define Perl_error_log (PL_stderrgv \
+ && GvIOp(PL_stderrgv) \
&& IoOFP(GvIOp(PL_stderrgv)) \
? IoOFP(GvIOp(PL_stderrgv)) \
: PerlIO_stderr())
else
gv = PL_defoutgv;
if ((mg = SvTIED_mg((SV*)gv, 'q'))) {
+ had_magic:
if (MARK == ORIGMARK) {
/* If using default handle then we need to make space to
* pass object as 1st arg, so move other args up ...
}
if (!(io = GvIO(gv))) {
dTHR;
+ if ((GvEGV(gv)) && (mg = SvTIED_mg((SV*)GvEGV(gv),'q')))
+ goto had_magic;
if (ckWARN2(WARN_UNOPENED,WARN_CLOSED))
report_evil_fh(gv, io, PL_op->op_type);
SETERRNO(EBADF,RMS$_IFI);
use Symbol;
-print "1..29\n";
+print "1..33\n";
my $fh = gensym;
@expect = (CLOSE => $ob);
$r = close $fh;
ok($r == 5);
+
+# Does aliasing work with tied FHs?
+*ALIAS = *$fh;
+@expect = (PRINT => $ob,"some","text");
+$r = print ALIAS @expect[2,3];
+ok($r == 1);
+
+{
+ use warnings;
+ # Special case of aliasing STDERR, which used
+ # to dump core when warnings were enabled
+ *STDERR = *$fh;
+ @expect = (PRINT => $ob,"some","text");
+ $r = print STDERR @expect[2,3];
+ ok($r == 1);
+}