/* doio.c
*
- * Copyright (c) 1991-2002, Larry Wall
+ * Copyright (c) 1991-2003, Larry Wall
*
* You may distribute under the terms of either the GNU General Public
* License or the Artistic License, as specified in the README file.
if (num_svs > 1) {
Perl_croak(aTHX_ "More than one argument to '%c&' open",IoTYPE(io));
}
+ /*SUPPRESS 530*/
+ for (; isSPACE(*type); type++) ;
if (num_svs && (SvIOK(*svp) || (SvPOK(*svp) && looks_like_number(*svp)))) {
fd = SvUV(*svp);
+ num_svs = 0;
}
else if (isDIGIT(*type)) {
- /*SUPPRESS 530*/
- for (; isSPACE(*type); type++) ;
fd = atoi(type);
}
else {
}
else {
GV *thatgv;
- /*SUPPRESS 530*/
- for (; isSPACE(*type); type++) ;
thatgv = gv_fetchpv(type,FALSE,SVt_PVIO);
thatio = GvIO(thatgv);
}
if ((IoTYPE(io) == IoTYPE_RDONLY) &&
(fp == PerlIO_stdout() || fp == PerlIO_stderr())) {
Perl_warner(aTHX_ packWARN(WARN_IO),
- "Filehandle STD%s opened only for input",
- (fp == PerlIO_stdout()) ? "OUT" : "ERR");
+ "Filehandle STD%s reopened as %s only for input",
+ ((fp == PerlIO_stdout()) ? "OUT" : "ERR"),
+ GvENAME(gv));
}
else if ((IoTYPE(io) == IoTYPE_WRONLY) && fp == PerlIO_stdin()) {
Perl_warner(aTHX_ packWARN(WARN_IO),
- "Filehandle STDIN opened only for output");
+ "Filehandle STDIN reopened as %s only for output",
+ GvENAME(gv));
}
}
#endif
}
PL_filemode = 0;
+ if (!GvAV(gv))
+ return Nullfp;
while (av_len(GvAV(gv)) >= 0) {
STRLEN oldlen;
sv = av_shift(GvAV(gv));
{
if (ckWARN_d(WARN_INPLACE))
Perl_warner(aTHX_ packWARN(WARN_INPLACE),
- "Can't do inplace edit: %s would not be unique",
- SvPVX(sv));
+ "Can't do inplace edit: %"SVf" would not be unique",
+ sv);
do_close(gv,FALSE);
continue;
}
if (PerlLIO_rename(PL_oldname,SvPVX(sv)) < 0) {
if (ckWARN_d(WARN_INPLACE))
Perl_warner(aTHX_ packWARN(WARN_INPLACE),
- "Can't rename %s to %s: %s, skipping file",
- PL_oldname, SvPVX(sv), Strerror(errno) );
+ "Can't rename %s to %"SVf": %s, skipping file",
+ PL_oldname, sv, Strerror(errno) );
do_close(gv,FALSE);
continue;
}
if (link(PL_oldname,SvPVX(sv)) < 0) {
if (ckWARN_d(WARN_INPLACE))
Perl_warner(aTHX_ packWARN(WARN_INPLACE),
- "Can't rename %s to %s: %s, skipping file",
- PL_oldname, SvPVX(sv), Strerror(errno) );
+ "Can't rename %s to %"SVf": %s, skipping file",
+ PL_oldname, sv, Strerror(errno) );
do_close(gv,FALSE);
continue;
}
if (PerlProc_pipe(fd) < 0)
goto badexit;
- IoIFP(rstio) = PerlIO_fdopen(fd[0], "r");
- IoOFP(wstio) = PerlIO_fdopen(fd[1], "w");
+ IoIFP(rstio) = PerlIO_fdopen(fd[0], "r"PIPESOCK_MODE);
+ IoOFP(wstio) = PerlIO_fdopen(fd[1], "w"PIPESOCK_MODE);
IoOFP(rstio) = IoIFP(rstio);
IoIFP(wstio) = IoOFP(wstio);
IoTYPE(rstio) = IoTYPE_RDONLY;
default:
if (PerlIO_isutf8(fp)) {
if (!SvUTF8(sv))
- sv_utf8_upgrade(sv = sv_mortalcopy(sv));
+ sv_utf8_upgrade_flags(sv = sv_mortalcopy(sv),
+ SV_GMAGIC|SV_UTF8_NO_ENCODING);
}
else if (DO_UTF8(sv)) {
if (!sv_utf8_downgrade((sv = sv_mortalcopy(sv)), TRUE)
else {
SV* sv = POPs;
char *s;
- STRLEN n_a;
+ STRLEN len;
PUTBACK;
if (SvTYPE(sv) == SVt_PVGV) {
gv = (GV*)sv;
goto do_fstat;
}
- s = SvPV(sv, n_a);
+ s = SvPV(sv, len);
PL_statgv = Nullgv;
- sv_setpv(PL_statname, s);
+ sv_setpvn(PL_statname, s, len);
+ s = SvPVX(PL_statname); /* s now NUL-terminated */
PL_laststype = OP_STAT;
PL_laststatval = PerlLIO_stat(s, &PL_statcache);
if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(s, '\n'))
if (mark == sp)
break;
s = SvPVx(*++mark, n_a);
- if (isUPPER(*s)) {
+ if (isALPHA(*s)) {
if (*s == 'S' && s[1] == 'I' && s[2] == 'G')
s += 3;
- if (!(val = whichsig(s)))
+ if ((val = whichsig(s)) < 0)
Perl_croak(aTHX_ "Unrecognized signal name \"%s\"",s);
}
else
SV* modified = *++mark;
void * utbufp = &utbuf;
- /* be like C, and if both times are undefined, let the C
- library figure out what to do. This usually means
- "current time" */
+ /* Be like C, and if both times are undefined, let the C
+ * library figure out what to do. This usually means
+ * "current time". */
if ( accessed == &PL_sv_undef && modified == &PL_sv_undef )
- utbufp = NULL;
-
- Zero(&utbuf, sizeof utbuf, char);
+ utbufp = NULL;
+ else {
+ Zero(&utbuf, sizeof utbuf, char);
#ifdef BIG_TIME
- utbuf.actime = (Time_t)SvNVx(accessed); /* time accessed */
- utbuf.modtime = (Time_t)SvNVx(modified); /* time modified */
+ utbuf.actime = (Time_t)SvNVx(accessed); /* time accessed */
+ utbuf.modtime = (Time_t)SvNVx(modified); /* time modified */
#else
- utbuf.actime = (Time_t)SvIVx(accessed); /* time accessed */
- utbuf.modtime = (Time_t)SvIVx(modified); /* time modified */
+ utbuf.actime = (Time_t)SvIVx(accessed); /* time accessed */
+ utbuf.modtime = (Time_t)SvIVx(modified); /* time modified */
#endif
- APPLY_TAINT_PROPER();
+ }
+ APPLY_TAINT_PROPER();
tot = sp - mark;
while (++mark <= sp) {
char *name = SvPVx(*mark, n_a);