From: Andy Lester Date: Thu, 22 Dec 2005 10:57:17 +0000 (-0600) Subject: Ho! Ho! Ho! Santa brings consting! X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c445ea15829fa1ef23c4453a817f9c096a56a192;p=p5sagit%2Fp5-mst-13.2.git Ho! Ho! Ho! Santa brings consting! Message-ID: <20051222165717.GA2874@petdance.com> p4raw-id: //depot/perl@26450 --- diff --git a/dump.c b/dump.c index f07e95f..0679ed9 100644 --- a/dump.c +++ b/dump.c @@ -410,7 +410,7 @@ S_sequence(pTHX_ register const OP *o) SV *op; const char *key; STRLEN len; - const OP *oldop = 0; + const OP *oldop = NULL; OP *l; if (!o) @@ -941,7 +941,7 @@ Perl_do_magic_dump(pTHX_ I32 level, PerlIO *file, const MAGIC *mg, I32 nest, I32 " MAGIC = 0x%"UVxf"\n", PTR2UV(mg)); if (mg->mg_virtual) { const MGVTBL * const v = mg->mg_virtual; - const char *s = 0; + const char *s = NULL; if (v == &PL_vtbl_sv) s = "sv"; else if (v == &PL_vtbl_env) s = "env"; else if (v == &PL_vtbl_envelem) s = "envelem"; @@ -984,7 +984,7 @@ Perl_do_magic_dump(pTHX_ I32 level, PerlIO *file, const MAGIC *mg, I32 nest, I32 { int n; - const char *name = 0; + const char *name = NULL; for (n = 0; magic_names[n].name; n++) { if (mg->mg_type == magic_names[n].type) { name = magic_names[n].name; @@ -1381,7 +1381,8 @@ Perl_do_sv_dump(pTHX_ I32 level, PerlIO *file, SV *sv, I32 nest, I32 maxnest, bo PerlIO_printf(file, " ("); Zero(freq, FREQ_MAX + 1, int); for (i = 0; (STRLEN)i <= HvMAX(sv); i++) { - HE* h; int count = 0; + HE* h; + int count = 0; for (h = HvARRAY(sv)[i]; h; h = HeNEXT(h)) count++; if (count > FREQ_MAX) diff --git a/embed.fnc b/embed.fnc index 4d91c30..46d12a2 100644 --- a/embed.fnc +++ b/embed.fnc @@ -1326,6 +1326,8 @@ s |bool |utf8_mg_pos |NN SV *sv|NN MAGIC **mgp|NN STRLEN **cachep \ s |bool |utf8_mg_pos_init |NN SV *sv|NN MAGIC **mgp \ |NN STRLEN **cachep|I32 i|I32 offsetp \ |NN const U8 *s|NN const U8 *start +s |char * |stringify_regexp|NN SV *sv|NN MAGIC *mg|NULLOK STRLEN *lp +sn |char * |F0convert |NV nv|NN char *endbuf|NN STRLEN *len #if defined(PERL_OLD_COPY_ON_WRITE) sM |void |sv_release_COW |NN SV *sv|NN const char *pvx|STRLEN len|NN SV *after #endif @@ -1371,16 +1373,15 @@ sR |HV * |find_in_my_stash|NN const char *pkgname|I32 len sR |char * |tokenize_use |int is_use|NN char *s s |SV* |new_constant |NULLOK const char *s|STRLEN len|NN const char *key|NN SV *sv \ |NULLOK SV *pv|NULLOK const char *type -# if defined(DEBUGGING) -s |int |tokereport |I32 rv -# endif s |int |ao |int toketype -s |void |depcom s |const char*|incl_perldb # if defined(PERL_CR_FILTER) s |I32 |cr_textfilter |int idx|NULLOK SV *sv|int maxlen s |void |strip_return |NN SV *sv # endif +# if defined(DEBUGGING) +s |int |tokereport |I32 rv +# endif #endif #if defined(PERL_IN_UNIVERSAL_C) || defined(PERL_DECL_PROT) diff --git a/embed.h b/embed.h index 10e6af3..c0e3b52 100644 --- a/embed.h +++ b/embed.h @@ -1354,6 +1354,8 @@ #ifdef PERL_CORE #define utf8_mg_pos S_utf8_mg_pos #define utf8_mg_pos_init S_utf8_mg_pos_init +#define stringify_regexp S_stringify_regexp +#define F0convert S_F0convert #endif #if defined(PERL_OLD_COPY_ON_WRITE) #ifdef PERL_CORE @@ -1398,15 +1400,7 @@ #define find_in_my_stash S_find_in_my_stash #define tokenize_use S_tokenize_use #define new_constant S_new_constant -#endif -# if defined(DEBUGGING) -#ifdef PERL_CORE -#define tokereport S_tokereport -#endif -# endif -#ifdef PERL_CORE #define ao S_ao -#define depcom S_depcom #define incl_perldb S_incl_perldb #endif # if defined(PERL_CR_FILTER) @@ -1415,6 +1409,11 @@ #define strip_return S_strip_return #endif # endif +# if defined(DEBUGGING) +#ifdef PERL_CORE +#define tokereport S_tokereport +#endif +# endif #endif #if defined(PERL_IN_UNIVERSAL_C) || defined(PERL_DECL_PROT) #ifdef PERL_CORE @@ -3391,6 +3390,8 @@ #ifdef PERL_CORE #define utf8_mg_pos(a,b,c,d,e,f,g,h,i) S_utf8_mg_pos(aTHX_ a,b,c,d,e,f,g,h,i) #define utf8_mg_pos_init(a,b,c,d,e,f,g) S_utf8_mg_pos_init(aTHX_ a,b,c,d,e,f,g) +#define stringify_regexp(a,b,c) S_stringify_regexp(aTHX_ a,b,c) +#define F0convert S_F0convert #endif #if defined(PERL_OLD_COPY_ON_WRITE) #ifdef PERL_CORE @@ -3435,15 +3436,7 @@ #define find_in_my_stash(a,b) S_find_in_my_stash(aTHX_ a,b) #define tokenize_use(a,b) S_tokenize_use(aTHX_ a,b) #define new_constant(a,b,c,d,e,f) S_new_constant(aTHX_ a,b,c,d,e,f) -#endif -# if defined(DEBUGGING) -#ifdef PERL_CORE -#define tokereport(a) S_tokereport(aTHX_ a) -#endif -# endif -#ifdef PERL_CORE #define ao(a) S_ao(aTHX_ a) -#define depcom() S_depcom(aTHX) #define incl_perldb() S_incl_perldb(aTHX) #endif # if defined(PERL_CR_FILTER) @@ -3452,6 +3445,11 @@ #define strip_return(a) S_strip_return(aTHX_ a) #endif # endif +# if defined(DEBUGGING) +#ifdef PERL_CORE +#define tokereport(a) S_tokereport(aTHX_ a) +#endif +# endif #endif #if defined(PERL_IN_UNIVERSAL_C) || defined(PERL_DECL_PROT) #ifdef PERL_CORE diff --git a/gv.c b/gv.c index 4763cd8..e1b1e94 100644 --- a/gv.c +++ b/gv.c @@ -179,7 +179,7 @@ Perl_gv_init(pTHX_ GV *gv, HV *stash, const char *name, STRLEN len, int multi) Newxz(gp, 1, GP); GvGP(gv) = gp_ref(gp); #ifdef PERL_DONT_CREATE_GVSV - GvSV(gv) = 0; + GvSV(gv) = NULL; #else GvSV(gv) = NEWSV(72,0); #endif @@ -470,7 +470,7 @@ GV * Perl_gv_fetchmethod_autoload(pTHX_ HV *stash, const char *name, I32 autoload) { register const char *nend; - const char *nsplit = 0; + const char *nsplit = NULL; GV* gv; HV* ostash = stash; @@ -736,11 +736,11 @@ Perl_gv_fetchpvn_flags(pTHX_ const char *nambeg, STRLEN full_len, I32 flags, I32 sv_type) { register const char *name = nambeg; - register GV *gv = 0; + register GV *gv = NULL; GV**gvp; I32 len; register const char *namend; - HV *stash = 0; + HV *stash = NULL; const I32 no_init = flags & (GV_NOADD_NOINIT | GV_NOINIT); const I32 no_expand = flags & GV_NOEXPAND; const I32 add = flags & ~SVf_UTF8 & ~GV_NOADD_NOINIT & ~GV_NOEXPAND; diff --git a/hv.c b/hv.c index 6f5dd2e..9682e71 100644 --- a/hv.c +++ b/hv.c @@ -366,7 +366,7 @@ Perl_hv_fetch(pTHX_ HV *hv, const char *key, I32 klen_i32, I32 lval) flags = 0; } hek = hv_fetch_common (hv, NULL, key, klen, flags, - HV_FETCH_JUST_SV | (lval ? HV_FETCH_LVALUE : 0), + lval ? (HV_FETCH_JUST_SV | HV_FETCH_LVALUE) : HV_FETCH_JUST_SV, Nullsv, 0); return hek ? &HeVAL(hek) : NULL; } @@ -760,7 +760,7 @@ S_hv_fetch_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, #endif if (!entry && SvREADONLY(hv) && !(action & HV_FETCH_ISEXISTS)) { - S_hv_notallowed(aTHX_ flags, key, klen, + hv_notallowed(flags, key, klen, "Attempt to access disallowed key '%"SVf"' in" " a restricted hash"); } @@ -1011,7 +1011,7 @@ S_hv_delete_common(pTHX_ HV *hv, SV *keysv, const char *key, STRLEN klen, return Nullsv; if (is_utf8) { - const char *keysave = key; + const char * const keysave = key; key = (char*)bytes_from_utf8((U8*)key, &klen, &is_utf8); if (is_utf8) diff --git a/op.c b/op.c index f8caa99..eebaf67 100644 --- a/op.c +++ b/op.c @@ -631,7 +631,7 @@ Perl_scalarvoid(pTHX_ OP *o) { dVAR; OP *kid; - const char* useless = 0; + const char* useless = NULL; SV* sv; U8 want; @@ -2430,7 +2430,7 @@ Perl_pmtrans(pTHX_ OP *o, OP *expr, OP *repl) if (o->op_private & (OPpTRANS_FROM_UTF|OPpTRANS_TO_UTF)) { SV* const listsv = newSVpvn("# comment\n",10); - SV* transv = 0; + SV* transv = NULL; const U8* tend = t + tlen; const U8* rend = r + rlen; STRLEN ulen; @@ -2886,7 +2886,7 @@ Perl_pmruntime(pTHX_ OP *o, OP *expr, bool isreg) else if (repl->op_type == OP_CONST) curop = repl; else { - OP *lastop = 0; + OP *lastop = NULL; for (curop = LINKLIST(repl); curop!=repl; curop = LINKLIST(curop)) { if (PL_opargs[curop->op_type] & OA_DANGEROUS) { if (curop->op_type == OP_GV) { @@ -3827,7 +3827,7 @@ whileline, OP *expr, OP *block, OP *cont, I32 has_my) { dVAR; OP *redo; - OP *next = 0; + OP *next = NULL; OP *listop; OP *o; U8 loopflags = 0; @@ -4438,7 +4438,7 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) GV *gv; const char *ps; STRLEN ps_len; - register CV *cv=0; + register CV *cv = NULL; SV *const_sv; I32 gv_fetch_flags; @@ -6469,13 +6469,13 @@ Perl_ck_subr(pTHX_ OP *o) ? cUNOPo : ((UNOP*)cUNOPo->op_first))->op_first; OP *o2 = prev->op_sibling; OP *cvop; - char *proto = 0; - CV *cv = 0; - GV *namegv = 0; + char *proto = NULL; + CV *cv = NULL; + GV *namegv = NULL; int optional = 0; I32 arg = 0; I32 contextclass = 0; - char *e = 0; + char *e = NULL; bool delete_op = 0; o->op_private |= OPpENTERSUB_HASTARG; @@ -6758,7 +6758,7 @@ void Perl_peep(pTHX_ register OP *o) { dVAR; - register OP* oldop = 0; + register OP* oldop = NULL; if (!o || o->op_opt) return; diff --git a/pp.c b/pp.c index 28fa03f..cbc20fb 100644 --- a/pp.c +++ b/pp.c @@ -221,7 +221,7 @@ PP(pp_rv2gv) PP(pp_rv2sv) { - GV *gv = Nullgv; + GV *gv = NULL; dSP; dTOPss; if (SvROK(sv)) { @@ -299,7 +299,7 @@ PP(pp_av2arylen) if (!*sv) { *sv = NEWSV(0,0); sv_upgrade(*sv, SVt_PVMG); - sv_magic(*sv, (SV*)av, PERL_MAGIC_arylen, Nullch, 0); + sv_magic(*sv, (SV*)av, PERL_MAGIC_arylen, NULL, 0); } SETs(*sv); RETURN; @@ -312,7 +312,7 @@ PP(pp_pos) if (PL_op->op_flags & OPf_MOD || LVRET) { if (SvTYPE(TARG) < SVt_PVLV) { sv_upgrade(TARG, SVt_PVLV); - sv_magic(TARG, Nullsv, PERL_MAGIC_pos, Nullch, 0); + sv_magic(TARG, NULL, PERL_MAGIC_pos, NULL, 0); } LvTYPE(TARG) = '.'; @@ -344,9 +344,11 @@ PP(pp_rv2cv) dSP; GV *gv; HV *stash; - I32 flags = (PL_op->op_flags & OPf_SPECIAL) ? 0 - : ((PL_op->op_private & (OPpLVAL_INTRO|OPpMAY_RETURN_CONSTANT)) - == OPpMAY_RETURN_CONSTANT) ? GV_ADD|GV_NOEXPAND : GV_ADD; + const I32 flags = (PL_op->op_flags & OPf_SPECIAL) + ? 0 + : ((PL_op->op_private & (OPpLVAL_INTRO|OPpMAY_RETURN_CONSTANT)) == OPpMAY_RETURN_CONSTANT) + ? GV_ADD|GV_NOEXPAND + : GV_ADD; /* We usually try to add a non-existent subroutine in case of AUTOLOAD. */ /* (But not in defined().) */ @@ -554,9 +556,9 @@ PP(pp_gelem) SV *sv = POPs; const char * const elem = SvPV_nolen_const(sv); GV * const gv = (GV*)POPs; - SV * tmpRef = Nullsv; + SV * tmpRef = NULL; - sv = Nullsv; + sv = NULL; if (elem) { /* elem will always be NUL terminated. */ const char * const second_letter = elem + 1; @@ -597,7 +599,7 @@ PP(pp_gelem) break; case 'P': if (strEQ(second_letter, "ACKAGE")) { - const HEK *hek = HvNAME_HEK(GvSTASH(gv)); + const HEK * const hek = HvNAME_HEK(GvSTASH(gv)); sv = hek ? newSVhek(hek) : newSVpvn("__ANON__", 8); } break; @@ -678,7 +680,7 @@ PP(pp_study) SvSCREAM_on(sv); /* piggyback on m//g magic */ - sv_magic(sv, Nullsv, PERL_MAGIC_regex_global, Nullch, 0); + sv_magic(sv, NULL, PERL_MAGIC_regex_global, NULL, 0); RETPUSHYES; } @@ -793,7 +795,7 @@ PP(pp_undef) default: if (SvTYPE(sv) >= SVt_PV && SvPVX_const(sv) && SvLEN(sv)) { SvPV_free(sv); - SvPV_set(sv, Nullch); + SvPV_set(sv, NULL); SvLEN_set(sv, 0); } SvOK_off(sv); @@ -1047,7 +1049,7 @@ PP(pp_multiply) } else if (!ahigh && !bhigh) { /* eg 32 bit is at most 0xFFFF * 0xFFFF == 0xFFFE0001 so the unsigned multiply cannot overflow. */ - UV product = alow * blow; + const UV product = alow * blow; if (auvok == buvok) { /* -ve * -ve or +ve * +ve gives a +ve result. */ SP--; @@ -1448,7 +1450,7 @@ PP(pp_repeat) if (count < 1) SvCUR_set(TARG, 0); else { - STRLEN max = (UV)count * len; + const STRLEN max = (UV)count * len; if (len > ((MEM_SIZE)~0)/count) Perl_croak(aTHX_ oom_string_extend); MEM_WRAP_CHECK_1(max, char, oom_string_extend); @@ -1601,11 +1603,11 @@ PP(pp_left_shift) { const IV shift = POPi; if (PL_op->op_private & HINT_INTEGER) { - IV i = TOPi; + const IV i = TOPi; SETi(i << shift); } else { - UV u = TOPu; + const UV u = TOPu; SETu(u << shift); } RETURN; @@ -2287,7 +2289,7 @@ PP(pp_negate) SETn(-SvNV(sv)); else if (SvPOKp(sv)) { STRLEN len; - const char *s = SvPV_const(sv, len); + const char * const s = SvPV_const(sv, len); if (isIDFIRST(*s)) { sv_setpvn(TARG, "-", 1); sv_catsv(TARG, sv); @@ -3050,7 +3052,7 @@ PP(pp_substr) if (SvTYPE(TARG) < SVt_PVLV) { sv_upgrade(TARG, SVt_PVLV); - sv_magic(TARG, Nullsv, PERL_MAGIC_substr, Nullch, 0); + sv_magic(TARG, NULL, PERL_MAGIC_substr, NULL, 0); } else SvOK_off(TARG); @@ -3084,7 +3086,7 @@ PP(pp_vec) TARG = sv_newmortal(); if (SvTYPE(TARG) < SVt_PVLV) { sv_upgrade(TARG, SVt_PVLV); - sv_magic(TARG, Nullsv, PERL_MAGIC_vec, Nullch, 0); + sv_magic(TARG, NULL, PERL_MAGIC_vec, NULL, 0); } LvTYPE(TARG) = 'v'; if (LvTARG(TARG) != src) { @@ -3106,7 +3108,7 @@ PP(pp_index) dSP; dTARGET; SV *big; SV *little; - SV *temp = Nullsv; + SV *temp = NULL; I32 offset; I32 retval; const char *tmps; @@ -3169,7 +3171,7 @@ PP(pp_rindex) dSP; dTARGET; SV *big; SV *little; - SV *temp = Nullsv; + SV *temp = NULL; STRLEN blen; STRLEN llen; I32 offset; diff --git a/pp_ctl.c b/pp_ctl.c index 5483499..9c8cb83 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -188,7 +188,7 @@ PP(pp_substcont) register char *m = cx->sb_m; char *orig = cx->sb_orig; register REGEXP * const rx = cx->sb_rx; - SV *nsv = Nullsv; + SV *nsv = NULL; REGEXP *old = PM_GETRE(pm); if(old != rx) { if(old) @@ -280,7 +280,7 @@ PP(pp_substcont) if (SvTYPE(sv) < SVt_PVMG) SvUPGRADE(sv, SVt_PVMG); if (!(mg = mg_find(sv, PERL_MAGIC_regex_global))) { - sv_magic(sv, Nullsv, PERL_MAGIC_regex_global, Nullch, 0); + sv_magic(sv, NULL, PERL_MAGIC_regex_global, NULL, 0); mg = mg_find(sv, PERL_MAGIC_regex_global); } i = m - orig; @@ -314,12 +314,12 @@ Perl_rxres_save(pTHX_ void **rsp, REGEXP *rx) *rsp = (void*)p; } - *p++ = PTR2UV(RX_MATCH_COPIED(rx) ? rx->subbeg : Nullch); + *p++ = PTR2UV(RX_MATCH_COPIED(rx) ? rx->subbeg : NULL); RX_MATCH_COPIED_off(rx); #ifdef PERL_OLD_COPY_ON_WRITE *p++ = PTR2UV(rx->saved_copy); - rx->saved_copy = Nullsv; + rx->saved_copy = NULL; #endif *p++ = rx->nparens; @@ -391,14 +391,14 @@ PP(pp_formline) register char *t; const char *f; register I32 arg; - register SV *sv = Nullsv; - const char *item = Nullch; + register SV *sv = NULL; + const char *item = NULL; I32 itemsize = 0; I32 fieldsize = 0; I32 lines = 0; - bool chopspace = (strchr(PL_chopset, ' ') != Nullch); - const char *chophere = Nullch; - char *linemark = Nullch; + bool chopspace = (strchr(PL_chopset, ' ') != NULL); + const char *chophere = NULL; + char *linemark = NULL; NV value; bool gotsome = FALSE; STRLEN len; @@ -406,7 +406,7 @@ PP(pp_formline) ? (SvCUR(tmpForm) * (IN_BYTES ? 1 : 3) + 1) : 0; bool item_is_utf8 = FALSE; bool targ_is_utf8 = FALSE; - SV * nsv = Nullsv; + SV * nsv = NULL; OP * parseres = 0; const char *fmt; bool oneline; @@ -1442,7 +1442,7 @@ Perl_die_where(pTHX_ const char *message, STRLEN msglen) if (PL_in_eval & EVAL_KEEPERR) { static const char prefix[] = "\t(in cleanup) "; SV * const err = ERRSV; - const char *e = Nullch; + const char *e = NULL; if (!SvPOK(err)) sv_setpvn(err,"",0); else if (SvCUR(err) >= sizeof(prefix)+msglen-1) { @@ -1450,7 +1450,7 @@ Perl_die_where(pTHX_ const char *message, STRLEN msglen) e = SvPV_const(err, len); e += len - msglen; if (*e != *message || strNE(e,message)) - e = Nullch; + e = NULL; } if (!e) { SvGROW(err, SvCUR(err)+sizeof(prefix)+msglen); @@ -1609,7 +1609,7 @@ PP(pp_caller) /* So is ccstack[dbcxix]. */ if (isGV(cvgv)) { SV * const sv = NEWSV(49, 0); - gv_efullname3(sv, cvgv, Nullch); + gv_efullname3(sv, cvgv, NULL); PUSHs(sv_2mortal(sv)); PUSHs(sv_2mortal(newSViv((I32)cx->blk_sub.hasargs))); } @@ -2033,7 +2033,7 @@ PP(pp_return) POPSUB(cx,sv); /* release CV and @_ ... */ } else - sv = Nullsv; + sv = NULL; PL_curpm = newpm; /* ... and pop $1 et al */ LEAVESUB(sv); @@ -2054,7 +2054,7 @@ PP(pp_last) SV **newsp; PMOP *newpm; SV **mark; - SV *sv = Nullsv; + SV *sv = NULL; if (PL_op->op_flags & OPf_SPECIAL) { @@ -2286,7 +2286,7 @@ PP(pp_goto) if (autogv && (cv = GvCV(autogv))) goto retry; tmpstr = sv_newmortal(); - gv_efullname3(tmpstr, gv, Nullch); + gv_efullname3(tmpstr, gv, NULL); DIE(aTHX_ "Goto undefined subroutine &%"SVf"",tmpstr); } DIE(aTHX_ "Goto undefined subroutine"); @@ -2462,7 +2462,7 @@ PP(pp_goto) (void)SvIOK_on(sv); SvIV_set(sv, PTR2IV(cv)); /* Do it the quickest way */ } else { - gv_efullname3(sv, CvGV(cv), Nullch); + gv_efullname3(sv, CvGV(cv), NULL); } if ( PERLDB_GOTO && (gotocv = get_cv("DB::goto", FALSE)) ) { @@ -3031,8 +3031,7 @@ STATIC PerlIO * S_check_type_and_open(pTHX_ const char *name, const char *mode) { Stat_t st; - int st_rc; - st_rc = PerlLIO_stat(name, &st); + const int st_rc = PerlLIO_stat(name, &st); if (st_rc < 0) { return Nullfp; } @@ -3087,15 +3086,15 @@ PP(pp_require) SV *sv; const char *name; STRLEN len; - const char *tryname = Nullch; - SV *namesv = Nullsv; + const char *tryname = NULL; + SV *namesv = NULL; const I32 gimme = GIMME_V; - PerlIO *tryrsfp = 0; int filter_has_file = 0; - GV *filter_child_proc = 0; - SV *filter_state = 0; - SV *filter_sub = 0; - SV *hook_sv = 0; + PerlIO *tryrsfp = NULL; + GV *filter_child_proc = NULL; + SV *filter_state = NULL; + SV *filter_sub = NULL; + SV *hook_sv = NULL; SV *encoding; OP *op; @@ -3157,7 +3156,7 @@ PP(pp_require) I32 i; #ifdef VMS char *unixname; - if ((unixname = tounixspec(name, Nullch)) != Nullch) + if ((unixname = tounixspec(name, NULL)) != NULL) #endif { namesv = NEWSV(806, 0); @@ -3177,7 +3176,7 @@ PP(pp_require) Perl_sv_setpvf(aTHX_ namesv, "/loader/0x%"UVxf"/%s", PTR2UV(SvRV(dirsv)), name); tryname = SvPVX_const(namesv); - tryrsfp = 0; + tryrsfp = NULL; ENTER; SAVETMPS; @@ -3244,9 +3243,8 @@ PP(pp_require) (void)SvREFCNT_inc(filter_state); } - if (tryrsfp == 0) { - tryrsfp = PerlIO_open("/dev/null", - PERL_SCRIPT_MODE); + if (!tryrsfp) { + tryrsfp = PerlIO_open("/dev/null", PERL_SCRIPT_MODE); } } SP--; @@ -3264,15 +3262,15 @@ PP(pp_require) filter_has_file = 0; if (filter_child_proc) { SvREFCNT_dec(filter_child_proc); - filter_child_proc = 0; + filter_child_proc = NULL; } if (filter_state) { SvREFCNT_dec(filter_state); - filter_state = 0; + filter_state = NULL; } if (filter_sub) { SvREFCNT_dec(filter_sub); - filter_sub = 0; + filter_sub = NULL; } } else { @@ -3294,7 +3292,7 @@ PP(pp_require) #else # ifdef VMS char *unixdir; - if ((unixdir = tounixpath(dir, Nullch)) == Nullch) + if ((unixdir = tounixpath(dir, NULL)) == NULL) continue; sv_setpv(namesv, unixdir); sv_catpv(namesv, unixname); @@ -3400,10 +3398,10 @@ PP(pp_require) else PL_compiling.cop_warnings = pWARN_STD ; SAVESPTR(PL_compiling.cop_io); - PL_compiling.cop_io = Nullsv; + PL_compiling.cop_io = NULL; if (filter_sub || filter_child_proc) { - SV * const datasv = filter_add(S_run_user_filter, Nullsv); + SV * const datasv = filter_add(S_run_user_filter, NULL); IoLINES(datasv) = filter_has_file; IoFMT_GV(datasv) = (GV *)filter_child_proc; IoTOP_GV(datasv) = (GV *)filter_state; @@ -3422,7 +3420,7 @@ PP(pp_require) /* Store and reset encoding. */ encoding = PL_encoding; - PL_encoding = Nullsv; + PL_encoding = NULL; op = DOCATCH(doeval(gimme, NULL, Nullcv, PL_curcop->cop_seq)); @@ -3446,7 +3444,7 @@ PP(pp_entereval) OP *ret; CV* runcv; U32 seq; - HV *saved_hh = 0; + HV *saved_hh = NULL; if (PL_op->op_private & OPpEVAL_HAS_HH) { saved_hh = (HV*) SvREFCNT_inc(POPs); @@ -3616,7 +3614,6 @@ PP(pp_entertry) PP(pp_leavetry) { dVAR; dSP; - register SV **mark; SV **newsp; PMOP *newpm; I32 gimme; @@ -3631,6 +3628,7 @@ PP(pp_leavetry) if (gimme == G_VOID) SP = newsp; else if (gimme == G_SCALAR) { + register SV **mark; MARK = newsp + 1; if (MARK <= SP) { if (SvFLAGS(TOPs) & (SVs_PADTMP|SVs_TEMP)) @@ -3646,6 +3644,7 @@ PP(pp_leavetry) } else { /* in case LEAVE wipes old return values */ + register SV **mark; for (mark = newsp + 1; mark <= SP; mark++) { if (!(SvFLAGS(*mark) & (SVs_PADTMP|SVs_TEMP))) { *mark = sv_mortalcopy(*mark); @@ -3670,7 +3669,7 @@ PP(pp_entergiven) SAVETMPS; if (PL_op->op_targ == 0) { - SV **defsv_p = &GvSV(PL_defgv); + SV ** const defsv_p = &GvSV(PL_defgv); *defsv_p = newSVsv(POPs); SAVECLEARSV(*defsv_p); } @@ -3894,7 +3893,7 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other) tied = TRUE; } else if (SvTIED_mg((SV *) other_hv, PERL_MAGIC_tied)) { - HV * temp = other_hv; + HV * const temp = other_hv; other_hv = (HV *) this; this = (SV *) temp; tied = TRUE; @@ -3910,7 +3909,7 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other) (void) hv_iterinit((HV *) this); while ( (he = hv_iternext((HV *) this)) ) { I32 key_len; - char *key = hv_iterkey(he, &key_len); + char * const key = hv_iterkey(he, &key_len); ++ this_key_count; @@ -3934,15 +3933,15 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other) RETPUSHYES; } else if (SM_OTHER_REF(PVAV)) { - AV *other_av = (AV *) SvRV(other); - I32 other_len = av_len(other_av) + 1; + AV * const other_av = (AV *) SvRV(other); + const I32 other_len = av_len(other_av) + 1; I32 i; if (HvUSEDKEYS((HV *) this) != other_len) RETPUSHNO; for(i = 0; i < other_len; ++i) { - SV **svp = av_fetch(other_av, i, FALSE); + SV ** const svp = av_fetch(other_av, i, FALSE); char *key; STRLEN key_len; @@ -3956,7 +3955,7 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other) RETPUSHYES; } else if (SM_OTHER_REGEX) { - PMOP *matcher = make_matcher(other_regex); + PMOP * const matcher = make_matcher(other_regex); HE *he; (void) hv_iterinit((HV *) this); @@ -3984,7 +3983,7 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other) RETPUSHNO; else { I32 i; - I32 other_len = av_len(other_av); + const I32 other_len = av_len(other_av); if (Nullhv == seen_this) { seen_this = newHV(); @@ -3995,9 +3994,9 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other) (void) sv_2mortal((SV *) seen_other); } for(i = 0; i <= other_len; ++i) { - SV **this_elem = av_fetch((AV *)this, i, FALSE); - SV **other_elem = av_fetch(other_av, i, FALSE); - + SV * const * const this_elem = av_fetch((AV *)this, i, FALSE); + SV * const * const other_elem = av_fetch(other_av, i, FALSE); + if (!this_elem || !other_elem) { if (this_elem || other_elem) RETPUSHNO; @@ -4030,12 +4029,12 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other) } } else if (SM_OTHER_REGEX) { - PMOP *matcher = make_matcher(other_regex); + PMOP * const matcher = make_matcher(other_regex); + const I32 this_len = av_len((AV *) this); I32 i; - I32 this_len = av_len((AV *) this); for(i = 0; i <= this_len; ++i) { - SV ** svp = av_fetch((AV *)this, i, FALSE); + SV * const * const svp = av_fetch((AV *)this, i, FALSE); if (svp && matcher_matches_sv(matcher, *svp)) { destroy_matcher(matcher); RETPUSHYES; @@ -4048,7 +4047,7 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other) I32 i; for(i = 0; i <= AvFILL((AV *) this); ++i) { - SV ** svp = av_fetch((AV *)this, i, FALSE); + SV * const * const svp = av_fetch((AV *)this, i, FALSE); if (!svp) continue; @@ -4066,11 +4065,11 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other) RETPUSHNO; } else if (SvPOK(other)) { + const I32 this_len = av_len((AV *) this); I32 i; - I32 this_len = av_len((AV *) this); for(i = 0; i <= this_len; ++i) { - SV ** svp = av_fetch((AV *)this, i, FALSE); + SV * const * const svp = av_fetch((AV *)this, i, FALSE); if (!svp) continue; @@ -4092,7 +4091,7 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other) RETPUSHNO; } else if (SM_REGEX) { - PMOP *matcher = make_matcher(this_regex); + PMOP * const matcher = make_matcher(this_regex); PUTBACK; PUSHs(matcher_matches_sv(matcher, other) @@ -4269,8 +4268,8 @@ S_doparseform(pTHX_ SV *sv) { STRLEN len; register char *s = SvPV_force(sv, len); - register char *send = s + len; - register char *base = Nullch; + register char * const send = s + len; + register char *base = NULL; register I32 skipspaces = 0; bool noblank = FALSE; bool repeat = FALSE; @@ -4292,7 +4291,7 @@ S_doparseform(pTHX_ SV *sv) maxops += 10; } s = base; - base = Nullch; + base = NULL; Newx(fops, maxops, U32); fpc = fops; @@ -4473,7 +4472,7 @@ S_doparseform(pTHX_ SV *sv) } Copy(fops, s, arg, U32); Safefree(fops); - sv_magic(sv, Nullsv, PERL_MAGIC_fm, Nullch, 0); + sv_magic(sv, NULL, PERL_MAGIC_fm, NULL, 0); SvCOMPILED_on(sv); if (unchopnum && repeat) diff --git a/pp_hot.c b/pp_hot.c index c4cd739..b999b23 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -608,7 +608,7 @@ PP(pp_add) PP(pp_aelemfast) { dSP; - AV *av = PL_op->op_flags & OPf_SPECIAL ? + AV * const av = PL_op->op_flags & OPf_SPECIAL ? (AV*)PAD_SV(PL_op->op_targ) : GvAV(cGVOP_gv); const U32 lval = PL_op->op_flags & OPf_MOD; SV** const svp = av_fetch(av, PL_op->op_private, lval); @@ -1311,7 +1311,7 @@ PP(pp_match) if ((global = dynpm->op_pmflags & PMf_GLOBAL)) { rx->startp[0] = -1; if (SvTYPE(TARG) >= SVt_PVMG && SvMAGIC(TARG)) { - MAGIC* mg = mg_find(TARG, PERL_MAGIC_regex_global); + MAGIC* const mg = mg_find(TARG, PERL_MAGIC_regex_global); if (mg && mg->mg_len >= 0) { if (!(rx->reganch & ROPT_GPOS_SEEN)) rx->endp[0] = rx->startp[0] = mg->mg_len; @@ -1685,7 +1685,7 @@ Perl_do_readline(pTHX) continue; } } else if (SvUTF8(sv)) { /* OP_READLINE, OP_RCATLINE */ - const U8 *s = (const U8*)SvPVX_const(sv) + offset; + const U8 * const s = (const U8*)SvPVX_const(sv) + offset; const STRLEN len = SvCUR(sv) - offset; const U8 *f; @@ -1739,8 +1739,8 @@ PP(pp_helem) dSP; HE* he; SV **svp; - SV *keysv = POPs; - HV *hv = (HV*)POPs; + SV * const keysv = POPs; + HV * const hv = (HV*)POPs; const U32 lval = PL_op->op_flags & OPf_MOD || LVRET; const U32 defer = PL_op->op_private & OPpLVAL_DEFER; SV *sv; @@ -1947,7 +1947,7 @@ PP(pp_iter) RETPUSHNO; if (SvMAGICAL(av) || AvREIFY(av)) { - SV ** const svp = av_fetch(av, --cx->blk_loop.iterix, FALSE); + SV * const * const svp = av_fetch(av, --cx->blk_loop.iterix, FALSE); sv = svp ? *svp : Nullsv; } else { @@ -1960,7 +1960,7 @@ PP(pp_iter) RETPUSHNO; if (SvMAGICAL(av) || AvREIFY(av)) { - SV ** const svp = av_fetch(av, ++cx->blk_loop.iterix, FALSE); + SV * const * const svp = av_fetch(av, ++cx->blk_loop.iterix, FALSE); sv = svp ? *svp : Nullsv; } else { diff --git a/pp_sys.c b/pp_sys.c index 6fdf86d..ab14c67 100644 --- a/pp_sys.c +++ b/pp_sys.c @@ -3296,7 +3296,7 @@ PP(pp_fttext) PP(pp_chdir) { dSP; dTARGET; - const char *tmps = 0; + const char *tmps = NULL; GV *gv = NULL; if( MAXARG == 1 ) { diff --git a/proto.h b/proto.h index ff0e856..e115a41 100644 --- a/proto.h +++ b/proto.h @@ -3690,6 +3690,14 @@ STATIC bool S_utf8_mg_pos_init(pTHX_ SV *sv, MAGIC **mgp, STRLEN **cachep, I32 i __attribute__nonnull__(pTHX_6) __attribute__nonnull__(pTHX_7); +STATIC char * S_stringify_regexp(pTHX_ SV *sv, MAGIC *mg, STRLEN *lp) + __attribute__nonnull__(pTHX_1) + __attribute__nonnull__(pTHX_2); + +STATIC char * S_F0convert(NV nv, char *endbuf, STRLEN *len) + __attribute__nonnull__(2) + __attribute__nonnull__(3); + #if defined(PERL_OLD_COPY_ON_WRITE) STATIC void S_sv_release_COW(pTHX_ SV *sv, const char *pvx, STRLEN len, SV *after) __attribute__nonnull__(pTHX_1) @@ -3818,11 +3826,7 @@ STATIC SV* S_new_constant(pTHX_ const char *s, STRLEN len, const char *key, SV * __attribute__nonnull__(pTHX_3) __attribute__nonnull__(pTHX_4); -# if defined(DEBUGGING) -STATIC int S_tokereport(pTHX_ I32 rv); -# endif STATIC int S_ao(pTHX_ int toketype); -STATIC void S_depcom(pTHX); STATIC const char* S_incl_perldb(pTHX); # if defined(PERL_CR_FILTER) STATIC I32 S_cr_textfilter(pTHX_ int idx, SV *sv, int maxlen); @@ -3830,6 +3834,9 @@ STATIC void S_strip_return(pTHX_ SV *sv) __attribute__nonnull__(pTHX_1); # endif +# if defined(DEBUGGING) +STATIC int S_tokereport(pTHX_ I32 rv); +# endif #endif #if defined(PERL_IN_UNIVERSAL_C) || defined(PERL_DECL_PROT) diff --git a/regcomp.c b/regcomp.c index 18b2abf..3dcc152 100644 --- a/regcomp.c +++ b/regcomp.c @@ -886,7 +886,7 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs for ( cur = first ; cur < last ; cur = regnext( cur ) ) { - regnode *noper = NEXTOPER( cur ); + regnode * const noper = NEXTOPER( cur ); const U8 *uc = (U8*)STRING( noper ); const U8 * const e = uc + STR_LEN( noper ); STRLEN foldlen = 0; @@ -974,72 +974,70 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs for ( cur = first ; cur < last ; cur = regnext( cur ) ) { - regnode *noper = NEXTOPER( cur ); - U8 *uc = (U8*)STRING( noper ); - const U8 * const e = uc + STR_LEN( noper ); - U32 state = 1; /* required init */ - U16 charid = 0; /* sanity init */ - U8 *scan = (U8*)NULL; /* sanity init */ - STRLEN foldlen = 0; /* required init */ - U8 foldbuf[ UTF8_MAXBYTES_CASE + 1 ]; - - - for ( ; uc < e ; uc += len ) { - - TRIE_READ_CHAR; - - if ( uvc < 256 ) { - charid = trie->charmap[ uvc ]; - } else { - SV** svpp=(SV**)NULL; - svpp = hv_fetch( trie->widecharmap, (char*)&uvc, sizeof( UV ), 0); - if ( !svpp ) { - charid = 0; - } else { - charid=(U16)SvIV( *svpp ); - } - } - if ( charid ) { + regnode * const noper = NEXTOPER( cur ); + U8 *uc = (U8*)STRING( noper ); + const U8 * const e = uc + STR_LEN( noper ); + U32 state = 1; /* required init */ + U16 charid = 0; /* sanity init */ + U8 *scan = (U8*)NULL; /* sanity init */ + STRLEN foldlen = 0; /* required init */ + U8 foldbuf[ UTF8_MAXBYTES_CASE + 1 ]; + + for ( ; uc < e ; uc += len ) { + + TRIE_READ_CHAR; + + if ( uvc < 256 ) { + charid = trie->charmap[ uvc ]; + } else { + SV** const svpp = hv_fetch( trie->widecharmap, (char*)&uvc, sizeof( UV ), 0); + if ( !svpp ) { + charid = 0; + } else { + charid=(U16)SvIV( *svpp ); + } + } + if ( charid ) { - U16 check; - U32 newstate = 0; + U16 check; + U32 newstate = 0; - charid--; - if ( !trie->states[ state ].trans.list ) { - TRIE_LIST_NEW( state ); - } - for ( check = 1; check <= TRIE_LIST_USED( state ); check++ ) { - if ( TRIE_LIST_ITEM( state, check ).forid == charid ) { - newstate = TRIE_LIST_ITEM( state, check ).newstate; - break; - } - } - if ( ! newstate ) { - newstate = next_alloc++; - TRIE_LIST_PUSH( state, charid, newstate ); - transcount++; + charid--; + if ( !trie->states[ state ].trans.list ) { + TRIE_LIST_NEW( state ); + } + for ( check = 1; check <= TRIE_LIST_USED( state ); check++ ) { + if ( TRIE_LIST_ITEM( state, check ).forid == charid ) { + newstate = TRIE_LIST_ITEM( state, check ).newstate; + break; + } + } + if ( ! newstate ) { + newstate = next_alloc++; + TRIE_LIST_PUSH( state, charid, newstate ); + transcount++; + } + state = newstate; + } else { + Perl_croak( aTHX_ "panic! In trie construction, no char mapping for %"IVdf, uvc ); } - state = newstate; - } else { - Perl_croak( aTHX_ "panic! In trie construction, no char mapping for %"IVdf, uvc ); - } - /* charid is now 0 if we dont know the char read, or nonzero if we do */ - } + /* charid is now 0 if we dont know the char read, or nonzero if we do */ + } - if ( !trie->states[ state ].wordnum ) { - /* we havent inserted this word into the structure yet. */ - trie->states[ state ].wordnum = ++curword; + if ( !trie->states[ state ].wordnum ) { + /* we havent inserted this word into the structure yet. */ + trie->states[ state ].wordnum = ++curword; - DEBUG_r({ - /* store the word for dumping */ - SV* tmp = newSVpvn( STRING( noper ), STR_LEN( noper ) ); - if ( UTF ) SvUTF8_on( tmp ); - av_push( trie->words, tmp ); - }); + DEBUG_r({ + /* store the word for dumping */ + SV* tmp = newSVpvn( STRING( noper ), STR_LEN( noper ) ); + if ( UTF ) SvUTF8_on( tmp ); + av_push( trie->words, tmp ); + }); - } else { - /* Its a dupe. So ignore it. */ - } + } else { + /* Its a dupe. So ignore it. */ + } } /* end second pass */ @@ -1100,11 +1098,12 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs U16 idx; for( idx = 2 ; idx <= TRIE_LIST_USED( state ) ; idx++ ) { - if ( TRIE_LIST_ITEM( state, idx).forid < minid ) { - minid=TRIE_LIST_ITEM( state, idx).forid; - } else if ( TRIE_LIST_ITEM( state, idx).forid > maxid ) { - maxid=TRIE_LIST_ITEM( state, idx).forid; - } + const U16 forid = TRIE_LIST_ITEM( state, idx).forid; + if ( forid < minid ) { + minid=forid; + } else if ( forid > maxid ) { + maxid=forid; + } } if ( transcount < tp + maxid - minid + 1) { transcount *= 2; @@ -1131,7 +1130,7 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs } } else { for ( idx=1; idx <= TRIE_LIST_USED( state ) ; idx++ ) { - U32 tid = base - trie->uniquecharcount + TRIE_LIST_ITEM( state, idx ).forid; + const U32 tid = base - trie->uniquecharcount + TRIE_LIST_ITEM( state, idx ).forid; trie->trans[ tid ].next = TRIE_LIST_ITEM( state, idx ).newstate; trie->trans[ tid ].check = state; } @@ -1192,7 +1191,7 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs for ( cur = first ; cur < last ; cur = regnext( cur ) ) { - regnode *noper = NEXTOPER( cur ); + regnode * const noper = NEXTOPER( cur ); const U8 *uc = (U8*)STRING( noper ); const U8 * const e = uc + STR_LEN( noper ); @@ -1213,13 +1212,8 @@ S_make_trie(pTHX_ RExC_state_t *pRExC_state, regnode *startbranch, regnode *firs if ( uvc < 256 ) { charid = trie->charmap[ uvc ]; } else { - SV** svpp=(SV**)NULL; - svpp = hv_fetch( trie->widecharmap, (char*)&uvc, sizeof( UV ), 0); - if ( !svpp ) { - charid = 0; - } else { - charid=(U16)SvIV( *svpp ); - } + SV* const * const svpp = hv_fetch( trie->widecharmap, (char*)&uvc, sizeof( UV ), 0); + charid = svpp ? (U16)SvIV(*svpp) : 0; } if ( charid ) { charid--; @@ -1561,7 +1555,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, while (scan && OP(scan) != END && scan < last) { /* Peephole optimizer: */ DEBUG_OPTIMISE_r({ - SV *mysv=sv_newmortal(); + SV * const mysv=sv_newmortal(); regprop( mysv, scan); PerlIO_printf(Perl_debug_log, "%*speep: %s (0x%08"UVXf")\n", (int)depth*2, "", SvPV_nolen_const(mysv), PTR2UV(scan)); @@ -1595,7 +1589,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, } else if (stringok) { const int oldl = STR_LEN(scan); - regnode *nnext = regnext(n); + regnode * const nnext = regnext(n); if (oldl + STR_LEN(n) > U8_MAX) break; @@ -1640,8 +1634,9 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, another valid sequence of UTF-8 bytes. */ - char *s0 = STRING(scan), *s, *t; - char *s1 = s0 + STR_LEN(scan) - 1, *s2 = s1 - 4; + char * const s0 = STRING(scan), *s, *t; + char * const s1 = s0 + STR_LEN(scan) - 1; + char * const s2 = s1 - 4; const char * const t0 = "\xcc\x88\xcc\x81"; const char * const t1 = t0 + 3; @@ -1840,7 +1835,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, U32 count=0; #ifdef DEBUGGING - SV *mysv = sv_newmortal(); /* for dumping */ + SV * const mysv = sv_newmortal(); /* for dumping */ #endif /* var tail is used because there may be a TAIL regop in the way. Ie, the exacts will point to the @@ -1985,11 +1980,13 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, } else if (OP(scan) == EXACT) { I32 l = STR_LEN(scan); - UV uc = *((U8*)STRING(scan)); + UV uc; if (UTF) { const U8 * const s = (U8*)STRING(scan); l = utf8_length(s, s + l); uc = utf8_to_uvchr(s, NULL); + } else { + uc = *((U8*)STRING(scan)); } min += l; if (flags & SCF_DO_SUBSTR) { /* Update longest substr. */ @@ -2334,7 +2331,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, if (data && fl & (SF_HAS_PAR|SF_IN_PAR)) pars++; if (flags & SCF_DO_SUBSTR) { - SV *last_str = Nullsv; + SV *last_str = NULL; int counted = mincount != 0; if (data->last_end > 0 && mincount != 0) { /* Ends with a string. */ @@ -2858,7 +2855,7 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm) REGC((U8)REG_MAGIC, (char*)RExC_emit); #endif if (reg(pRExC_state, 0, &flags) == NULL) { - RExC_precomp = Nullch; + RExC_precomp = NULL; return(NULL); } DEBUG_COMPILE_r(PerlIO_printf(Perl_debug_log, "size %"IVdf" ", (IV)RExC_size)); @@ -2887,7 +2884,7 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm) r->precomp = savepvn(RExC_precomp, r->prelen); r->subbeg = NULL; #ifdef PERL_OLD_COPY_ON_WRITE - r->saved_copy = Nullsv; + r->saved_copy = NULL; #endif r->reganch = pm->op_pmflags & PMf_COMPILETIME; r->nparens = RExC_npar - 1; /* set early to validate backrefs */ @@ -3060,10 +3057,10 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm) if (SvUTF8(data.longest_float)) { r->float_utf8 = data.longest_float; - r->float_substr = Nullsv; + r->float_substr = NULL; } else { r->float_substr = data.longest_float; - r->float_utf8 = Nullsv; + r->float_utf8 = NULL; } r->float_min_offset = data.offset_float_min; r->float_max_offset = data.offset_float_max; @@ -3074,7 +3071,7 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm) } else { remove_float: - r->float_substr = r->float_utf8 = Nullsv; + r->float_substr = r->float_utf8 = NULL; SvREFCNT_dec(data.longest_float); longest_float_length = 0; } @@ -3088,10 +3085,10 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm) if (SvUTF8(data.longest_fixed)) { r->anchored_utf8 = data.longest_fixed; - r->anchored_substr = Nullsv; + r->anchored_substr = NULL; } else { r->anchored_substr = data.longest_fixed; - r->anchored_utf8 = Nullsv; + r->anchored_utf8 = NULL; } r->anchored_offset = data.offset_fixed; t = (data.flags & SF_FIX_BEFORE_EOL /* Can't have SEOL and MULTI */ @@ -3100,7 +3097,7 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm) fbm_compile(data.longest_fixed, t ? FBMcf_TAIL : 0); } else { - r->anchored_substr = r->anchored_utf8 = Nullsv; + r->anchored_substr = r->anchored_utf8 = NULL; SvREFCNT_dec(data.longest_fixed); longest_fixed_length = 0; } @@ -3164,7 +3161,7 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm) data.last_closep = &last_close; minlen = study_chunk(pRExC_state, &scan, &fake, scan + RExC_size, &data, SCF_DO_STCLASS_AND|SCF_WHILEM_VISITED_POS,0); r->check_substr = r->check_utf8 = r->anchored_substr = r->anchored_utf8 - = r->float_substr = r->float_utf8 = Nullsv; + = r->float_substr = r->float_utf8 = NULL; if (!(data.start_class->flags & ANYOF_EOS) && !cl_is_anything(data.start_class)) { @@ -3716,7 +3713,7 @@ S_regpiece(pTHX_ RExC_state_t *pRExC_state, I32 *flagp) if (op == '{' && regcurly(RExC_parse)) { parse_start = RExC_parse; /* MJD */ next = RExC_parse + 1; - maxpos = Nullch; + maxpos = NULL; while (isDIGIT(*next) || *next == ',') { if (*next == ',') { if (maxpos) @@ -4655,7 +4652,7 @@ S_regclass(pTHX_ RExC_state_t *pRExC_state) IV namedclass; char *rangebegin = 0; bool need_class = 0; - SV *listsv = Nullsv; + SV *listsv = NULL; register char *e; UV n; bool optimize_invert = TRUE; @@ -5666,7 +5663,7 @@ void Perl_regdump(pTHX_ regexp *r) { #ifdef DEBUGGING - SV *sv = sv_newmortal(); + SV * const sv = sv_newmortal(); (void)dumpuntil(r->program, r->program + 1, NULL, sv, 0); @@ -5932,7 +5929,7 @@ Perl_regprop(pTHX_ SV *sv, const regnode *o) { char *s = savesvpv(lv); - char *origs = s; + char * const origs = s; while(*s && *s != '\n') s++; @@ -5993,15 +5990,15 @@ Perl_pregfree(pTHX_ struct regexp *r) { dVAR; #ifdef DEBUGGING - SV *dsv = PERL_DEBUG_PAD_ZERO(0); - SV *re_debug_flags=get_sv(RE_DEBUG_FLAGS,0); + SV * const dsv = PERL_DEBUG_PAD_ZERO(0); + SV * const re_debug_flags=get_sv(RE_DEBUG_FLAGS,0); #endif if (!r || (--r->refcnt > 0)) return; DEBUG_r(if (re_debug_flags && (SvIV(re_debug_flags) & RE_DEBUG_COMPILE)) { - const char *s = (r->reganch & ROPT_UTF8) + const char * const s = (r->reganch & ROPT_UTF8) ? pv_uni_display(dsv, (U8*)r->precomp, r->prelen, 60, UNI_DISPLAY_REGEX) : pv_display(dsv, r->precomp, r->prelen, 0, 60); const int len = SvCUR(dsv); @@ -6058,8 +6055,7 @@ Perl_pregfree(pTHX_ struct regexp *r) Perl_croak(aTHX_ "panic: pregfree comppad"); PAD_SAVE_LOCAL(old_comppad, /* Watch out for global destruction's random ordering. */ - (SvTYPE(new_comppad) == SVt_PVAV) ? - new_comppad : Null(PAD *) + (SvTYPE(new_comppad) == SVt_PVAV) ? new_comppad : NULL ); OP_REFCNT_LOCK; refcnt = OpREFCNT_dec((OP_4tree*)r->data->data[n]); @@ -6075,7 +6071,7 @@ Perl_pregfree(pTHX_ struct regexp *r) break; case 't': { - reg_trie_data *trie=(reg_trie_data*)r->data->data[n]; + reg_trie_data * const trie=(reg_trie_data*)r->data->data[n]; U32 refcount; OP_REFCNT_LOCK; refcount = --trie->refcount; @@ -6196,36 +6192,35 @@ Perl_save_re_context(pTHX) SAVEVPTR(PL_reg_oldcurpm); /* from regexec.c */ SAVEVPTR(PL_reg_curpm); /* from regexec.c */ SAVEPPTR(PL_reg_oldsaved); /* old saved substr during match */ - PL_reg_oldsaved = Nullch; + PL_reg_oldsaved = NULL; SAVEI32(PL_reg_oldsavedlen); /* old length of saved substr during match */ PL_reg_oldsavedlen = 0; #ifdef PERL_OLD_COPY_ON_WRITE SAVESPTR(PL_nrs); - PL_nrs = Nullsv; + PL_nrs = NULL; #endif SAVEI32(PL_reg_maxiter); /* max wait until caching pos */ PL_reg_maxiter = 0; SAVEI32(PL_reg_leftiter); /* wait until caching pos */ PL_reg_leftiter = 0; SAVEGENERICPV(PL_reg_poscache); /* cache of pos of WHILEM */ - PL_reg_poscache = Nullch; + PL_reg_poscache = NULL; SAVEI32(PL_reg_poscache_size); /* size of pos cache of WHILEM */ PL_reg_poscache_size = 0; SAVEPPTR(PL_regprecomp); /* uncompiled string. */ SAVEI32(PL_regnpar); /* () count. */ SAVEI32(PL_regsize); /* from regexec.c */ - { - /* Save $1..$n (#18107: UTF-8 s/(\w+)/uc($1)/e); AMS 20021106. */ - REGEXP *rx; - - if (PL_curpm && (rx = PM_GETRE(PL_curpm))) { + /* Save $1..$n (#18107: UTF-8 s/(\w+)/uc($1)/e); AMS 20021106. */ + if (PL_curpm) { + const REGEXP * const rx = PM_GETRE(PL_curpm); + if (rx) { U32 i; for (i = 1; i <= rx->nparens; i++) { - GV *mgv; char digits[TYPE_CHARS(long)]; const STRLEN len = my_sprintf(digits, "%lu", (long)i); - if ((mgv = gv_fetchpvn_flags(digits, len, 0, SVt_PV))) + GV * const mgv = gv_fetchpvn_flags(digits, len, 0, SVt_PV); + if (mgv) save_scalar(mgv); } } diff --git a/sv.c b/sv.c index d8f2824..00261cd 100644 --- a/sv.c +++ b/sv.c @@ -2455,7 +2455,7 @@ Perl_sv_2pv_flags(pTHX_ register SV *sv, STRLEN *lp, I32 flags) (SVs_OBJECT|SVf_OK|SVs_GMG|SVs_SMG|SVs_RMG)) == (SVs_OBJECT|SVs_SMG)) && (mg = mg_find(referent, PERL_MAGIC_qr))) { - return S_stringify_regexp(aTHX_ sv, mg, lp); + return stringify_regexp(sv, mg, lp); } else { const char *const typestr = sv_reftype(referent, 0); @@ -7611,8 +7611,6 @@ Perl_sv_vsetpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV sv_vcatpvfn(sv, pat, patlen, args, svargs, svmax, maybe_tainted); } -/* private function for use in sv_vcatpvfn via the EXPECT_NUMBER macro */ - STATIC I32 S_expect_number(pTHX_ char** pattern) { @@ -7631,10 +7629,9 @@ S_expect_number(pTHX_ char** pattern) } return var; } -#define EXPECT_NUMBER(pattern, var) (var = S_expect_number(aTHX_ &pattern)) -static char * -F0convert(NV nv, char *endbuf, STRLEN *len) +STATIC char * +S_F0convert(NV nv, char *endbuf, STRLEN *len) { const int neg = nv < 0; UV uv; @@ -7783,7 +7780,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV STRLEN zeros = 0; bool has_precis = FALSE; STRLEN precis = 0; - I32 osvix = svix; + const I32 osvix = svix; bool is_utf8 = FALSE; /* is this item utf8? */ #ifdef HAS_LDBL_SPRINTF_BUG /* This is to try to fix a bug with irix/nonstop-ux/powerux and @@ -7870,7 +7867,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV STRLEN n = 0; if (*q == '-') sv = *q++; - EXPECT_NUMBER(q, n); + n = expect_number(&q); if (*q++ == 'p') { if (sv) { /* SVf */ if (n) { @@ -7899,7 +7896,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV q = r; } - if (EXPECT_NUMBER(q, width)) { + if ( (width = expect_number(&q)) ) { if (*q == '$') { ++q; efix = width; @@ -7940,7 +7937,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV tryasterisk: if (*q == '*') { q++; - if (EXPECT_NUMBER(q, ewix)) + if ( (ewix = expect_number(&q)) ) if (*q++ != '$') goto unknown; asterisk = TRUE; @@ -7962,7 +7959,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV { if( *q == '0' ) fill = *q++; - EXPECT_NUMBER(q, width); + width = expect_number(&q); } if (vectorize) { @@ -8036,7 +8033,7 @@ Perl_sv_vcatpvfn(pTHX_ SV *sv, const char *pat, STRLEN patlen, va_list *args, SV q++; if (*q == '*') { q++; - if (EXPECT_NUMBER(q, epix) && *q++ != '$') + if ( ((epix = expect_number(&q))) && (*q++ != '$') ) goto unknown; /* XXX: todo, support specified precision parameter */ if (epix) @@ -9010,7 +9007,7 @@ Perl_mg_dup(pTHX_ MAGIC *mg, CLONE_PARAMS* param) if (mg->mg_type == PERL_MAGIC_overload_table && AMT_AMAGIC((AMT*)mg->mg_ptr)) { - AMT * const amtp = (AMT*)mg->mg_ptr; + const AMT * const amtp = (AMT*)mg->mg_ptr; AMT * const namtp = (AMT*)nmg->mg_ptr; I32 i; for (i = 1; i < NofAMmeth; i++) { @@ -9136,7 +9133,7 @@ void Perl_ptr_table_clear(pTHX_ PTR_TBL_t *tbl) { if (tbl && tbl->tbl_items) { - register PTR_TBL_ENT_t **array = tbl->tbl_ary; + register PTR_TBL_ENT_t * const * const array = tbl->tbl_ary; UV riter = tbl->tbl_max; do { @@ -9539,8 +9536,8 @@ Perl_cx_dup(pTHX_ PERL_CONTEXT *cxs, I32 ix, I32 max, CLONE_PARAMS* param) ptr_table_store(PL_ptr_table, cxs, ncxs); while (ix >= 0) { - PERL_CONTEXT *cx = &cxs[ix]; - PERL_CONTEXT *ncx = &ncxs[ix]; + PERL_CONTEXT * const cx = &cxs[ix]; + PERL_CONTEXT * const ncx = &ncxs[ix]; ncx->cx_type = cx->cx_type; if (CxTYPE(cx) == CXt_SUBST) { Perl_croak(aTHX_ "Cloning substitution context is unimplemented"); diff --git a/toke.c b/toke.c index aed01c0..6f54416 100644 --- a/toke.c +++ b/toke.c @@ -27,6 +27,7 @@ #define yylval (*PL_yylvalp) static const char ident_too_long[] = "Identifier too long"; +static const char commaless_variable_list[] = "comma-less variable list"; static void restore_rsfp(pTHX_ void *f); #ifndef PERL_NO_UTF16_FILTER @@ -502,17 +503,6 @@ Perl_deprecate_old(pTHX_ const char *s) } /* - * depcom - * Deprecate a comma-less variable list. - */ - -STATIC void -S_depcom(pTHX) -{ - deprecate_old("comma-less variable list"); -} - -/* * experimental text filters for win32 carriage-returns, utf16-to-utf8 and * utf16-to-utf8-reversed. */ @@ -3757,7 +3747,7 @@ Perl_yylex(pTHX) if (PL_expect == XOPERATOR) { if (PL_lex_formbrack && PL_lex_brackets == PL_lex_formbrack) { PL_expect = XTERM; - depcom(); + deprecate_old(commaless_variable_list); return REPORT(','); /* grandfather non-comma-format format */ } } @@ -4007,7 +3997,7 @@ Perl_yylex(pTHX) if (PL_expect == XOPERATOR) { if (PL_lex_formbrack && PL_lex_brackets == PL_lex_formbrack) { PL_expect = XTERM; - depcom(); + deprecate_old(commaless_variable_list); return REPORT(','); /* grandfather non-comma-format format */ } else @@ -4024,7 +4014,7 @@ Perl_yylex(pTHX) if (PL_expect == XOPERATOR) { if (PL_lex_formbrack && PL_lex_brackets == PL_lex_formbrack) { PL_expect = XTERM; - depcom(); + deprecate_old(commaless_variable_list); return REPORT(','); /* grandfather non-comma-format format */ } else diff --git a/universal.c b/universal.c index 784fe53..097cc64 100644 --- a/universal.c +++ b/universal.c @@ -39,7 +39,7 @@ S_isa_lookup(pTHX_ HV *stash, const char *name, HV* name_stash, GV* gv; GV** gvp; HV* hv = NULL; - SV* subgen = Nullsv; + SV* subgen = NULL; const char *hvname; /* A stash/class can go by many names (ie. User == main::User), so @@ -140,7 +140,7 @@ for class names as well as for objects. bool Perl_sv_derived_from(pTHX_ SV *sv, const char *name) { - const char *type = Nullch; + const char *type = NULL; HV *stash = NULL; HV *name_stash; @@ -341,7 +341,7 @@ XS(XS_UNIVERSAL_VERSION) sv = nsv; if ( !sv_derived_from(sv, "version")) upg_version(sv); - undef = Nullch; + undef = NULL; } else { sv = (SV*)&PL_sv_undef;