From: Andy Lester Date: Sun, 3 Jul 2005 18:31:56 +0000 (-0500) Subject: Post-YAPC consting, now with an attachment! X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b64e5050699224c037d91354e38766884caa0910;p=p5sagit%2Fp5-mst-13.2.git Post-YAPC consting, now with an attachment! Message-ID: <20050703233156.GA20967@petdance.com> p4raw-id: //depot/perl@25067 --- diff --git a/deb.c b/deb.c index 8696bce..878b7cb 100644 --- a/deb.c +++ b/deb.c @@ -93,7 +93,7 @@ S_deb_stack_n(pTHX_ SV** stack_base, I32 stack_min, I32 stack_max, { #ifdef DEBUGGING register I32 i = stack_max - 30; - I32 *markscan = PL_markstack + mark_min; + const I32 *markscan = PL_markstack + mark_min; if (i < stack_min) i = stack_min; diff --git a/embed.fnc b/embed.fnc index 5bcac57..6e709ef 100644 --- a/embed.fnc +++ b/embed.fnc @@ -921,18 +921,18 @@ Ap |void |reginitcolors Apd |char* |sv_2pv_nolen |SV* sv Apd |char* |sv_2pvutf8_nolen|SV* sv Apd |char* |sv_2pvbyte_nolen|SV* sv -Amdb |char* |sv_pv |SV *sv -Amdb |char* |sv_pvutf8 |SV *sv -Amdb |char* |sv_pvbyte |SV *sv -Amdb |STRLEN |sv_utf8_upgrade|SV *sv -ApdM |bool |sv_utf8_downgrade|SV *sv|bool fail_ok -Apd |void |sv_utf8_encode |SV *sv -ApdM |bool |sv_utf8_decode |SV *sv -Apd |void |sv_force_normal|SV *sv -Apd |void |sv_force_normal_flags|SV *sv|U32 flags +AmdbR |char* |sv_pv |NN SV *sv +AmdbR |char* |sv_pvutf8 |NN SV *sv +AmdbR |char* |sv_pvbyte |NN SV *sv +Amdb |STRLEN |sv_utf8_upgrade|NN SV *sv +ApdM |bool |sv_utf8_downgrade|NN SV *sv|bool fail_ok +Apd |void |sv_utf8_encode |NN SV *sv +ApdM |bool |sv_utf8_decode |NN SV *sv +Apd |void |sv_force_normal|NN SV *sv +Apd |void |sv_force_normal_flags|NN SV *sv|U32 flags Ap |void |tmps_grow |I32 n -Apd |SV* |sv_rvweaken |SV *sv -p |int |magic_killbackrefs|SV *sv|MAGIC *mg +Apd |SV* |sv_rvweaken |NN SV *sv +p |int |magic_killbackrefs|NN SV *sv|NN MAGIC *mg Ap |OP* |newANONATTRSUB |I32 floor|OP *proto|OP *attrs|OP *block Ap |CV* |newATTRSUB |I32 floor|OP *o|OP *proto|OP *attrs|OP *block Apr |void |newMYSUB |I32 floor|OP *o|OP *proto|OP *attrs|OP *block @@ -1380,37 +1380,36 @@ Ap |PerlIO *|PerlIO_stderr p |void |deb_stack_all #ifdef PERL_IN_DEB_C -s |void |deb_stack_n |SV** stack_base|I32 stack_min \ +s |void |deb_stack_n |NN SV** stack_base|I32 stack_min \ |I32 stack_max|I32 mark_min|I32 mark_max #endif pda |PADLIST*|pad_new |int flags -pd |void |pad_undef |CV* cv +pd |void |pad_undef |NN CV* cv pd |PADOFFSET|pad_add_name |NN const char *name\ - |HV* typestash|HV* ourstash \ - |bool clone -pd |PADOFFSET|pad_add_anon |SV* sv|OPCODE op_type + |NULLOK HV* typestash|NULLOK HV* ourstash|bool clone +pd |PADOFFSET|pad_add_anon |NN SV* sv|OPCODE op_type pd |void |pad_check_dup |NN const char* name|bool is_our|NN const HV* ourstash #ifdef DEBUGGING pd |void |pad_setsv |PADOFFSET po|NN SV* sv #endif pd |void |pad_block_start|int full pd |void |pad_tidy |padtidy_type type -pd |void |do_dump_pad |I32 level|NN PerlIO *file|PADLIST *padlist|int full +pd |void |do_dump_pad |I32 level|NN PerlIO *file|NULLOK PADLIST *padlist|int full pd |void |pad_fixup_inner_anons|NN PADLIST *padlist|CV *old_cv|CV *new_cv pd |void |pad_push |NN PADLIST *padlist|int depth pR |HV* |pad_compname_type|const PADOFFSET po #if defined(PERL_IN_PAD_C) || defined(PERL_DECL_PROT) -sd |PADOFFSET|pad_findlex |const char *name|const CV* cv|U32 seq|int warn \ - |SV** out_capture|SV** out_name_sv \ - |int *out_flags +sd |PADOFFSET|pad_findlex |NN const char *name|NN const CV* cv|U32 seq|int warn \ + |NULLOK SV** out_capture|NN SV** out_name_sv \ + |NN int *out_flags # if defined(DEBUGGING) sd |void |cv_dump |NN const CV *cv|NN const char *title # endif #endif -pdR |CV* |find_runcv |U32 *db_seqp +pdR |CV* |find_runcv |NULLOK U32 *db_seqp p |void |free_tied_hv_pool #if defined(DEBUGGING) p |int |get_debug_opts |const char **s|bool givehelp @@ -1431,7 +1430,7 @@ Apo |void |hv_placeholders_set |NN HV* hv|I32 ph p |SV* |magic_scalarpack|NN HV* hv|NN MAGIC* mg #ifdef PERL_IN_SV_C -sMd |SV* |find_uninit_var|OP* obase|SV* uninit_sv|bool top +sMd |SV* |find_uninit_var|NULLOK OP* obase|NULLOK SV* uninit_sv|bool top #endif #ifdef PERL_NEED_MY_HTOLE16 @@ -1508,10 +1507,10 @@ np |long |my_htobel |long n np |long |my_betohl |long n #endif -np |void |my_swabn |void* ptr|int n +np |void |my_swabn |NN void* ptr|int n -Ap |GV* |gv_fetchpvn_flags|const char* name|STRLEN len|I32 flags|I32 sv_type -Ap |GV* |gv_fetchsv|SV *name|I32 flags|I32 sv_type +ApR |GV* |gv_fetchpvn_flags|NN const char* name|STRLEN len|I32 flags|I32 sv_type +ApR |GV* |gv_fetchsv|NN SV *name|I32 flags|I32 sv_type dpR |bool |is_gv_magical_sv|NN SV *name|U32 flags ApR |bool |stashpv_hvname_match|NN const COP *cop|NN const HV *hv diff --git a/gv.c b/gv.c index 39f4b6a..d1678d0 100644 --- a/gv.c +++ b/gv.c @@ -1897,7 +1897,7 @@ bool Perl_is_gv_magical_sv(pTHX_ SV *name, U32 flags) { STRLEN len; - const char *temp = SvPV_const(name, len); + const char * const temp = SvPV_const(name, len); return is_gv_magical(temp, len, flags); } diff --git a/pad.c b/pad.c index de61002..9ebe266 100644 --- a/pad.c +++ b/pad.c @@ -229,7 +229,7 @@ void Perl_pad_undef(pTHX_ CV* cv) { I32 ix; - const PADLIST *padlist = CvPADLIST(cv); + const PADLIST * const padlist = CvPADLIST(cv); if (!padlist) return; @@ -457,9 +457,7 @@ PADOFFSET Perl_pad_add_anon(pTHX_ SV* sv, OPCODE op_type) { PADOFFSET ix; - SV* name; - - name = NEWSV(1106, 0); + SV* const name = NEWSV(1106, 0); sv_upgrade(name, SVt_PVNV); sv_setpvn(name, "&", 1); SvIV_set(name, -1); @@ -654,7 +652,7 @@ S_pad_findlex(pTHX_ const char *name, const CV* cv, U32 seq, int warn, I32 offset, new_offset; SV *new_capture; SV **new_capturep; - const AV *padlist = CvPADLIST(cv); + const AV * const padlist = CvPADLIST(cv); *out_flags = 0; diff --git a/sv.c b/sv.c index 0bf15d3..0dfe6a2 100644 --- a/sv.c +++ b/sv.c @@ -3661,7 +3661,7 @@ Perl_sv_utf8_decode(pTHX_ register SV *sv) return FALSE; e = (const U8 *) SvEND(sv); while (c < e) { - U8 ch = *c++; + const U8 ch = *c++; if (!UTF8_IS_INVARIANT(ch)) { SvUTF8_on(sv); break; @@ -4555,7 +4555,7 @@ Perl_sv_force_normal_flags(pTHX_ register SV *sv, U32 flags) if (SvREADONLY(sv)) { /* At this point I believe I should acquire a global SV mutex. */ if (SvFAKE(sv)) { - const char *pvx = SvPVX_const(sv); + const char * const pvx = SvPVX_const(sv); const STRLEN len = SvLEN(sv); const STRLEN cur = SvCUR(sv); SV * const next = SV_COW_NEXT_SV(sv); /* next COW sv in the loop. */ @@ -4591,7 +4591,7 @@ Perl_sv_force_normal_flags(pTHX_ register SV *sv, U32 flags) #else if (SvREADONLY(sv)) { if (SvFAKE(sv)) { - const char *pvx = SvPVX_const(sv); + const char * const pvx = SvPVX_const(sv); const STRLEN len = SvCUR(sv); SvFAKE_off(sv); SvREADONLY_off(sv); @@ -7266,8 +7266,8 @@ Perl_newSVhek(pTHX_ const HEK *hek) Andreas would like keys he put in as utf8 to come back as utf8 */ STRLEN utf8_len = HEK_LEN(hek); - U8 *as_utf8 = bytes_to_utf8 ((U8*)HEK_KEY(hek), &utf8_len); - SV *sv = newSVpvn ((char*)as_utf8, utf8_len); + const U8 *as_utf8 = bytes_to_utf8 ((U8*)HEK_KEY(hek), &utf8_len); + SV * const sv = newSVpvn ((const char*)as_utf8, utf8_len); SvUTF8_on (sv); Safefree (as_utf8); /* bytes_to_utf8() allocates a new string */ @@ -7279,7 +7279,7 @@ Perl_newSVhek(pTHX_ const HEK *hek) that would contain the (wrong) hash value, and might get passed into an hv routine with a regular hash */ - SV *sv = newSVpvn (HEK_KEY(hek), HEK_LEN(hek)); + SV * const sv = newSVpvn (HEK_KEY(hek), HEK_LEN(hek)); if (HEK_UTF8(hek)) SvUTF8_on (sv); return sv; @@ -7910,19 +7910,17 @@ Perl_sv_pvn_force_flags(pTHX_ SV *sv, STRLEN *lp, I32 flags) STRLEN len; if (SvREADONLY(sv) && !(flags & SV_MUTABLE_RETURN)) { + const char * const ref = sv_reftype(sv,0); if (PL_op) Perl_croak(aTHX_ "Can't coerce readonly %s to string in %s", - sv_reftype(sv,0), OP_NAME(PL_op)); + ref, OP_NAME(PL_op)); else - Perl_croak(aTHX_ "Can't coerce readonly %s to string", - sv_reftype(sv,0)); + Perl_croak(aTHX_ "Can't coerce readonly %s to string", ref); } - if (SvTYPE(sv) > SVt_PVLV && SvTYPE(sv) != SVt_PVFM) { + if (SvTYPE(sv) > SVt_PVLV && SvTYPE(sv) != SVt_PVFM) Perl_croak(aTHX_ "Can't coerce %s to string in %s", sv_reftype(sv,0), OP_NAME(PL_op)); - } - else - s = sv_2pv_flags(sv, &len, flags); + s = sv_2pv_flags(sv, &len, flags); if (lp) *lp = len; @@ -8403,7 +8401,7 @@ See C. void Perl_sv_unref_flags(pTHX_ SV *ref, U32 flags) { - SV* target = SvRV(ref); + SV* const target = SvRV(ref); if (SvWEAKREF(ref)) { sv_del_backref(target, ref); @@ -8462,7 +8460,7 @@ void Perl_sv_untaint(pTHX_ SV *sv) { if (SvTYPE(sv) >= SVt_PVMG && SvMAGIC(sv)) { - MAGIC *mg = mg_find(sv, PERL_MAGIC_taint); + MAGIC * const mg = mg_find(sv, PERL_MAGIC_taint); if (mg) mg->mg_len &= ~1; } @@ -8500,7 +8498,7 @@ Perl_sv_setpviv(pTHX_ SV *sv, IV iv) { char buf[TYPE_CHARS(UV)]; char *ebuf; - char *ptr = uiv_2buf(buf, iv, 0, 0, &ebuf); + char * const ptr = uiv_2buf(buf, iv, 0, 0, &ebuf); sv_setpvn(sv, ptr, ebuf - ptr); } @@ -8518,7 +8516,7 @@ Perl_sv_setpviv_mg(pTHX_ SV *sv, IV iv) { char buf[TYPE_CHARS(UV)]; char *ebuf; - char *ptr = uiv_2buf(buf, iv, 0, 0, &ebuf); + char * const ptr = uiv_2buf(buf, iv, 0, 0, &ebuf); sv_setpvn(sv, ptr, ebuf - ptr); SvSETMAGIC(sv); diff --git a/toke.c b/toke.c index efdd214..22a975c 100644 --- a/toke.c +++ b/toke.c @@ -3665,10 +3665,10 @@ Perl_yylex(pTHX) s = skipspace(s); if ((PL_expect != XREF || PL_oldoldbufptr == PL_last_lop) && intuit_more(s)) { - char *t; if (*s == '[') { PL_tokenbuf[0] = '@'; if (ckWARN(WARN_SYNTAX)) { + char *t; for(t = s + 1; isSPACE(*t) || isALNUM_lazy_if(t,UTF) || *t == '$'; t++) ; @@ -3683,6 +3683,7 @@ Perl_yylex(pTHX) } } else if (*s == '{') { + char *t; PL_tokenbuf[0] = '%'; if (ckWARN(WARN_SYNTAX) && strEQ(PL_tokenbuf+1, "SIG") && (t = strchr(s, '}')) && (t = strchr(t, '='))) @@ -5524,9 +5525,9 @@ S_pending_ident(pTHX) /* might be an "our" variable" */ if (PAD_COMPNAME_FLAGS(tmp) & SVpad_OUR) { /* build ops for a bareword */ - HV *stash = PAD_COMPNAME_OURSTASH(tmp); - HEK *stashname = HvNAME_HEK(stash); - SV *sym = newSVhek(stashname); + HV * const stash = PAD_COMPNAME_OURSTASH(tmp); + HEK * const stashname = HvNAME_HEK(stash); + SV * const sym = newSVhek(stashname); sv_catpvn(sym, "::", 2); sv_catpv(sym, PL_tokenbuf+1); yylval.opval = (OP*)newSVOP(OP_CONST, 0, sym); diff --git a/util.c b/util.c index 6ef7a01..4c2d664 100644 --- a/util.c +++ b/util.c @@ -3265,23 +3265,19 @@ Perl_my_fflush_all(pTHX) void Perl_report_evil_fh(pTHX_ const GV *gv, const IO *io, I32 op) { - const char *func = + const char * const func = op == OP_READLINE ? "readline" : /* "" not nice */ op == OP_LEAVEWRITE ? "write" : /* "write exit" not nice */ PL_op_desc[op]; - const char *pars = OP_IS_FILETEST(op) ? "" : "()"; - const char *type = OP_IS_SOCKET(op) + const char * const pars = OP_IS_FILETEST(op) ? "" : "()"; + const char * const type = OP_IS_SOCKET(op) || (gv && io && IoTYPE(io) == IoTYPE_SOCKET) ? "socket" : "filehandle"; - const char *name = NULL; - - if (gv && isGV(gv)) { - name = GvENAME(gv); - } + const char * const name = gv && isGV(gv) ? GvENAME(gv) : NULL; if (op == OP_phoney_OUTPUT_ONLY || op == OP_phoney_INPUT_ONLY) { if (ckWARN(WARN_IO)) { - const char *direction = (op == OP_phoney_INPUT_ONLY) ? "in" : "out"; + const char * const direction = (op == OP_phoney_INPUT_ONLY) ? "in" : "out"; if (name && *name) Perl_warner(aTHX_ packWARN(WARN_IO), "Filehandle %s opened only for %sput",