rxres_restore(&cx->sb_rxres, rx);
if (cx->sb_iters++) {
- const I32 saviters = cx->sb_iters;
+ const SSize_t saviters = cx->sb_iters;
if (cx->sb_iters > cx->sb_maxiters)
DIE(aTHX_ "Substitution loop");
break;
}
itembytes = s - item;
+ chophere = s;
break;
}
PP(pp_range)
{
- if (GIMME == G_ARRAY)
+ if (GIMME_V == G_ARRAY)
return NORMAL;
if (SvTRUEx(PAD_SV(PL_op->op_targ)))
return cLOGOP->op_other;
{
dSP;
- if (GIMME == G_ARRAY) {
+ if (GIMME_V == G_ARRAY) {
RETURNOP(((LOGOP*)cUNOP->op_first)->op_other);
}
else {
{
dSP;
- if (GIMME == G_ARRAY) {
+ if (GIMME_V == G_ARRAY) {
dPOPPOPssrl;
SvGETMAGIC(left);
else
n = 0;
while (n--) {
- SV * const sv = sv_2mortal(newSViv(i++));
+ SV * const sv = sv_2mortal(newSViv(i));
PUSHs(sv);
+ if (n) /* avoid incrementing above IV_MAX */
+ i++;
}
}
else {
dSP;
const PERL_CONTEXT *cx;
const PERL_CONTEXT *dbcx;
- I32 gimme;
+ I32 gimme = GIMME_V;
const HEK *stash_hek;
I32 count = 0;
bool has_arg = MAXARG && TOPs;
cx = caller_cx(count + !!(PL_op->op_private & OPpOFFBYONE), &dbcx);
if (!cx) {
- if (GIMME != G_ARRAY) {
+ if (gimme != G_ARRAY) {
EXTEND(SP, 1);
RETPUSHUNDEF;
}
stash_hek = SvTYPE(CopSTASH(cx->blk_oldcop)) == SVt_PVHV
? HvNAME_HEK((HV*)CopSTASH(cx->blk_oldcop))
: NULL;
- if (GIMME != G_ARRAY) {
+ if (gimme != G_ARRAY) {
EXTEND(SP, 1);
if (!stash_hek)
PUSHs(&PL_sv_undef);
RETURN;
}
+static bool
+S_outside_integer(pTHX_ SV *sv)
+{
+ if (SvOK(sv)) {
+ const NV nv = SvNV_nomg(sv);
+ if (Perl_isinfnan(nv))
+ return TRUE;
+#ifdef NV_PRESERVES_UV
+ if (nv < (NV)IV_MIN || nv > (NV)IV_MAX)
+ return TRUE;
+#else
+ if (nv <= (NV)IV_MIN)
+ return TRUE;
+ if ((nv > 0) &&
+ ((nv > (NV)UV_MAX ||
+ SvUV_nomg(sv) > (UV)IV_MAX)))
+ return TRUE;
+#endif
+ }
+ return FALSE;
+}
+
PP(pp_enteriter)
{
dSP; dMARK;
SvGETMAGIC(sv);
SvGETMAGIC(right);
if (RANGE_IS_NUMERIC(sv,right)) {
- NV nv;
cx->cx_type &= ~CXTYPEMASK;
cx->cx_type |= CXt_LOOP_LAZYIV;
/* Make sure that no-one re-orders cop.h and breaks our
assumptions */
assert(CxTYPE(cx) == CXt_LOOP_LAZYIV);
-#ifdef NV_PRESERVES_UV
- if ((SvOK(sv) && (((nv = SvNV_nomg(sv)) < (NV)IV_MIN) ||
- (nv > (NV)IV_MAX)))
- ||
- (SvOK(right) && (((nv = SvNV_nomg(right)) > (NV)IV_MAX) ||
- (nv < (NV)IV_MIN))))
-#else
- if ((SvOK(sv) && (((nv = SvNV_nomg(sv)) <= (NV)IV_MIN)
- ||
- ((nv > 0) &&
- ((nv > (NV)UV_MAX) ||
- (SvUV_nomg(sv) > (UV)IV_MAX)))))
- ||
- (SvOK(right) && (((nv = SvNV_nomg(right)) <= (NV)IV_MIN)
- ||
- ((nv > 0) &&
- ((nv > (NV)UV_MAX) ||
- (SvUV_nomg(right) > (UV)IV_MAX))
- ))))
-#endif
+ if (S_outside_integer(aTHX_ sv) ||
+ S_outside_integer(aTHX_ right))
DIE(aTHX_ "Range iterator outside integer range");
cx->blk_loop.state_u.lazyiv.cur = SvIV_nomg(sv);
cx->blk_loop.state_u.lazyiv.end = SvIV_nomg(right);
}
}
- else {
- assert(do_dump);
+ if (do_dump) {
#ifdef VMS
if (!retop) retop = PL_main_start;
#endif
{
Stat_t st;
STRLEN len;
+ PerlIO * retio;
const char *p = SvPV_const(name, len);
int st_rc;
if (!IS_SAFE_PATHNAME(p, len, "require"))
return NULL;
+ /* on Win32 stat is expensive (it does an open() and close() twice and
+ a couple other IO calls), the open will fail with a dir on its own with
+ errno EACCES, so only do a stat to separate a dir from a real EACCES
+ caused by user perms */
+#ifndef WIN32
/* we use the value of errno later to see how stat() or open() failed.
* We don't want it set if the stat succeeded but we still failed,
* such as if the name exists, but is a directory */
if (st_rc < 0 || S_ISDIR(st.st_mode) || S_ISBLK(st.st_mode)) {
return NULL;
}
+#endif
#if !defined(PERLIO_IS_STDIO)
- return PerlIO_openn(aTHX_ ":", PERL_SCRIPT_MODE, -1, 0, 0, NULL, 1, &name);
+ retio = PerlIO_openn(aTHX_ ":", PERL_SCRIPT_MODE, -1, 0, 0, NULL, 1, &name);
#else
- return PerlIO_open(p, PERL_SCRIPT_MODE);
+ retio = PerlIO_open(p, PERL_SCRIPT_MODE);
+#endif
+#ifdef WIN32
+ /* EACCES stops the INC search early in pp_require to implement
+ feature RT #113422 */
+ if(!retio && errno == EACCES) { /* exists but probably a directory */
+ int eno;
+ st_rc = PerlLIO_stat(p, &st);
+ if (st_rc >= 0) {
+ if(S_ISDIR(st.st_mode) || S_ISBLK(st.st_mode))
+ eno = 0;
+ else
+ eno = EACCES;
+ errno = eno;
+ }
+ }
#endif
+ return retio;
}
#ifndef PERL_DISABLE_PMC
#endif /* !PERL_DISABLE_PMC */
/* require doesn't search for absolute names, or when the name is
- explicity relative the current directory */
+ explicitly relative the current directory */
PERL_STATIC_INLINE bool
S_path_is_searchable(const char *name)
{
umaxlen = maxlen;
/* I was having segfault trouble under Linux 2.2.5 after a
- parse error occured. (Had to hack around it with a test
+ parse error occurred. (Had to hack around it with a test
for PL_parser->error_count == 0.) Solaris doesn't segfault --
not sure where the trouble is yet. XXX */