X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pp_hot.c;h=3ab4f304e7b9f59f58d2e15e20161627d8a0c069;hb=2680586ee66b8de4d2b5f26a2013220f2bec9d5f;hp=27af29d071b219257b2f7bbad5f29f8542b3d80a;hpb=35cd451c5a1303394968903750cc3b3a1a6bc892;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pp_hot.c b/pp_hot.c index 27af29d..3ab4f30 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -855,7 +855,7 @@ PP(pp_match) register char *s; char *strend; I32 global; - I32 r_flags; + I32 r_flags = 0; char *truebase; register REGEXP *rx = pm->op_pmregexp; bool rxtainted; @@ -904,14 +904,18 @@ PP(pp_match) if (mg && mg->mg_len >= 0) { if (!(rx->reganch & ROPT_GPOS_SEEN)) rx->endp[0] = rx->startp[0] = s + mg->mg_len; + else if (rx->reganch & ROPT_ANCH_GPOS) { + r_flags |= REXEC_IGNOREPOS; + rx->endp[0] = rx->startp[0] = s + mg->mg_len; + } minmatch = (mg->mg_flags & MGf_MINMATCH); update_minmatch = 0; } } } - r_flags = ((gimme != G_ARRAY && !global && rx->nparens) - || SvTEMP(TARG) || PL_sawampersand) - ? REXEC_COPY_STR : 0; + if ((gimme != G_ARRAY && !global && rx->nparens) + || SvTEMP(TARG) || PL_sawampersand) + r_flags |= REXEC_COPY_STR; if (SvSCREAM(TARG) && rx->check_substr && SvTYPE(rx->check_substr) == SVt_PVBM && SvVALID(rx->check_substr)) @@ -1297,8 +1301,18 @@ do_readline(void) sv = sv_2mortal(NEWSV(57, 80)); offset = 0; } + +/* flip-flop EOF state for a snarfed empty file */ +#define SNARF_EOF(gimme,rs,io,sv) \ + ((gimme != G_SCALAR || SvCUR(sv) \ + || (IoFLAGS(io) & IOf_NOLINE) || IoLINES(io) || !RsSNARF(rs)) \ + ? ((IoFLAGS(io) &= ~IOf_NOLINE), TRUE) \ + : ((IoFLAGS(io) |= IOf_NOLINE), FALSE)) + for (;;) { - if (!sv_gets(sv, fp, offset)) { + if (!sv_gets(sv, fp, offset) + && (type == OP_GLOB || SNARF_EOF(gimme, PL_rs, io, sv))) + { PerlIO_clearerr(fp); if (IoFLAGS(io) & IOf_ARGV) { fp = nextargv(PL_last_in_gv);