return 0;
if (SvRMAGICAL(av)) {
- MAGIC *tied_magic = mg_find((SV*)av, PERL_MAGIC_tied);
+ const MAGIC * const tied_magic = mg_find((SV*)av, PERL_MAGIC_tied);
if (tied_magic || mg_find((SV*)av, PERL_MAGIC_regdata)) {
U32 adjust_index = 1;
val = &PL_sv_undef;
if (SvRMAGICAL(av)) {
- MAGIC *tied_magic = mg_find((SV*)av, PERL_MAGIC_tied);
+ const MAGIC * const tied_magic = mg_find((SV*)av, PERL_MAGIC_tied);
if (tied_magic) {
/* Handle negative array indices 20020222 MJD */
if (key < 0) {
*/
I32
-Perl_av_len(pTHX_ register AV *av)
+Perl_av_len(pTHX_ const register AV *av)
{
return AvFILL(av);
}
Perl_croak(aTHX_ PL_no_modify);
if (SvRMAGICAL(av)) {
- MAGIC *tied_magic = mg_find((SV*)av, PERL_MAGIC_tied);
- SV **svp;
+ const MAGIC * const tied_magic = mg_find((SV*)av, PERL_MAGIC_tied);
if ((tied_magic || mg_find((SV*)av, PERL_MAGIC_regdata))) {
/* Handle negative array indices 20020222 MJD */
+ SV **svp;
if (key < 0) {
unsigned adjust_index = 1;
if (tied_magic) {
if (SvRMAGICAL(av)) {
- MAGIC *tied_magic = mg_find((SV*)av, PERL_MAGIC_tied);
+ const MAGIC * const tied_magic = mg_find((SV*)av, PERL_MAGIC_tied);
if (tied_magic || mg_find((SV*)av, PERL_MAGIC_regdata)) {
SV *sv = sv_newmortal();
MAGIC *mg;
p |AV* |av_fake |I32 size|SV** svp
Apd |SV** |av_fetch |AV* ar|I32 key|I32 lval
Apd |void |av_fill |AV* ar|I32 fill
-Apd |I32 |av_len |AV* ar
+Apd |I32 |av_len |const AV* ar
Apd |AV* |av_make |I32 size|SV** svp
Apd |SV* |av_pop |AV* ar
Apd |void |av_push |AV* ar|SV* val
Afnp |int |fprintf_nocontext|PerlIO* stream|const char* fmt|...
Afnp |int |printf_nocontext|const char* fmt|...
#endif
-p |void |cv_ckproto |CV* cv|GV* gv|char* p
+p |void |cv_ckproto |const CV* cv|const GV* gv|const char* p
pd |CV* |cv_clone |CV* proto
Apd |SV* |cv_const_sv |CV* cv
p |SV* |op_const_sv |OP* o|CV* cv
p |void |deprecate_old |char* s
Afp |OP* |die |const char* pat|...
p |OP* |vdie |const char* pat|va_list* args
-p |OP* |die_where |char* message|STRLEN msglen
+p |OP* |die_where |const char* message|STRLEN msglen
Ap |void |dounwind |I32 cxix
p |bool |do_aexec |SV* really|SV** mark|SV** sp
p |bool |do_aexec5 |SV* really|SV** mark|SV** sp|int fd|int flag
Ap |GV* |gv_autoload4 |HV* stash|const char* name|STRLEN len \
|I32 method
Ap |void |gv_check |HV* stash
-Ap |void |gv_efullname |SV* sv|GV* gv
-Amb |void |gv_efullname3 |SV* sv|GV* gv|const char* prefix
-Ap |void |gv_efullname4 |SV* sv|GV* gv|const char* prefix|bool keepmain
+Ap |void |gv_efullname |SV* sv|const GV* gv
+Amb |void |gv_efullname3 |SV* sv|const GV* gv|const char* prefix
+Ap |void |gv_efullname4 |SV* sv|const GV* gv|const char* prefix|bool keepmain
Ap |GV* |gv_fetchfile |const char* name
Apd |GV* |gv_fetchmeth |HV* stash|const char* name|STRLEN len \
|I32 level
Apd |GV* |gv_fetchmethod_autoload|HV* stash|const char* name \
|I32 autoload
Ap |GV* |gv_fetchpv |const char* name|I32 add|I32 sv_type
-Ap |void |gv_fullname |SV* sv|GV* gv
-Amb |void |gv_fullname3 |SV* sv|GV* gv|const char* prefix
-Ap |void |gv_fullname4 |SV* sv|GV* gv|const char* prefix|bool keepmain
+Ap |void |gv_fullname |SV* sv|const GV* gv
+Amb |void |gv_fullname3 |SV* sv|const GV* gv|const char* prefix
+Ap |void |gv_fullname4 |SV* sv|const GV* gv|const char* prefix|bool keepmain
Ap |void |gv_init |GV* gv|HV* stash|const char* name \
|STRLEN len|int multi
Apd |HV* |gv_stashpv |const char* name|I32 create
Apd |void |sortsv |SV ** array|size_t num_elts|SVCOMPARE_t cmp
Apd |int |mg_clear |SV* sv
Apd |int |mg_copy |SV* sv|SV* nsv|const char* key|I32 klen
-Apd |MAGIC* |mg_find |SV* sv|int type
+Apd |MAGIC* |mg_find |const SV* sv|int type
Apd |int |mg_free |SV* sv
Apd |int |mg_get |SV* sv
Apd |U32 |mg_length |SV* sv
Apd |char* |savepvn |const char* pv|I32 len
Ap |void |savestack_grow
Ap |void |savestack_grow_cnt |I32 need
-Ap |void |save_aelem |AV* av|I32 idx|SV **sptr
+Ap |void |save_aelem |const AV* av|I32 idx|SV **sptr
Ap |I32 |save_alloc |I32 size|I32 pad
Ap |void |save_aptr |AV** aptr
Ap |AV* |save_ary |GV* gv
Ap |void |save_shared_pvref|char** str
Ap |void |save_gp |GV* gv|I32 empty
Ap |HV* |save_hash |GV* gv
-Ap |void |save_helem |HV* hv|SV *key|SV **sptr
+Ap |void |save_helem |const HV* hv|SV *key|SV **sptr
Ap |void |save_hints
Ap |void |save_hptr |HV** hptr
Ap |void |save_I16 |I16* intp
p |void |utilize |int aver|I32 floor|OP* version|OP* idop|OP* arg
Ap |U8* |utf16_to_utf8 |U8* p|U8 *d|I32 bytelen|I32 *newlen
Ap |U8* |utf16_to_utf8_reversed|U8* p|U8 *d|I32 bytelen|I32 *newlen
-Adp |STRLEN |utf8_length |U8* s|U8 *e
-Apd |IV |utf8_distance |U8 *a|U8 *b
+Adp |STRLEN |utf8_length |const U8* s|const U8 *e
+Apd |IV |utf8_distance |const U8 *a|const U8 *b
Apd |U8* |utf8_hop |U8 *s|I32 off
ApMd |U8* |utf8_to_bytes |U8 *s|STRLEN *len
ApMd |U8* |bytes_from_utf8|U8 *s|STRLEN *len|bool *is_utf8
-ApMd |U8* |bytes_to_utf8 |U8 *s|STRLEN *len
+ApMd |U8* |bytes_to_utf8 |const U8 *s|STRLEN *len
Apd |UV |utf8_to_uvchr |U8 *s|STRLEN* retlen
Apd |UV |utf8_to_uvuni |U8 *s|STRLEN* retlen
Adp |UV |utf8n_to_uvchr |U8 *s|STRLEN curlen|STRLEN* retlen|U32 flags
Afp |void |warner |U32 err|const char* pat|...
Ap |void |vwarner |U32 err|const char* pat|va_list* args
p |void |watch |char** addr
-Ap |I32 |whichsig |char* sig
+Ap |I32 |whichsig |const char* sig
p |void |write_to_stderr|const char* message|int msglen
p |int |yyerror |char* s
p |int |yylex
break;
case '\026': /* $^V */
{
- SV *sv = GvSV(gv);
+ SV * const sv = GvSV(gv);
GvSV(gv) = new_version(PL_patchlevel);
SvREADONLY_on(GvSV(gv));
SvREFCNT_dec(sv);
}
void
-Perl_gv_fullname4(pTHX_ SV *sv, GV *gv, const char *prefix, bool keepmain)
+Perl_gv_fullname4(pTHX_ SV *sv, const GV *gv, const char *prefix, bool keepmain)
{
- char *name;
- HV *hv = GvSTASH(gv);
+ const char *name;
+ const HV * const hv = GvSTASH(gv);
if (!hv) {
SvOK_off(sv);
return;
}
void
-Perl_gv_fullname3(pTHX_ SV *sv, GV *gv, const char *prefix)
+Perl_gv_fullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
{
gv_fullname4(sv, gv, prefix, TRUE);
}
void
-Perl_gv_efullname4(pTHX_ SV *sv, GV *gv, const char *prefix, bool keepmain)
+Perl_gv_efullname4(pTHX_ SV *sv, const GV *gv, const char *prefix, bool keepmain)
{
- GV *egv = GvEGV(gv);
+ const GV *egv = GvEGV(gv);
if (!egv)
egv = gv;
gv_fullname4(sv, egv, prefix, keepmain);
}
void
-Perl_gv_efullname3(pTHX_ SV *sv, GV *gv, const char *prefix)
+Perl_gv_efullname3(pTHX_ SV *sv, const GV *gv, const char *prefix)
{
gv_efullname4(sv, gv, prefix, TRUE);
}
-/* XXX compatibility with versions <= 5.003. */
+/* compatibility with versions <= 5.003. */
void
-Perl_gv_fullname(pTHX_ SV *sv, GV *gv)
+Perl_gv_fullname(pTHX_ SV *sv, const GV *gv)
{
- gv_fullname3(sv, gv, sv == (SV*)gv ? "*" : "");
+ gv_fullname3(sv, gv, sv == (const SV*)gv ? "*" : "");
}
-/* XXX compatibility with versions <= 5.003. */
+/* compatibility with versions <= 5.003. */
void
-Perl_gv_efullname(pTHX_ SV *sv, GV *gv)
+Perl_gv_efullname(pTHX_ SV *sv, const GV *gv)
{
gv_efullname3(sv, gv, sv == (SV*)gv ? "*" : "");
}
STATIC HEK *
S_save_hek_flags(pTHX_ const char *str, I32 len, U32 hash, int flags)
{
- int flags_masked = flags & HVhek_MASK;
+ const int flags_masked = flags & HVhek_MASK;
char *k;
register HEK *hek;
break;
}
} else {
- int flags_masked = k_flags & HVhek_MASK;
+ const int flags_masked = k_flags & HVhek_MASK;
for (entry = *oentry; entry; i=0, oentry = &HeNEXT(entry), entry = *oentry) {
if (HeHASH(entry) != hash) /* strings can't be equal */
continue;
register HE **oentry;
register I32 i = 1;
I32 found = 0;
- int flags_masked = flags & HVhek_MASK;
+ const int flags_masked = flags & HVhek_MASK;
/* what follows is the moral equivalent of:
# define FAKE_DEFAULT_SIGNAL_HANDLERS
#endif
-static void restore_magic(pTHX_ void *p);
-static void unwind_handler_stack(pTHX_ void *p);
+static void restore_magic(pTHX_ const void *p);
+static void unwind_handler_stack(pTHX_ const void *p);
#ifdef __Lynx__
/* Missing protos on LynxOS */
{
MAGIC* mg;
for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
- MGVTBL* vtbl = mg->mg_virtual;
+ const MGVTBL* const vtbl = mg->mg_virtual;
if (vtbl) {
if (vtbl->svt_get && !(mg->mg_flags & MGf_GSKIP))
SvGMAGICAL_on(sv);
int
Perl_mg_get(pTHX_ SV *sv)
{
+ const I32 mgs_ix = SSNEW(sizeof(MGS));
+ const bool was_temp = SvTEMP(sv);
int new = 0;
MAGIC *newmg, *head, *cur, *mg;
- I32 mgs_ix = SSNEW(sizeof(MGS));
- int was_temp = SvTEMP(sv);
/* guard against sv having being freed midway by holding a private
reference. */
newmg = cur = head = mg = SvMAGIC(sv);
while (mg) {
- MGVTBL *vtbl = mg->mg_virtual;
+ const MGVTBL * const vtbl = mg->mg_virtual;
if (!(mg->mg_flags & MGf_GSKIP) && vtbl && vtbl->svt_get) {
CALL_FPTR(vtbl->svt_get)(aTHX_ sv, mg);
int
Perl_mg_set(pTHX_ SV *sv)
{
- I32 mgs_ix;
+ const I32 mgs_ix = SSNEW(sizeof(MGS));
MAGIC* mg;
MAGIC* nextmg;
- mgs_ix = SSNEW(sizeof(MGS));
save_magic(mgs_ix, sv);
for (mg = SvMAGIC(sv); mg; mg = nextmg) {
STRLEN len;
for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
- MGVTBL* vtbl = mg->mg_virtual;
+ const MGVTBL * const vtbl = mg->mg_virtual;
if (vtbl && vtbl->svt_len) {
- I32 mgs_ix;
-
- mgs_ix = SSNEW(sizeof(MGS));
+ const I32 mgs_ix = SSNEW(sizeof(MGS));
save_magic(mgs_ix, sv);
/* omit MGf_GSKIP -- not changed here */
len = CALL_FPTR(vtbl->svt_len)(aTHX_ sv, mg);
}
}
- if (DO_UTF8(sv))
- {
+ if (DO_UTF8(sv)) {
U8 *s = (U8*)SvPV(sv, len);
len = Perl_utf8_length(aTHX_ s, s + len);
}
Perl_mg_size(pTHX_ SV *sv)
{
MAGIC* mg;
- I32 len;
for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
- MGVTBL* vtbl = mg->mg_virtual;
+ const MGVTBL* const vtbl = mg->mg_virtual;
if (vtbl && vtbl->svt_len) {
- I32 mgs_ix;
-
- mgs_ix = SSNEW(sizeof(MGS));
+ const I32 mgs_ix = SSNEW(sizeof(MGS));
+ I32 len;
save_magic(mgs_ix, sv);
/* omit MGf_GSKIP -- not changed here */
len = CALL_FPTR(vtbl->svt_len)(aTHX_ sv, mg);
switch(SvTYPE(sv)) {
case SVt_PVAV:
- len = AvFILLp((AV *) sv); /* Fallback to non-tied array */
- return len;
+ return AvFILLp((AV *) sv); /* Fallback to non-tied array */
case SVt_PVHV:
/* FIXME */
default:
int
Perl_mg_clear(pTHX_ SV *sv)
{
- I32 mgs_ix;
+ const I32 mgs_ix = SSNEW(sizeof(MGS));
MAGIC* mg;
- mgs_ix = SSNEW(sizeof(MGS));
save_magic(mgs_ix, sv);
for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
- MGVTBL* vtbl = mg->mg_virtual;
+ const MGVTBL* const vtbl = mg->mg_virtual;
/* omit GSKIP -- never set here */
if (vtbl && vtbl->svt_clear)
*/
MAGIC*
-Perl_mg_find(pTHX_ SV *sv, int type)
+Perl_mg_find(pTHX_ const SV *sv, int type)
{
- MAGIC* mg;
- if (!sv)
- return 0;
- for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
- if (mg->mg_type == type)
- return mg;
+ if (sv) {
+ MAGIC *mg;
+ for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
+ if (mg->mg_type == type)
+ return mg;
+ }
}
return 0;
}
int count = 0;
MAGIC* mg;
for (mg = SvMAGIC(sv); mg; mg = mg->mg_moremagic) {
- MGVTBL* vtbl = mg->mg_virtual;
+ const MGVTBL* const vtbl = mg->mg_virtual;
if ((mg->mg_flags & MGf_COPY) && vtbl->svt_copy){
count += CALL_FPTR(vtbl->svt_copy)(aTHX_ sv, mg, nsv, key, klen);
}
MAGIC* mg;
MAGIC* moremagic;
for (mg = SvMAGIC(sv); mg; mg = moremagic) {
- MGVTBL* vtbl = mg->mg_virtual;
+ const MGVTBL* const vtbl = mg->mg_virtual;
moremagic = mg->mg_moremagic;
if (vtbl && vtbl->svt_free)
CALL_FPTR(vtbl->svt_free)(aTHX_ sv, mg);
U32
Perl_magic_regdata_cnt(pTHX_ SV *sv, MAGIC *mg)
{
- register REGEXP *rx;
+ register const REGEXP *rx;
if (PL_curpm && (rx = PM_GETRE(PL_curpm))) {
if (mg->mg_obj) /* @+ */
int
Perl_magic_regdatum_get(pTHX_ SV *sv, MAGIC *mg)
{
- register I32 paren;
- register I32 s;
- register I32 i;
register REGEXP *rx;
- I32 t;
if (PL_curpm && (rx = PM_GETRE(PL_curpm))) {
- paren = mg->mg_len;
+ register const I32 paren = mg->mg_len;
+ register I32 s;
+ register I32 t;
if (paren < 0)
return 0;
if (paren <= (I32)rx->nparens &&
(s = rx->startp[paren]) != -1 &&
(t = rx->endp[paren]) != -1)
{
+ register I32 i;
if (mg->mg_obj) /* @+ */
i = t;
else /* @- */
/* XXX Some of this code was copied from Perl_magic_setsig. A little
* refactoring might be in order.
*/
- register char *s;
STRLEN n_a;
SV* to_dec;
- s = MgPV(mg,n_a);
+ register const char *s = MgPV(mg,n_a);
if (*s == '_') {
SV** svp;
if (strEQ(s,"__DIE__"))
int
Perl_magic_setsig(pTHX_ SV *sv, MAGIC *mg)
{
- register char *s;
I32 i;
SV** svp = 0;
/* Need to be careful with SvREFCNT_dec(), because that can have side
SV* save_sv;
#endif
- s = MgPV(mg,len);
+ register const char *s = MgPV(mg,len);
if (*s == '_') {
if (strEQ(s,"__DIE__"))
svp = &PL_diehook;
Perl_magic_nextpack(pTHX_ SV *sv, MAGIC *mg, SV *key)
{
dSP;
- const char *meth = SvOK(key) ? "NEXTKEY" : "FIRSTKEY";
+ const char * const meth = SvOK(key) ? "NEXTKEY" : "FIRSTKEY";
ENTER;
SAVETMPS;
Perl_magic_getsubstr(pTHX_ SV *sv, MAGIC *mg)
{
STRLEN len;
- SV *lsv = LvTARG(sv);
- char *tmps = SvPV(lsv,len);
+ SV * const lsv = LvTARG(sv);
+ const char * const tmps = SvPV(lsv,len);
I32 offs = LvTARGOFF(sv);
I32 rem = LvTARGLEN(sv);
int
Perl_magic_getvec(pTHX_ SV *sv, MAGIC *mg)
{
- SV *lsv = LvTARG(sv);
+ SV * const lsv = LvTARG(sv);
if (!lsv) {
SvOK_off(sv);
int
Perl_magic_setuvar(pTHX_ SV *sv, MAGIC *mg)
{
- struct ufuncs *uf = (struct ufuncs *)mg->mg_ptr;
+ const struct ufuncs * const uf = (struct ufuncs *)mg->mg_ptr;
if (uf && uf->uf_set)
(*uf->uf_set)(aTHX_ uf->uf_index, sv);
STRLEN len, i;
int accumulate = 0 ;
int any_fatals = 0 ;
- char * ptr = (char*)SvPV(sv, len) ;
+ const char * const ptr = (char*)SvPV(sv, len) ;
for (i = 0 ; i < len ; ++i) {
accumulate |= ptr[i] ;
any_fatals |= (ptr[i] & 0xAA) ;
case ')':
#ifdef HAS_SETGROUPS
{
- char *p = SvPV(sv, len);
+ const char *p = SvPV(sv, len);
Groups_t gary[NGROUPS];
while (isSPACE(*p))
}
I32
-Perl_whichsig(pTHX_ char *sig)
+Perl_whichsig(pTHX_ const char *sig)
{
register char **sigv;
static void
-restore_magic(pTHX_ void *p)
+restore_magic(pTHX_ const void *p)
{
MGS* mgs = SSPTR(PTR2IV(p), MGS*);
SV* sv = mgs->mgs_sv;
}
static void
-unwind_handler_stack(pTHX_ void *p)
+unwind_handler_stack(pTHX_ const void *p)
{
- U32 flags = *(U32*)p;
+ const U32 flags = *(U32*)p;
if (flags & 1)
PL_savestack_ix -= 5; /* Unprotect save in progress. */
}
void
-Perl_cv_ckproto(pTHX_ CV *cv, GV *gv, char *p)
+Perl_cv_ckproto(pTHX_ const CV *cv, const GV *gv, const char *p)
{
if (((!p != !SvPOK(cv)) || (p && strNE(p, SvPVX(cv)))) && ckWARN_d(WARN_PROTOTYPE)) {
SV* msg = sv_newmortal();
Returns the highest index in the array. Returns -1 if the array is
empty.
- I32 av_len(AV* ar)
+ I32 av_len(const AV* ar)
=for hackers
Found in file av.c
Finds the magic pointer for type matching the SV. See C<sv_magic>.
- MAGIC* mg_find(SV* sv, int type)
+ MAGIC* mg_find(const SV* sv, int type)
=for hackers
Found in file mg.c
=item bytes_from_utf8
Converts a string C<s> of length C<len> from UTF-8 into byte encoding.
-Unlike <utf8_to_bytes> but like C<bytes_to_utf8>, returns a pointer to
+Unlike C<utf8_to_bytes> but like C<bytes_to_utf8>, returns a pointer to
the newly-created string, and updates C<len> to contain the new
length. Returns the original string if no conversion occurs, C<len>
is unchanged. Do nothing if C<is_utf8> points to 0. Sets C<is_utf8> to
NOTE: this function is experimental and may change or be
removed without notice.
- U8* bytes_to_utf8(U8 *s, STRLEN *len)
+ U8* bytes_to_utf8(const U8 *s, STRLEN *len)
=for hackers
Found in file utf8.c
WARNING: use only if you *know* that the pointers point inside the
same UTF-8 buffer.
- IV utf8_distance(U8 *a, U8 *b)
+ IV utf8_distance(const U8 *a, const U8 *b)
=for hackers
Found in file utf8.c
Stops at C<e> (inclusive). If C<e E<lt> s> or if the scan would end
up past C<e>, croaks.
- STRLEN utf8_length(U8* s, U8 *e)
+ STRLEN utf8_length(const U8* s, const U8 *e)
=for hackers
Found in file utf8.c
}
OP *
-Perl_die_where(pTHX_ char *message, STRLEN msglen)
+Perl_die_where(pTHX_ const char *message, STRLEN msglen)
{
STRLEN n_a;
if (PL_in_eval) {
I32 cxix;
- register PERL_CONTEXT *cx;
I32 gimme;
SV **newsp;
if (cxix >= 0) {
I32 optype;
+ register PERL_CONTEXT *cx;
if (cxix < cxstack_ix)
dounwind(cxix);
PL_curcop = cx->blk_oldcop;
if (optype == OP_REQUIRE) {
- char* msg = SvPVx(ERRSV, n_a);
- SV *nsv = cx->blk_eval.old_namesv;
- (void)hv_store(GvHVn(PL_incgv), SvPVX(nsv), SvCUR(nsv),
+ const char* msg = SvPVx(ERRSV, n_a);
+ SV *nsv = cx->blk_eval.old_namesv;
+ (void)hv_store(GvHVn(PL_incgv), SvPVX(nsv), SvCUR(nsv),
&PL_sv_undef, 0);
DIE(aTHX_ "%sCompilation failed in require",
*msg ? msg : "Unknown error\n");
PERL_CALLCONV AV* Perl_av_fake(pTHX_ I32 size, SV** svp);
PERL_CALLCONV SV** Perl_av_fetch(pTHX_ AV* ar, I32 key, I32 lval);
PERL_CALLCONV void Perl_av_fill(pTHX_ AV* ar, I32 fill);
-PERL_CALLCONV I32 Perl_av_len(pTHX_ AV* ar);
+PERL_CALLCONV I32 Perl_av_len(pTHX_ const AV* ar);
PERL_CALLCONV AV* Perl_av_make(pTHX_ I32 size, SV** svp);
PERL_CALLCONV SV* Perl_av_pop(pTHX_ AV* ar);
PERL_CALLCONV void Perl_av_push(pTHX_ AV* ar, SV* val);
PERL_CALLCONV int Perl_printf_nocontext(const char* fmt, ...)
__attribute__format__(__printf__,1,2);
#endif
-PERL_CALLCONV void Perl_cv_ckproto(pTHX_ CV* cv, GV* gv, char* p);
+PERL_CALLCONV void Perl_cv_ckproto(pTHX_ const CV* cv, const GV* gv, const char* p);
PERL_CALLCONV CV* Perl_cv_clone(pTHX_ CV* proto);
PERL_CALLCONV SV* Perl_cv_const_sv(pTHX_ CV* cv);
PERL_CALLCONV SV* Perl_op_const_sv(pTHX_ OP* o, CV* cv);
PERL_CALLCONV OP* Perl_die(pTHX_ const char* pat, ...)
__attribute__format__(__printf__,pTHX_1,pTHX_2);
PERL_CALLCONV OP* Perl_vdie(pTHX_ const char* pat, va_list* args);
-PERL_CALLCONV OP* Perl_die_where(pTHX_ char* message, STRLEN msglen);
+PERL_CALLCONV OP* Perl_die_where(pTHX_ const char* message, STRLEN msglen);
PERL_CALLCONV void Perl_dounwind(pTHX_ I32 cxix);
PERL_CALLCONV bool Perl_do_aexec(pTHX_ SV* really, SV** mark, SV** sp);
PERL_CALLCONV bool Perl_do_aexec5(pTHX_ SV* really, SV** mark, SV** sp, int fd, int flag);
PERL_CALLCONV GV* Perl_gv_IOadd(pTHX_ GV* gv);
PERL_CALLCONV GV* Perl_gv_autoload4(pTHX_ HV* stash, const char* name, STRLEN len, I32 method);
PERL_CALLCONV void Perl_gv_check(pTHX_ HV* stash);
-PERL_CALLCONV void Perl_gv_efullname(pTHX_ SV* sv, GV* gv);
-/* PERL_CALLCONV void gv_efullname3(pTHX_ SV* sv, GV* gv, const char* prefix); */
-PERL_CALLCONV void Perl_gv_efullname4(pTHX_ SV* sv, GV* gv, const char* prefix, bool keepmain);
+PERL_CALLCONV void Perl_gv_efullname(pTHX_ SV* sv, const GV* gv);
+/* PERL_CALLCONV void gv_efullname3(pTHX_ SV* sv, const GV* gv, const char* prefix); */
+PERL_CALLCONV void Perl_gv_efullname4(pTHX_ SV* sv, const GV* gv, const char* prefix, bool keepmain);
PERL_CALLCONV GV* Perl_gv_fetchfile(pTHX_ const char* name);
PERL_CALLCONV GV* Perl_gv_fetchmeth(pTHX_ HV* stash, const char* name, STRLEN len, I32 level);
PERL_CALLCONV GV* Perl_gv_fetchmeth_autoload(pTHX_ HV* stash, const char* name, STRLEN len, I32 level);
PERL_CALLCONV GV* Perl_gv_fetchmethod(pTHX_ HV* stash, const char* name);
PERL_CALLCONV GV* Perl_gv_fetchmethod_autoload(pTHX_ HV* stash, const char* name, I32 autoload);
PERL_CALLCONV GV* Perl_gv_fetchpv(pTHX_ const char* name, I32 add, I32 sv_type);
-PERL_CALLCONV void Perl_gv_fullname(pTHX_ SV* sv, GV* gv);
-/* PERL_CALLCONV void gv_fullname3(pTHX_ SV* sv, GV* gv, const char* prefix); */
-PERL_CALLCONV void Perl_gv_fullname4(pTHX_ SV* sv, GV* gv, const char* prefix, bool keepmain);
+PERL_CALLCONV void Perl_gv_fullname(pTHX_ SV* sv, const GV* gv);
+/* PERL_CALLCONV void gv_fullname3(pTHX_ SV* sv, const GV* gv, const char* prefix); */
+PERL_CALLCONV void Perl_gv_fullname4(pTHX_ SV* sv, const GV* gv, const char* prefix, bool keepmain);
PERL_CALLCONV void Perl_gv_init(pTHX_ GV* gv, HV* stash, const char* name, STRLEN len, int multi);
PERL_CALLCONV HV* Perl_gv_stashpv(pTHX_ const char* name, I32 create);
PERL_CALLCONV HV* Perl_gv_stashpvn(pTHX_ const char* name, U32 namelen, I32 create);
PERL_CALLCONV void Perl_sortsv(pTHX_ SV ** array, size_t num_elts, SVCOMPARE_t cmp);
PERL_CALLCONV int Perl_mg_clear(pTHX_ SV* sv);
PERL_CALLCONV int Perl_mg_copy(pTHX_ SV* sv, SV* nsv, const char* key, I32 klen);
-PERL_CALLCONV MAGIC* Perl_mg_find(pTHX_ SV* sv, int type);
+PERL_CALLCONV MAGIC* Perl_mg_find(pTHX_ const SV* sv, int type);
PERL_CALLCONV int Perl_mg_free(pTHX_ SV* sv);
PERL_CALLCONV int Perl_mg_get(pTHX_ SV* sv);
PERL_CALLCONV U32 Perl_mg_length(pTHX_ SV* sv);
PERL_CALLCONV char* Perl_savepvn(pTHX_ const char* pv, I32 len);
PERL_CALLCONV void Perl_savestack_grow(pTHX);
PERL_CALLCONV void Perl_savestack_grow_cnt(pTHX_ I32 need);
-PERL_CALLCONV void Perl_save_aelem(pTHX_ AV* av, I32 idx, SV **sptr);
+PERL_CALLCONV void Perl_save_aelem(pTHX_ const AV* av, I32 idx, SV **sptr);
PERL_CALLCONV I32 Perl_save_alloc(pTHX_ I32 size, I32 pad);
PERL_CALLCONV void Perl_save_aptr(pTHX_ AV** aptr);
PERL_CALLCONV AV* Perl_save_ary(pTHX_ GV* gv);
PERL_CALLCONV void Perl_save_shared_pvref(pTHX_ char** str);
PERL_CALLCONV void Perl_save_gp(pTHX_ GV* gv, I32 empty);
PERL_CALLCONV HV* Perl_save_hash(pTHX_ GV* gv);
-PERL_CALLCONV void Perl_save_helem(pTHX_ HV* hv, SV *key, SV **sptr);
+PERL_CALLCONV void Perl_save_helem(pTHX_ const HV* hv, SV *key, SV **sptr);
PERL_CALLCONV void Perl_save_hints(pTHX);
PERL_CALLCONV void Perl_save_hptr(pTHX_ HV** hptr);
PERL_CALLCONV void Perl_save_I16(pTHX_ I16* intp);
PERL_CALLCONV void Perl_utilize(pTHX_ int aver, I32 floor, OP* version, OP* idop, OP* arg);
PERL_CALLCONV U8* Perl_utf16_to_utf8(pTHX_ U8* p, U8 *d, I32 bytelen, I32 *newlen);
PERL_CALLCONV U8* Perl_utf16_to_utf8_reversed(pTHX_ U8* p, U8 *d, I32 bytelen, I32 *newlen);
-PERL_CALLCONV STRLEN Perl_utf8_length(pTHX_ U8* s, U8 *e);
-PERL_CALLCONV IV Perl_utf8_distance(pTHX_ U8 *a, U8 *b);
+PERL_CALLCONV STRLEN Perl_utf8_length(pTHX_ const U8* s, const U8 *e);
+PERL_CALLCONV IV Perl_utf8_distance(pTHX_ const U8 *a, const U8 *b);
PERL_CALLCONV U8* Perl_utf8_hop(pTHX_ U8 *s, I32 off);
PERL_CALLCONV U8* Perl_utf8_to_bytes(pTHX_ U8 *s, STRLEN *len);
PERL_CALLCONV U8* Perl_bytes_from_utf8(pTHX_ U8 *s, STRLEN *len, bool *is_utf8);
-PERL_CALLCONV U8* Perl_bytes_to_utf8(pTHX_ U8 *s, STRLEN *len);
+PERL_CALLCONV U8* Perl_bytes_to_utf8(pTHX_ const U8 *s, STRLEN *len);
PERL_CALLCONV UV Perl_utf8_to_uvchr(pTHX_ U8 *s, STRLEN* retlen);
PERL_CALLCONV UV Perl_utf8_to_uvuni(pTHX_ U8 *s, STRLEN* retlen);
PERL_CALLCONV UV Perl_utf8n_to_uvchr(pTHX_ U8 *s, STRLEN curlen, STRLEN* retlen, U32 flags);
__attribute__format__(__printf__,pTHX_2,pTHX_3);
PERL_CALLCONV void Perl_vwarner(pTHX_ U32 err, const char* pat, va_list* args);
PERL_CALLCONV void Perl_watch(pTHX_ char** addr);
-PERL_CALLCONV I32 Perl_whichsig(pTHX_ char* sig);
+PERL_CALLCONV I32 Perl_whichsig(pTHX_ const char* sig);
PERL_CALLCONV void Perl_write_to_stderr(pTHX_ const char* message, int msglen);
PERL_CALLCONV int Perl_yyerror(pTHX_ char* s);
PERL_CALLCONV int Perl_yylex(pTHX);
void
Perl_pop_scope(pTHX)
{
- I32 oldsave = PL_scopestack[--PL_scopestack_ix];
+ const I32 oldsave = PL_scopestack[--PL_scopestack_ix];
LEAVE_SCOPE(oldsave);
}
void
Perl_markstack_grow(pTHX)
{
- I32 oldmax = PL_markstack_max - PL_markstack;
- I32 newmax = GROW(oldmax);
+ const I32 oldmax = PL_markstack_max - PL_markstack;
+ const I32 newmax = GROW(oldmax);
Renew(PL_markstack, newmax, I32);
PL_markstack_ptr = PL_markstack + oldmax;
Perl_free_tmps(pTHX)
{
/* XXX should tmps_floor live in cxstack? */
- I32 myfloor = PL_tmps_floor;
+ const I32 myfloor = PL_tmps_floor;
while (PL_tmps_ix > myfloor) { /* clean up after last statement */
SV* sv = PL_tmps_stack[PL_tmps_ix];
PL_tmps_stack[PL_tmps_ix--] = Nullsv;
MAGIC *mg;
sv_upgrade(sv, SvTYPE(osv));
if (SvGMAGICAL(osv)) {
- bool oldtainted = PL_tainted;
+ const bool oldtainted = PL_tainted;
mg_get(osv); /* note, can croak! */
if (PL_tainting && PL_tainted &&
(mg = mg_find(osv, PERL_MAGIC_taint))) {
}
void
-Perl_save_aelem(pTHX_ AV *av, I32 idx, SV **sptr)
+Perl_save_aelem(pTHX_ const AV *av, I32 idx, SV **sptr)
{
SV *sv;
SSCHECK(4);
}
void
-Perl_save_helem(pTHX_ HV *hv, SV *key, SV **sptr)
+Perl_save_helem(pTHX_ const HV *hv, SV *key, SV **sptr)
{
SV *sv;
SSCHECK(4);
I32
Perl_save_alloc(pTHX_ I32 size, I32 pad)
{
- register I32 start = pad + ((char*)&PL_savestack[PL_savestack_ix]
+ register const I32 start = pad + ((char*)&PL_savestack[PL_savestack_ix]
- (char*)PL_savestack);
- register I32 elems = 1 + ((size + pad - 1) / sizeof(*PL_savestack));
+ register const I32 elems = 1 + ((size + pad - 1) / sizeof(*PL_savestack));
/* SSCHECK may not be good enough */
while (PL_savestack_ix + elems + 2 > PL_savestack_max)
av = (AV*)SSPOPPTR;
gv = (GV*)SSPOPPTR;
if (GvAV(gv)) {
- AV *goner = GvAV(gv);
+ AV * const goner = GvAV(gv);
SvMAGIC(av) = SvMAGIC(goner);
SvFLAGS((SV*)av) |= SvMAGICAL(goner);
SvMAGICAL_off(goner);
hv = (HV*)SSPOPPTR;
gv = (GV*)SSPOPPTR;
if (GvHV(gv)) {
- HV *goner = GvHV(gv);
+ HV * const goner = GvHV(gv);
SvMAGIC(hv) = SvMAGIC(goner);
SvFLAGS(hv) |= SvMAGICAL(goner);
SvMAGICAL_off(goner);
SvPADSTALE_on(sv); /* mark as no longer live */
}
else { /* Someone has a claim on this, so abandon it. */
- U32 padflags = SvFLAGS(sv) & (SVs_PADMY|SVs_PADTMP);
+ const U32 padflags = SvFLAGS(sv) & (SVs_PADMY|SVs_PADTMP);
switch (SvTYPE(sv)) { /* Console ourselves with a new value */
case SVt_PVAV: *(SV**)ptr = (SV*)newAV(); break;
case SVt_PVHV: *(SV**)ptr = (SV*)newHV(); break;
hv = (HV*)SSPOPPTR;
ptr = hv_fetch_ent(hv, sv, 1, 0);
if (ptr) {
- SV *oval = HeVAL((HE*)ptr);
+ const SV * const oval = HeVAL((HE*)ptr);
if (oval && oval != &PL_sv_undef) {
ptr = &HeVAL((HE*)ptr);
if (SvTIED_mg((SV*)hv, PERL_MAGIC_tied))
break;
case SAVEt_PADSV:
{
- PADOFFSET off = (PADOFFSET)SSPOPLONG;
+ const PADOFFSET off = (PADOFFSET)SSPOPLONG;
ptr = SSPOPPTR;
if (ptr)
AvARRAY((PAD*)ptr)[off] = (SV*)SSPOPPTR;
break;
case SAVEt_SET_SVFLAGS:
{
- U32 val = (U32)SSPOPINT;
- U32 mask = (U32)SSPOPINT;
+ const U32 val = (U32)SSPOPINT;
+ const U32 mask = (U32)SSPOPINT;
sv = (SV*)SSPOPPTR;
SvFLAGS(sv) &= ~mask;
SvFLAGS(sv) |= val;
}
/*
-=for apidoc A|STRLEN|utf8_length|U8 *s|U8 *e
+=for apidoc A|STRLEN|utf8_length|const U8 *s|const U8 *e
Return the length of the UTF-8 char encoded string C<s> in characters.
Stops at C<e> (inclusive). If C<e E<lt> s> or if the scan would end
*/
STRLEN
-Perl_utf8_length(pTHX_ U8 *s, U8 *e)
+Perl_utf8_length(pTHX_ const U8 *s, const U8 *e)
{
STRLEN len = 0;
}
/*
-=for apidoc A|IV|utf8_distance|U8 *a|U8 *b
+=for apidoc A|IV|utf8_distance|const U8 *a|const U8 *b
Returns the number of UTF-8 characters between the UTF-8 pointers C<a>
and C<b>.
*/
IV
-Perl_utf8_distance(pTHX_ U8 *a, U8 *b)
+Perl_utf8_distance(pTHX_ const U8 *a, const U8 *b)
{
IV off = 0;
if (a < b) {
while (a < b) {
- U8 c = UTF8SKIP(a);
+ const U8 c = UTF8SKIP(a);
if (b - a < c) {
if (ckWARN_d(WARN_UTF8)) {
=for apidoc A|U8 *|bytes_from_utf8|U8 *s|STRLEN *len|bool *is_utf8
Converts a string C<s> of length C<len> from UTF-8 into byte encoding.
-Unlike <utf8_to_bytes> but like C<bytes_to_utf8>, returns a pointer to
+Unlike C<utf8_to_bytes> but like C<bytes_to_utf8>, returns a pointer to
the newly-created string, and updates C<len> to contain the new
length. Returns the original string if no conversion occurs, C<len>
is unchanged. Do nothing if C<is_utf8> points to 0. Sets C<is_utf8> to
}
/*
-=for apidoc A|U8 *|bytes_to_utf8|U8 *s|STRLEN *len
+=for apidoc A|U8 *|bytes_to_utf8|const U8 *s|STRLEN *len
Converts a string C<s> of length C<len> from ASCII into UTF-8 encoding.
Returns a pointer to the newly-created string, and sets C<len> to
*/
U8*
-Perl_bytes_to_utf8(pTHX_ U8 *s, STRLEN *len)
+Perl_bytes_to_utf8(pTHX_ const U8 *s, STRLEN *len)
{
- U8 *send;
+ const U8 * const send = s + (*len);
U8 *d;
U8 *dst;
- send = s + (*len);
Newz(801, d, (*len) * 2 + 1, U8);
dst = d;
while (s < send) {
- UV uv = NATIVE_TO_ASCII(*s++);
+ const UV uv = NATIVE_TO_ASCII(*s++);
if (UNI_IS_INVARIANT(uv))
*d++ = (U8)UTF_TO_NATIVE(uv);
else {