X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pp_ctl.c;h=567370be8b70ece6dd7bf012c01dbe3e4403ab7f;hb=895fe8448c39ec9ce61fb5a2b7f671d3d15dcb46;hp=f64b18d6208a25378f78b41cef9bee18298c4319;hpb=4d1ff10ffec86208b0da135b87c76b89e61c866e;p=p5sagit%2Fp5-mst-13.2.git diff --git a/pp_ctl.c b/pp_ctl.c index f64b18d..567370b 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -26,24 +26,19 @@ #define DOCATCH(o) ((CATCH_GET == TRUE) ? docatch(o) : (o)) -static I32 sortcv(pTHXo_ SV *a, SV *b); -static I32 sortcv_stacked(pTHXo_ SV *a, SV *b); -static I32 sortcv_xsub(pTHXo_ SV *a, SV *b); -static I32 sv_ncmp(pTHXo_ SV *a, SV *b); -static I32 sv_i_ncmp(pTHXo_ SV *a, SV *b); -static I32 amagic_ncmp(pTHXo_ SV *a, SV *b); -static I32 amagic_i_ncmp(pTHXo_ SV *a, SV *b); -static I32 amagic_cmp(pTHXo_ SV *a, SV *b); -static I32 amagic_cmp_locale(pTHXo_ SV *a, SV *b); -static I32 run_user_filter(pTHXo_ int idx, SV *buf_sv, int maxlen); - -#ifdef PERL_OBJECT -static I32 sv_cmp_static(pTHXo_ SV *a, SV *b); -static I32 sv_cmp_locale_static(pTHXo_ SV *a, SV *b); -#else +static I32 sortcv(pTHX_ SV *a, SV *b); +static I32 sortcv_stacked(pTHX_ SV *a, SV *b); +static I32 sortcv_xsub(pTHX_ SV *a, SV *b); +static I32 sv_ncmp(pTHX_ SV *a, SV *b); +static I32 sv_i_ncmp(pTHX_ SV *a, SV *b); +static I32 amagic_ncmp(pTHX_ SV *a, SV *b); +static I32 amagic_i_ncmp(pTHX_ SV *a, SV *b); +static I32 amagic_cmp(pTHX_ SV *a, SV *b); +static I32 amagic_cmp_locale(pTHX_ SV *a, SV *b); +static I32 run_user_filter(pTHX_ int idx, SV *buf_sv, int maxlen); + #define sv_cmp_static Perl_sv_cmp #define sv_cmp_locale_static Perl_sv_cmp_locale -#endif PP(pp_wantarray) { @@ -177,6 +172,7 @@ PP(pp_substcont) rxres_restore(&cx->sb_rxres, rx); if (cx->sb_iters++) { + I32 saviters = cx->sb_iters; if (cx->sb_iters > cx->sb_maxiters) DIE(aTHX_ "Substitution loop"); @@ -218,6 +214,7 @@ PP(pp_substcont) POPSUBST(cx); RETURNOP(pm->op_next); } + cx->sb_iters = saviters; } if (RX_MATCH_COPIED(rx) && rx->subbeg != orig) { m = s; @@ -1023,8 +1020,8 @@ PP(pp_sort) cx->blk_sub.oldcurpad = PL_curpad; cx->blk_sub.argarray = av; } - qsortsv((myorigmark+1), max, - is_xsub ? sortcv_xsub : hasargs ? sortcv_stacked : sortcv); + sortsv((myorigmark+1), max, + is_xsub ? sortcv_xsub : hasargs ? sortcv_stacked : sortcv); POPBLOCK(cx,PL_curpm); PL_stack_sp = newsp; @@ -1035,8 +1032,8 @@ PP(pp_sort) else { if (max > 1) { MEXTEND(SP, 20); /* Can't afford stack realloc on signal. */ - qsortsv(ORIGMARK+1, max, - (PL_op->op_private & OPpSORT_NUMERIC) + sortsv(ORIGMARK+1, max, + (PL_op->op_private & OPpSORT_NUMERIC) ? ( (PL_op->op_private & OPpSORT_INTEGER) ? ( overloading ? amagic_i_ncmp : sv_i_ncmp) : ( overloading ? amagic_ncmp : sv_ncmp)) @@ -1498,7 +1495,7 @@ Perl_die_where(pTHX_ char *message, STRLEN msglen) #endif PerlIO *serr = Perl_error_log; - PerlIO_write(serr, message, msglen); + PERL_WRITE_MSG_TO_CONSOLE(serr, message, msglen); (void)PerlIO_flush(serr); #ifdef USE_SFIO errno = e; @@ -1784,7 +1781,7 @@ PP(pp_enteriter) SAVESPTR(*svp); #else SAVEPADSV(PL_op->op_targ); - iterdata = (void*)PL_op->op_targ; + iterdata = INT2PTR(void*, PL_op->op_targ); cxtype |= CXp_PADVAR; #endif } @@ -2309,7 +2306,7 @@ PP(pp_goto) PL_stack_sp--; /* There is no cv arg. */ /* Push a mark for the start of arglist */ PUSHMARK(mark); - (void)(*CvXSUB(cv))(aTHXo_ cv); + (void)(*CvXSUB(cv))(aTHX_ cv); /* Pop the current context like a decent sub should */ POPBLOCK(cx, PL_curpm); /* Do _not_ use PUTBACK, keep the XSUB's return stack! */ @@ -2596,6 +2593,7 @@ PP(pp_exit) #ifdef VMS if (anum == 1 && (PL_op->op_private & OPpEXIT_VMSISH)) anum = 0; + VMSISH_HUSHED = VMSISH_HUSHED || (PL_op->op_private & OPpHUSH_VMSISH); #endif } PL_exit_flags |= PERL_EXIT_EXPECTED; @@ -2899,8 +2897,6 @@ S_doeval(pTHX_ int gimme, OP** startop) PL_error_count = 0; PL_curcop = &PL_compiling; PL_curcop->cop_arybase = 0; - SvREFCNT_dec(PL_rs); - PL_rs = newSVpvn("\n", 1); if (saveop && saveop->op_flags & OPf_SPECIAL) PL_in_eval |= EVAL_KEEPERR; else @@ -2938,8 +2934,6 @@ S_doeval(pTHX_ int gimme, OP** startop) Perl_croak(aTHX_ "%sCompilation failed in regexp", (*msg ? msg : "Unknown error\n")); } - SvREFCNT_dec(PL_rs); - PL_rs = SvREFCNT_inc(PL_nrs); #ifdef USE_5005THREADS MUTEX_LOCK(&PL_eval_mutex); PL_eval_owner = 0; @@ -2948,8 +2942,6 @@ S_doeval(pTHX_ int gimme, OP** startop) #endif /* USE_5005THREADS */ RETPUSHUNDEF; } - SvREFCNT_dec(PL_rs); - PL_rs = SvREFCNT_inc(PL_nrs); CopLINE_set(&PL_compiling, 0); if (startop) { *startop = PL_eval_root; @@ -3043,6 +3035,7 @@ PP(pp_require) GV *filter_child_proc = 0; SV *filter_state = 0; SV *filter_sub = 0; + SV *hook_sv = 0; sv = POPs; if (SvNIOKp(sv)) { @@ -3071,6 +3064,9 @@ PP(pp_require) "v%d.%d.%d, stopped", rev, ver, sver, PERL_REVISION, PERL_VERSION, PERL_SUBVERSION); } + if (ckWARN(WARN_PORTABLE)) + Perl_warner(aTHX_ WARN_PORTABLE, + "v-string in use/require non-portable"); RETPUSHYES; } else if (!SvPOKp(sv)) { /* require 5.005_03 */ @@ -3089,7 +3085,7 @@ PP(pp_require) if (sver == 0 && (rev > 5 || (rev == 5 && ver >= 100))) { DIE(aTHX_ "Perl v%"UVuf".%"UVuf".%"UVuf" required--" "this is only v%d.%d.%d, stopped" - " (did you mean v%"UVuf".%"UVuf".0?)", + " (did you mean v%"UVuf".%03"UVuf"?)", rev, ver, sver, PERL_REVISION, PERL_VERSION, PERL_SUBVERSION, rev, ver/100); } @@ -3160,7 +3156,7 @@ trylocal: { } Perl_sv_setpvf(aTHX_ namesv, "/loader/0x%"UVxf"/%s", - PTR2UV(SvANY(loader)), name); + PTR2UV(SvRV(dirsv)), name); tryname = SvPVX(namesv); tryrsfp = 0; @@ -3241,6 +3237,7 @@ trylocal: { LEAVE; if (tryrsfp) { + hook_sv = dirsv; break; } @@ -3329,8 +3326,14 @@ trylocal: { SETERRNO(0, SS$_NORMAL); /* Assume success here to prevent recursive requirement. */ - (void)hv_store(GvHVn(PL_incgv), name, strlen(name), - newSVpv(CopFILE(&PL_compiling), 0), 0 ); + len = strlen(name); + /* Check whether a hook in @INC has already filled %INC */ + if (!hook_sv || !(svp = hv_fetch(GvHVn(PL_incgv), name, len, 0))) { + (void)hv_store(GvHVn(PL_incgv), name, len, + (hook_sv ? SvREFCNT_inc(hook_sv) + : newSVpv(CopFILE(&PL_compiling), 0)), + 0 ); + } ENTER; SAVETMPS; @@ -3815,12 +3818,11 @@ S_doparseform(pTHX_ SV *sv) #ifdef TESTHARNESS #include typedef void SV; -#define pTHXo_ #define pTHX_ #define STATIC #define New(ID,VAR,N,TYPE) VAR=(TYPE *)malloc((N)*sizeof(TYPE)) #define Safefree(VAR) free(VAR) -typedef int (*SVCOMPARE_t) (pTHXo_ SV*, SV*); +typedef int (*SVCOMPARE_t) (pTHX_ SV*, SV*); #endif /* TESTHARNESS */ typedef char * aptr; /* pointer for arithmetic on sizes */ @@ -4037,8 +4039,18 @@ dynprep(pTHX_ gptr *list1, gptr *list2, size_t nmemb, SVCOMPARE_t cmp) ** They make convenient temporary pointers in other places. */ -STATIC void -S_qsortsv(pTHX_ gptr *list1, size_t nmemb, SVCOMPARE_t cmp) +/* +=for apidoc sortsv + +Sort an array. Here is an example: + + sortsv(AvARRAY(av), av_len(av)+1, Perl_sv_cmp_locale); + +=cut +*/ + +void +Perl_sortsv(pTHX_ gptr *list1, size_t nmemb, SVCOMPARE_t cmp) { int i, run; int sense; @@ -4164,16 +4176,8 @@ S_qsortsv(pTHX_ gptr *list1, size_t nmemb, SVCOMPARE_t cmp) return; } - -#ifdef PERL_OBJECT -#undef this -#define this pPerl -#include "XSUB.h" -#endif - - static I32 -sortcv(pTHXo_ SV *a, SV *b) +sortcv(pTHX_ SV *a, SV *b) { I32 oldsaveix = PL_savestack_ix; I32 oldscopeix = PL_scopestack_ix; @@ -4196,7 +4200,7 @@ sortcv(pTHXo_ SV *a, SV *b) } static I32 -sortcv_stacked(pTHXo_ SV *a, SV *b) +sortcv_stacked(pTHX_ SV *a, SV *b) { I32 oldsaveix = PL_savestack_ix; I32 oldscopeix = PL_scopestack_ix; @@ -4241,7 +4245,7 @@ sortcv_stacked(pTHXo_ SV *a, SV *b) } static I32 -sortcv_xsub(pTHXo_ SV *a, SV *b) +sortcv_xsub(pTHX_ SV *a, SV *b) { dSP; I32 oldsaveix = PL_savestack_ix; @@ -4255,7 +4259,7 @@ sortcv_xsub(pTHXo_ SV *a, SV *b) *++SP = a; *++SP = b; PUTBACK; - (void)(*CvXSUB(cv))(aTHXo_ cv); + (void)(*CvXSUB(cv))(aTHX_ cv); if (PL_stack_sp != PL_stack_base + 1) Perl_croak(aTHX_ "Sort subroutine didn't return single value"); if (!SvNIOKp(*PL_stack_sp)) @@ -4270,7 +4274,7 @@ sortcv_xsub(pTHXo_ SV *a, SV *b) static I32 -sv_ncmp(pTHXo_ SV *a, SV *b) +sv_ncmp(pTHX_ SV *a, SV *b) { NV nv1 = SvNV(a); NV nv2 = SvNV(b); @@ -4278,7 +4282,7 @@ sv_ncmp(pTHXo_ SV *a, SV *b) } static I32 -sv_i_ncmp(pTHXo_ SV *a, SV *b) +sv_i_ncmp(pTHX_ SV *a, SV *b) { IV iv1 = SvIV(a); IV iv2 = SvIV(b); @@ -4296,7 +4300,7 @@ sv_i_ncmp(pTHXo_ SV *a, SV *b) } STMT_END static I32 -amagic_ncmp(pTHXo_ register SV *a, register SV *b) +amagic_ncmp(pTHX_ register SV *a, register SV *b) { SV *tmpsv; tryCALL_AMAGICbin(a,b,ncmp,&tmpsv); @@ -4314,11 +4318,11 @@ amagic_ncmp(pTHXo_ register SV *a, register SV *b) return 1; return d? -1 : 0; } - return sv_ncmp(aTHXo_ a, b); + return sv_ncmp(aTHX_ a, b); } static I32 -amagic_i_ncmp(pTHXo_ register SV *a, register SV *b) +amagic_i_ncmp(pTHX_ register SV *a, register SV *b) { SV *tmpsv; tryCALL_AMAGICbin(a,b,ncmp,&tmpsv); @@ -4336,11 +4340,11 @@ amagic_i_ncmp(pTHXo_ register SV *a, register SV *b) return 1; return d? -1 : 0; } - return sv_i_ncmp(aTHXo_ a, b); + return sv_i_ncmp(aTHX_ a, b); } static I32 -amagic_cmp(pTHXo_ register SV *str1, register SV *str2) +amagic_cmp(pTHX_ register SV *str1, register SV *str2) { SV *tmpsv; tryCALL_AMAGICbin(str1,str2,scmp,&tmpsv); @@ -4362,7 +4366,7 @@ amagic_cmp(pTHXo_ register SV *str1, register SV *str2) } static I32 -amagic_cmp_locale(pTHXo_ register SV *str1, register SV *str2) +amagic_cmp_locale(pTHX_ register SV *str1, register SV *str2) { SV *tmpsv; tryCALL_AMAGICbin(str1,str2,scmp,&tmpsv); @@ -4384,7 +4388,7 @@ amagic_cmp_locale(pTHXo_ register SV *str1, register SV *str2) } static I32 -run_user_filter(pTHXo_ int idx, SV *buf_sv, int maxlen) +run_user_filter(pTHX_ int idx, SV *buf_sv, int maxlen) { SV *datasv = FILTER_DATA(idx); int filter_has_file = IoLINES(datasv); @@ -4452,19 +4456,3 @@ run_user_filter(pTHXo_ int idx, SV *buf_sv, int maxlen) return len; } - -#ifdef PERL_OBJECT - -static I32 -sv_cmp_locale_static(pTHXo_ register SV *str1, register SV *str2) -{ - return sv_cmp_locale(str1, str2); -} - -static I32 -sv_cmp_static(pTHXo_ register SV *str1, register SV *str2) -{ - return sv_cmp(str1, str2); -} - -#endif /* PERL_OBJECT */