/* pp_sys.c
*
- * Copyright (c) 1991-1997, Larry Wall
+ * Copyright (c) 1991-1999, 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.
*/
#include "EXTERN.h"
+#define PERL_IN_PP_SYS_C
#include "perl.h"
+#ifdef I_SHADOW
+/* Shadow password support for solaris - pdo@cs.umd.edu
+ * Not just Solaris: at least HP-UX, IRIX, Linux.
+ * the API is from SysV. --jhi */
+#ifdef __hpux__
+/* There is a MAXINT coming from <shadow.h> <- <hpsecurity.h> <- <values.h>
+ * and another MAXINT from "perl.h" <- <sys/param.h>. */
+#undef MAXINT
+#endif
+#include <shadow.h>
+#endif
+
/* XXX If this causes problems, set i_unistd=undef in the hint file. */
#ifdef I_UNISTD
# include <unistd.h>
#if defined(HAS_SOCKET) && !defined(VMS) /* VMS handles sockets via vmsish.h */
# include <sys/socket.h>
+# if defined(USE_SOCKS) && defined(I_SOCKS)
+# include <socks.h>
+# endif
# ifdef I_NETDB
# include <netdb.h>
# endif
# ifdef I_PWD
# include <pwd.h>
# else
- struct passwd *getpwnam _((char *));
- struct passwd *getpwuid _((Uid_t));
+ struct passwd *getpwnam (char *);
+ struct passwd *getpwuid (Uid_t);
# endif
# ifdef HAS_GETPWENT
- struct passwd *getpwent _((void));
+ struct passwd *getpwent (void);
# endif
#endif
# ifdef I_GRP
# include <grp.h>
# else
- struct group *getgrnam _((char *));
- struct group *getgrgid _((Gid_t));
+ struct group *getgrnam (char *);
+ struct group *getgrgid (Gid_t);
# endif
# ifdef HAS_GETGRENT
- struct group *getgrent _((void));
+ struct group *getgrent (void);
# endif
#endif
# endif
#endif
-#if !defined(HAS_MKDIR) || !defined(HAS_RMDIR)
-static int dooneliner _((char *cmd, char *filename));
-#endif
-
#ifdef HAS_CHSIZE
# ifdef my_chsize /* Probably #defined to Perl_my_chsize in embed.h */
# undef my_chsize
# endif /* no flock() or fcntl(F_SETLK,...) */
# ifdef FLOCK
- static int FLOCK _((int, int));
+ static int FLOCK (int, int);
/*
* These are the flock() constants. Since this sytems doesn't have
#endif /* no flock() */
+#define ZBTLEN 10
+static char zero_but_true[ZBTLEN + 1] = "0 but true";
+
#if defined(I_SYS_ACCESS) && !defined(R_OK)
# include <sys/access.h>
#endif
+#if defined(HAS_FCNTL) && defined(F_SETFD) && !defined(FD_CLOEXEC)
+# define FD_CLOEXEC 1 /* NeXT needs this */
+#endif
+
#undef PERL_EFF_ACCESS_R_OK /* EFFective uid/gid ACCESS R_OK */
#undef PERL_EFF_ACCESS_W_OK
#undef PERL_EFF_ACCESS_X_OK
/* F_OK unused: if stat() cannot find it... */
#if !defined(PERL_EFF_ACCESS_R_OK) && defined(HAS_ACCESS) && defined(EFF_ONLY_OK) && !defined(NO_EFF_ONLY_OK)
-/* Digital UNIX, UnixWare */
+ /* Digital UNIX (when the EFF_ONLY_OK gets fixed), UnixWare */
# define PERL_EFF_ACCESS_R_OK(p) (access((p), R_OK | EFF_ONLY_OK))
# define PERL_EFF_ACCESS_W_OK(p) (access((p), W_OK | EFF_ONLY_OK))
# define PERL_EFF_ACCESS_X_OK(p) (access((p), X_OK | EFF_ONLY_OK))
#endif
#if !defined(PERL_EFF_ACCESS_R_OK) && defined(HAS_EACCESS)
-/* HP SecureWare */
# if defined(I_SYS_SECURITY)
# include <sys/security.h>
# endif
-# define PERL_EFF_ACCESS_R_OK(p) (eaccess((p), R_OK, ACC_SELF))
-# define PERL_EFF_ACCESS_W_OK(p) (eaccess((p), W_OK, ACC_SELF))
-# define PERL_EFF_ACCESS_X_OK(p) (eaccess((p), X_OK, ACC_SELF))
+ /* XXX Configure test needed for eaccess */
+# ifdef ACC_SELF
+ /* HP SecureWare */
+# define PERL_EFF_ACCESS_R_OK(p) (eaccess((p), R_OK, ACC_SELF))
+# define PERL_EFF_ACCESS_W_OK(p) (eaccess((p), W_OK, ACC_SELF))
+# define PERL_EFF_ACCESS_X_OK(p) (eaccess((p), X_OK, ACC_SELF))
+# else
+ /* SCO */
+# define PERL_EFF_ACCESS_R_OK(p) (eaccess((p), R_OK))
+# define PERL_EFF_ACCESS_W_OK(p) (eaccess((p), W_OK))
+# define PERL_EFF_ACCESS_X_OK(p) (eaccess((p), X_OK))
+# endif
#endif
#if !defined(PERL_EFF_ACCESS_R_OK) && defined(HAS_ACCESSX) && defined(ACC_SELF)
-/* AIX */
+ /* AIX */
# define PERL_EFF_ACCESS_R_OK(p) (accessx((p), R_OK, ACC_SELF))
# define PERL_EFF_ACCESS_W_OK(p) (accessx((p), W_OK, ACC_SELF))
# define PERL_EFF_ACCESS_X_OK(p) (accessx((p), X_OK, ACC_SELF))
|| defined(HAS_SETREGID) || defined(HAS_SETRESGID))
/* The Hard Way. */
STATIC int
-emulate_eaccess (const char* path, int mode) {
+S_emulate_eaccess(pTHX_ const char* path, Mode_t mode)
+{
Uid_t ruid = getuid();
Uid_t euid = geteuid();
Gid_t rgid = getgid();
MUTEX_LOCK(&PL_cred_mutex);
#if !defined(HAS_SETREUID) && !defined(HAS_SETRESUID)
- croak("effective uid access is not implemented");
+ Perl_croak(aTHX_ "switching effective uid is not implemented");
#else
#ifdef HAS_SETREUID
if (setreuid(euid, ruid))
if (setresuid(euid, ruid, (Uid_t)-1))
#endif
#endif
- croak("entering effective uid access failed");
+ Perl_croak(aTHX_ "entering effective uid failed");
#endif
#if !defined(HAS_SETREGID) && !defined(HAS_SETRESGID)
- croak("effective gid access is not implemented");
+ Perl_croak(aTHX_ "switching effective gid is not implemented");
#else
#ifdef HAS_SETREGID
if (setregid(egid, rgid))
if (setresgid(egid, rgid, (Gid_t)-1))
#endif
#endif
- croak("entering effective gid access failed");
+ Perl_croak(aTHX_ "entering effective gid failed");
#endif
res = access(path, mode);
if (setresuid(ruid, euid, (Uid_t)-1))
#endif
#endif
- croak("leaving effective uid access failed");
+ Perl_croak(aTHX_ "leaving effective uid failed");
#ifdef HAS_SETREGID
if (setregid(rgid, egid))
if (setresgid(rgid, egid, (Gid_t)-1))
#endif
#endif
- croak("leaving effective gid access failed");
+ Perl_croak(aTHX_ "leaving effective gid failed");
MUTEX_UNLOCK(&PL_cred_mutex);
return res;
#if !defined(PERL_EFF_ACCESS_R_OK)
STATIC int
-emulate_eaccess (const char* path, int mode) {
- croak("effective uid access is not implemented");
+S_emulate_eaccess(pTHX_ const char* path, Mode_t mode)
+{
+ Perl_croak(aTHX_ "switching effective uid is not implemented");
/*NOTREACHED*/
return -1;
}
#endif
-#ifndef MAXPATHLEN
-# ifdef PATH_MAX
-# define MAXPATHLEN PATH_MAX
-# else
-# define MAXPATHLEN 1024
-# endif
-#endif
-
-#define ZBTLEN 10
-static char zero_but_true[ZBTLEN + 1] = "0 but true";
-
PP(pp_backtick)
{
djSP; dTARGET;
PerlIO *fp;
- char *tmps = POPp;
+ STRLEN n_a;
+ char *tmps = POPpx;
I32 gimme = GIMME_V;
TAINT_PROPER("``");
PP(pp_glob)
{
OP *result;
+ tryAMAGICunTARGET(iter, -1);
+
ENTER;
#ifndef VMS
* so for security reasons we must assume the worst.
*/
TAINT;
- taint_proper(no_security, "glob");
+ taint_proper(PL_no_security, "glob");
}
#endif /* !VMS */
PL_last_in_gv = (GV*)*PL_stack_sp--;
SAVESPTR(PL_rs); /* This is not permanent, either. */
- PL_rs = sv_2mortal(newSVpv("", 1));
+ PL_rs = sv_2mortal(newSVpvn("\000", 1));
#ifndef DOSISH
#ifndef CSH
*SvPVX(PL_rs) = '\n';
#if 0 /* XXX never used! */
PP(pp_indread)
{
- PL_last_in_gv = gv_fetchpv(SvPVx(GvSV((GV*)(*PL_stack_sp--)), PL_na), TRUE,SVt_PVIO);
+ STRLEN n_a;
+ PL_last_in_gv = gv_fetchpv(SvPVx(GvSV((GV*)(*PL_stack_sp--)), n_a), TRUE,SVt_PVIO);
return do_readline();
}
#endif
PP(pp_rcatline)
{
- PL_last_in_gv = cGVOP->op_gv;
+ PL_last_in_gv = cGVOP;
return do_readline();
}
PP(pp_warn)
{
djSP; dMARK;
+ SV *tmpsv;
char *tmps;
+ STRLEN len;
if (SP - MARK != 1) {
dTARGET;
do_join(TARG, &PL_sv_no, MARK, SP);
- tmps = SvPV(TARG, PL_na);
+ tmpsv = TARG;
SP = MARK + 1;
}
else {
- tmps = SvPV(TOPs, PL_na);
+ tmpsv = TOPs;
}
- if (!tmps || !*tmps) {
+ tmps = SvPV(tmpsv, len);
+ if (!tmps || !len) {
SV *error = ERRSV;
(void)SvUPGRADE(error, SVt_PV);
if (SvPOK(error) && SvCUR(error))
sv_catpv(error, "\t...caught");
- tmps = SvPV(error, PL_na);
+ tmpsv = error;
+ tmps = SvPV(tmpsv, len);
}
- if (!tmps || !*tmps)
- tmps = "Warning: something's wrong";
- warn("%s", tmps);
+ if (!tmps || !len)
+ tmpsv = sv_2mortal(newSVpvn("Warning: something's wrong", 26));
+
+ Perl_warn(aTHX_ "%_", tmpsv);
RETSETYES;
}
{
djSP; dMARK;
char *tmps;
- SV *tmpsv = Nullsv;
- char *pat = "%s";
+ SV *tmpsv;
+ STRLEN len;
+ bool multiarg = 0;
if (SP - MARK != 1) {
dTARGET;
do_join(TARG, &PL_sv_no, MARK, SP);
- tmps = SvPV(TARG, PL_na);
+ tmpsv = TARG;
+ tmps = SvPV(tmpsv, len);
+ multiarg = 1;
SP = MARK + 1;
}
else {
tmpsv = TOPs;
- tmps = SvROK(tmpsv) ? Nullch : SvPV(tmpsv, PL_na);
+ tmps = SvROK(tmpsv) ? Nullch : SvPV(tmpsv, len);
}
- if (!tmps || !*tmps) {
+ if (!tmps || !len) {
SV *error = ERRSV;
(void)SvUPGRADE(error, SVt_PV);
- if(tmpsv ? SvROK(tmpsv) : SvROK(error)) {
- if(tmpsv)
+ if (multiarg ? SvROK(error) : SvROK(tmpsv)) {
+ if (!multiarg)
SvSetSV(error,tmpsv);
- else if(sv_isobject(error)) {
+ else if (sv_isobject(error)) {
HV *stash = SvSTASH(SvRV(error));
GV *gv = gv_fetchmethod(stash, "PROPAGATE");
if (gv) {
- SV *file = sv_2mortal(newSVsv(GvSV(PL_curcop->cop_filegv)));
- SV *line = sv_2mortal(newSViv(PL_curcop->cop_line));
+ SV *file = sv_2mortal(newSVsv(CopFILESV(PL_curcop)));
+ SV *line = sv_2mortal(newSViv(CopLINE(PL_curcop)));
EXTEND(SP, 3);
PUSHMARK(SP);
PUSHs(error);
PUSHs(file);
PUSHs(line);
PUTBACK;
- perl_call_sv((SV*)GvCV(gv),
- G_SCALAR|G_EVAL|G_KEEPERR);
+ call_sv((SV*)GvCV(gv),
+ G_SCALAR|G_EVAL|G_KEEPERR);
sv_setsv(error,*PL_stack_sp--);
}
}
- pat = Nullch;
+ DIE(aTHX_ Nullch);
}
else {
if (SvPOK(error) && SvCUR(error))
sv_catpv(error, "\t...propagated");
- tmps = SvPV(error, PL_na);
+ tmpsv = error;
+ tmps = SvPV(tmpsv, len);
}
}
- if (!tmps || !*tmps)
- tmps = "Died";
- DIE(pat, tmps);
+ if (!tmps || !len)
+ tmpsv = sv_2mortal(newSVpvn("Died", 4));
+
+ DIE(aTHX_ "%_", tmpsv);
}
/* I/O. */
djSP; dTARGET;
GV *gv;
SV *sv;
+ SV *name;
+ I32 have_name = 0;
char *tmps;
STRLEN len;
+ MAGIC *mg;
+ if (MAXARG > 2) {
+ name = POPs;
+ have_name = 1;
+ }
if (MAXARG > 1)
sv = POPs;
if (!isGV(TOPs))
- DIE(no_usym, "filehandle");
+ DIE(aTHX_ PL_no_usym, "filehandle");
if (MAXARG <= 1)
sv = GvSV(TOPs);
gv = (GV*)POPs;
if (!isGV(gv))
- DIE(no_usym, "filehandle");
+ DIE(aTHX_ PL_no_usym, "filehandle");
if (GvIOp(gv))
IoFLAGS(GvIOp(gv)) &= ~IOf_UNTAINT;
+
+ if (mg = SvTIED_mg((SV*)gv, 'q')) {
+ PUSHMARK(SP);
+ XPUSHs(SvTIED_obj((SV*)gv, mg));
+ XPUSHs(sv);
+ if (have_name)
+ XPUSHs(name);
+ PUTBACK;
+ ENTER;
+ call_method("OPEN", G_SCALAR);
+ LEAVE;
+ SPAGAIN;
+ RETURN;
+ }
+
tmps = SvPV(sv, len);
- if (do_open(gv, tmps, len, FALSE, O_RDONLY, 0, Nullfp))
+ if (do_open9(gv, tmps, len, FALSE, O_RDONLY, 0, Nullfp, name, have_name))
PUSHi( (I32)PL_forkprocess );
else if (PL_forkprocess == 0) /* we are a new child */
PUSHi(0);
else
gv = (GV*)POPs;
- if (SvRMAGICAL(gv) && (mg = mg_find((SV*)gv, 'q'))) {
+ if (mg = SvTIED_mg((SV*)gv, 'q')) {
PUSHMARK(SP);
- XPUSHs(mg->mg_obj);
+ XPUSHs(SvTIED_obj((SV*)gv, mg));
PUTBACK;
ENTER;
- perl_call_method("CLOSE", G_SCALAR);
+ call_method("CLOSE", G_SCALAR);
LEAVE;
SPAGAIN;
RETURN;
goto badexit;
if (SvTYPE(rgv) != SVt_PVGV || SvTYPE(wgv) != SVt_PVGV)
- DIE(no_usym, "filehandle");
+ DIE(aTHX_ PL_no_usym, "filehandle");
rstio = GvIOn(rgv);
wstio = GvIOn(wgv);
else PerlLIO_close(fd[1]);
goto badexit;
}
-
+#if defined(HAS_FCNTL) && defined(F_SETFD)
+ fcntl(fd[0],F_SETFD,fd[0] > PL_maxsysfd); /* ensure close-on-exec */
+ fcntl(fd[1],F_SETFD,fd[1] > PL_maxsysfd); /* ensure close-on-exec */
+#endif
RETPUSHYES;
badexit:
RETPUSHUNDEF;
#else
- DIE(no_func, "pipe");
+ DIE(aTHX_ PL_no_func, "pipe");
#endif
}
GV *gv;
IO *io;
PerlIO *fp;
+ MAGIC *mg;
+
if (MAXARG < 1)
RETPUSHUNDEF;
gv = (GV*)POPs;
+
+ if (gv && (mg = SvTIED_mg((SV*)gv, 'q'))) {
+ PUSHMARK(SP);
+ XPUSHs(SvTIED_obj((SV*)gv, mg));
+ PUTBACK;
+ ENTER;
+ call_method("FILENO", G_SCALAR);
+ LEAVE;
+ SPAGAIN;
+ RETURN;
+ }
+
if (!gv || !(io = GvIO(gv)) || !(fp = IoIFP(io)))
RETPUSHUNDEF;
PUSHi(PerlIO_fileno(fp));
PP(pp_umask)
{
djSP; dTARGET;
- int anum;
+ Mode_t anum;
#ifdef HAS_UMASK
if (MAXARG < 1) {
* Otherwise it's harmless and more useful to just return undef
* since 'group' and 'other' concepts probably don't exist here. */
if (MAXARG >= 1 && (POPi & 0700))
- DIE("umask not implemented");
+ DIE(aTHX_ "umask not implemented");
XPUSHs(&PL_sv_undef);
#endif
RETURN;
GV *gv;
IO *io;
PerlIO *fp;
+ MAGIC *mg;
if (MAXARG < 1)
RETPUSHUNDEF;
- gv = (GV*)POPs;
+ gv = (GV*)POPs;
+
+ if (gv && (mg = SvTIED_mg((SV*)gv, 'q'))) {
+ PUSHMARK(SP);
+ XPUSHs(SvTIED_obj((SV*)gv, mg));
+ PUTBACK;
+ ENTER;
+ call_method("BINMODE", G_SCALAR);
+ LEAVE;
+ SPAGAIN;
+ RETURN;
+ }
EXTEND(SP, 1);
if (!(io = GvIO(gv)) || !(fp = IoIFP(io)))
char *methname;
int how = 'P';
U32 items;
+ STRLEN n_a;
varsv = *++MARK;
switch(SvTYPE(varsv)) {
while (items--)
PUSHs(*MARK++);
PUTBACK;
- perl_call_method(methname, G_SCALAR);
+ call_method(methname, G_SCALAR);
}
else {
- /* Not clear why we don't call perl_call_method here too.
+ /* Not clear why we don't call call_method here too.
* perhaps to get different error message ?
*/
stash = gv_stashsv(*MARK, FALSE);
if (!stash || !(gv = gv_fetchmethod(stash, methname))) {
- DIE("Can't locate object method \"%s\" via package \"%s\"",
- methname, SvPV(*MARK,PL_na));
+ DIE(aTHX_ "Can't locate object method \"%s\" via package \"%s\"",
+ methname, SvPV(*MARK,n_a));
}
ENTER;
PUSHSTACKi(PERLSI_MAGIC);
while (items--)
PUSHs(*MARK++);
PUTBACK;
- perl_call_sv((SV*)GvCV(gv), G_SCALAR);
+ call_sv((SV*)GvCV(gv), G_SCALAR);
}
SPAGAIN;
sv = TOPs;
POPSTACK;
if (sv_isobject(sv)) {
- sv_unmagic(varsv, how);
- sv_magic(varsv, sv, how, Nullch, 0);
+ sv_unmagic(varsv, how);
+ sv_magic(varsv, (SvRV(sv) == varsv ? Nullsv : sv), how, Nullch, 0);
}
LEAVE;
SP = PL_stack_base + markoff;
PP(pp_untie)
{
djSP;
- SV * sv ;
-
- sv = POPs;
+ SV *sv = POPs;
+ char how = (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV) ? 'P' : 'q';
if (ckWARN(WARN_UNTIE)) {
MAGIC * mg ;
- if (SvMAGICAL(sv)) {
- if (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV)
- mg = mg_find(sv, 'P') ;
- else
- mg = mg_find(sv, 'q') ;
-
+ if (mg = SvTIED_mg(sv, how)) {
if (mg && SvREFCNT(SvRV(mg->mg_obj)) > 1)
- warner(WARN_UNTIE,
- "untie attempted while %lu inner references still exist",
- (unsigned long)SvREFCNT(SvRV(mg->mg_obj)) - 1 ) ;
+ Perl_warner(aTHX_ WARN_UNTIE,
+ "untie attempted while %"UVuf" inner references still exist",
+ (UV)SvREFCNT(SvRV(mg->mg_obj)) - 1 ) ;
}
}
- if (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV)
- sv_unmagic(sv, 'P');
- else
- sv_unmagic(sv, 'q');
+ sv_unmagic(sv, how);
RETPUSHYES;
}
PP(pp_tied)
{
djSP;
- SV * sv ;
- MAGIC * mg ;
+ SV *sv = POPs;
+ char how = (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV) ? 'P' : 'q';
+ MAGIC *mg;
- sv = POPs;
- if (SvMAGICAL(sv)) {
- if (SvTYPE(sv) == SVt_PVHV || SvTYPE(sv) == SVt_PVAV)
- mg = mg_find(sv, 'P') ;
- else
- mg = mg_find(sv, 'q') ;
-
- if (mg) {
- PUSHs(sv_2mortal(newSVsv(mg->mg_obj))) ;
- RETURN ;
- }
+ if (mg = SvTIED_mg(sv, how)) {
+ SV *osv = SvTIED_obj(sv, mg);
+ if (osv == mg->mg_obj)
+ osv = sv_mortalcopy(osv);
+ PUSHs(osv);
+ RETURN;
}
RETPUSHUNDEF;
}
stash = gv_stashsv(sv, FALSE);
if (!stash || !(gv = gv_fetchmethod(stash, "TIEHASH"))) {
PUTBACK;
- perl_require_pv("AnyDBM_File.pm");
+ require_pv("AnyDBM_File.pm");
SPAGAIN;
if (!(gv = gv_fetchmethod(stash, "TIEHASH")))
- DIE("No dbm on this machine");
+ DIE(aTHX_ "No dbm on this machine");
}
ENTER;
PUSHs(sv_2mortal(newSViv(O_RDWR)));
PUSHs(right);
PUTBACK;
- perl_call_sv((SV*)GvCV(gv), G_SCALAR);
+ call_sv((SV*)GvCV(gv), G_SCALAR);
SPAGAIN;
if (!sv_isobject(TOPs)) {
PUSHs(sv_2mortal(newSViv(O_RDONLY)));
PUSHs(right);
PUTBACK;
- perl_call_sv((SV*)GvCV(gv), G_SCALAR);
+ call_sv((SV*)GvCV(gv), G_SCALAR);
SPAGAIN;
}
PP(pp_dbmclose)
{
- return pp_untie(ARGS);
+ return pp_untie();
}
PP(pp_sselect)
register I32 j;
register char *s;
register SV *sv;
- double value;
+ NV value;
I32 maxlen = 0;
I32 nfound;
struct timeval timebuf;
struct timeval *tbuf = &timebuf;
I32 growsize;
char *fd_sets[4];
+ STRLEN n_a;
#if BYTEORDER != 0x1234 && BYTEORDER != 0x12345678
I32 masksize;
I32 offset;
/* little endians can use vecs directly */
#if BYTEORDER == 0x1234 || BYTEORDER == 0x12345678
# if SELECT_MIN_BITS > 1
- growsize = SELECT_MIN_BITS / 8;
+ /* If SELECT_MIN_BITS is greater than one we most probably will want
+ * to align the sizes with SELECT_MIN_BITS/8 because for example
+ * in many little-endian (Intel, Alpha) systems (Linux, OS/2, Digital
+ * UNIX, Solaris, NeXT, Rhapsody) the smallest quantum select() operates
+ * on (sets/tests/clears bits) is 32 bits. */
+ growsize = maxlen + (SELECT_MIN_BITS/8 - (maxlen % (SELECT_MIN_BITS/8)));
# else
growsize = sizeof(fd_set);
# endif
if (value < 0.0)
value = 0.0;
timebuf.tv_sec = (long)value;
- value -= (double)timebuf.tv_sec;
+ value -= (NV)timebuf.tv_sec;
timebuf.tv_usec = (long)(value * 1000000.0);
}
else
continue;
}
else if (!SvPOK(sv))
- SvPV_force(sv,PL_na); /* force string conversion */
+ SvPV_force(sv,n_a); /* force string conversion */
j = SvLEN(sv);
if (j < growsize) {
Sv_Grow(sv, growsize);
PUSHi(nfound);
if (GIMME == G_ARRAY && tbuf) {
- value = (double)(timebuf.tv_sec) +
- (double)(timebuf.tv_usec) / 1000000.0;
+ value = (NV)(timebuf.tv_sec) +
+ (NV)(timebuf.tv_usec) / 1000000.0;
PUSHs(sv = sv_mortalcopy(&PL_sv_no));
sv_setnv(sv, value);
}
RETURN;
#else
- DIE("select not implemented");
+ DIE(aTHX_ "select not implemented");
#endif
}
void
-setdefout(GV *gv)
+Perl_setdefout(pTHX_ GV *gv)
{
dTHR;
if (gv)
if (!gv)
gv = PL_argvgv;
- if (SvRMAGICAL(gv) && (mg = mg_find((SV*)gv, 'q'))) {
+ if (mg = SvTIED_mg((SV*)gv, 'q')) {
I32 gimme = GIMME_V;
PUSHMARK(SP);
- XPUSHs(mg->mg_obj);
+ XPUSHs(SvTIED_obj((SV*)gv, mg));
PUTBACK;
ENTER;
- perl_call_method("GETC", gimme);
+ call_method("GETC", gimme);
LEAVE;
SPAGAIN;
if (gimme == G_SCALAR)
PP(pp_read)
{
- return pp_sysread(ARGS);
+ return pp_sysread();
}
STATIC OP *
-doform(CV *cv, GV *gv, OP *retop)
+S_doform(pTHX_ CV *cv, GV *gv, OP *retop)
{
dTHR;
register PERL_CONTEXT *cx;
if (fgv) {
SV *tmpsv = sv_newmortal();
gv_efullname3(tmpsv, fgv, Nullch);
- DIE("Undefined format \"%s\" called",SvPVX(tmpsv));
+ DIE(aTHX_ "Undefined format \"%s\" called",SvPVX(tmpsv));
}
- DIE("Not a format reference");
+ DIE(aTHX_ "Not a format reference");
}
if (CvCLONE(cv))
cv = (CV*)sv_2mortal((SV*)cv_clone(cv));
if (!IoTOP_NAME(io)) {
if (!IoFMT_NAME(io))
IoFMT_NAME(io) = savepv(GvNAME(gv));
- topname = sv_2mortal(newSVpvf("%s_TOP", IoFMT_NAME(io)));
+ topname = sv_2mortal(Perl_newSVpvf(aTHX_ "%s_TOP", IoFMT_NAME(io)));
topgv = gv_fetchpv(SvPVX(topname), FALSE, SVt_PVFM);
if ((topgv && GvFORM(topgv)) ||
!gv_fetchpv("top",FALSE,SVt_PVFM))
IoFLAGS(io) |= IOf_DIDTOP;
fgv = IoTOP_GV(io);
if (!fgv)
- DIE("bad top format reference");
+ DIE(aTHX_ "bad top format reference");
cv = GvFORM(fgv);
if (!cv) {
SV *tmpsv = sv_newmortal();
gv_efullname3(tmpsv, fgv, Nullch);
- DIE("Undefined top format \"%s\" called",SvPVX(tmpsv));
+ DIE(aTHX_ "Undefined top format \"%s\" called",SvPVX(tmpsv));
}
if (CvCLONE(cv))
cv = (CV*)sv_2mortal((SV*)cv_clone(cv));
fp = IoOFP(io);
if (!fp) {
if (ckWARN2(WARN_CLOSED,WARN_IO)) {
+ SV* sv = sv_newmortal();
+ gv_efullname3(sv, gv, Nullch);
if (IoIFP(io))
- warner(WARN_IO, "Filehandle only opened for input");
+ Perl_warner(aTHX_ WARN_IO,
+ "Filehandle %s opened only for input",
+ SvPV_nolen(sv));
else if (ckWARN(WARN_CLOSED))
- warner(WARN_CLOSED, "Write on closed filehandle");
+ Perl_warner(aTHX_ WARN_CLOSED,
+ "Write on closed filehandle %s", SvPV_nolen(sv));
}
PUSHs(&PL_sv_no);
}
else {
if ((IoLINES_LEFT(io) -= FmLINES(PL_formtarget)) < 0) {
if (ckWARN(WARN_IO))
- warner(WARN_IO, "page overflow");
+ Perl_warner(aTHX_ WARN_IO, "page overflow");
}
if (!PerlIO_write(ofp, SvPVX(PL_formtarget), SvCUR(PL_formtarget)) ||
PerlIO_error(fp))
PerlIO *fp;
SV *sv;
MAGIC *mg;
+ STRLEN n_a;
if (PL_op->op_flags & OPf_STACKED)
gv = (GV*)*++MARK;
else
gv = PL_defoutgv;
- if (SvRMAGICAL(gv) && (mg = mg_find((SV*)gv, 'q'))) {
+ if (mg = SvTIED_mg((SV*)gv, 'q')) {
if (MARK == ORIGMARK) {
MEXTEND(SP, 1);
++MARK;
++SP;
}
PUSHMARK(MARK - 1);
- *MARK = mg->mg_obj;
+ *MARK = SvTIED_obj((SV*)gv, mg);
PUTBACK;
ENTER;
- perl_call_method("PRINTF", G_SCALAR);
+ call_method("PRINTF", G_SCALAR);
LEAVE;
SPAGAIN;
MARK = ORIGMARK + 1;
sv = NEWSV(0,0);
if (!(io = GvIO(gv))) {
if (ckWARN(WARN_UNOPENED)) {
- gv_fullname3(sv, gv, Nullch);
- warner(WARN_UNOPENED, "Filehandle %s never opened", SvPV(sv,PL_na));
+ gv_efullname3(sv, gv, Nullch);
+ Perl_warner(aTHX_ WARN_UNOPENED,
+ "Filehandle %s never opened", SvPV(sv,n_a));
}
SETERRNO(EBADF,RMS$_IFI);
goto just_say_no;
}
else if (!(fp = IoOFP(io))) {
if (ckWARN2(WARN_CLOSED,WARN_IO)) {
- gv_fullname3(sv, gv, Nullch);
+ gv_efullname3(sv, gv, Nullch);
if (IoIFP(io))
- warner(WARN_IO, "Filehandle %s opened only for input",
- SvPV(sv,PL_na));
+ Perl_warner(aTHX_ WARN_IO,
+ "Filehandle %s opened only for input",
+ SvPV(sv,n_a));
else if (ckWARN(WARN_CLOSED))
- warner(WARN_CLOSED, "printf on closed filehandle %s",
- SvPV(sv,PL_na));
+ Perl_warner(aTHX_ WARN_CLOSED,
+ "printf on closed filehandle %s", SvPV(sv,n_a));
}
SETERRNO(EBADF,IoIFP(io)?RMS$_FAC:RMS$_IFI);
goto just_say_no;
}
else {
-#ifdef USE_LOCALE_NUMERIC
- if (PL_op->op_private & OPpLOCALE)
- SET_NUMERIC_LOCAL();
- else
- SET_NUMERIC_STANDARD();
-#endif
do_sprintf(sv, SP - MARK, MARK + 1);
if (!do_print(sv, fp))
goto just_say_no;
sv = POPs;
gv = (GV *)POPs;
+ /* Need TIEHANDLE method ? */
+
tmps = SvPV(sv, len);
if (do_open(gv, tmps, len, TRUE, mode, perm, Nullfp)) {
IoLINES(GvIOp(gv)) = 0;
gv = (GV*)*++MARK;
if ((PL_op->op_type == OP_READ || PL_op->op_type == OP_SYSREAD) &&
- SvRMAGICAL(gv) && (mg = mg_find((SV*)gv, 'q')))
+ (mg = SvTIED_mg((SV*)gv, 'q')))
{
SV *sv;
PUSHMARK(MARK-1);
- *MARK = mg->mg_obj;
+ *MARK = SvTIED_obj((SV*)gv, mg);
ENTER;
- perl_call_method("READ", G_SCALAR);
+ call_method("READ", G_SCALAR);
LEAVE;
SPAGAIN;
sv = POPs;
buffer = SvPV_force(bufsv, blen);
length = SvIVx(*++MARK);
if (length < 0)
- DIE("Negative length");
+ DIE(aTHX_ "Negative length");
SETERRNO(0,0);
if (MARK < SP)
offset = SvIVx(*++MARK);
#else
bufsize = sizeof namebuf;
#endif
+#ifdef OS2 /* At least Warp3+IAK: only the first byte of bufsize set */
+ if (bufsize >= 256)
+ bufsize = 255;
+#endif
+#ifdef OS2 /* At least Warp3+IAK: only the first byte of bufsize set */
+ if (bufsize >= 256)
+ bufsize = 255;
+#endif
buffer = SvGROW(bufsv, length+1);
/* 'offset' means 'flags' here */
length = PerlSock_recvfrom(PerlIO_fileno(IoIFP(io)), buffer, length, offset,
}
#else
if (PL_op->op_type == OP_RECV)
- DIE(no_sock_func, "recv");
+ DIE(aTHX_ PL_no_sock_func, "recv");
#endif
if (offset < 0) {
if (-offset > blen)
- DIE("Offset outside string");
+ DIE(aTHX_ "Offset outside string");
offset += blen;
}
bufsize = SvCUR(bufsv);
Zero(buffer+bufsize, offset-bufsize, char);
}
if (PL_op->op_type == OP_SYSREAD) {
- length = PerlLIO_read(PerlIO_fileno(IoIFP(io)), buffer+offset, length);
+#ifdef PERL_SOCK_SYSREAD_IS_RECV
+ if (IoTYPE(io) == 's') {
+ length = PerlSock_recv(PerlIO_fileno(IoIFP(io)),
+ buffer+offset, length, 0);
+ }
+ else
+#endif
+ {
+ length = PerlLIO_read(PerlIO_fileno(IoIFP(io)),
+ buffer+offset, length);
+ }
}
else
#ifdef HAS_SOCKET__bad_code_maybe
if (length == 0 && PerlIO_error(IoIFP(io)))
length = -1;
}
- if (length < 0)
+ if (length < 0) {
+ if ((IoTYPE(io) == '>' || IoIFP(io) == PerlIO_stdout()
+ || IoIFP(io) == PerlIO_stderr()) && ckWARN(WARN_IO))
+ {
+ SV* sv = sv_newmortal();
+ gv_efullname3(sv, gv, Nullch);
+ Perl_warner(aTHX_ WARN_IO, "Filehandle %s opened only for output",
+ SvPV_nolen(sv));
+ }
goto say_undef;
+ }
SvCUR_set(bufsv, length+offset);
*SvEND(bufsv) = '\0';
(void)SvPOK_only(bufsv);
PP(pp_syswrite)
{
- return pp_send(ARGS);
+ djSP;
+ int items = (SP - PL_stack_base) - TOPMARK;
+ if (items == 2) {
+ SV *sv;
+ EXTEND(SP, 1);
+ sv = sv_2mortal(newSViv(sv_len(*SP)));
+ PUSHs(sv);
+ PUTBACK;
+ }
+ return pp_send();
}
PP(pp_send)
djSP; dMARK; dORIGMARK; dTARGET;
GV *gv;
IO *io;
- int offset;
+ STRLEN offset;
SV *bufsv;
char *buffer;
- int length;
+ STRLEN length;
STRLEN blen;
MAGIC *mg;
gv = (GV*)*++MARK;
- if (PL_op->op_type == OP_SYSWRITE &&
- SvRMAGICAL(gv) && (mg = mg_find((SV*)gv, 'q')))
- {
+ if (PL_op->op_type == OP_SYSWRITE && (mg = SvTIED_mg((SV*)gv, 'q'))) {
SV *sv;
PUSHMARK(MARK-1);
- *MARK = mg->mg_obj;
+ *MARK = SvTIED_obj((SV*)gv, mg);
ENTER;
- perl_call_method("WRITE", G_SCALAR);
+ call_method("WRITE", G_SCALAR);
LEAVE;
SPAGAIN;
sv = POPs;
buffer = SvPV(bufsv, blen);
length = SvIVx(*++MARK);
if (length < 0)
- DIE("Negative length");
+ DIE(aTHX_ "Negative length");
SETERRNO(0,0);
io = GvIO(gv);
if (!io || !IoIFP(io)) {
length = -1;
if (ckWARN(WARN_CLOSED)) {
if (PL_op->op_type == OP_SYSWRITE)
- warner(WARN_CLOSED, "Syswrite on closed filehandle");
+ Perl_warner(aTHX_ WARN_CLOSED, "Syswrite on closed filehandle");
else
- warner(WARN_CLOSED, "Send on closed socket");
+ Perl_warner(aTHX_ WARN_CLOSED, "Send on closed socket");
}
}
else if (PL_op->op_type == OP_SYSWRITE) {
offset = SvIVx(*++MARK);
if (offset < 0) {
if (-offset > blen)
- DIE("Offset outside string");
+ DIE(aTHX_ "Offset outside string");
offset += blen;
} else if (offset >= blen && blen > 0)
- DIE("Offset outside string");
+ DIE(aTHX_ "Offset outside string");
} else
offset = 0;
if (length > blen - offset)
length = blen - offset;
- length = PerlLIO_write(PerlIO_fileno(IoIFP(io)), buffer+offset, length);
+#ifdef PERL_SOCK_SYSWRITE_IS_SEND
+ if (IoTYPE(io) == 's') {
+ length = PerlSock_send(PerlIO_fileno(IoIFP(io)),
+ buffer+offset, length, 0);
+ }
+ else
+#endif
+ {
+ /* See the note at doio.c:do_print about filesize limits. --jhi */
+ length = PerlLIO_write(PerlIO_fileno(IoIFP(io)),
+ buffer+offset, length);
+ }
}
#ifdef HAS_SOCKET
else if (SP > MARK) {
#else
else
- DIE(no_sock_func, "send");
+ DIE(aTHX_ PL_no_sock_func, "send");
#endif
if (length < 0)
goto say_undef;
PP(pp_recv)
{
- return pp_sysread(ARGS);
+ return pp_sysread();
}
PP(pp_eof)
{
djSP;
GV *gv;
+ MAGIC *mg;
if (MAXARG <= 0)
gv = PL_last_in_gv;
else
gv = PL_last_in_gv = (GV*)POPs;
+
+ if (gv && (mg = SvTIED_mg((SV*)gv, 'q'))) {
+ PUSHMARK(SP);
+ XPUSHs(SvTIED_obj((SV*)gv, mg));
+ PUTBACK;
+ ENTER;
+ call_method("EOF", G_SCALAR);
+ LEAVE;
+ SPAGAIN;
+ RETURN;
+ }
+
PUSHs(boolSV(!gv || do_eof(gv)));
RETURN;
}
PP(pp_tell)
{
djSP; dTARGET;
- GV *gv;
+ GV *gv;
+ MAGIC *mg;
if (MAXARG <= 0)
gv = PL_last_in_gv;
else
gv = PL_last_in_gv = (GV*)POPs;
+
+ if (gv && (mg = SvTIED_mg((SV*)gv, 'q'))) {
+ PUSHMARK(SP);
+ XPUSHs(SvTIED_obj((SV*)gv, mg));
+ PUTBACK;
+ ENTER;
+ call_method("TELL", G_SCALAR);
+ LEAVE;
+ SPAGAIN;
+ RETURN;
+ }
+
+#if LSEEKSIZE > IVSIZE
+ PUSHn( do_tell(gv) );
+#else
PUSHi( do_tell(gv) );
+#endif
RETURN;
}
PP(pp_seek)
{
- return pp_sysseek(ARGS);
+ return pp_sysseek();
}
PP(pp_sysseek)
djSP;
GV *gv;
int whence = POPi;
- long offset = POPl;
+#if LSEEKSIZE > IVSIZE
+ Off_t offset = (Off_t)SvNVx(POPs);
+#else
+ Off_t offset = (Off_t)SvIVx(POPs);
+#endif
+ MAGIC *mg;
gv = PL_last_in_gv = (GV*)POPs;
+
+ if (gv && (mg = SvTIED_mg((SV*)gv, 'q'))) {
+ PUSHMARK(SP);
+ XPUSHs(SvTIED_obj((SV*)gv, mg));
+ XPUSHs(sv_2mortal(newSViv((IV) offset)));
+ XPUSHs(sv_2mortal(newSViv((IV) whence)));
+ PUTBACK;
+ ENTER;
+ call_method("SEEK", G_SCALAR);
+ LEAVE;
+ SPAGAIN;
+ RETURN;
+ }
+
if (PL_op->op_type == OP_SEEK)
PUSHs(boolSV(do_seek(gv, offset, whence)));
else {
- long n = do_sysseek(gv, offset, whence);
- PUSHs((n < 0) ? &PL_sv_undef
- : sv_2mortal(n ? newSViv((IV)n)
- : newSVpv(zero_but_true, ZBTLEN)));
+ Off_t n = do_sysseek(gv, offset, whence);
+ if (n < 0)
+ PUSHs(&PL_sv_undef);
+ else {
+ SV* sv = n ?
+#if LSEEKSIZE > IVSIZE
+ newSVnv((NV)n)
+#else
+ newSViv((IV)n)
+#endif
+ : newSVpvn(zero_but_true, ZBTLEN);
+ PUSHs(sv_2mortal(sv));
+ }
}
RETURN;
}
Off_t len = (Off_t)POPn;
int result = 1;
GV *tmpgv;
+ STRLEN n_a;
SETERRNO(0,0);
#if defined(HAS_TRUNCATE) || defined(HAS_CHSIZE) || defined(F_FREESP)
if (PL_op->op_flags & OPf_SPECIAL) {
- tmpgv = gv_fetchpv(POPp, FALSE, SVt_PVIO);
+ tmpgv = gv_fetchpv(POPpx, FALSE, SVt_PVIO);
do_ftruncate:
TAINT_PROPER("truncate");
if (!GvIO(tmpgv) || !IoIFP(GvIOp(tmpgv)) ||
else {
SV *sv = POPs;
char *name;
+ STRLEN n_a;
if (SvTYPE(sv) == SVt_PVGV) {
tmpgv = (GV*)sv; /* *main::FRED for example */
goto do_ftruncate;
}
- name = SvPV(sv, PL_na);
+ name = SvPV(sv, n_a);
TAINT_PROPER("truncate");
#ifdef HAS_TRUNCATE
if (truncate(name, len) < 0)
SETERRNO(EBADF,RMS$_IFI);
RETPUSHUNDEF;
#else
- DIE("truncate not implemented");
+ DIE(aTHX_ "truncate not implemented");
#endif
}
PP(pp_fcntl)
{
- return pp_ioctl(ARGS);
+ return pp_ioctl();
}
PP(pp_ioctl)
}
else {
retval = SvIV(argsv);
- s = (char*)retval; /* ouch */
+ s = INT2PTR(char*,retval); /* ouch */
}
TAINT_PROPER(optype == OP_IOCTL ? "ioctl" : "fcntl");
#ifdef HAS_IOCTL
retval = PerlLIO_ioctl(PerlIO_fileno(IoIFP(io)), func, s);
#else
- DIE("ioctl is not implemented");
+ DIE(aTHX_ "ioctl is not implemented");
#endif
else
#ifdef HAS_FCNTL
retval = fcntl(PerlIO_fileno(IoIFP(io)), func, s);
#endif
#else
- DIE("fcntl is not implemented");
+ DIE(aTHX_ "fcntl is not implemented");
#endif
if (SvPOK(argsv)) {
if (s[SvCUR(argsv)] != 17)
- DIE("Possible memory corruption: %s overflowed 3rd argument",
- op_name[optype]);
+ DIE(aTHX_ "Possible memory corruption: %s overflowed 3rd argument",
+ PL_op_name[optype]);
s[SvCUR(argsv)] = 0; /* put our null back */
SvSETMAGIC(argsv); /* Assume it has changed */
}
PUSHi(value);
RETURN;
#else
- DIE(no_func, "flock()");
+ DIE(aTHX_ PL_no_func, "flock()");
#endif
}
RETPUSHYES;
#else
- DIE(no_sock_func, "socket");
+ DIE(aTHX_ PL_no_sock_func, "socket");
#endif
}
RETPUSHYES;
#else
- DIE(no_sock_func, "socketpair");
+ DIE(aTHX_ PL_no_sock_func, "socketpair");
#endif
}
nuts:
if (ckWARN(WARN_CLOSED))
- warner(WARN_CLOSED, "bind() on closed fd");
+ Perl_warner(aTHX_ WARN_CLOSED, "bind() on closed fd");
SETERRNO(EBADF,SS$_IVCHAN);
RETPUSHUNDEF;
#else
- DIE(no_sock_func, "bind");
+ DIE(aTHX_ PL_no_sock_func, "bind");
#endif
}
nuts:
if (ckWARN(WARN_CLOSED))
- warner(WARN_CLOSED, "connect() on closed fd");
+ Perl_warner(aTHX_ WARN_CLOSED, "connect() on closed fd");
SETERRNO(EBADF,SS$_IVCHAN);
RETPUSHUNDEF;
#else
- DIE(no_sock_func, "connect");
+ DIE(aTHX_ PL_no_sock_func, "connect");
#endif
}
nuts:
if (ckWARN(WARN_CLOSED))
- warner(WARN_CLOSED, "listen() on closed fd");
+ Perl_warner(aTHX_ WARN_CLOSED, "listen() on closed fd");
SETERRNO(EBADF,SS$_IVCHAN);
RETPUSHUNDEF;
#else
- DIE(no_sock_func, "listen");
+ DIE(aTHX_ PL_no_sock_func, "listen");
#endif
}
nuts:
if (ckWARN(WARN_CLOSED))
- warner(WARN_CLOSED, "accept() on closed fd");
+ Perl_warner(aTHX_ WARN_CLOSED, "accept() on closed fd");
SETERRNO(EBADF,SS$_IVCHAN);
badexit:
RETPUSHUNDEF;
#else
- DIE(no_sock_func, "accept");
+ DIE(aTHX_ PL_no_sock_func, "accept");
#endif
}
nuts:
if (ckWARN(WARN_CLOSED))
- warner(WARN_CLOSED, "shutdown() on closed fd");
+ Perl_warner(aTHX_ WARN_CLOSED, "shutdown() on closed fd");
SETERRNO(EBADF,SS$_IVCHAN);
RETPUSHUNDEF;
#else
- DIE(no_sock_func, "shutdown");
+ DIE(aTHX_ PL_no_sock_func, "shutdown");
#endif
}
PP(pp_gsockopt)
{
#ifdef HAS_SOCKET
- return pp_ssockopt(ARGS);
+ return pp_ssockopt();
#else
- DIE(no_sock_func, "getsockopt");
+ DIE(aTHX_ PL_no_sock_func, "getsockopt");
#endif
}
char *buf;
int aint;
if (SvPOKp(sv)) {
- buf = SvPV(sv, PL_na);
- len = PL_na;
+ STRLEN l;
+ buf = SvPV(sv, l);
+ len = l;
}
else {
aint = (int)SvIV(sv);
nuts:
if (ckWARN(WARN_CLOSED))
- warner(WARN_CLOSED, "[gs]etsockopt() on closed fd");
+ Perl_warner(aTHX_ WARN_CLOSED, "[gs]etsockopt() on closed fd");
SETERRNO(EBADF,SS$_IVCHAN);
nuts2:
RETPUSHUNDEF;
#else
- DIE(no_sock_func, "setsockopt");
+ DIE(aTHX_ PL_no_sock_func, "setsockopt");
#endif
}
PP(pp_getsockname)
{
#ifdef HAS_SOCKET
- return pp_getpeername(ARGS);
+ return pp_getpeername();
#else
- DIE(no_sock_func, "getsockname");
+ DIE(aTHX_ PL_no_sock_func, "getsockname");
#endif
}
nuts:
if (ckWARN(WARN_CLOSED))
- warner(WARN_CLOSED, "get{sock, peer}name() on closed fd");
+ Perl_warner(aTHX_ WARN_CLOSED, "get{sock, peer}name() on closed fd");
SETERRNO(EBADF,SS$_IVCHAN);
nuts2:
RETPUSHUNDEF;
#else
- DIE(no_sock_func, "getpeername");
+ DIE(aTHX_ PL_no_sock_func, "getpeername");
#endif
}
PP(pp_lstat)
{
- return pp_stat(ARGS);
+ return pp_stat();
}
PP(pp_stat)
GV *tmpgv;
I32 gimme;
I32 max = 13;
+ STRLEN n_a;
if (PL_op->op_flags & OPf_REF) {
- tmpgv = cGVOP->op_gv;
+ tmpgv = cGVOP;
do_fstat:
if (tmpgv != PL_defgv) {
PL_laststype = OP_STAT;
tmpgv = (GV*)SvRV(sv);
goto do_fstat;
}
- sv_setpv(PL_statname, SvPV(sv,PL_na));
+ sv_setpv(PL_statname, SvPV(sv,n_a));
PL_statgv = Nullgv;
#ifdef HAS_LSTAT
PL_laststype = PL_op->op_type;
if (PL_op->op_type == OP_LSTAT)
- PL_laststatval = PerlLIO_lstat(SvPV(PL_statname, PL_na), &PL_statcache);
+ PL_laststatval = PerlLIO_lstat(SvPV(PL_statname, n_a), &PL_statcache);
else
#endif
- PL_laststatval = PerlLIO_stat(SvPV(PL_statname, PL_na), &PL_statcache);
+ PL_laststatval = PerlLIO_stat(SvPV(PL_statname, n_a), &PL_statcache);
if (PL_laststatval < 0) {
- if (ckWARN(WARN_NEWLINE) && strchr(SvPV(PL_statname, PL_na), '\n'))
- warner(WARN_NEWLINE, warn_nl, "stat");
+ if (ckWARN(WARN_NEWLINE) && strchr(SvPV(PL_statname, n_a), '\n'))
+ Perl_warner(aTHX_ WARN_NEWLINE, PL_warn_nl, "stat");
max = 0;
}
}
if (max) {
EXTEND(SP, max);
EXTEND_MORTAL(max);
- PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_dev)));
- PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_ino)));
- PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_mode)));
- PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_nlink)));
- PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_uid)));
- PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_gid)));
+ PUSHs(sv_2mortal(newSViv(PL_statcache.st_dev)));
+ PUSHs(sv_2mortal(newSViv(PL_statcache.st_ino)));
+ PUSHs(sv_2mortal(newSViv(PL_statcache.st_mode)));
+ PUSHs(sv_2mortal(newSViv(PL_statcache.st_nlink)));
+#if Uid_t_size > IVSIZE
+ PUSHs(sv_2mortal(newSVnv(PL_statcache.st_uid)));
+#else
+ PUSHs(sv_2mortal(newSViv(PL_statcache.st_uid)));
+#endif
+#if Gid_t_size > IVSIZE
+ PUSHs(sv_2mortal(newSVnv(PL_statcache.st_gid)));
+#else
+ PUSHs(sv_2mortal(newSViv(PL_statcache.st_gid)));
+#endif
#ifdef USE_STAT_RDEV
- PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_rdev)));
+ PUSHs(sv_2mortal(newSViv(PL_statcache.st_rdev)));
+#else
+ PUSHs(sv_2mortal(newSVpvn("", 0)));
+#endif
+#if Off_t_size > IVSIZE
+ PUSHs(sv_2mortal(newSVnv(PL_statcache.st_size)));
#else
- PUSHs(sv_2mortal(newSVpv("", 0)));
+ PUSHs(sv_2mortal(newSViv(PL_statcache.st_size)));
#endif
- PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_size)));
#ifdef BIG_TIME
- PUSHs(sv_2mortal(newSVnv((U32)PL_statcache.st_atime)));
- PUSHs(sv_2mortal(newSVnv((U32)PL_statcache.st_mtime)));
- PUSHs(sv_2mortal(newSVnv((U32)PL_statcache.st_ctime)));
+ PUSHs(sv_2mortal(newSVnv(PL_statcache.st_atime)));
+ PUSHs(sv_2mortal(newSVnv(PL_statcache.st_mtime)));
+ PUSHs(sv_2mortal(newSVnv(PL_statcache.st_ctime)));
#else
- PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_atime)));
- PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_mtime)));
- PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_ctime)));
+ PUSHs(sv_2mortal(newSViv(PL_statcache.st_atime)));
+ PUSHs(sv_2mortal(newSViv(PL_statcache.st_mtime)));
+ PUSHs(sv_2mortal(newSViv(PL_statcache.st_ctime)));
#endif
#ifdef USE_STAT_BLOCKS
- PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_blksize)));
- PUSHs(sv_2mortal(newSViv((I32)PL_statcache.st_blocks)));
+ PUSHs(sv_2mortal(newSViv(PL_statcache.st_blksize)));
+ PUSHs(sv_2mortal(newSViv(PL_statcache.st_blocks)));
#else
- PUSHs(sv_2mortal(newSVpv("", 0)));
- PUSHs(sv_2mortal(newSVpv("", 0)));
+ PUSHs(sv_2mortal(newSVpvn("", 0)));
+ PUSHs(sv_2mortal(newSVpvn("", 0)));
#endif
}
RETURN;
I32 result;
djSP;
#if defined(HAS_ACCESS) && defined(R_OK)
+ STRLEN n_a;
if ((PL_hints & HINT_FILETEST_ACCESS) && SvPOK(TOPs)) {
- result = access(TOPp, R_OK);
+ result = access(TOPpx, R_OK);
if (result == 0)
RETPUSHYES;
if (result < 0)
RETPUSHUNDEF;
RETPUSHNO;
- } else
- result = my_stat(ARGS);
+ }
+ else
+ result = my_stat();
#else
- result = my_stat(ARGS);
+ result = my_stat();
#endif
+ SPAGAIN;
if (result < 0)
RETPUSHUNDEF;
if (cando(S_IRUSR, 0, &PL_statcache))
I32 result;
djSP;
#if defined(HAS_ACCESS) && defined(W_OK)
+ STRLEN n_a;
if ((PL_hints & HINT_FILETEST_ACCESS) && SvPOK(TOPs)) {
- result = access(TOPp, W_OK);
+ result = access(TOPpx, W_OK);
if (result == 0)
RETPUSHYES;
if (result < 0)
RETPUSHUNDEF;
RETPUSHNO;
- } else
- result = my_stat(ARGS);
+ }
+ else
+ result = my_stat();
#else
- result = my_stat(ARGS);
+ result = my_stat();
#endif
+ SPAGAIN;
if (result < 0)
RETPUSHUNDEF;
if (cando(S_IWUSR, 0, &PL_statcache))
I32 result;
djSP;
#if defined(HAS_ACCESS) && defined(X_OK)
+ STRLEN n_a;
if ((PL_hints & HINT_FILETEST_ACCESS) && SvPOK(TOPs)) {
- result = access(TOPp, X_OK);
+ result = access(TOPpx, X_OK);
if (result == 0)
RETPUSHYES;
if (result < 0)
RETPUSHUNDEF;
RETPUSHNO;
- } else
- result = my_stat(ARGS);
+ }
+ else
+ result = my_stat();
#else
- result = my_stat(ARGS);
+ result = my_stat();
#endif
+ SPAGAIN;
if (result < 0)
RETPUSHUNDEF;
if (cando(S_IXUSR, 0, &PL_statcache))
I32 result;
djSP;
#ifdef PERL_EFF_ACCESS_R_OK
+ STRLEN n_a;
if ((PL_hints & HINT_FILETEST_ACCESS) && SvPOK(TOPs)) {
- result = PERL_EFF_ACCESS_R_OK(TOPp);
+ result = PERL_EFF_ACCESS_R_OK(TOPpx);
if (result == 0)
RETPUSHYES;
if (result < 0)
RETPUSHUNDEF;
RETPUSHNO;
- } else
- result = my_stat(ARGS);
+ }
+ else
+ result = my_stat();
#else
- result = my_stat(ARGS);
+ result = my_stat();
#endif
+ SPAGAIN;
if (result < 0)
RETPUSHUNDEF;
if (cando(S_IRUSR, 1, &PL_statcache))
I32 result;
djSP;
#ifdef PERL_EFF_ACCESS_W_OK
+ STRLEN n_a;
if ((PL_hints & HINT_FILETEST_ACCESS) && SvPOK(TOPs)) {
- result = PERL_EFF_ACCESS_W_OK(TOPp);
+ result = PERL_EFF_ACCESS_W_OK(TOPpx);
if (result == 0)
RETPUSHYES;
if (result < 0)
RETPUSHUNDEF;
RETPUSHNO;
- } else
- result = my_stat(ARGS);
+ }
+ else
+ result = my_stat();
#else
- result = my_stat(ARGS);
+ result = my_stat();
#endif
+ SPAGAIN;
if (result < 0)
RETPUSHUNDEF;
if (cando(S_IWUSR, 1, &PL_statcache))
I32 result;
djSP;
#ifdef PERL_EFF_ACCESS_X_OK
+ STRLEN n_a;
if ((PL_hints & HINT_FILETEST_ACCESS) && SvPOK(TOPs)) {
- result = PERL_EFF_ACCESS_X_OK(TOPp);
+ result = PERL_EFF_ACCESS_X_OK(TOPpx);
if (result == 0)
RETPUSHYES;
if (result < 0)
RETPUSHUNDEF;
RETPUSHNO;
- } else
- result = my_stat(ARGS);
+ }
+ else
+ result = my_stat();
#else
- result = my_stat(ARGS);
+ result = my_stat();
#endif
+ SPAGAIN;
if (result < 0)
RETPUSHUNDEF;
if (cando(S_IXUSR, 1, &PL_statcache))
PP(pp_ftis)
{
- I32 result = my_stat(ARGS);
+ I32 result = my_stat();
djSP;
if (result < 0)
RETPUSHUNDEF;
PP(pp_fteowned)
{
- return pp_ftrowned(ARGS);
+ return pp_ftrowned();
}
PP(pp_ftrowned)
{
- I32 result = my_stat(ARGS);
+ I32 result = my_stat();
djSP;
if (result < 0)
RETPUSHUNDEF;
- if (PL_statcache.st_uid == (PL_op->op_type == OP_FTEOWNED ? PL_euid : PL_uid) )
+ if (PL_statcache.st_uid == (PL_op->op_type == OP_FTEOWNED ?
+ PL_euid : PL_uid) )
RETPUSHYES;
RETPUSHNO;
}
PP(pp_ftzero)
{
- I32 result = my_stat(ARGS);
+ I32 result = my_stat();
djSP;
if (result < 0)
RETPUSHUNDEF;
- if (!PL_statcache.st_size)
+ if (PL_statcache.st_size == 0)
RETPUSHYES;
RETPUSHNO;
}
PP(pp_ftsize)
{
- I32 result = my_stat(ARGS);
+ I32 result = my_stat();
djSP; dTARGET;
if (result < 0)
RETPUSHUNDEF;
+#if Off_t_size > IVSIZE
+ PUSHn(PL_statcache.st_size);
+#else
PUSHi(PL_statcache.st_size);
+#endif
RETURN;
}
PP(pp_ftmtime)
{
- I32 result = my_stat(ARGS);
+ I32 result = my_stat();
djSP; dTARGET;
if (result < 0)
RETPUSHUNDEF;
- PUSHn( ((I32)PL_basetime - (I32)PL_statcache.st_mtime) / 86400.0 );
+ PUSHn( (PL_basetime - PL_statcache.st_mtime) / 86400.0 );
RETURN;
}
PP(pp_ftatime)
{
- I32 result = my_stat(ARGS);
+ I32 result = my_stat();
djSP; dTARGET;
if (result < 0)
RETPUSHUNDEF;
- PUSHn( ((I32)PL_basetime - (I32)PL_statcache.st_atime) / 86400.0 );
+ PUSHn( (PL_basetime - PL_statcache.st_atime) / 86400.0 );
RETURN;
}
PP(pp_ftctime)
{
- I32 result = my_stat(ARGS);
+ I32 result = my_stat();
djSP; dTARGET;
if (result < 0)
RETPUSHUNDEF;
- PUSHn( ((I32)PL_basetime - (I32)PL_statcache.st_ctime) / 86400.0 );
+ PUSHn( (PL_basetime - PL_statcache.st_ctime) / 86400.0 );
RETURN;
}
PP(pp_ftsock)
{
- I32 result = my_stat(ARGS);
+ I32 result = my_stat();
djSP;
if (result < 0)
RETPUSHUNDEF;
PP(pp_ftchr)
{
- I32 result = my_stat(ARGS);
+ I32 result = my_stat();
djSP;
if (result < 0)
RETPUSHUNDEF;
PP(pp_ftblk)
{
- I32 result = my_stat(ARGS);
+ I32 result = my_stat();
djSP;
if (result < 0)
RETPUSHUNDEF;
PP(pp_ftfile)
{
- I32 result = my_stat(ARGS);
+ I32 result = my_stat();
djSP;
if (result < 0)
RETPUSHUNDEF;
PP(pp_ftdir)
{
- I32 result = my_stat(ARGS);
+ I32 result = my_stat();
djSP;
if (result < 0)
RETPUSHUNDEF;
PP(pp_ftpipe)
{
- I32 result = my_stat(ARGS);
+ I32 result = my_stat();
djSP;
if (result < 0)
RETPUSHUNDEF;
PP(pp_ftlink)
{
- I32 result = my_lstat(ARGS);
+ I32 result = my_lstat();
djSP;
if (result < 0)
RETPUSHUNDEF;
{
djSP;
#ifdef S_ISUID
- I32 result = my_stat(ARGS);
+ I32 result = my_stat();
SPAGAIN;
if (result < 0)
RETPUSHUNDEF;
{
djSP;
#ifdef S_ISGID
- I32 result = my_stat(ARGS);
+ I32 result = my_stat();
SPAGAIN;
if (result < 0)
RETPUSHUNDEF;
{
djSP;
#ifdef S_ISVTX
- I32 result = my_stat(ARGS);
+ I32 result = my_stat();
SPAGAIN;
if (result < 0)
RETPUSHUNDEF;
int fd;
GV *gv;
char *tmps = Nullch;
+ STRLEN n_a;
if (PL_op->op_flags & OPf_REF)
- gv = cGVOP->op_gv;
+ gv = cGVOP;
else if (isGV(TOPs))
gv = (GV*)POPs;
else if (SvROK(TOPs) && isGV(SvRV(TOPs)))
gv = (GV*)SvRV(POPs);
else
- gv = gv_fetchpv(tmps = POPp, FALSE, SVt_PVIO);
+ gv = gv_fetchpv(tmps = POPpx, FALSE, SVt_PVIO);
if (GvIO(gv) && IoIFP(GvIOp(gv)))
fd = PerlIO_fileno(IoIFP(GvIOp(gv)));
register IO *io;
register SV *sv;
GV *gv;
+ STRLEN n_a;
+ PerlIO *fp;
if (PL_op->op_flags & OPf_REF)
- gv = cGVOP->op_gv;
+ gv = cGVOP;
else if (isGV(TOPs))
gv = (GV*)POPs;
else if (SvROK(TOPs) && isGV(SvRV(TOPs)))
}
if (io && IoIFP(io)) {
if (! PerlIO_has_base(IoIFP(io)))
- DIE("-T and -B not implemented on filehandles");
+ DIE(aTHX_ "-T and -B not implemented on filehandles");
PL_laststatval = PerlLIO_fstat(PerlIO_fileno(IoIFP(io)), &PL_statcache);
if (PL_laststatval < 0)
RETPUSHUNDEF;
}
else {
if (ckWARN(WARN_UNOPENED))
- warner(WARN_UNOPENED, "Test on unopened file <%s>",
- GvENAME(cGVOP->op_gv));
+ Perl_warner(aTHX_ WARN_UNOPENED, "Test on unopened file <%s>",
+ GvENAME(cGVOP));
SETERRNO(EBADF,RMS$_IFI);
RETPUSHUNDEF;
}
really_filename:
PL_statgv = Nullgv;
PL_laststatval = -1;
- sv_setpv(PL_statname, SvPV(sv, PL_na));
-#ifdef HAS_OPEN3
- i = PerlLIO_open3(SvPV(sv, PL_na), O_RDONLY, 0);
-#else
- i = PerlLIO_open(SvPV(sv, PL_na), 0);
-#endif
- if (i < 0) {
- if (ckWARN(WARN_NEWLINE) && strchr(SvPV(sv, PL_na), '\n'))
- warner(WARN_NEWLINE, warn_nl, "open");
+ sv_setpv(PL_statname, SvPV(sv, n_a));
+ if (!(fp = PerlIO_open(SvPVX(PL_statname), "r"))) {
+ if (ckWARN(WARN_NEWLINE) && strchr(SvPV(sv, n_a), '\n'))
+ Perl_warner(aTHX_ WARN_NEWLINE, PL_warn_nl, "open");
RETPUSHUNDEF;
}
- PL_laststatval = PerlLIO_fstat(i, &PL_statcache);
- if (PL_laststatval < 0)
+ PL_laststatval = PerlLIO_fstat(PerlIO_fileno(fp), &PL_statcache);
+ if (PL_laststatval < 0) {
+ (void)PerlIO_close(fp);
RETPUSHUNDEF;
- len = PerlLIO_read(i, tbuf, 512);
- (void)PerlLIO_close(i);
+ }
+ do_binmode(fp, '<', TRUE);
+ len = PerlIO_read(fp, tbuf, sizeof(tbuf));
+ (void)PerlIO_close(fp);
if (len <= 0) {
if (S_ISDIR(PL_statcache.st_mode) && PL_op->op_type == OP_FTTEXT)
RETPUSHNO; /* special case NFS directories */
/* now scan s to look for textiness */
/* XXX ASCII dependent code */
+#if defined(DOSISH) || defined(USEMYBINMODE)
+ /* ignore trailing ^Z on short files */
+ if (len && len < sizeof(tbuf) && tbuf[len-1] == 26)
+ --len;
+#endif
+
for (i = 0; i < len; i++, s++) {
if (!*s) { /* null never allowed in text */
odd += len;
else if (!(isPRINT(*s) || isSPACE(*s)))
odd++;
#else
- else if (*s & 128)
- odd++;
+ else if (*s & 128) {
+#ifdef USE_LOCALE
+ if (!(PL_op->op_private & OPpLOCALE) || !isALPHA_LC(*s))
+#endif
+ odd++;
+ }
else if (*s < 32 &&
*s != '\n' && *s != '\r' && *s != '\b' &&
*s != '\t' && *s != '\f' && *s != 27)
PP(pp_ftbinary)
{
- return pp_fttext(ARGS);
+ return pp_fttext();
}
/* File calls. */
djSP; dTARGET;
char *tmps;
SV **svp;
+ STRLEN n_a;
if (MAXARG < 1)
tmps = Nullch;
else
- tmps = POPp;
+ tmps = POPpx;
if (!tmps || !*tmps) {
svp = hv_fetch(GvHVn(PL_envgv), "HOME", 4, FALSE);
if (svp)
- tmps = SvPV(*svp, PL_na);
+ tmps = SvPV(*svp, n_a);
}
if (!tmps || !*tmps) {
svp = hv_fetch(GvHVn(PL_envgv), "LOGDIR", 6, FALSE);
if (svp)
- tmps = SvPV(*svp, PL_na);
+ tmps = SvPV(*svp, n_a);
}
#ifdef VMS
if (!tmps || !*tmps) {
svp = hv_fetch(GvHVn(PL_envgv), "SYS$LOGIN", 9, FALSE);
if (svp)
- tmps = SvPV(*svp, PL_na);
+ tmps = SvPV(*svp, n_a);
}
#endif
TAINT_PROPER("chdir");
PUSHi(value);
RETURN;
#else
- DIE(no_func, "Unsupported function chown");
+ DIE(aTHX_ PL_no_func, "Unsupported function chown");
#endif
}
djSP; dTARGET;
char *tmps;
#ifdef HAS_CHROOT
- tmps = POPp;
+ STRLEN n_a;
+ tmps = POPpx;
TAINT_PROPER("chroot");
PUSHi( chroot(tmps) >= 0 );
RETURN;
#else
- DIE(no_func, "chroot");
+ DIE(aTHX_ PL_no_func, "chroot");
#endif
}
{
djSP; dTARGET;
int anum;
+ STRLEN n_a;
- char *tmps2 = POPp;
- char *tmps = SvPV(TOPs, PL_na);
+ char *tmps2 = POPpx;
+ char *tmps = SvPV(TOPs, n_a);
TAINT_PROPER("rename");
#ifdef HAS_RENAME
anum = PerlLIO_rename(tmps, tmps2);
{
djSP; dTARGET;
#ifdef HAS_LINK
- char *tmps2 = POPp;
- char *tmps = SvPV(TOPs, PL_na);
+ STRLEN n_a;
+ char *tmps2 = POPpx;
+ char *tmps = SvPV(TOPs, n_a);
TAINT_PROPER("link");
SETi( link(tmps, tmps2) >= 0 );
#else
- DIE(no_func, "Unsupported function link");
+ DIE(aTHX_ PL_no_func, "Unsupported function link");
#endif
RETURN;
}
{
djSP; dTARGET;
#ifdef HAS_SYMLINK
- char *tmps2 = POPp;
- char *tmps = SvPV(TOPs, PL_na);
+ STRLEN n_a;
+ char *tmps2 = POPpx;
+ char *tmps = SvPV(TOPs, n_a);
TAINT_PROPER("symlink");
SETi( symlink(tmps, tmps2) >= 0 );
RETURN;
#else
- DIE(no_func, "symlink");
+ DIE(aTHX_ PL_no_func, "symlink");
#endif
}
char *tmps;
char buf[MAXPATHLEN];
int len;
+ STRLEN n_a;
#ifndef INCOMPLETE_TAINTS
TAINT;
#endif
- tmps = POPp;
+ tmps = POPpx;
len = readlink(tmps, buf, sizeof buf);
EXTEND(SP, 1);
if (len < 0)
}
#if !defined(HAS_MKDIR) || !defined(HAS_RMDIR)
-static int
-dooneliner(cmd, filename)
-char *cmd;
-char *filename;
+STATIC int
+S_dooneliner(pTHX_ char *cmd, char *filename)
{
char *save_filename = filename;
char *cmdline;
#ifndef HAS_MKDIR
int oldumask;
#endif
- char *tmps = SvPV(TOPs, PL_na);
+ STRLEN n_a;
+ char *tmps = SvPV(TOPs, n_a);
TAINT_PROPER("mkdir");
#ifdef HAS_MKDIR
{
djSP; dTARGET;
char *tmps;
+ STRLEN n_a;
- tmps = POPp;
+ tmps = POPpx;
TAINT_PROPER("rmdir");
#ifdef HAS_RMDIR
XPUSHi( PerlDir_rmdir(tmps) >= 0 );
{
djSP;
#if defined(Direntry_t) && defined(HAS_READDIR)
- char *dirname = POPp;
+ STRLEN n_a;
+ char *dirname = POPpx;
GV *gv = (GV*)POPs;
register IO *io = GvIOn(gv);
SETERRNO(EBADF,RMS$_DIR);
RETPUSHUNDEF;
#else
- DIE(no_dir_func, "opendir");
+ DIE(aTHX_ PL_no_dir_func, "opendir");
#endif
}
djSP;
#if defined(Direntry_t) && defined(HAS_READDIR)
#ifndef I_DIRENT
- Direntry_t *readdir _((DIR *));
+ Direntry_t *readdir (DIR *);
#endif
register Direntry_t *dp;
GV *gv = (GV*)POPs;
/*SUPPRESS 560*/
while (dp = (Direntry_t *)PerlDir_read(IoDIRP(io))) {
#ifdef DIRNAMLEN
- sv = newSVpv(dp->d_name, dp->d_namlen);
+ sv = newSVpvn(dp->d_name, dp->d_namlen);
#else
sv = newSVpv(dp->d_name, 0);
#endif
if (!(dp = (Direntry_t *)PerlDir_read(IoDIRP(io))))
goto nope;
#ifdef DIRNAMLEN
- sv = newSVpv(dp->d_name, dp->d_namlen);
+ sv = newSVpvn(dp->d_name, dp->d_namlen);
#else
sv = newSVpv(dp->d_name, 0);
#endif
else
RETPUSHUNDEF;
#else
- DIE(no_dir_func, "readdir");
+ DIE(aTHX_ PL_no_dir_func, "readdir");
#endif
}
{
djSP; dTARGET;
#if defined(HAS_TELLDIR) || defined(telldir)
-# ifdef NEED_TELLDIR_PROTO /* XXX does _anyone_ need this? --AD 2/20/1998 */
- long telldir _((DIR *));
+ /* XXX does _anyone_ need this? --AD 2/20/1998 */
+ /* XXX netbsd still seemed to.
+ XXX HAS_TELLDIR_PROTO is new style, NEED_TELLDIR_PROTO is old style.
+ --JHI 1999-Feb-02 */
+# if !defined(HAS_TELLDIR_PROTO) || defined(NEED_TELLDIR_PROTO)
+ long telldir (DIR *);
# endif
GV *gv = (GV*)POPs;
register IO *io = GvIOn(gv);
SETERRNO(EBADF,RMS$_ISI);
RETPUSHUNDEF;
#else
- DIE(no_dir_func, "telldir");
+ DIE(aTHX_ PL_no_dir_func, "telldir");
#endif
}
SETERRNO(EBADF,RMS$_ISI);
RETPUSHUNDEF;
#else
- DIE(no_dir_func, "seekdir");
+ DIE(aTHX_ PL_no_dir_func, "seekdir");
#endif
}
SETERRNO(EBADF,RMS$_ISI);
RETPUSHUNDEF;
#else
- DIE(no_dir_func, "rewinddir");
+ DIE(aTHX_ PL_no_dir_func, "rewinddir");
#endif
}
SETERRNO(EBADF,RMS$_IFI);
RETPUSHUNDEF;
#else
- DIE(no_dir_func, "closedir");
+ DIE(aTHX_ PL_no_dir_func, "closedir");
#endif
}
{
#ifdef HAS_FORK
djSP; dTARGET;
- int childpid;
+ Pid_t childpid;
GV *tmpgv;
EXTEND(SP, 1);
+ PERL_FLUSHALL_FOR_CHILD;
childpid = fork();
if (childpid < 0)
RETSETUNDEF;
PUSHi(childpid);
RETURN;
#else
- DIE(no_func, "Unsupported function fork");
+ DIE(aTHX_ PL_no_func, "Unsupported function fork");
#endif
}
PP(pp_wait)
{
-#if !defined(DOSISH) || defined(OS2) || defined(WIN32)
+#if (!defined(DOSISH) || defined(OS2) || defined(WIN32)) && !defined(MACOS_TRADITIONAL)
djSP; dTARGET;
- int childpid;
+ Pid_t childpid;
int argflags;
childpid = wait4pid(-1, &argflags, 0);
XPUSHi(childpid);
RETURN;
#else
- DIE(no_func, "Unsupported function wait");
+ DIE(aTHX_ PL_no_func, "Unsupported function wait");
#endif
}
PP(pp_waitpid)
{
-#if !defined(DOSISH) || defined(OS2) || defined(WIN32)
+#if (!defined(DOSISH) || defined(OS2) || defined(WIN32)) && !defined(MACOS_TRADITIONAL)
djSP; dTARGET;
- int childpid;
+ Pid_t childpid;
int optype;
int argflags;
SETi(childpid);
RETURN;
#else
- DIE(no_func, "Unsupported function waitpid");
+ DIE(aTHX_ PL_no_func, "Unsupported function waitpid");
#endif
}
{
djSP; dMARK; dORIGMARK; dTARGET;
I32 value;
- int childpid;
+ Pid_t childpid;
int result;
int status;
Sigsave_t ihand,qhand; /* place to save signals during system() */
+ STRLEN n_a;
+ I32 did_pipes = 0;
+ int pp[2];
if (SP - MARK == 1) {
if (PL_tainting) {
- char *junk = SvPV(TOPs, PL_na);
+ char *junk = SvPV(TOPs, n_a);
TAINT_ENV();
TAINT_PROPER("system");
}
}
+ PERL_FLUSHALL_FOR_CHILD;
#if (defined(HAS_FORK) || defined(AMIGAOS)) && !defined(VMS) && !defined(OS2)
+ if (PerlProc_pipe(pp) >= 0)
+ did_pipes = 1;
while ((childpid = vfork()) == -1) {
if (errno != EAGAIN) {
value = -1;
SP = ORIGMARK;
PUSHi(value);
+ if (did_pipes) {
+ PerlLIO_close(pp[0]);
+ PerlLIO_close(pp[1]);
+ }
RETURN;
}
sleep(5);
}
if (childpid > 0) {
+ if (did_pipes)
+ PerlLIO_close(pp[1]);
rsignal_save(SIGINT, SIG_IGN, &ihand);
rsignal_save(SIGQUIT, SIG_IGN, &qhand);
do {
STATUS_NATIVE_SET(result == -1 ? -1 : status);
do_execfree(); /* free any memory child malloced on vfork */
SP = ORIGMARK;
+ if (did_pipes) {
+ int errkid;
+ int n = 0, n1;
+
+ while (n < sizeof(int)) {
+ n1 = PerlLIO_read(pp[0],
+ (void*)(((char*)&errkid)+n),
+ (sizeof(int)) - n);
+ if (n1 <= 0)
+ break;
+ n += n1;
+ }
+ PerlLIO_close(pp[0]);
+ if (n) { /* Error */
+ if (n != sizeof(int))
+ DIE(aTHX_ "panic: kid popen errno read");
+ errno = errkid; /* Propagate errno from kid */
+ STATUS_CURRENT = -1;
+ }
+ }
PUSHi(STATUS_CURRENT);
RETURN;
}
+ if (did_pipes) {
+ PerlLIO_close(pp[0]);
+#if defined(HAS_FCNTL) && defined(F_SETFD)
+ fcntl(pp[1], F_SETFD, FD_CLOEXEC);
+#endif
+ }
if (PL_op->op_flags & OPf_STACKED) {
SV *really = *++MARK;
- value = (I32)do_aexec(really, MARK, SP);
+ value = (I32)do_aexec5(really, MARK, SP, pp[1], did_pipes);
}
else if (SP - MARK != 1)
- value = (I32)do_aexec(Nullsv, MARK, SP);
+ value = (I32)do_aexec5(Nullsv, MARK, SP, pp[1], did_pipes);
else {
- value = (I32)do_exec(SvPVx(sv_mortalcopy(*SP), PL_na));
+ value = (I32)do_exec3(SvPVx(sv_mortalcopy(*SP), n_a), pp[1], did_pipes);
}
PerlProc__exit(-1);
#else /* ! FORK or VMS or OS/2 */
else if (SP - MARK != 1)
value = (I32)do_aspawn(Nullsv, (void **)MARK, (void **)SP);
else {
- value = (I32)do_spawn(SvPVx(sv_mortalcopy(*SP), PL_na));
+ value = (I32)do_spawn(SvPVx(sv_mortalcopy(*SP), n_a));
}
STATUS_NATIVE_SET(value);
do_execfree();
{
djSP; dMARK; dORIGMARK; dTARGET;
I32 value;
+ STRLEN n_a;
+ PERL_FLUSHALL_FOR_CHILD;
if (PL_op->op_flags & OPf_STACKED) {
SV *really = *++MARK;
value = (I32)do_aexec(really, MARK, SP);
#ifdef VMS
value = (I32)vms_do_aexec(Nullsv, MARK, SP);
#else
+# ifdef __OPEN_VM
+ {
+ (void ) do_aspawn(Nullsv, MARK, SP);
+ value = 0;
+ }
+# else
value = (I32)do_aexec(Nullsv, MARK, SP);
+# endif
#endif
else {
if (PL_tainting) {
- char *junk = SvPV(*SP, PL_na);
+ char *junk = SvPV(*SP, n_a);
TAINT_ENV();
TAINT_PROPER("exec");
}
#ifdef VMS
- value = (I32)vms_do_exec(SvPVx(sv_mortalcopy(*SP), PL_na));
+ value = (I32)vms_do_exec(SvPVx(sv_mortalcopy(*SP), n_a));
#else
- value = (I32)do_exec(SvPVx(sv_mortalcopy(*SP), PL_na));
+# ifdef __OPEN_VM
+ (void) do_spawn(SvPVx(sv_mortalcopy(*SP), n_a));
+ value = 0;
+# else
+ value = (I32)do_exec(SvPVx(sv_mortalcopy(*SP), n_a));
+# endif
#endif
}
SP = ORIGMARK;
PUSHi(value);
RETURN;
#else
- DIE(no_func, "Unsupported function kill");
+ DIE(aTHX_ PL_no_func, "Unsupported function kill");
#endif
}
XPUSHi( getppid() );
RETURN;
#else
- DIE(no_func, "getppid");
+ DIE(aTHX_ PL_no_func, "getppid");
#endif
}
{
#ifdef HAS_GETPGRP
djSP; dTARGET;
- int pid;
- I32 value;
+ Pid_t pid;
+ Pid_t pgrp;
if (MAXARG < 1)
pid = 0;
else
pid = SvIVx(POPs);
#ifdef BSD_GETPGRP
- value = (I32)BSD_GETPGRP(pid);
+ pgrp = (I32)BSD_GETPGRP(pid);
#else
if (pid != 0 && pid != getpid())
- DIE("POSIX getpgrp can't take an argument");
- value = (I32)getpgrp();
+ DIE(aTHX_ "POSIX getpgrp can't take an argument");
+ pgrp = getpgrp();
#endif
- XPUSHi(value);
+ XPUSHi(pgrp);
RETURN;
#else
- DIE(no_func, "getpgrp()");
+ DIE(aTHX_ PL_no_func, "getpgrp()");
#endif
}
{
#ifdef HAS_SETPGRP
djSP; dTARGET;
- int pgrp;
- int pid;
+ Pid_t pgrp;
+ Pid_t pid;
if (MAXARG < 2) {
pgrp = 0;
pid = 0;
SETi( BSD_SETPGRP(pid, pgrp) >= 0 );
#else
if ((pgrp != 0 && pgrp != getpid()) || (pid != 0 && pid != getpid()))
- DIE("POSIX setpgrp can't take an argument");
+ DIE(aTHX_ "setpgrp can't take arguments");
SETi( setpgrp() >= 0 );
#endif /* USE_BSDPGRP */
RETURN;
#else
- DIE(no_func, "setpgrp()");
+ DIE(aTHX_ PL_no_func, "setpgrp()");
#endif
}
SETi( getpriority(which, who) );
RETURN;
#else
- DIE(no_func, "getpriority()");
+ DIE(aTHX_ PL_no_func, "getpriority()");
#endif
}
SETi( setpriority(which, who, niceval) >= 0 );
RETURN;
#else
- DIE(no_func, "setpriority()");
+ DIE(aTHX_ PL_no_func, "setpriority()");
#endif
}
djSP;
#ifndef HAS_TIMES
- DIE("times not implemented");
+ DIE(aTHX_ "times not implemented");
#else
EXTEND(SP, 4);
/* is returned. */
#endif
- PUSHs(sv_2mortal(newSVnv(((double)PL_timesbuf.tms_utime)/HZ)));
+ PUSHs(sv_2mortal(newSVnv(((NV)PL_timesbuf.tms_utime)/HZ)));
if (GIMME == G_ARRAY) {
- PUSHs(sv_2mortal(newSVnv(((double)PL_timesbuf.tms_stime)/HZ)));
- PUSHs(sv_2mortal(newSVnv(((double)PL_timesbuf.tms_cutime)/HZ)));
- PUSHs(sv_2mortal(newSVnv(((double)PL_timesbuf.tms_cstime)/HZ)));
+ PUSHs(sv_2mortal(newSVnv(((NV)PL_timesbuf.tms_stime)/HZ)));
+ PUSHs(sv_2mortal(newSVnv(((NV)PL_timesbuf.tms_cutime)/HZ)));
+ PUSHs(sv_2mortal(newSVnv(((NV)PL_timesbuf.tms_cstime)/HZ)));
}
RETURN;
#endif /* HAS_TIMES */
PP(pp_localtime)
{
- return pp_gmtime(ARGS);
+ return pp_gmtime();
}
PP(pp_gmtime)
SV *tsv;
if (!tmbuf)
RETPUSHUNDEF;
- tsv = newSVpvf("%s %s %2d %02d:%02d:%02d %d",
- dayname[tmbuf->tm_wday],
- monname[tmbuf->tm_mon],
- tmbuf->tm_mday,
- tmbuf->tm_hour,
- tmbuf->tm_min,
- tmbuf->tm_sec,
- tmbuf->tm_year + 1900);
+ tsv = Perl_newSVpvf(aTHX_ "%s %s %2d %02d:%02d:%02d %d",
+ dayname[tmbuf->tm_wday],
+ monname[tmbuf->tm_mon],
+ tmbuf->tm_mday,
+ tmbuf->tm_hour,
+ tmbuf->tm_min,
+ tmbuf->tm_sec,
+ tmbuf->tm_year + 1900);
PUSHs(sv_2mortal(tsv));
}
else if (tmbuf) {
- PUSHs(sv_2mortal(newSViv((I32)tmbuf->tm_sec)));
- PUSHs(sv_2mortal(newSViv((I32)tmbuf->tm_min)));
- PUSHs(sv_2mortal(newSViv((I32)tmbuf->tm_hour)));
- PUSHs(sv_2mortal(newSViv((I32)tmbuf->tm_mday)));
- PUSHs(sv_2mortal(newSViv((I32)tmbuf->tm_mon)));
- PUSHs(sv_2mortal(newSViv((I32)tmbuf->tm_year)));
- PUSHs(sv_2mortal(newSViv((I32)tmbuf->tm_wday)));
- PUSHs(sv_2mortal(newSViv((I32)tmbuf->tm_yday)));
- PUSHs(sv_2mortal(newSViv((I32)tmbuf->tm_isdst)));
+ PUSHs(sv_2mortal(newSViv(tmbuf->tm_sec)));
+ PUSHs(sv_2mortal(newSViv(tmbuf->tm_min)));
+ PUSHs(sv_2mortal(newSViv(tmbuf->tm_hour)));
+ PUSHs(sv_2mortal(newSViv(tmbuf->tm_mday)));
+ PUSHs(sv_2mortal(newSViv(tmbuf->tm_mon)));
+ PUSHs(sv_2mortal(newSViv(tmbuf->tm_year)));
+ PUSHs(sv_2mortal(newSViv(tmbuf->tm_wday)));
+ PUSHs(sv_2mortal(newSViv(tmbuf->tm_yday)));
+ PUSHs(sv_2mortal(newSViv(tmbuf->tm_isdst)));
}
RETURN;
}
EXTEND(SP, 1);
if (anum < 0)
RETPUSHUNDEF;
- PUSHi((I32)anum);
+ PUSHi(anum);
RETURN;
#else
- DIE(no_func, "Unsupported function alarm");
+ DIE(aTHX_ PL_no_func, "Unsupported function alarm");
#endif
}
PP(pp_shmget)
{
- return pp_semget(ARGS);
+ return pp_semget();
}
PP(pp_shmctl)
{
- return pp_semctl(ARGS);
+ return pp_semctl();
}
PP(pp_shmread)
{
- return pp_shmwrite(ARGS);
+ return pp_shmwrite();
}
PP(pp_shmwrite)
PUSHi(value);
RETURN;
#else
- return pp_semget(ARGS);
+ return pp_semget();
#endif
}
PP(pp_msgget)
{
- return pp_semget(ARGS);
+ return pp_semget();
}
PP(pp_msgctl)
{
- return pp_semctl(ARGS);
+ return pp_semctl();
}
PP(pp_msgsnd)
PUSHi(value);
RETURN;
#else
- return pp_semget(ARGS);
+ return pp_semget();
#endif
}
PUSHi(value);
RETURN;
#else
- return pp_semget(ARGS);
+ return pp_semget();
#endif
}
PUSHi(anum);
RETURN;
#else
- DIE("System V IPC is not implemented on this machine");
+ DIE(aTHX_ "System V IPC is not implemented on this machine");
#endif
}
}
RETURN;
#else
- return pp_semget(ARGS);
+ return pp_semget();
#endif
}
PUSHi(value);
RETURN;
#else
- return pp_semget(ARGS);
+ return pp_semget();
#endif
}
PP(pp_ghbyname)
{
#ifdef HAS_GETHOSTBYNAME
- return pp_ghostent(ARGS);
+ return pp_ghostent();
#else
- DIE(no_sock_func, "gethostbyname");
+ DIE(aTHX_ PL_no_sock_func, "gethostbyname");
#endif
}
PP(pp_ghbyaddr)
{
#ifdef HAS_GETHOSTBYADDR
- return pp_ghostent(ARGS);
+ return pp_ghostent();
#else
- DIE(no_sock_func, "gethostbyaddr");
+ DIE(aTHX_ PL_no_sock_func, "gethostbyaddr");
#endif
}
#endif
struct hostent *hent;
unsigned long len;
+ STRLEN n_a;
EXTEND(SP, 10);
if (which == OP_GHBYNAME)
#ifdef HAS_GETHOSTBYNAME
- hent = PerlSock_gethostbyname(POPp);
+ hent = PerlSock_gethostbyname(POPpx);
#else
- DIE(no_sock_func, "gethostbyname");
+ DIE(aTHX_ PL_no_sock_func, "gethostbyname");
#endif
else if (which == OP_GHBYADDR) {
#ifdef HAS_GETHOSTBYADDR
hent = PerlSock_gethostbyaddr(addr, (Netdb_hlen_t) addrlen, addrtype);
#else
- DIE(no_sock_func, "gethostbyaddr");
+ DIE(aTHX_ PL_no_sock_func, "gethostbyaddr");
#endif
}
else
#ifdef HAS_GETHOSTENT
hent = PerlSock_gethostent();
#else
- DIE(no_sock_func, "gethostent");
+ DIE(aTHX_ PL_no_sock_func, "gethostent");
#endif
#ifdef HOST_NOT_FOUND
}
RETURN;
#else
- DIE(no_sock_func, "gethostent");
+ DIE(aTHX_ PL_no_sock_func, "gethostent");
#endif
}
PP(pp_gnbyname)
{
#ifdef HAS_GETNETBYNAME
- return pp_gnetent(ARGS);
+ return pp_gnetent();
#else
- DIE(no_sock_func, "getnetbyname");
+ DIE(aTHX_ PL_no_sock_func, "getnetbyname");
#endif
}
PP(pp_gnbyaddr)
{
#ifdef HAS_GETNETBYADDR
- return pp_gnetent(ARGS);
+ return pp_gnetent();
#else
- DIE(no_sock_func, "getnetbyaddr");
+ DIE(aTHX_ PL_no_sock_func, "getnetbyaddr");
#endif
}
struct netent *PerlSock_getnetent(void);
#endif
struct netent *nent;
+ STRLEN n_a;
if (which == OP_GNBYNAME)
#ifdef HAS_GETNETBYNAME
- nent = PerlSock_getnetbyname(POPp);
+ nent = PerlSock_getnetbyname(POPpx);
#else
- DIE(no_sock_func, "getnetbyname");
+ DIE(aTHX_ PL_no_sock_func, "getnetbyname");
#endif
else if (which == OP_GNBYADDR) {
#ifdef HAS_GETNETBYADDR
Netdb_net_t addr = (Netdb_net_t) U_L(POPn);
nent = PerlSock_getnetbyaddr(addr, addrtype);
#else
- DIE(no_sock_func, "getnetbyaddr");
+ DIE(aTHX_ PL_no_sock_func, "getnetbyaddr");
#endif
}
else
#ifdef HAS_GETNETENT
nent = PerlSock_getnetent();
#else
- DIE(no_sock_func, "getnetent");
+ DIE(aTHX_ PL_no_sock_func, "getnetent");
#endif
EXTEND(SP, 4);
RETURN;
#else
- DIE(no_sock_func, "getnetent");
+ DIE(aTHX_ PL_no_sock_func, "getnetent");
#endif
}
PP(pp_gpbyname)
{
#ifdef HAS_GETPROTOBYNAME
- return pp_gprotoent(ARGS);
+ return pp_gprotoent();
#else
- DIE(no_sock_func, "getprotobyname");
+ DIE(aTHX_ PL_no_sock_func, "getprotobyname");
#endif
}
PP(pp_gpbynumber)
{
#ifdef HAS_GETPROTOBYNUMBER
- return pp_gprotoent(ARGS);
+ return pp_gprotoent();
#else
- DIE(no_sock_func, "getprotobynumber");
+ DIE(aTHX_ PL_no_sock_func, "getprotobynumber");
#endif
}
struct protoent *PerlSock_getprotoent(void);
#endif
struct protoent *pent;
+ STRLEN n_a;
if (which == OP_GPBYNAME)
#ifdef HAS_GETPROTOBYNAME
- pent = PerlSock_getprotobyname(POPp);
+ pent = PerlSock_getprotobyname(POPpx);
#else
- DIE(no_sock_func, "getprotobyname");
+ DIE(aTHX_ PL_no_sock_func, "getprotobyname");
#endif
else if (which == OP_GPBYNUMBER)
#ifdef HAS_GETPROTOBYNUMBER
pent = PerlSock_getprotobynumber(POPi);
#else
- DIE(no_sock_func, "getprotobynumber");
+ DIE(aTHX_ PL_no_sock_func, "getprotobynumber");
#endif
else
#ifdef HAS_GETPROTOENT
pent = PerlSock_getprotoent();
#else
- DIE(no_sock_func, "getprotoent");
+ DIE(aTHX_ PL_no_sock_func, "getprotoent");
#endif
EXTEND(SP, 3);
RETURN;
#else
- DIE(no_sock_func, "getprotoent");
+ DIE(aTHX_ PL_no_sock_func, "getprotoent");
#endif
}
PP(pp_gsbyname)
{
#ifdef HAS_GETSERVBYNAME
- return pp_gservent(ARGS);
+ return pp_gservent();
#else
- DIE(no_sock_func, "getservbyname");
+ DIE(aTHX_ PL_no_sock_func, "getservbyname");
#endif
}
PP(pp_gsbyport)
{
#ifdef HAS_GETSERVBYPORT
- return pp_gservent(ARGS);
+ return pp_gservent();
#else
- DIE(no_sock_func, "getservbyport");
+ DIE(aTHX_ PL_no_sock_func, "getservbyport");
#endif
}
struct servent *PerlSock_getservent(void);
#endif
struct servent *sent;
+ STRLEN n_a;
if (which == OP_GSBYNAME) {
#ifdef HAS_GETSERVBYNAME
- char *proto = POPp;
- char *name = POPp;
+ char *proto = POPpx;
+ char *name = POPpx;
if (proto && !*proto)
proto = Nullch;
sent = PerlSock_getservbyname(name, proto);
#else
- DIE(no_sock_func, "getservbyname");
+ DIE(aTHX_ PL_no_sock_func, "getservbyname");
#endif
}
else if (which == OP_GSBYPORT) {
#ifdef HAS_GETSERVBYPORT
- char *proto = POPp;
+ char *proto = POPpx;
unsigned short port = POPu;
#ifdef HAS_HTONS
#endif
sent = PerlSock_getservbyport(port, proto);
#else
- DIE(no_sock_func, "getservbyport");
+ DIE(aTHX_ PL_no_sock_func, "getservbyport");
#endif
}
else
#ifdef HAS_GETSERVENT
sent = PerlSock_getservent();
#else
- DIE(no_sock_func, "getservent");
+ DIE(aTHX_ PL_no_sock_func, "getservent");
#endif
EXTEND(SP, 4);
RETURN;
#else
- DIE(no_sock_func, "getservent");
+ DIE(aTHX_ PL_no_sock_func, "getservent");
#endif
}
PerlSock_sethostent(TOPi);
RETSETYES;
#else
- DIE(no_sock_func, "sethostent");
+ DIE(aTHX_ PL_no_sock_func, "sethostent");
#endif
}
PerlSock_setnetent(TOPi);
RETSETYES;
#else
- DIE(no_sock_func, "setnetent");
+ DIE(aTHX_ PL_no_sock_func, "setnetent");
#endif
}
PerlSock_setprotoent(TOPi);
RETSETYES;
#else
- DIE(no_sock_func, "setprotoent");
+ DIE(aTHX_ PL_no_sock_func, "setprotoent");
#endif
}
PerlSock_setservent(TOPi);
RETSETYES;
#else
- DIE(no_sock_func, "setservent");
+ DIE(aTHX_ PL_no_sock_func, "setservent");
#endif
}
EXTEND(SP,1);
RETPUSHYES;
#else
- DIE(no_sock_func, "endhostent");
+ DIE(aTHX_ PL_no_sock_func, "endhostent");
#endif
}
EXTEND(SP,1);
RETPUSHYES;
#else
- DIE(no_sock_func, "endnetent");
+ DIE(aTHX_ PL_no_sock_func, "endnetent");
#endif
}
EXTEND(SP,1);
RETPUSHYES;
#else
- DIE(no_sock_func, "endprotoent");
+ DIE(aTHX_ PL_no_sock_func, "endprotoent");
#endif
}
EXTEND(SP,1);
RETPUSHYES;
#else
- DIE(no_sock_func, "endservent");
+ DIE(aTHX_ PL_no_sock_func, "endservent");
#endif
}
PP(pp_gpwnam)
{
#ifdef HAS_PASSWD
- return pp_gpwent(ARGS);
+ return pp_gpwent();
#else
- DIE(no_func, "getpwnam");
+ DIE(aTHX_ PL_no_func, "getpwnam");
#endif
}
PP(pp_gpwuid)
{
#ifdef HAS_PASSWD
- return pp_gpwent(ARGS);
+ return pp_gpwent();
#else
- DIE(no_func, "getpwuid");
+ DIE(aTHX_ PL_no_func, "getpwuid");
#endif
}
I32 which = PL_op->op_type;
register SV *sv;
struct passwd *pwent;
+ STRLEN n_a;
+#if defined(HAS_GETSPENT) || defined(HAS_GETSPNAM)
+ struct spwd *spwent = NULL;
+#endif
if (which == OP_GPWNAM)
- pwent = getpwnam(POPp);
+ pwent = getpwnam(POPpx);
else if (which == OP_GPWUID)
pwent = getpwuid(POPi);
else
pwent = (struct passwd *)getpwent();
+#ifdef HAS_GETSPNAM
+ if (which == OP_GPWNAM) {
+ if (pwent)
+ spwent = getspnam(pwent->pw_name);
+ }
+# ifdef HAS_GETSPUID /* AFAIK there isn't any anywhere. --jhi */
+ else if (which == OP_GPWUID) {
+ if (pwent)
+ spwent = getspnam(pwent->pw_name);
+ }
+# endif
+# ifdef HAS_GETSPENT
+ else
+ spwent = (struct spwd *)getspent();
+# endif
+#endif
+
EXTEND(SP, 10);
if (GIMME != G_ARRAY) {
PUSHs(sv = sv_newmortal());
PUSHs(sv = sv_mortalcopy(&PL_sv_no));
#ifdef PWPASSWD
+# if defined(HAS_GETSPENT) || defined(HAS_GETSPNAM)
+ if (spwent)
+ sv_setpv(sv, spwent->sp_pwdp);
+ else
+ sv_setpv(sv, pwent->pw_passwd);
+# else
sv_setpv(sv, pwent->pw_passwd);
+# endif
#endif
PUSHs(sv = sv_mortalcopy(&PL_sv_no));
}
RETURN;
#else
- DIE(no_func, "getpwent");
+ DIE(aTHX_ PL_no_func, "getpwent");
#endif
}
PP(pp_spwent)
{
djSP;
-#if defined(HAS_PASSWD) && defined(HAS_SETPWENT) && !defined(CYGWIN32)
+#if defined(HAS_PASSWD) && defined(HAS_SETPWENT)
setpwent();
+# ifdef HAS_SETSPENT
+ setspent();
+# endif
RETPUSHYES;
#else
- DIE(no_func, "setpwent");
+ DIE(aTHX_ PL_no_func, "setpwent");
#endif
}
djSP;
#if defined(HAS_PASSWD) && defined(HAS_ENDPWENT)
endpwent();
+# ifdef HAS_ENDSPENT
+ endspent();
+# endif
RETPUSHYES;
#else
- DIE(no_func, "endpwent");
+ DIE(aTHX_ PL_no_func, "endpwent");
#endif
}
PP(pp_ggrnam)
{
#ifdef HAS_GROUP
- return pp_ggrent(ARGS);
+ return pp_ggrent();
#else
- DIE(no_func, "getgrnam");
+ DIE(aTHX_ PL_no_func, "getgrnam");
#endif
}
PP(pp_ggrgid)
{
#ifdef HAS_GROUP
- return pp_ggrent(ARGS);
+ return pp_ggrent();
#else
- DIE(no_func, "getgrgid");
+ DIE(aTHX_ PL_no_func, "getgrgid");
#endif
}
register char **elem;
register SV *sv;
struct group *grent;
+ STRLEN n_a;
if (which == OP_GGRNAM)
- grent = (struct group *)getgrnam(POPp);
+ grent = (struct group *)getgrnam(POPpx);
else if (which == OP_GGRGID)
grent = (struct group *)getgrgid(POPi);
else
RETURN;
#else
- DIE(no_func, "getgrent");
+ DIE(aTHX_ PL_no_func, "getgrent");
#endif
}
setgrent();
RETPUSHYES;
#else
- DIE(no_func, "setgrent");
+ DIE(aTHX_ PL_no_func, "setgrent");
#endif
}
endgrent();
RETPUSHYES;
#else
- DIE(no_func, "endgrent");
+ DIE(aTHX_ PL_no_func, "endgrent");
#endif
}
PUSHp(tmps, strlen(tmps));
RETURN;
#else
- DIE(no_func, "getlogin");
+ DIE(aTHX_ PL_no_func, "getlogin");
#endif
}
register I32 i = 0;
I32 retval = -1;
MAGIC *mg;
+ STRLEN n_a;
if (PL_tainting) {
while (++MARK <= SP) {
else if (*MARK == &PL_sv_undef)
a[i++] = 0;
else
- a[i++] = (unsigned long)SvPV_force(*MARK, PL_na);
+ a[i++] = (unsigned long)SvPV_force(*MARK, n_a);
if (i > 15)
break;
}
switch (items) {
default:
- DIE("Too many args to syscall");
+ DIE(aTHX_ "Too many args to syscall");
case 0:
- DIE("Too few args to syscall");
+ DIE(aTHX_ "Too few args to syscall");
case 1:
retval = syscall(a[0]);
break;
PUSHi(retval);
RETURN;
#else
- DIE(no_func, "syscall");
+ DIE(aTHX_ PL_no_func, "syscall");
#endif
}
return -1;
}
flock.l_whence = SEEK_SET;
- flock.l_start = flock.l_len = 0L;
+ flock.l_start = flock.l_len = (Off_t)0;
return fcntl(fd, (operation & LOCK_NB) ? F_SETLK : F_SETLKW, &flock);
}
# endif
static int
-lockf_emulate_flock (fd, operation)
-int fd;
-int operation;
+lockf_emulate_flock(int fd, int operation)
{
int i;
int save_errno;