X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pp_sys.c;h=fdda73034f019c9589b53dcf5345bf630bf71b9a;hb=2c4e3d5f2923e4800b186420d39202e45c831e51;hp=ab14c679a989d6a18effd5951a94f9e0d9dd62c5;hpb=c445ea15829fa1ef23c4453a817f9c096a56a192;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pp_sys.c b/pp_sys.c index ab14c67..fdda730 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -1,7 +1,7 @@ /* pp_sys.c * * Copyright (C) 1995, 1996, 1997, 1998, 1999, - * 2000, 2001, 2002, 2003, 2004, 2005, by Larry Wall and others + * 2000, 2001, 2002, 2003, 2004, 2005, 2006, 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. @@ -317,7 +317,7 @@ S_emulate_eaccess(pTHX_ const char* path, Mode_t mode) PP(pp_backtick) { - dSP; dTARGET; + dVAR; dSP; dTARGET; PerlIO *fp; const char * const tmps = POPpconstx; const I32 gimme = GIMME_V; @@ -344,7 +344,7 @@ PP(pp_backtick) SAVESPTR(PL_rs); PL_rs = &PL_sv_undef; sv_setpvn(TARG, "", 0); /* note that this preserves previous buffer */ - while (sv_gets(TARG, fp, SvCUR(TARG)) != Nullch) + while (sv_gets(TARG, fp, SvCUR(TARG)) != NULL) ; LEAVE; XPUSHs(TARG); @@ -352,8 +352,8 @@ PP(pp_backtick) } else { for (;;) { - SV * const sv = NEWSV(56, 79); - if (sv_gets(sv, fp, 0) == Nullch) { + SV * const sv = newSV(79); + if (sv_gets(sv, fp, 0) == NULL) { SvREFCNT_dec(sv); break; } @@ -403,7 +403,7 @@ PP(pp_glob) PL_last_in_gv = (GV*)*PL_stack_sp--; SAVESPTR(PL_rs); /* This is not permanent, either. */ - PL_rs = sv_2mortal(newSVpvn("\000", 1)); + PL_rs = sv_2mortal(newSVpvs("\000")); #ifndef DOSISH #ifndef CSH *SvPVX(PL_rs) = '\n'; @@ -417,13 +417,14 @@ PP(pp_glob) PP(pp_rcatline) { + dVAR; PL_last_in_gv = cGVOP_gv; return do_readline(); } PP(pp_warn) { - dSP; dMARK; + dVAR; dSP; dMARK; SV *tmpsv; const char *tmps; STRLEN len; @@ -445,12 +446,12 @@ PP(pp_warn) SV * const error = ERRSV; SvUPGRADE(error, SVt_PV); if (SvPOK(error) && SvCUR(error)) - sv_catpv(error, "\t...caught"); + sv_catpvs(error, "\t...caught"); tmpsv = error; tmps = SvPV_const(tmpsv, len); } if (!tmps || !len) - tmpsv = sv_2mortal(newSVpvn("Warning: something's wrong", 26)); + tmpsv = sv_2mortal(newSVpvs("Warning: something's wrong")); Perl_warn(aTHX_ "%"SVf, tmpsv); RETSETYES; @@ -458,7 +459,7 @@ PP(pp_warn) PP(pp_die) { - dSP; dMARK; + dVAR; dSP; dMARK; const char *tmps; SV *tmpsv; STRLEN len; @@ -476,7 +477,7 @@ PP(pp_die) } else { tmpsv = TOPs; - tmps = SvROK(tmpsv) ? Nullch : SvPV_const(tmpsv, len); + tmps = SvROK(tmpsv) ? NULL : SvPV_const(tmpsv, len); } if (!tmps || !len) { SV * const error = ERRSV; @@ -501,20 +502,20 @@ PP(pp_die) sv_setsv(error,*PL_stack_sp--); } } - DIE(aTHX_ Nullch); + DIE(aTHX_ NULL); } else { if (SvPOK(error) && SvCUR(error)) - sv_catpv(error, "\t...propagated"); + sv_catpvs(error, "\t...propagated"); tmpsv = error; if (SvOK(tmpsv)) tmps = SvPV_const(tmpsv, len); else - tmps = Nullch; + tmps = NULL; } } if (!tmps || !len) - tmpsv = sv_2mortal(newSVpvn("Died", 4)); + tmpsv = sv_2mortal(newSVpvs("Died")); DIE(aTHX_ "%"SVf, tmpsv); } @@ -601,6 +602,7 @@ PP(pp_close) PP(pp_pipe_op) { #ifdef HAS_PIPE + dVAR; dSP; register IO *rstio; register IO *wstio; @@ -692,6 +694,7 @@ PP(pp_fileno) PP(pp_umask) { + dVAR; dSP; #ifdef HAS_UMASK dTARGET; @@ -723,7 +726,7 @@ PP(pp_binmode) IO *io; PerlIO *fp; MAGIC *mg; - SV *discp = Nullsv; + SV *discp = NULL; if (MAXARG < 1) RETPUSHUNDEF; @@ -758,11 +761,11 @@ PP(pp_binmode) PUTBACK; if (PerlIO_binmode(aTHX_ fp,IoTYPE(io),mode_from_discipline(discp), - (discp) ? SvPV_nolen_const(discp) : Nullch)) { + (discp) ? SvPV_nolen_const(discp) : NULL)) { if (IoOFP(io) && IoOFP(io) != IoIFP(io)) { if (!PerlIO_binmode(aTHX_ IoOFP(io),IoTYPE(io), mode_from_discipline(discp), - (discp) ? SvPV_nolen_const(discp) : Nullch)) { + (discp) ? SvPV_nolen_const(discp) : NULL)) { SPAGAIN; RETPUSHUNDEF; } @@ -856,7 +859,7 @@ PP(pp_tie) SvTYPE(varsv) == SVt_PVHV)) Perl_croak(aTHX_ "Self-ties of arrays and hashes are not supported"); - sv_magic(varsv, (SvRV(sv) == varsv ? Nullsv : sv), how, Nullch, 0); + sv_magic(varsv, (SvRV(sv) == varsv ? NULL : sv), how, NULL, 0); } LEAVE; SP = PL_stack_base + markoff; @@ -903,6 +906,7 @@ PP(pp_untie) PP(pp_tied) { + dVAR; dSP; const MAGIC *mg; SV *sv = POPs; @@ -971,7 +975,7 @@ PP(pp_dbmopen) if (sv_isobject(TOPs)) { sv_unmagic((SV *) hv, PERL_MAGIC_tied); - sv_magic((SV*)hv, TOPs, PERL_MAGIC_tied, Nullch, 0); + sv_magic((SV*)hv, TOPs, PERL_MAGIC_tied, NULL, 0); } LEAVE; RETURN; @@ -980,7 +984,7 @@ PP(pp_dbmopen) PP(pp_sselect) { #ifdef HAS_SELECT - dSP; dTARGET; + dVAR; dSP; dTARGET; register I32 i; register I32 j; register char *s; @@ -1145,6 +1149,7 @@ PP(pp_sselect) void Perl_setdefout(pTHX_ GV *gv) { + dVAR; if (gv) (void)SvREFCNT_inc(gv); if (PL_defoutgv) @@ -1154,7 +1159,7 @@ Perl_setdefout(pTHX_ GV *gv) PP(pp_select) { - dSP; dTARGET; + dVAR; dSP; dTARGET; HV *hv; GV * const newdefout = (PL_op->op_private > 0) ? ((GV *) POPs) : (GV *) NULL; GV * egv = GvEGV(PL_defoutgv); @@ -1167,7 +1172,7 @@ PP(pp_select) else { GV * const * const gvp = (GV**)hv_fetch(hv, GvNAME(egv), GvNAMELEN(egv), FALSE); if (gvp && *gvp == egv) { - gv_efullname4(TARG, PL_defoutgv, Nullch, TRUE); + gv_efullname4(TARG, PL_defoutgv, NULL, TRUE); XPUSHTARG; } else { @@ -1252,6 +1257,7 @@ S_doform(pTHX_ CV *cv, GV *gv, OP *retop) PP(pp_enterwrite) { + dVAR; dSP; register GV *gv; register IO *io; @@ -1280,7 +1286,7 @@ PP(pp_enterwrite) if (fgv) { SV * const tmpsv = sv_newmortal(); const char *name; - gv_efullname4(tmpsv, fgv, Nullch, FALSE); + gv_efullname4(tmpsv, fgv, NULL, FALSE); name = SvPV_nolen_const(tmpsv); if (name && *name) DIE(aTHX_ "Undefined format \"%s\" called", name); @@ -1324,10 +1330,10 @@ PP(pp_leavewrite) topname = sv_2mortal(Perl_newSVpvf(aTHX_ "%s_TOP", GvNAME(gv))); topgv = gv_fetchsv(topname, 0, SVt_PVFM); if ((topgv && GvFORM(topgv)) || - !gv_fetchpv("top", 0, SVt_PVFM)) + !gv_fetchpvs("top", GV_NOTQUAL, SVt_PVFM)) IoTOP_NAME(io) = savesvpv(topname); else - IoTOP_NAME(io) = savepvn("top", 3); + IoTOP_NAME(io) = savepvs("top"); } topgv = gv_fetchpv(IoTOP_NAME(io), 0, SVt_PVFM); if (!topgv || !GvFORM(topgv)) { @@ -1369,7 +1375,7 @@ PP(pp_leavewrite) if (!cv) { SV * const sv = sv_newmortal(); const char *name; - gv_efullname4(sv, fgv, Nullch, FALSE); + gv_efullname4(sv, fgv, NULL, FALSE); name = SvPV_nolen_const(sv); if (name && *name) DIE(aTHX_ "Undefined top format \"%s\" called",name); @@ -1454,7 +1460,7 @@ PP(pp_prtf) RETURN; } - sv = NEWSV(0,0); + sv = newSV(0); if (!(io = GvIO(gv))) { if (ckWARN2(WARN_UNOPENED,WARN_CLOSED)) report_evil_fh(gv, io, PL_op->op_type); @@ -1494,6 +1500,7 @@ PP(pp_prtf) PP(pp_sysopen) { + dVAR; dSP; const int perm = (MAXARG > 3) ? POPi : 0666; const int mode = POPi; @@ -1925,8 +1932,6 @@ PP(pp_eof) { dVAR; dSP; GV *gv; - IO *io; - MAGIC *mg; if (MAXARG == 0) { if (PL_op->op_flags & OPf_SPECIAL) { /* eof() */ @@ -1951,17 +1956,19 @@ PP(pp_eof) else gv = PL_last_in_gv = (GV*)POPs; /* eof(FH) */ - if (gv && (io = GvIO(gv)) - && (mg = SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar))) - { - PUSHMARK(SP); - XPUSHs(SvTIED_obj((SV*)io, mg)); - PUTBACK; - ENTER; - call_method("EOF", G_SCALAR); - LEAVE; - SPAGAIN; - RETURN; + if (gv) { + IO * const io = GvIO(gv); + MAGIC * mg; + if (io && (mg = SvTIED_mg((SV*)io, PERL_MAGIC_tiedscalar))) { + PUSHMARK(SP); + XPUSHs(SvTIED_obj((SV*)io, mg)); + PUTBACK; + ENTER; + call_method("EOF", G_SCALAR); + LEAVE; + SPAGAIN; + RETURN; + } } PUSHs(boolSV(!gv || do_eof(gv))); @@ -2055,6 +2062,7 @@ PP(pp_sysseek) PP(pp_truncate) { + dVAR; dSP; /* There seems to be no consensus on the length type of truncate() * and ftruncate(), both off_t and size_t have supporters. In @@ -2149,7 +2157,7 @@ PP(pp_truncate) PP(pp_ioctl) { - dSP; dTARGET; + dVAR; dSP; dTARGET; SV * const argsv = POPs; const unsigned int func = POPu; const int optype = PL_op->op_type; @@ -2225,7 +2233,7 @@ PP(pp_ioctl) PP(pp_flock) { #ifdef FLOCK - dSP; dTARGET; + dVAR; dSP; dTARGET; I32 value; IO *io = NULL; PerlIO *fp; @@ -2261,7 +2269,7 @@ PP(pp_flock) PP(pp_socket) { #ifdef HAS_SOCKET - dSP; + dVAR; dSP; const int protocol = POPi; const int type = POPi; const int domain = POPi; @@ -2311,7 +2319,7 @@ PP(pp_socket) PP(pp_sockpair) { #if defined (HAS_SOCKETPAIR) || (defined (HAS_SOCKET) && defined(SOCK_DGRAM) && defined(AF_INET) && defined(PF_INET)) - dSP; + dVAR; dSP; const int protocol = POPi; const int type = POPi; const int domain = POPi; @@ -2372,11 +2380,7 @@ PP(pp_sockpair) PP(pp_bind) { #ifdef HAS_SOCKET - dSP; -#ifdef MPE /* Requires PRIV mode to bind() to ports < 1024 */ - extern void GETPRIVMODE(); - extern void GETUSERMODE(); -#endif + dVAR; dSP; SV * const addrsv = POPs; /* OK, so on what platform does bind modify addr? */ const char *addr; @@ -2384,35 +2388,16 @@ PP(pp_bind) register IO * const io = GvIOn(gv); STRLEN len; int bind_ok = 0; -#ifdef MPE - int mpeprivmode = 0; -#endif if (!io || !IoIFP(io)) goto nuts; addr = SvPV_const(addrsv, len); TAINT_PROPER("bind"); -#ifdef MPE /* Deal with MPE bind() peculiarities */ - if (((struct sockaddr *)addr)->sa_family == AF_INET) { - /* The address *MUST* stupidly be zero. */ - ((struct sockaddr_in *)addr)->sin_addr.s_addr = INADDR_ANY; - /* PRIV mode is required to bind() to ports < 1024. */ - if (((struct sockaddr_in *)addr)->sin_port < 1024 && - ((struct sockaddr_in *)addr)->sin_port > 0) { - GETPRIVMODE(); /* If this fails, we are aborted by MPE/iX. */ - mpeprivmode = 1; - } - } -#endif /* MPE */ if (PerlSock_bind(PerlIO_fileno(IoIFP(io)), (struct sockaddr *)addr, len) >= 0) bind_ok = 1; -#ifdef MPE /* Switch back to USER mode */ - if (mpeprivmode) - GETUSERMODE(); -#endif /* MPE */ if (bind_ok) RETPUSHYES; @@ -2432,7 +2417,7 @@ nuts: PP(pp_connect) { #ifdef HAS_SOCKET - dSP; + dVAR; dSP; SV * const addrsv = POPs; GV * const gv = (GV*)POPs; register IO * const io = GvIOn(gv); @@ -2462,7 +2447,7 @@ nuts: PP(pp_listen) { #ifdef HAS_SOCKET - dSP; + dVAR; dSP; const int backlog = POPi; GV * const gv = (GV*)POPs; register IO * const io = gv ? GvIOn(gv) : NULL; @@ -2488,7 +2473,7 @@ nuts: PP(pp_accept) { #ifdef HAS_SOCKET - dSP; dTARGET; + dVAR; dSP; dTARGET; register IO *nstio; register IO *gstio; char namebuf[MAXPATHLEN]; @@ -2556,7 +2541,7 @@ badexit: PP(pp_shutdown) { #ifdef HAS_SOCKET - dSP; dTARGET; + dVAR; dSP; dTARGET; const int how = POPi; GV * const gv = (GV*)POPs; register IO * const io = GvIOn(gv); @@ -2580,9 +2565,9 @@ nuts: PP(pp_ssockopt) { #ifdef HAS_SOCKET - dSP; + dVAR; dSP; const int optype = PL_op->op_type; - SV * const sv = (optype == OP_GSOCKOPT) ? sv_2mortal(NEWSV(22, 257)) : POPs; + SV * const sv = (optype == OP_GSOCKOPT) ? sv_2mortal(newSV(257)) : POPs; const unsigned int optname = (unsigned int) POPi; const unsigned int lvl = (unsigned int) POPi; GV * const gv = (GV*)POPs; @@ -2657,7 +2642,7 @@ nuts2: PP(pp_getpeername) { #ifdef HAS_SOCKET - dSP; + dVAR; dSP; const int optype = PL_op->op_type; GV * const gv = (GV*)POPs; register IO * const io = GvIOn(gv); @@ -2668,7 +2653,7 @@ PP(pp_getpeername) if (!io || !IoIFP(io)) goto nuts; - sv = sv_2mortal(NEWSV(22, 257)); + sv = sv_2mortal(newSV(257)); (void)SvPOK_only(sv); len = 256; SvCUR_set(sv, len); @@ -2722,6 +2707,7 @@ nuts2: PP(pp_stat) { + dVAR; dSP; GV *gv; I32 gimme; @@ -2766,7 +2752,7 @@ PP(pp_stat) goto do_fstat; } sv_setpv(PL_statname, SvPV_nolen_const(sv)); - PL_statgv = Nullgv; + PL_statgv = NULL; PL_laststype = PL_op->op_type; if (PL_op->op_type == OP_LSTAT) PL_laststatval = PerlLIO_lstat(SvPV_nolen_const(PL_statname), &PL_statcache); @@ -2813,7 +2799,7 @@ PP(pp_stat) #ifdef USE_STAT_RDEV PUSHs(sv_2mortal(newSViv(PL_statcache.st_rdev))); #else - PUSHs(sv_2mortal(newSVpvn("", 0))); + PUSHs(sv_2mortal(newSVpvs(""))); #endif #if Off_t_size > IVSIZE PUSHs(sv_2mortal(newSVnv((NV)PL_statcache.st_size))); @@ -2833,8 +2819,8 @@ PP(pp_stat) PUSHs(sv_2mortal(newSVuv(PL_statcache.st_blksize))); PUSHs(sv_2mortal(newSVuv(PL_statcache.st_blocks))); #else - PUSHs(sv_2mortal(newSVpvn("", 0))); - PUSHs(sv_2mortal(newSVpvn("", 0))); + PUSHs(sv_2mortal(newSVpvs(""))); + PUSHs(sv_2mortal(newSVpvs(""))); #endif } RETURN; @@ -2851,6 +2837,7 @@ PP(pp_stat) PP(pp_ftrread) { + dVAR; I32 result; /* Not const, because things tweak this below. Not bool, because there's no guarantee that OPp_FT_ACCESS is <= CHAR_MAX */ @@ -2962,6 +2949,7 @@ PP(pp_ftrread) PP(pp_ftis) { + dVAR; I32 result; const int op_type = PL_op->op_type; dSP; @@ -3000,6 +2988,7 @@ PP(pp_ftis) PP(pp_ftrowned) { + dVAR; I32 result; dSP; @@ -3084,6 +3073,7 @@ PP(pp_ftrowned) PP(pp_ftlink) { + dVAR; I32 result = my_lstat(); dSP; if (result < 0) @@ -3095,10 +3085,11 @@ PP(pp_ftlink) PP(pp_fttty) { + dVAR; dSP; int fd; GV *gv; - SV *tmpsv = Nullsv; + SV *tmpsv = NULL; STACKED_FTEST_CHECK; @@ -3137,6 +3128,7 @@ PP(pp_fttty) PP(pp_fttext) { + dVAR; dSP; I32 i; I32 len; @@ -3157,7 +3149,7 @@ PP(pp_fttext) else if (SvROK(TOPs) && isGV(SvRV(TOPs))) gv = (GV*)SvRV(POPs); else - gv = Nullgv; + gv = NULL; if (gv) { EXTEND(SP, 1); @@ -3212,7 +3204,7 @@ PP(pp_fttext) else { sv = POPs; really_filename: - PL_statgv = Nullgv; + PL_statgv = NULL; PL_laststype = OP_STAT; sv_setpv(PL_statname, SvPV_nolen_const(sv)); if (!(fp = PerlIO_open(SvPVX_const(PL_statname), "r"))) { @@ -3226,7 +3218,7 @@ PP(pp_fttext) (void)PerlIO_close(fp); RETPUSHUNDEF; } - PerlIO_binmode(aTHX_ fp, '<', O_BINARY, Nullch); + PerlIO_binmode(aTHX_ fp, '<', O_BINARY, NULL); len = PerlIO_read(fp, tbuf, sizeof(tbuf)); (void)PerlIO_close(fp); if (len <= 0) { @@ -3295,7 +3287,7 @@ PP(pp_fttext) PP(pp_chdir) { - dSP; dTARGET; + dVAR; dSP; dTARGET; const char *tmps = NULL; GV *gv = NULL; @@ -3316,10 +3308,10 @@ PP(pp_chdir) HV * const table = GvHVn(PL_envgv); SV **svp; - if ( (svp = hv_fetch(table, "HOME", 4, FALSE)) - || (svp = hv_fetch(table, "LOGDIR", 6, FALSE)) + if ( (svp = hv_fetchs(table, "HOME", FALSE)) + || (svp = hv_fetchs(table, "LOGDIR", FALSE)) #ifdef VMS - || (svp = hv_fetch(table, "SYS$LOGIN", 9, FALSE)) + || (svp = hv_fetchs(table, "SYS$LOGIN", FALSE)) #endif ) { @@ -3372,7 +3364,7 @@ PP(pp_chdir) PP(pp_chown) { - dSP; dMARK; dTARGET; + dVAR; dSP; dMARK; dTARGET; const I32 value = (I32)apply(PL_op->op_type, MARK, SP); SP = MARK; @@ -3383,7 +3375,7 @@ PP(pp_chown) PP(pp_chroot) { #ifdef HAS_CHROOT - dSP; dTARGET; + dVAR; dSP; dTARGET; char * const tmps = POPpx; TAINT_PROPER("chroot"); PUSHi( chroot(tmps) >= 0 ); @@ -3395,7 +3387,7 @@ PP(pp_chroot) PP(pp_rename) { - dSP; dTARGET; + dVAR; dSP; dTARGET; int anum; const char * const tmps2 = POPpconstx; const char * const tmps = SvPV_nolen_const(TOPs); @@ -3421,7 +3413,7 @@ PP(pp_rename) #if defined(HAS_LINK) || defined(HAS_SYMLINK) PP(pp_link) { - dSP; dTARGET; + dVAR; dSP; dTARGET; const int op_type = PL_op->op_type; int result; @@ -3469,6 +3461,7 @@ PP(pp_link) PP(pp_readlink) { + dVAR; dSP; #ifdef HAS_SYMLINK dTARGET; @@ -3518,7 +3511,7 @@ S_dooneliner(pTHX_ const char *cmd, const char *filename) /* Need to save/restore 'PL_rs' ?? */ s = sv_gets(tmpsv, myfp, 0); (void)PerlProc_pclose(myfp); - if (s != Nullch) { + if (s != NULL) { int e; for (e = 1; #ifdef HAS_SYS_ERRLIST @@ -3527,7 +3520,7 @@ S_dooneliner(pTHX_ const char *cmd, const char *filename) ; e++) { /* you don't see this */ - char *errmsg = + const char * const errmsg = #ifdef HAS_SYS_ERRLIST sys_errlist[e] #else @@ -3601,7 +3594,7 @@ S_dooneliner(pTHX_ const char *cmd, const char *filename) PP(pp_mkdir) { - dSP; dTARGET; + dVAR; dSP; dTARGET; STRLEN len; const char *tmps; bool copy = FALSE; @@ -3628,7 +3621,7 @@ PP(pp_mkdir) PP(pp_rmdir) { - dSP; dTARGET; + dVAR; dSP; dTARGET; STRLEN len; const char *tmps; bool copy = FALSE; @@ -3650,7 +3643,7 @@ PP(pp_rmdir) PP(pp_open_dir) { #if defined(Direntry_t) && defined(HAS_READDIR) - dSP; + dVAR; dSP; const char * const dirname = POPpconstx; GV * const gv = (GV*)POPs; register IO * const io = GvIOn(gv); @@ -3681,6 +3674,7 @@ PP(pp_readdir) #if !defined(I_DIRENT) && !defined(VMS) Direntry_t *readdir (DIR *); #endif + dVAR; dSP; SV *sv; @@ -3689,8 +3683,13 @@ PP(pp_readdir) register const Direntry_t *dp; register IO * const io = GvIOn(gv); - if (!io || !IoDIRP(io)) - goto nope; + if (!io || !IoDIRP(io)) { + if(ckWARN(WARN_IO)) { + Perl_warner(aTHX_ packWARN(WARN_IO), + "readdir() attempted on invalid dirhandle %s", GvENAME(gv)); + } + goto nope; + } do { dp = (Direntry_t *)PerlDir_read(IoDIRP(io)); @@ -3738,8 +3737,13 @@ PP(pp_telldir) GV * const gv = (GV*)POPs; register IO * const io = GvIOn(gv); - if (!io || !IoDIRP(io)) - goto nope; + if (!io || !IoDIRP(io)) { + if(ckWARN(WARN_IO)) { + Perl_warner(aTHX_ packWARN(WARN_IO), + "telldir() attempted on invalid dirhandle %s", GvENAME(gv)); + } + goto nope; + } PUSHi( PerlDir_tell(IoDIRP(io)) ); RETURN; @@ -3755,14 +3759,18 @@ nope: PP(pp_seekdir) { #if defined(HAS_SEEKDIR) || defined(seekdir) - dSP; + dVAR; dSP; const long along = POPl; GV * const gv = (GV*)POPs; register IO * const io = GvIOn(gv); - if (!io || !IoDIRP(io)) - goto nope; - + if (!io || !IoDIRP(io)) { + if(ckWARN(WARN_IO)) { + Perl_warner(aTHX_ packWARN(WARN_IO), + "seekdir() attempted on invalid dirhandle %s", GvENAME(gv)); + } + goto nope; + } (void)PerlDir_seek(IoDIRP(io), along); RETPUSHYES; @@ -3778,13 +3786,17 @@ nope: PP(pp_rewinddir) { #if defined(HAS_REWINDDIR) || defined(rewinddir) - dSP; + dVAR; dSP; GV * const gv = (GV*)POPs; register IO * const io = GvIOn(gv); - if (!io || !IoDIRP(io)) + if (!io || !IoDIRP(io)) { + if(ckWARN(WARN_IO)) { + Perl_warner(aTHX_ packWARN(WARN_IO), + "rewinddir() attempted on invalid dirhandle %s", GvENAME(gv)); + } goto nope; - + } (void)PerlDir_rewind(IoDIRP(io)); RETPUSHYES; nope: @@ -3799,13 +3811,17 @@ nope: PP(pp_closedir) { #if defined(Direntry_t) && defined(HAS_READDIR) - dSP; + dVAR; dSP; GV * const gv = (GV*)POPs; register IO * const io = GvIOn(gv); - if (!io || !IoDIRP(io)) - goto nope; - + if (!io || !IoDIRP(io)) { + if(ckWARN(WARN_IO)) { + Perl_warner(aTHX_ packWARN(WARN_IO), + "closedir() attempted on invalid dirhandle %s", GvENAME(gv)); + } + goto nope; + } #ifdef VOID_CLOSEDIR PerlDir_close(IoDIRP(io)); #else @@ -3831,7 +3847,7 @@ nope: PP(pp_fork) { #ifdef HAS_FORK - dSP; dTARGET; + dVAR; dSP; dTARGET; Pid_t childpid; EXTEND(SP, 1); @@ -3840,7 +3856,7 @@ PP(pp_fork) if (childpid < 0) RETSETUNDEF; if (!childpid) { - GV * const tmpgv = gv_fetchpv("$", GV_ADD, SVt_PV); + GV * const tmpgv = gv_fetchpvs("$", GV_ADD|GV_NOTQUAL, SVt_PV); if (tmpgv) { SvREADONLY_off(GvSV(tmpgv)); sv_setiv(GvSV(tmpgv), (IV)PerlProc_getpid()); @@ -3876,7 +3892,7 @@ PP(pp_fork) PP(pp_wait) { #if (!defined(DOSISH) || defined(OS2) || defined(WIN32)) && !defined(MACOS_TRADITIONAL) - dSP; dTARGET; + dVAR; dSP; dTARGET; Pid_t childpid; int argflags; @@ -3904,7 +3920,7 @@ PP(pp_wait) PP(pp_waitpid) { #if (!defined(DOSISH) || defined(OS2) || defined(WIN32)) && !defined(MACOS_TRADITIONAL) - dSP; dTARGET; + dVAR; dSP; dTARGET; const int optype = POPi; const Pid_t pid = TOPi; Pid_t result; @@ -3933,7 +3949,7 @@ PP(pp_waitpid) PP(pp_system) { - dSP; dMARK; dORIGMARK; dTARGET; + dVAR; dSP; dMARK; dORIGMARK; dTARGET; I32 value; int result; @@ -4023,7 +4039,7 @@ PP(pp_system) value = (I32)do_aexec5(really, MARK, SP, pp[1], did_pipes); } else if (SP - MARK != 1) - value = (I32)do_aexec5(Nullsv, MARK, SP, pp[1], did_pipes); + value = (I32)do_aexec5(NULL, MARK, SP, pp[1], did_pipes); else { value = (I32)do_exec3(SvPVx_nolen(sv_mortalcopy(*SP)), pp[1], did_pipes); } @@ -4042,9 +4058,9 @@ PP(pp_system) } else if (SP - MARK != 1) { # if defined(WIN32) || defined(OS2) || defined(__SYMBIAN32__) - value = (I32)do_aspawn(Nullsv, MARK, SP); + value = (I32)do_aspawn(NULL, MARK, SP); # else - value = (I32)do_aspawn(Nullsv, (void **)MARK, (void **)SP); + value = (I32)do_aspawn(NULL, (void **)MARK, (void **)SP); # endif } else { @@ -4062,7 +4078,7 @@ PP(pp_system) PP(pp_exec) { - dSP; dMARK; dORIGMARK; dTARGET; + dVAR; dSP; dMARK; dORIGMARK; dTARGET; I32 value; if (PL_tainting) { @@ -4082,15 +4098,15 @@ PP(pp_exec) } else if (SP - MARK != 1) #ifdef VMS - value = (I32)vms_do_aexec(Nullsv, MARK, SP); + value = (I32)vms_do_aexec(NULL, MARK, SP); #else # ifdef __OPEN_VM { - (void ) do_aspawn(Nullsv, MARK, SP); + (void ) do_aspawn(NULL, MARK, SP); value = 0; } # else - value = (I32)do_aexec(Nullsv, MARK, SP); + value = (I32)do_aexec(NULL, MARK, SP); # endif #endif else { @@ -4114,7 +4130,7 @@ PP(pp_exec) PP(pp_getppid) { #ifdef HAS_GETPPID - dSP; dTARGET; + dVAR; dSP; dTARGET; # ifdef THREADS_HAVE_PIDS if (PL_ppid != 1 && getppid() == 1) /* maybe the parent process has died. Refresh ppid cache */ @@ -4132,7 +4148,7 @@ PP(pp_getppid) PP(pp_getpgrp) { #ifdef HAS_GETPGRP - dSP; dTARGET; + dVAR; dSP; dTARGET; Pid_t pgrp; const Pid_t pid = (MAXARG < 1) ? 0 : SvIVx(POPs); @@ -4153,7 +4169,7 @@ PP(pp_getpgrp) PP(pp_setpgrp) { #ifdef HAS_SETPGRP - dSP; dTARGET; + dVAR; dSP; dTARGET; Pid_t pgrp; Pid_t pid; if (MAXARG < 2) { @@ -4185,7 +4201,7 @@ PP(pp_setpgrp) PP(pp_getpriority) { #ifdef HAS_GETPRIORITY - dSP; dTARGET; + dVAR; dSP; dTARGET; const int who = POPi; const int which = TOPi; SETi( getpriority(which, who) ); @@ -4198,7 +4214,7 @@ PP(pp_getpriority) PP(pp_setpriority) { #ifdef HAS_SETPRIORITY - dSP; dTARGET; + dVAR; dSP; dTARGET; const int niceval = POPi; const int who = POPi; const int which = TOPi; @@ -4214,7 +4230,7 @@ PP(pp_setpriority) PP(pp_time) { - dSP; dTARGET; + dVAR; dSP; dTARGET; #ifdef BIG_TIME XPUSHn( time(Null(Time_t*)) ); #else @@ -4226,6 +4242,7 @@ PP(pp_time) PP(pp_tms) { #ifdef HAS_TIMES + dVAR; dSP; EXTEND(SP, 4); #ifndef VMS @@ -4302,6 +4319,7 @@ static struct tm *S_my_localtime (pTHX_ Time_t *tp) PP(pp_gmtime) { + dVAR; dSP; Time_t when; const struct tm *tmbuf; @@ -4364,7 +4382,7 @@ PP(pp_gmtime) PP(pp_alarm) { #ifdef HAS_ALARM - dSP; dTARGET; + dVAR; dSP; dTARGET; int anum; anum = POPi; anum = alarm((unsigned int)anum); @@ -4380,7 +4398,7 @@ PP(pp_alarm) PP(pp_sleep) { - dSP; dTARGET; + dVAR; dSP; dTARGET; I32 duration; Time_t lasttime; Time_t when; @@ -4403,7 +4421,7 @@ PP(pp_sleep) PP(pp_shmwrite) { #if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM) - dSP; dMARK; dTARGET; + dVAR; dSP; dMARK; dTARGET; const int op_type = PL_op->op_type; I32 value; @@ -4435,7 +4453,7 @@ PP(pp_shmwrite) PP(pp_semget) { #if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM) - dSP; dMARK; dTARGET; + dVAR; dSP; dMARK; dTARGET; const int anum = do_ipcget(PL_op->op_type, MARK, SP); SP = MARK; if (anum == -1) @@ -4450,7 +4468,7 @@ PP(pp_semget) PP(pp_semctl) { #if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM) - dSP; dMARK; dTARGET; + dVAR; dSP; dMARK; dTARGET; const int anum = do_ipcctl(PL_op->op_type, MARK, SP); SP = MARK; if (anum == -1) @@ -4472,7 +4490,7 @@ PP(pp_semctl) PP(pp_ghostent) { #if defined(HAS_GETHOSTBYNAME) || defined(HAS_GETHOSTBYADDR) || defined(HAS_GETHOSTENT) - dSP; + dVAR; dSP; I32 which = PL_op->op_type; register char **elem; register SV *sv; @@ -4543,7 +4561,7 @@ PP(pp_ghostent) for (elem = hent->h_aliases; elem && *elem; elem++) { sv_catpv(sv, *elem); if (elem[1]) - sv_catpvn(sv, " ", 1); + sv_catpvs(sv, " "); } PUSHs(sv = sv_mortalcopy(&PL_sv_no)); sv_setiv(sv, (IV)hent->h_addrtype); @@ -4570,7 +4588,7 @@ PP(pp_ghostent) PP(pp_gnetent) { #if defined(HAS_GETNETBYNAME) || defined(HAS_GETNETBYADDR) || defined(HAS_GETNETENT) - dSP; + dVAR; dSP; I32 which = PL_op->op_type; register char **elem; register SV *sv; @@ -4635,7 +4653,7 @@ PP(pp_gnetent) for (elem = nent->n_aliases; elem && *elem; elem++) { sv_catpv(sv, *elem); if (elem[1]) - sv_catpvn(sv, " ", 1); + sv_catpvs(sv, " "); } PUSHs(sv = sv_mortalcopy(&PL_sv_no)); sv_setiv(sv, (IV)nent->n_addrtype); @@ -4652,7 +4670,7 @@ PP(pp_gnetent) PP(pp_gprotoent) { #if defined(HAS_GETPROTOBYNAME) || defined(HAS_GETPROTOBYNUMBER) || defined(HAS_GETPROTOENT) - dSP; + dVAR; dSP; I32 which = PL_op->op_type; register char **elem; register SV *sv; @@ -4705,7 +4723,7 @@ PP(pp_gprotoent) for (elem = pent->p_aliases; elem && *elem; elem++) { sv_catpv(sv, *elem); if (elem[1]) - sv_catpvn(sv, " ", 1); + sv_catpvs(sv, " "); } PUSHs(sv = sv_mortalcopy(&PL_sv_no)); sv_setiv(sv, (IV)pent->p_proto); @@ -4720,7 +4738,7 @@ PP(pp_gprotoent) PP(pp_gservent) { #if defined(HAS_GETSERVBYNAME) || defined(HAS_GETSERVBYPORT) || defined(HAS_GETSERVENT) - dSP; + dVAR; dSP; I32 which = PL_op->op_type; register char **elem; register SV *sv; @@ -4735,7 +4753,7 @@ PP(pp_gservent) #ifdef HAS_GETSERVBYNAME const char * const proto = POPpbytex; const char * const name = POPpbytex; - sent = PerlSock_getservbyname(name, (proto && !*proto) ? Nullch : proto); + sent = PerlSock_getservbyname(name, (proto && !*proto) ? NULL : proto); #else DIE(aTHX_ PL_no_sock_func, "getservbyname"); #endif @@ -4747,7 +4765,7 @@ PP(pp_gservent) #ifdef HAS_HTONS port = PerlSock_htons(port); #endif - sent = PerlSock_getservbyport(port, (proto && !*proto) ? Nullch : proto); + sent = PerlSock_getservbyport(port, (proto && !*proto) ? NULL : proto); #else DIE(aTHX_ PL_no_sock_func, "getservbyport"); #endif @@ -4783,7 +4801,7 @@ PP(pp_gservent) for (elem = sent->s_aliases; elem && *elem; elem++) { sv_catpv(sv, *elem); if (elem[1]) - sv_catpvn(sv, " ", 1); + sv_catpvs(sv, " "); } PUSHs(sv = sv_mortalcopy(&PL_sv_no)); #ifdef HAS_NTOHS @@ -4804,7 +4822,7 @@ PP(pp_gservent) PP(pp_shostent) { #ifdef HAS_SETHOSTENT - dSP; + dVAR; dSP; PerlSock_sethostent(TOPi); RETSETYES; #else @@ -4815,7 +4833,7 @@ PP(pp_shostent) PP(pp_snetent) { #ifdef HAS_SETNETENT - dSP; + dVAR; dSP; PerlSock_setnetent(TOPi); RETSETYES; #else @@ -4826,7 +4844,7 @@ PP(pp_snetent) PP(pp_sprotoent) { #ifdef HAS_SETPROTOENT - dSP; + dVAR; dSP; PerlSock_setprotoent(TOPi); RETSETYES; #else @@ -4837,7 +4855,7 @@ PP(pp_sprotoent) PP(pp_sservent) { #ifdef HAS_SETSERVENT - dSP; + dVAR; dSP; PerlSock_setservent(TOPi); RETSETYES; #else @@ -4848,7 +4866,7 @@ PP(pp_sservent) PP(pp_ehostent) { #ifdef HAS_ENDHOSTENT - dSP; + dVAR; dSP; PerlSock_endhostent(); EXTEND(SP,1); RETPUSHYES; @@ -4860,7 +4878,7 @@ PP(pp_ehostent) PP(pp_enetent) { #ifdef HAS_ENDNETENT - dSP; + dVAR; dSP; PerlSock_endnetent(); EXTEND(SP,1); RETPUSHYES; @@ -4872,7 +4890,7 @@ PP(pp_enetent) PP(pp_eprotoent) { #ifdef HAS_ENDPROTOENT - dSP; + dVAR; dSP; PerlSock_endprotoent(); EXTEND(SP,1); RETPUSHYES; @@ -4884,7 +4902,7 @@ PP(pp_eprotoent) PP(pp_eservent) { #ifdef HAS_ENDSERVENT - dSP; + dVAR; dSP; PerlSock_endservent(); EXTEND(SP,1); RETPUSHYES; @@ -4896,7 +4914,7 @@ PP(pp_eservent) PP(pp_gpwent) { #ifdef HAS_PASSWD - dSP; + dVAR; dSP; I32 which = PL_op->op_type; register SV *sv; struct passwd *pwent = NULL; @@ -5130,7 +5148,7 @@ PP(pp_gpwent) PP(pp_spwent) { #if defined(HAS_PASSWD) && defined(HAS_SETPWENT) - dSP; + dVAR; dSP; setpwent(); RETPUSHYES; #else @@ -5141,7 +5159,7 @@ PP(pp_spwent) PP(pp_epwent) { #if defined(HAS_PASSWD) && defined(HAS_ENDPWENT) - dSP; + dVAR; dSP; endpwent(); RETPUSHYES; #else @@ -5152,19 +5170,17 @@ PP(pp_epwent) PP(pp_ggrent) { #ifdef HAS_GROUP - dSP; - I32 which = PL_op->op_type; - register char **elem; - register SV *sv; - struct group *grent; + dVAR; dSP; + const I32 which = PL_op->op_type; + const struct group *grent; if (which == OP_GGRNAM) { const char* const name = POPpbytex; - grent = (struct group *)getgrnam(name); + grent = (const struct group *)getgrnam(name); } else if (which == OP_GGRGID) { const Gid_t gid = POPi; - grent = (struct group *)getgrgid(gid); + grent = (const struct group *)getgrgid(gid); } else #ifdef HAS_GETGRENT @@ -5175,7 +5191,9 @@ PP(pp_ggrent) EXTEND(SP, 4); if (GIMME != G_ARRAY) { - PUSHs(sv = sv_newmortal()); + SV * const sv = sv_newmortal(); + + PUSHs(sv); if (grent) { if (which == OP_GGRNAM) sv_setiv(sv, (IV)grent->gr_gid); @@ -5186,6 +5204,8 @@ PP(pp_ggrent) } if (grent) { + SV *sv; + char **elem; PUSHs(sv = sv_mortalcopy(&PL_sv_no)); sv_setpv(sv, grent->gr_name); @@ -5210,7 +5230,7 @@ PP(pp_ggrent) for (elem = grent->gr_mem; elem && *elem; elem++) { sv_catpv(sv, *elem); if (elem[1]) - sv_catpvn(sv, " ", 1); + sv_catpvs(sv, " "); } #endif } @@ -5224,7 +5244,7 @@ PP(pp_ggrent) PP(pp_sgrent) { #if defined(HAS_GROUP) && defined(HAS_SETGRENT) - dSP; + dVAR; dSP; setgrent(); RETPUSHYES; #else @@ -5235,7 +5255,7 @@ PP(pp_sgrent) PP(pp_egrent) { #if defined(HAS_GROUP) && defined(HAS_ENDGRENT) - dSP; + dVAR; dSP; endgrent(); RETPUSHYES; #else @@ -5246,7 +5266,7 @@ PP(pp_egrent) PP(pp_getlogin) { #ifdef HAS_GETLOGIN - dSP; dTARGET; + dVAR; dSP; dTARGET; char *tmps; EXTEND(SP, 1); if (!(tmps = PerlProc_getlogin())) @@ -5263,7 +5283,7 @@ PP(pp_getlogin) PP(pp_syscall) { #ifdef HAS_SYSCALL - dSP; dMARK; dORIGMARK; dTARGET; + dVAR; dSP; dMARK; dORIGMARK; dTARGET; register I32 items = SP - MARK; unsigned long a[20]; register I32 i = 0;