/* doio.c
*
* Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- * 2000, 2001, 2002, 2003, by Larry Wall and others
+ * 2000, 2001, 2002, 2003, 2004, by Larry Wall and others
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
# define OPEN_EXCL 0
#endif
-#if !defined(NSIG) || defined(M_UNIX) || defined(__unix) || defined(M_XENIX)
#include <signal.h>
-#endif
bool
Perl_do_open(pTHX_ GV *gv, register char *name, I32 len, int as_raw,
if (PL_filemode & (S_ISUID|S_ISGID)) {
PerlIO_flush(IoIFP(GvIOn(PL_argvoutgv))); /* chmod must follow last write */
#ifdef HAS_FCHMOD
- (void)fchmod(PL_lastfd,PL_filemode);
+ if (PL_lastfd != -1)
+ (void)fchmod(PL_lastfd,PL_filemode);
#else
(void)PerlLIO_chmod(PL_oldname,PL_filemode);
#endif
}
+ PL_lastfd = -1;
PL_filemode = 0;
if (!GvAV(gv))
return Nullfp;
switch (SvTYPE(sv)) {
case SVt_NULL:
if (ckWARN(WARN_UNINITIALIZED))
- report_uninit();
+ report_uninit(sv);
return TRUE;
case SVt_IV:
if (SvIOK(sv)) {
return (PL_laststatval = -1);
}
}
+ else if (PL_op->op_private & OPpFT_STACKED) {
+ return PL_laststatval;
+ }
else {
SV* sv = POPs;
char *s;
}
}
+static char no_prev_lstat[] = "The stat preceding -l _ wasn't an lstat";
+
I32
Perl_my_lstat(pTHX)
{
EXTEND(SP,1);
if (cGVOP_gv == PL_defgv) {
if (PL_laststype != OP_LSTAT)
- Perl_croak(aTHX_ "The stat preceding -l _ wasn't an lstat");
+ Perl_croak(aTHX_ no_prev_lstat);
return PL_laststatval;
}
if (ckWARN(WARN_IO)) {
return (PL_laststatval = -1);
}
}
+ else if (ckWARN(WARN_IO) && PL_laststype != OP_LSTAT
+ && (PL_op->op_private & OPpFT_STACKED))
+ Perl_croak(aTHX_ no_prev_lstat);
PL_laststype = OP_LSTAT;
PL_statgv = Nullgv;