#if defined(HAS_SOCKET) && !defined(VMS) /* VMS handles sockets via vmsish.h */
# include <sys/socket.h>
-# include <netdb.h>
+# if defined(USE_SOCKS) && defined(I_SOCKS)
+# include <socks.h>
+# endif
+# ifdef I_NETBSD
+# include <netdb.h>
+# endif
# ifndef ENOTSOCK
# ifdef I_NET_ERRNO
# include <net/errno.h>
if (*name == '\0') { /* command is missing 19990114 */
dTHR;
if (ckWARN(WARN_PIPE))
- warner(WARN_PIPE, "Missing command in piped open");
+ Perl_warner(aTHX_ WARN_PIPE, "Missing command in piped open");
errno = EPIPE;
goto say_false;
}
dTHR;
name[strlen(name)-1] = '\0' ;
if (ckWARN(WARN_PIPE))
- warner(WARN_PIPE, "Can't do bidirectional pipe");
+ Perl_warner(aTHX_ WARN_PIPE, "Can't do bidirectional pipe");
}
fp = PerlProc_popen(name,"w");
writing = 1;
if (*name == '\0') { /* command is missing 19990114 */
dTHR;
if (ckWARN(WARN_PIPE))
- warner(WARN_PIPE, "Missing command in piped open");
+ Perl_warner(aTHX_ WARN_PIPE, "Missing command in piped open");
errno = EPIPE;
goto say_false;
}
if (!fp) {
dTHR;
if (ckWARN(WARN_NEWLINE) && IoTYPE(io) == '<' && strchr(name, '\n'))
- warner(WARN_NEWLINE, PL_warn_nl, "open");
+ Perl_warner(aTHX_ WARN_NEWLINE, PL_warn_nl, "open");
goto say_false;
}
if (IoTYPE(io) &&
fileuid = PL_statbuf.st_uid;
filegid = PL_statbuf.st_gid;
if (!S_ISREG(PL_filemode)) {
- warn("Can't do inplace edit: %s is not a regular file",
- PL_oldname );
+ if (ckWARN_d(WARN_INPLACE))
+ Perl_warner(aTHX_ WARN_INPLACE,
+ "Can't do inplace edit: %s is not a regular file",
+ PL_oldname );
do_close(gv,FALSE);
continue;
}
#ifdef DJGPP
|| (_djstat_fail_bits & _STFAIL_TRUENAME)!=0
#endif
- ) {
- warn("Can't do inplace edit: %s would not be unique",
- SvPVX(sv) );
+ )
+ {
+ if (ckWARN_d(WARN_INPLACE))
+ Perl_warner(aTHX_ WARN_INPLACE,
+ "Can't do inplace edit: %s would not be unique",
+ SvPVX(sv));
do_close(gv,FALSE);
continue;
}
#ifdef HAS_RENAME
#ifndef DOSISH
if (PerlLIO_rename(PL_oldname,SvPVX(sv)) < 0) {
- warn("Can't rename %s to %s: %s, skipping file",
- PL_oldname, SvPVX(sv), Strerror(errno) );
+ if (ckWARN_d(WARN_INPLACE))
+ Perl_warner(aTHX_ WARN_INPLACE,
+ "Can't rename %s to %s: %s, skipping file",
+ PL_oldname, SvPVX(sv), Strerror(errno) );
do_close(gv,FALSE);
continue;
}
#else
(void)UNLINK(SvPVX(sv));
if (link(PL_oldname,SvPVX(sv)) < 0) {
- warn("Can't rename %s to %s: %s, skipping file",
- PL_oldname, SvPVX(sv), Strerror(errno) );
+ if (ckWARN_d(WARN_INPLACE))
+ Perl_warner(aTHX_ WARN_INPLACE,
+ "Can't rename %s to %s: %s, skipping file",
+ PL_oldname, SvPVX(sv), Strerror(errno) );
do_close(gv,FALSE);
continue;
}
#if !defined(DOSISH) && !defined(AMIGAOS)
# ifndef VMS /* Don't delete; use automatic file versioning */
if (UNLINK(PL_oldname) < 0) {
- warn("Can't remove %s: %s, skipping file",
- PL_oldname, Strerror(errno) );
+ if (ckWARN_d(WARN_INPLACE))
+ Perl_warner(aTHX_ WARN_INPLACE,
+ "Can't remove %s: %s, skipping file",
+ PL_oldname, Strerror(errno) );
do_close(gv,FALSE);
continue;
}
# endif
#else
- croak("Can't do inplace edit without backup");
+ Perl_croak(aTHX_ "Can't do inplace edit without backup");
#endif
}
if (!do_open(PL_argvoutgv,SvPVX(sv),SvCUR(sv),PL_inplace!=0,
O_WRONLY|O_CREAT|OPEN_EXCL,0666,Nullfp)) {
#endif
- warn("Can't do inplace edit on %s: %s",
- PL_oldname, Strerror(errno) );
+ if (ckWARN_d(WARN_INPLACE))
+ Perl_warner(aTHX_ WARN_INPLACE, "Can't do inplace edit on %s: %s",
+ PL_oldname, Strerror(errno) );
do_close(gv,FALSE);
continue;
}
}
return IoIFP(GvIOp(gv));
}
- else
- PerlIO_printf(PerlIO_stderr(), "Can't open %s: %s\n",
- SvPV(sv, oldlen), Strerror(errno));
+ else {
+ dTHR;
+ if (ckWARN_d(WARN_INPLACE)) {
+ if (!S_ISREG(PL_statbuf.st_mode))
+ Perl_warner(aTHX_ WARN_INPLACE,
+ "Can't do inplace edit: %s is not a regular file",
+ PL_oldname );
+ else
+ Perl_warner(aTHX_ WARN_INPLACE, "Can't open %s: %s\n",
+ PL_oldname, Strerror(errno));
+ }
+ }
}
if (PL_inplace) {
(void)do_close(PL_argvoutgv,FALSE);
if (not_implicit) {
dTHR;
if (ckWARN(WARN_UNOPENED))
- warner(WARN_UNOPENED,
+ Perl_warner(aTHX_ WARN_UNOPENED,
"Close on unopened file <%s>",GvENAME(gv));
SETERRNO(EBADF,SS$_IVCHAN);
}
if (!io)
return TRUE;
+ else if (ckWARN(WARN_IO)
+ && (IoTYPE(io) == '>' || IoIFP(io) == PerlIO_stdout()
+ || IoIFP(io) == PerlIO_stderr()))
+ {
+ SV* sv = sv_newmortal();
+ gv_efullname3(sv, gv, Nullch);
+ Perl_warner(aTHX_ WARN_IO, "Filehandle %s opened only for output",
+ SvPV_nolen(sv));
+ }
while (IoIFP(io)) {
{
dTHR;
if (ckWARN(WARN_UNOPENED))
- warner(WARN_UNOPENED, "tell() on unopened file");
+ Perl_warner(aTHX_ WARN_UNOPENED, "tell() on unopened file");
}
SETERRNO(EBADF,RMS$_IFI);
return (Off_t)-1;
{
dTHR;
if (ckWARN(WARN_UNOPENED))
- warner(WARN_UNOPENED, "seek() on unopened file");
+ Perl_warner(aTHX_ WARN_UNOPENED, "seek() on unopened file");
}
SETERRNO(EBADF,RMS$_IFI);
return FALSE;
{
dTHR;
if (ckWARN(WARN_UNOPENED))
- warner(WARN_UNOPENED, "sysseek() on unopened file");
+ Perl_warner(aTHX_ WARN_UNOPENED, "sysseek() on unopened file");
}
SETERRNO(EBADF,RMS$_IFI);
return -1L;
Perl_do_binmode(pTHX_ PerlIO *fp, int iotype, int flag)
{
if (flag != TRUE)
- croak("panic: unsetting binmode"); /* Not implemented yet */
+ Perl_croak(aTHX_ "panic: unsetting binmode"); /* Not implemented yet */
#ifdef DOSISH
#if defined(atarist) || defined(__MINT__)
if (!PerlIO_flush(fp) && (fp->_flag |= _IOBIN))
#endif
#else
#if defined(USEMYBINMODE)
- if (my_binmode(fp,iotype) != NULL)
+ if (my_binmode(fp,iotype) != FALSE)
return 1;
else
return 0;
if (SvGMAGICAL(sv))
mg_get(sv);
if (SvIOK(sv) && SvIVX(sv) != 0) {
- PerlIO_printf(fp, PL_ofmt, (double)SvIVX(sv));
+ PerlIO_printf(fp, PL_ofmt, (NV)SvIVX(sv));
return !PerlIO_error(fp);
}
if ( (SvNOK(sv) && SvNVX(sv) != 0.0)
{
dTHR;
if (ckWARN(WARN_UNINITIALIZED))
- warner(WARN_UNINITIALIZED, PL_warn_uninit);
+ Perl_warner(aTHX_ WARN_UNINITIALIZED, PL_warn_uninit);
}
return TRUE;
case SVt_IV:
}
I32
-Perl_my_stat(pTHX_ ARGSproto)
+Perl_my_stat(pTHX)
{
djSP;
IO *io;
if (tmpgv == PL_defgv)
return PL_laststatval;
if (ckWARN(WARN_UNOPENED))
- warner(WARN_UNOPENED, "Stat on unopened file <%s>",
+ Perl_warner(aTHX_ WARN_UNOPENED, "Stat on unopened file <%s>",
GvENAME(tmpgv));
PL_statgv = Nullgv;
sv_setpv(PL_statname,"");
PL_laststype = OP_STAT;
PL_laststatval = PerlLIO_stat(s, &PL_statcache);
if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(s, '\n'))
- warner(WARN_NEWLINE, PL_warn_nl, "stat");
+ Perl_warner(aTHX_ WARN_NEWLINE, PL_warn_nl, "stat");
return PL_laststatval;
}
}
I32
-Perl_my_lstat(pTHX_ ARGSproto)
+Perl_my_lstat(pTHX)
{
djSP;
SV *sv;
EXTEND(SP,1);
if (cGVOP->op_gv == PL_defgv) {
if (PL_laststype != OP_LSTAT)
- croak("The stat preceding -l _ wasn't an lstat");
+ Perl_croak(aTHX_ "The stat preceding -l _ wasn't an lstat");
return PL_laststatval;
}
- croak("You can't use -l on a filehandle");
+ Perl_croak(aTHX_ "You can't use -l on a filehandle");
}
PL_laststype = OP_LSTAT;
sv_setpv(PL_statname,SvPV(sv, n_a));
PL_laststatval = PerlLIO_lstat(SvPV(sv, n_a),&PL_statcache);
if (PL_laststatval < 0 && ckWARN(WARN_NEWLINE) && strchr(SvPV(sv, n_a), '\n'))
- warner(WARN_NEWLINE, PL_warn_nl, "lstat");
+ Perl_warner(aTHX_ WARN_NEWLINE, PL_warn_nl, "lstat");
return PL_laststatval;
}
else
PerlProc_execvp(PL_Argv[0],PL_Argv);
if (ckWARN(WARN_EXEC))
- warner(WARN_EXEC, "Can't exec \"%s\": %s",
+ Perl_warner(aTHX_ WARN_EXEC, "Can't exec \"%s\": %s",
PL_Argv[0], Strerror(errno));
}
do_execfree();
}
}
-#if !defined(OS2) && !defined(WIN32) && !defined(DJGPP)
+#if !defined(OS2) && !defined(WIN32) && !defined(DJGPP) && !defined(EPOC)
bool
Perl_do_exec(pTHX_ char *cmd)
*s = '\0';
break;
}
+ /* handle the 2>&1 construct at the end */
+ if (*s == '>' && s[1] == '&' && s[2] == '1'
+ && s > cmd + 1 && s[-1] == '2' && isSPACE(s[-2])
+ && (!s[3] || isSPACE(s[3])))
+ {
+ char *t = s + 3;
+
+ while (*t && isSPACE(*t))
+ ++t;
+ if (!*t && (dup2(1,2) != -1)) {
+ s[-2] = '\0';
+ break;
+ }
+ }
doshell:
PerlProc_execl(PL_sh_path, "sh", "-c", cmd, (char*)0);
return FALSE;
int e = errno;
if (ckWARN(WARN_EXEC))
- warner(WARN_EXEC, "Can't exec \"%s\": %s",
+ Perl_warner(aTHX_ WARN_EXEC, "Can't exec \"%s\": %s",
PL_Argv[0], Strerror(errno));
if (do_report) {
PerlLIO_write(fd, (void*)&e, sizeof(int));
if (*s == 'S' && s[1] == 'I' && s[2] == 'G')
s += 3;
if (!(val = whichsig(s)))
- croak("Unrecognized signal name \"%s\"",s);
+ Perl_croak(aTHX_ "Unrecognized signal name \"%s\"",s);
}
else
val = SvIVx(*mark);
#endif
#if !defined(HAS_MSG) || !defined(HAS_SEM) || !defined(HAS_SHM)
default:
- croak("%s not implemented", PL_op_desc[optype]);
+ Perl_croak(aTHX_ "%s not implemented", PL_op_desc[optype]);
#endif
}
return -1; /* should never happen */
than guessing about u_?short(_t)? */
}
#else
- croak("%s not implemented", PL_op_desc[optype]);
+ Perl_croak(aTHX_ "%s not implemented", PL_op_desc[optype]);
#endif
break;
#endif
#if !defined(HAS_MSG) || !defined(HAS_SEM) || !defined(HAS_SHM)
default:
- croak("%s not implemented", PL_op_desc[optype]);
+ Perl_croak(aTHX_ "%s not implemented", PL_op_desc[optype]);
#endif
}
{
a = SvPV(astr, len);
if (len != infosize)
- croak("Bad arg length for %s, is %lu, should be %ld",
+ Perl_croak(aTHX_ "Bad arg length for %s, is %lu, should be %ld",
PL_op_desc[optype],
(unsigned long)len,
(long)infosize);
unsemds.buf = (struct semid_ds *)a;
ret = Semctl(id, n, cmd, unsemds);
#else
- croak("%s not implemented", PL_op_desc[optype]);
+ Perl_croak(aTHX_ "%s not implemented", PL_op_desc[optype]);
#endif
}
break;
flags = SvIVx(*++mark);
mbuf = SvPV(mstr, len);
if ((msize = len - sizeof(long)) < 0)
- croak("Arg too short for msgsnd");
+ Perl_croak(aTHX_ "Arg too short for msgsnd");
SETERRNO(0,0);
return msgsnd(id, (struct msgbuf *)mbuf, msize, flags);
#else
- croak("msgsnd not implemented");
+ Perl_croak(aTHX_ "msgsnd not implemented");
#endif
}
}
return ret;
#else
- croak("msgrcv not implemented");
+ Perl_croak(aTHX_ "msgrcv not implemented");
#endif
}
SETERRNO(0,0);
return semop(id, (struct sembuf *)opbuf, opsize/sizeof(struct sembuf));
#else
- croak("semop not implemented");
+ Perl_croak(aTHX_ "semop not implemented");
#endif
}
}
return shmdt(shm);
#else
- croak("shm I/O not implemented");
+ Perl_croak(aTHX_ "shm I/O not implemented");
#endif
}