#define PUSH_MULTICALL(the_cv) \
STMT_START { \
- CV *_nOnclAshIngNamE_ = the_cv; \
- CV *cv = _nOnclAshIngNamE_; \
- AV* padlist = CvPADLIST(cv); \
+ CV * const _nOnclAshIngNamE_ = the_cv; \
+ CV * const cv = _nOnclAshIngNamE_; \
+ AV * const padlist = CvPADLIST(cv); \
ENTER; \
multicall_oldcatch = CATCH_GET; \
SAVETMPS; SAVEVPTR(PL_op); \
}
#if defined(HAS_FCNTL) && defined(F_SETFD)
if (fd >= 0) {
- int save_errno = errno;
+ const int save_errno = errno;
fcntl(fd,F_SETFD,fd > PL_maxsysfd); /* can change errno */
errno = save_errno;
}
retval = TRUE;
else {
if (IoOFP(io) && IoOFP(io) != IoIFP(io)) { /* a socket */
- bool prev_err = PerlIO_error(IoOFP(io));
+ const bool prev_err = PerlIO_error(IoOFP(io));
retval = (PerlIO_close(IoOFP(io)) != EOF && !prev_err);
PerlIO_close(IoIFP(io)); /* clear stdio, fd already closed */
}
else {
- bool prev_err = PerlIO_error(IoIFP(io));
+ const bool prev_err = PerlIO_error(IoIFP(io));
retval = (PerlIO_close(IoIFP(io)) != EOF && !prev_err);
}
}
bool
Perl_do_eof(pTHX_ GV *gv)
{
- register IO *io;
- int ch;
-
- io = GvIO(gv);
+ register IO * const io = GvIO(gv);
if (!io)
return TRUE;
while (IoIFP(io)) {
int saverrno;
+ int ch;
if (PerlIO_has_cntptr(IoIFP(io))) { /* (the code works without this) */
if (PerlIO_get_cnt(IoIFP(io)) > 0) /* cheat a little, since */
return PL_laststatval;
}
else {
- SV* sv = POPs;
+ SV* const sv = POPs;
const char *s;
STRLEN len;
PUTBACK;
register char **a;
register char *s;
char *cmd;
- int cmdlen;
/* Make a copy so we can change it */
- cmdlen = strlen(incmd);
+ const int cmdlen = strlen(incmd);
Newx(cmd, cmdlen+1, char);
strncpy(cmd, incmd, cmdlen);
cmd[cmdlen] = 0;
if (*s == ' ')
s++;
if (*s++ == '\'') {
- char *ncmd = s;
+ char * const ncmd = s;
while (*s)
s++;
if (val < 0) {
val = -val;
while (++mark <= sp) {
- I32 proc = SvIVx(*mark);
+ const I32 proc = SvIVx(*mark);
APPLY_TAINT_PROPER();
#ifdef HAS_KILLPG
if (PerlProc_killpg(proc,val)) /* BSD */
}
else {
while (++mark <= sp) {
- I32 proc = SvIVx(*mark);
+ const I32 proc = SvIVx(*mark);
APPLY_TAINT_PROPER();
if (PerlProc_kill(proc, val))
tot--;
void *utbufp = &utbuf;
#endif
- SV* accessed = *++mark;
- SV* modified = *++mark;
+ SV* const accessed = *++mark;
+ SV* const modified = *++mark;
/* Be like C, and if both times are undefined, let the C
* library figure out what to do. This usually means
goto do_futimes;
}
else {
- const char *name = SvPV_nolen_const(*mark);
+ const char * const name = SvPV_nolen_const(*mark);
APPLY_TAINT_PROPER();
#ifdef HAS_FUTIMES
if (utimes(name, utbufp))
I32
Perl_do_ipcget(pTHX_ I32 optype, SV **mark, SV **sp)
{
- key_t key = (key_t)SvNVx(*++mark);
+ const key_t key = (key_t)SvNVx(*++mark);
const I32 n = (optype == OP_MSGGET) ? 0 : SvIVx(*++mark);
const I32 flags = SvIVx(*++mark);
(void)sp;
I32
Perl_do_ipcctl(pTHX_ I32 optype, SV **mark, SV **sp)
{
- SV *astr;
char *a;
- STRLEN infosize;
- I32 getinfo;
I32 ret = -1;
const I32 id = SvIVx(*++mark);
const I32 n = (optype == OP_SEMCTL) ? SvIVx(*++mark) : 0;
const I32 cmd = SvIVx(*++mark);
- PERL_UNUSED_ARG(sp);
+ SV * const astr = *++mark;
+ STRLEN infosize = 0;
+ I32 getinfo = (cmd == IPC_STAT);
- astr = *++mark;
- infosize = 0;
- getinfo = (cmd == IPC_STAT);
+ PERL_UNUSED_ARG(sp);
switch (optype)
{
}
else
{
- IV i = SvIV(astr);
+ const IV i = SvIV(astr);
a = INT2PTR(char *,i); /* ouch */
}
SETERRNO(0,0);
Perl_do_msgsnd(pTHX_ SV **mark, SV **sp)
{
#ifdef HAS_MSG
- SV *mstr;
- const char *mbuf;
- I32 msize, flags;
STRLEN len;
const I32 id = SvIVx(*++mark);
+ SV * const mstr = *++mark;
+ const I32 flags = SvIVx(*++mark);
+ const char * const mbuf = SvPV_const(mstr, len);
+ const I32 msize = len - sizeof(long);
+
PERL_UNUSED_ARG(sp);
- mstr = *++mark;
- flags = SvIVx(*++mark);
- mbuf = SvPV_const(mstr, len);
- if ((msize = len - sizeof(long)) < 0)
+ if (msize < 0)
Perl_croak(aTHX_ "Arg too short for msgsnd");
SETERRNO(0,0);
return msgsnd(id, (struct msgbuf *)mbuf, msize, flags);
Perl_do_msgrcv(pTHX_ SV **mark, SV **sp)
{
#ifdef HAS_MSG
- SV *mstr;
char *mbuf;
long mtype;
I32 msize, flags, ret;
const I32 id = SvIVx(*++mark);
+ SV * const mstr = *++mark;
PERL_UNUSED_ARG(sp);
- mstr = *++mark;
/* suppress warning when reading into undef var --jhi */
if (! SvOK(mstr))
sv_setpvn(mstr, "", 0);
Perl_do_semop(pTHX_ SV **mark, SV **sp)
{
#ifdef HAS_SEM
- SV *opstr;
- const char *opbuf;
STRLEN opsize;
const I32 id = SvIVx(*++mark);
+ SV * const opstr = *++mark;
+ const char * const opbuf = SvPV_const(opstr, opsize);
PERL_UNUSED_ARG(sp);
- opstr = *++mark;
- opbuf = SvPV_const(opstr, opsize);
if (opsize < 3 * SHORTSIZE
|| (opsize % (3 * SHORTSIZE))) {
SETERRNO(EINVAL,LIB_INVARG);
{
const int nsops = opsize / (3 * sizeof (short));
int i = nsops;
- short *ops = (short *) opbuf;
+ short * const ops = (short *) opbuf;
short *o = ops;
struct sembuf *temps, *t;
I32 result;
Perl_do_shmio(pTHX_ I32 optype, SV **mark, SV **sp)
{
#ifdef HAS_SHM
- SV *mstr;
char *shm;
- I32 mpos, msize;
struct shmid_ds shmds;
const I32 id = SvIVx(*++mark);
+ SV * const mstr = *++mark;
+ const I32 mpos = SvIVx(*++mark);
+ const I32 msize = SvIVx(*++mark);
PERL_UNUSED_ARG(sp);
- mstr = *++mark;
- mpos = SvIVx(*++mark);
- msize = SvIVx(*++mark);
SETERRNO(0,0);
if (shmctl(id, IPC_STAT, &shmds) == -1)
return -1;
const UV none = svp ? SvUV(*svp) : 0x7fffffff;
const UV extra = none + 1;
UV final = 0;
- UV uv;
I32 isutf8;
U8 hibit = 0;
}
while (s < send) {
- if ((uv = swash_fetch(rv, s, TRUE)) < none) {
+ const UV uv = swash_fetch(rv, s, TRUE);
+ if (uv < none) {
s += UTF8SKIP(s);
matches++;
d = uvuni_to_utf8(d, uv);
if (DO_UTF8(sv)) {
if (s && len) {
char * const send = s + len;
- char *start = s;
+ char * const start = s;
s = send - 1;
while (s > start && UTF8_IS_CONTINUATION(*s))
s--;
if (SvRMAGICAL(av)) {
U32 i;
for (i=0; i < (U32)maxarg; i++) {
- SV **svp = av_fetch(av, i, FALSE);
+ SV ** const svp = av_fetch(av, i, FALSE);
/* See note in pp_helem, and bug id #27839 */
SP[i+1] = svp
? SvGMAGICAL(*svp) ? sv_mortalcopy(*svp) : *svp
rx->subbeg = (char *) truebase;
rx->startp[0] = s - truebase;
if (RX_MATCH_UTF8(rx)) {
- char *t = (char*)utf8_hop((U8*)s, rx->minlen);
+ char * const t = (char*)utf8_hop((U8*)s, rx->minlen);
rx->endp[0] = t - truebase;
}
else {
RETPUSHNO;
if (SvMAGICAL(av) || AvREIFY(av)) {
- SV **svp = av_fetch(av, cx->blk_loop.iterix--, FALSE);
- if (svp)
- sv = *svp;
- else
- sv = Nullsv;
+ SV ** const svp = av_fetch(av, cx->blk_loop.iterix--, FALSE);
+ sv = svp ? *svp : Nullsv;
}
else {
sv = AvARRAY(av)[cx->blk_loop.iterix--];
RETPUSHNO;
if (SvMAGICAL(av) || AvREIFY(av)) {
- SV **svp = av_fetch(av, ++cx->blk_loop.iterix, FALSE);
- if (svp)
- sv = *svp;
- else
- sv = Nullsv;
+ SV ** const svp = av_fetch(av, ++cx->blk_loop.iterix, FALSE);
+ sv = svp ? *svp : Nullsv;
}
else {
sv = AvARRAY(av)[++cx->blk_loop.iterix];
register REGEXP *rx = PM_GETRE(pm);
STRLEN len;
int force_on_match = 0;
- I32 oldsave = PL_savestack_ix;
+ const I32 oldsave = PL_savestack_ix;
STRLEN slen;
bool doutf8 = FALSE;
#ifdef PERL_OLD_COPY_ON_WRITE
STATIC CV *
S_get_db_sub(pTHX_ SV **svp, CV *cv)
{
- SV *dbsv = GvSVn(PL_DBsub);
+ SV * const dbsv = GvSVn(PL_DBsub);
save_item(dbsv);
if (!PERLDB_SUB_NN) {
/* This path taken at least 75% of the time */
dMARK;
register I32 items = SP - MARK;
- AV* padlist = CvPADLIST(cv);
+ AV* const padlist = CvPADLIST(cv);
PUSHBLOCK(cx, CXt_SUB, MARK);
PUSHSUB(cx);
cx->blk_sub.retop = PL_op->op_next;
PAD_SET_CUR_NOSAVE(padlist, CvDEPTH(cv));
if (hasargs)
{
- AV* av;
-#if 0
- DEBUG_S(PerlIO_printf(Perl_debug_log,
- "%p entersub preparing @_\n", thr));
-#endif
- av = (AV*)PAD_SVl(0);
+ AV* const av = (AV*)PAD_SVl(0);
if (AvREAL(av)) {
/* @_ is normally not REAL--this should only ever
* happen when DB::sub() calls things that modify @_ */
SV** svp;
SV* const elemsv = POPs;
IV elem = SvIV(elemsv);
- AV* av = (AV*)POPs;
+ AV* const av = (AV*)POPs;
const U32 lval = PL_op->op_flags & OPf_MOD || LVRET;
const U32 defer = (PL_op->op_private & OPpLVAL_DEFER) && (elem > av_len(av));
SV *sv;
char *t;
if (!strnEQ(s, "0000", 4)) { /* need to grow sv */
- SV *tmpNew = newSVpvn("0000000000", 10);
+ SV * const tmpNew = newSVpvn("0000000000", 10);
sv_catsv(tmpNew, sv);
SvREFCNT_dec(sv); /* free old sv */
STATIC U8
uni_to_byte(pTHX_ const char **s, const char *end, I32 datumtype)
{
- UV val;
STRLEN retlen;
- val = utf8n_to_uvchr((U8 *) *s, end-*s, &retlen,
+ UV val = utf8n_to_uvchr((U8 *) *s, end-*s, &retlen,
ckWARN(WARN_UTF8) ? 0 : UTF8_ALLOW_ANY);
/* We try to process malformed UTF-8 as much as possible (preferrably with
warnings), but these two mean we make no progress in the string and
STATIC bool
next_uni_uu(pTHX_ const char **s, const char *end, I32 *out)
{
- UV val;
STRLEN retlen;
- val = utf8n_to_uvchr((U8 *) *s, end-*s, &retlen, UTF8_CHECK_ONLY);
+ const UV val = utf8n_to_uvchr((U8 *) *s, end-*s, &retlen, UTF8_CHECK_ONLY);
if (val >= 0x100 || !ISUUCHAR(val) ||
retlen == (STRLEN) -1 || retlen == 0) {
*out = 0;
STATIC void
bytes_to_uni(pTHX_ const U8 *start, STRLEN len, char **dest) {
U8 buffer[UTF8_MAXLEN];
- const U8 *end = start + len;
+ const U8 * const end = start + len;
char *d = *dest;
while (start < end) {
const int length =
S_next_symbol(pTHX_ tempsym_t* symptr )
{
const char* patptr = symptr->patptr;
- const char* patend = symptr->patend;
+ const char* const patend = symptr->patend;
symptr->flags &= ~FLAG_SLASH;
static I32
cmpindir(pTHX_ gptr a, gptr b)
{
- I32 sense;
gptr * const ap = (gptr *)a;
gptr * const bp = (gptr *)b;
+ const I32 sense = PL_sort_RealCmp(aTHX_ *ap, *bp);
- if ((sense = PL_sort_RealCmp(aTHX_ *ap, *bp)) == 0)
- sense = (ap > bp) ? 1 : ((ap < bp) ? -1 : 0);
- return sense;
+ if (sense)
+ return sense;
+ return (ap > bp) ? 1 : ((ap < bp) ? -1 : 0);
}
static I32
cmpindir_desc(pTHX_ gptr a, gptr b)
{
- I32 sense;
gptr * const ap = (gptr *)a;
gptr * const bp = (gptr *)b;
+ const I32 sense = PL_sort_RealCmp(aTHX_ *ap, *bp);
/* Reverse the default */
- if ((sense = PL_sort_RealCmp(aTHX_ *ap, *bp)))
+ if (sense)
return -sense;
/* But don't reverse the stability test. */
return (ap > bp) ? 1 : ((ap < bp) ? -1 : 0);
GV *gv;
CV *cv = 0;
I32 gimme = GIMME;
- OP* nextop = PL_op->op_next;
+ OP* const nextop = PL_op->op_next;
I32 overloading = 0;
bool hasargs = FALSE;
I32 is_xsub = 0;
cx->blk_gimme = G_SCALAR;
PUSHSUB(cx);
if (!is_xsub) {
- AV* padlist = CvPADLIST(cv);
+ AV* const padlist = CvPADLIST(cv);
if (++CvDEPTH(cv) >= 2) {
PERL_STACK_OVERFLOW_CHECK();
if (priv & OPpSORT_REVERSE) {
SV **q = start+max-1;
while (start < q) {
- SV *tmp = *start;
+ SV * const tmp = *start;
*start++ = *q;
*q-- = tmp;
}
tmps = SvROK(tmpsv) ? Nullch : SvPV_const(tmpsv, len);
}
if (!tmps || !len) {
- SV *error = ERRSV;
+ SV * const error = ERRSV;
SvUPGRADE(error, SVt_PV);
if (multiarg ? SvROK(error) : SvROK(tmpsv)) {
if (!multiarg)
if ((mg = SvTIED_mg(sv, how))) {
SV * const obj = SvRV(SvTIED_obj(sv, mg));
- CV *cv;
+ CV *cv = NULL;
if (obj) {
GV * const gv = gv_fetchmethod_autoload(SvSTASH(obj), "UNTIE", FALSE);
if (gv && isGV(gv) && (cv = GvCV(gv))) {
if (PL_op->op_type == OP_SEEK)
PUSHs(boolSV(do_seek(gv, offset, whence)));
else {
- Off_t sought = do_sysseek(gv, offset, whence);
+ const Off_t sought = do_sysseek(gv, offset, whence);
if (sought < 0)
PUSHs(&PL_sv_undef);
else {
* general one would think that when using large files, off_t is
* at least as wide as size_t, so using an off_t should be okay. */
/* XXX Configure probe for the length type of *truncate() needed XXX */
+ Off_t len;
#if Off_t_size > IVSIZE
- const Off_t len = (Off_t)POPn;
+ len = (Off_t)POPn;
#else
- const Off_t len = (Off_t)POPi;
+ len = (Off_t)POPi;
#endif
/* Checking for length < 0 is problematic as the type might or
* might not be signed: if it is not, clever compilers will moan. */
fp = Nullfp;
io = NULL;
}
+ /* XXX Looks to me like io is always NULL at this point */
if (fp) {
(void)PerlIO_flush(fp);
value = (I32)(PerlLIO_flock(PerlIO_fileno(fp), argtype) >= 0);
Safefree(cmdline);
if (myfp) {
- SV *tmpsv = sv_newmortal();
+ SV * const tmpsv = sv_newmortal();
/* Need to save/restore 'PL_rs' ?? */
s = sv_gets(tmpsv, myfp, 0);
(void)PerlProc_pclose(myfp);
PP(pp_mkdir)
{
dSP; dTARGET;
-#ifndef HAS_MKDIR
- int oldumask;
-#endif
STRLEN len;
const char *tmps;
bool copy = FALSE;
#ifdef HAS_MKDIR
SETi( PerlDir_mkdir(tmps, mode) >= 0 );
#else
+ {
+ int oldumask;
SETi( dooneliner("mkdir", tmps) );
oldumask = PerlLIO_umask(0);
PerlLIO_umask(oldumask);
PerlLIO_chmod(tmps, (mode & ~oldumask) & 0777);
+ }
#endif
if (copy)
Safefree(tmps);
{
#if (!defined(DOSISH) || defined(OS2) || defined(WIN32)) && !defined(MACOS_TRADITIONAL)
dSP; dTARGET;
- Pid_t pid;
+ const int optype = POPi;
+ const Pid_t pid = TOPi;
Pid_t result;
- int optype;
int argflags;
- optype = POPi;
- pid = TOPi;
if (PL_signals & PERL_SIGNALS_UNSAFE_FLAG)
result = wait4pid(pid, &argflags, optype);
else {
#endif
}
if (PL_op->op_flags & OPf_STACKED) {
- SV *really = *++MARK;
+ SV * const really = *++MARK;
value = (I32)do_aexec5(really, MARK, SP, pp[1], did_pipes);
}
else if (SP - MARK != 1)
PL_statusvalue = 0;
result = 0;
if (PL_op->op_flags & OPf_STACKED) {
- SV *really = *++MARK;
+ SV * const really = *++MARK;
# if defined(WIN32) || defined(OS2) || defined(__SYMBIAN32__)
value = (I32)do_aspawn(really, MARK, SP);
# else
}
PERL_FLUSHALL_FOR_CHILD;
if (PL_op->op_flags & OPf_STACKED) {
- SV *really = *++MARK;
+ SV * const really = *++MARK;
value = (I32)do_aexec(really, MARK, SP);
}
else if (SP - MARK != 1)
{
#ifdef HAS_GETPGRP
dSP; dTARGET;
- Pid_t pid;
Pid_t pgrp;
+ const Pid_t pid = (MAXARG < 1) ? 0 : SvIVx(POPs);
- if (MAXARG < 1)
- pid = 0;
- else
- pid = SvIVx(POPs);
#ifdef BSD_GETPGRP
pgrp = (I32)BSD_GETPGRP(pid);
#else
{
#ifdef HAS_GETPRIORITY
dSP; dTARGET;
- int who = POPi;
- int which = TOPi;
+ const int who = POPi;
+ const int which = TOPi;
SETi( getpriority(which, who) );
RETURN;
#else
{
#ifdef HAS_SETPRIORITY
dSP; dTARGET;
- int niceval = POPi;
- int who = POPi;
- int which = TOPi;
+ const int niceval = POPi;
+ const int who = POPi;
+ const int which = TOPi;
TAINT_PROPER("setpriority");
SETi( setpriority(which, who, niceval) >= 0 );
RETURN;
{
#if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
dSP; dMARK; dTARGET;
- int anum = do_ipcget(PL_op->op_type, MARK, SP);
+ const int anum = do_ipcget(PL_op->op_type, MARK, SP);
SP = MARK;
if (anum == -1)
RETPUSHUNDEF;
{
#if defined(HAS_MSG) || defined(HAS_SEM) || defined(HAS_SHM)
dSP; dMARK; dTARGET;
- int anum = do_ipcctl(PL_op->op_type, MARK, SP);
+ const int anum = do_ipcctl(PL_op->op_type, MARK, SP);
SP = MARK;
if (anum == -1)
RETSETUNDEF;
EXTEND(SP, 10);
if (which == OP_GHBYNAME) {
#ifdef HAS_GETHOSTBYNAME
- char* name = POPpbytex;
+ const char* const name = POPpbytex;
hent = PerlSock_gethostbyname(name);
#else
DIE(aTHX_ PL_no_sock_func, "gethostbyname");
}
else if (which == OP_GHBYADDR) {
#ifdef HAS_GETHOSTBYADDR
- int addrtype = POPi;
- SV *addrsv = POPs;
+ const int addrtype = POPi;
+ SV * const addrsv = POPs;
STRLEN addrlen;
- Netdb_host_t addr = (Netdb_host_t) SvPVbyte(addrsv, addrlen);
+ const Netdb_host_t addr = (Netdb_host_t) SvPVbyte(addrsv, addrlen);
hent = PerlSock_gethostbyaddr(addr, (Netdb_hlen_t) addrlen, addrtype);
#else
if (which == OP_GNBYNAME){
#ifdef HAS_GETNETBYNAME
- char *name = POPpbytex;
+ const char * const name = POPpbytex;
nent = PerlSock_getnetbyname(name);
#else
DIE(aTHX_ PL_no_sock_func, "getnetbyname");
}
else if (which == OP_GNBYADDR) {
#ifdef HAS_GETNETBYADDR
- int addrtype = POPi;
- Netdb_net_t addr = (Netdb_net_t) (U32)POPu;
+ const int addrtype = POPi;
+ const Netdb_net_t addr = (Netdb_net_t) (U32)POPu;
nent = PerlSock_getnetbyaddr(addr, addrtype);
#else
DIE(aTHX_ PL_no_sock_func, "getnetbyaddr");
if (which == OP_GPBYNAME) {
#ifdef HAS_GETPROTOBYNAME
- char* name = POPpbytex;
+ const char* const name = POPpbytex;
pent = PerlSock_getprotobyname(name);
#else
DIE(aTHX_ PL_no_sock_func, "getprotobyname");
}
else if (which == OP_GPBYNUMBER) {
#ifdef HAS_GETPROTOBYNUMBER
- int number = POPi;
+ const int number = POPi;
pent = PerlSock_getprotobynumber(number);
#else
DIE(aTHX_ PL_no_sock_func, "getprotobynumber");
if (which == OP_GSBYNAME) {
#ifdef HAS_GETSERVBYNAME
- char *proto = POPpbytex;
- char *name = POPpbytex;
-
- if (proto && !*proto)
- proto = Nullch;
-
- sent = PerlSock_getservbyname(name, proto);
+ const char * const proto = POPpbytex;
+ const char * const name = POPpbytex;
+ sent = PerlSock_getservbyname(name, (proto && !*proto) ? Nullch : proto);
#else
DIE(aTHX_ PL_no_sock_func, "getservbyname");
#endif
}
else if (which == OP_GSBYPORT) {
#ifdef HAS_GETSERVBYPORT
- char *proto = POPpbytex;
+ const char * const proto = POPpbytex;
unsigned short port = (unsigned short)POPu;
-
- if (proto && !*proto)
- proto = Nullch;
-
#ifdef HAS_HTONS
port = PerlSock_htons(port);
#endif
- sent = PerlSock_getservbyport(port, proto);
+ sent = PerlSock_getservbyport(port, (proto && !*proto) ? Nullch : proto);
#else
DIE(aTHX_ PL_no_sock_func, "getservbyport");
#endif
switch (which) {
case OP_GPWNAM:
{
- char* name = POPpbytex;
+ const char* const name = POPpbytex;
pwent = getpwnam(name);
}
break;
* has a different API than the Solaris/IRIX one. */
# if defined(HAS_GETSPNAM) && !defined(_AIX)
{
- struct spwd *spwent;
- int saverrno; /* Save and restore errno so that
+ const int saverrno = errno;
+ const struct spwd * const spwent = getspnam(pwent->pw_name);
+ /* Save and restore errno so that
* underprivileged attempts seem
* to have never made the unsccessful
* attempt to retrieve the shadow password. */
-
- saverrno = errno;
- spwent = getspnam(pwent->pw_name);
errno = saverrno;
if (spwent && spwent->sp_pwdp)
sv_setpv(sv, spwent->sp_pwdp);
struct group *grent;
if (which == OP_GGRNAM) {
- char* name = POPpbytex;
+ const char* const name = POPpbytex;
grent = (struct group *)getgrnam(name);
}
else if (which == OP_GGRGID) {
- Gid_t gid = POPi;
+ const Gid_t gid = POPi;
grent = (struct group *)getgrgid(gid);
}
else
lockf_emulate_flock(int fd, int operation)
{
int i;
- int save_errno;
+ const int save_errno = errno;
Off_t pos;
/* flock locks entire file so for lockf we need to do the same */
- save_errno = errno;
pos = PerlLIO_lseek(fd, (Off_t)0, SEEK_CUR); /* get pos to restore later */
if (pos > 0) /* is seekable and needs to be repositioned */
if (PerlLIO_lseek(fd, (Off_t)0, SEEK_SET) < 0)
if (mg->mg_type == PERL_MAGIC_overload_table &&
AMT_AMAGIC((AMT*)mg->mg_ptr))
{
- AMT *amtp = (AMT*)mg->mg_ptr;
- AMT *namtp = (AMT*)nmg->mg_ptr;
+ AMT * const amtp = (AMT*)mg->mg_ptr;
+ AMT * const namtp = (AMT*)nmg->mg_ptr;
I32 i;
for (i = 1; i < NofAMmeth; i++) {
namtp->table[i] = cv_dup_inc(amtp->table[i], param);
if ((entry = hv_iternext(PL_pidstatus))) {
SV * const sv = hv_iterval(PL_pidstatus,entry);
I32 len;
- const char *spid = hv_iterkey(entry,&len);
+ const char * const spid = hv_iterkey(entry,&len);
assert (len == sizeof(Pid_t));
memcpy((char *)&pid, spid, len);
#endif
/* additional extensions to try in each dir if scriptname not found */
#ifdef SEARCH_EXTS
- const char *const exts[] = { SEARCH_EXTS };
+ static const char *const exts[] = { SEARCH_EXTS };
const char *const *const ext = search_ext ? search_ext : exts;
int extidx = 0, i = 0;
const char *curext = Nullch;