summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Lester <andy@petdance.com>2005-03-18 19:28:30 -0600
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-03-21 09:39:35 +0000
commitbfed75c6338f0ba740aa210f4b0267e39ca4662b (patch)
treeceaa91a3d877b0eaf3000f01f413f942619a2d9f
parenta87115f0a1b74f765307464de281024d76c71ad6 (diff)
downloadperl-bfed75c6338f0ba740aa210f4b0267e39ca4662b.tar.gz
More consting goodness
Message-ID: <20050319072830.GA7721@petdance.com> p4raw-id: //depot/perl@24049
-rw-r--r--deb.c2
-rw-r--r--dump.c6
-rw-r--r--embed.fnc38
-rw-r--r--handy.h16
-rw-r--r--op.c10
-rw-r--r--opcode.h8
-rwxr-xr-xopcode.pl8
-rw-r--r--perl.c6
-rw-r--r--pod/perlapi.pod2
-rw-r--r--pp_ctl.c61
-rw-r--r--pp_sys.c6
-rw-r--r--proto.h38
-rw-r--r--regcomp.c24
-rw-r--r--regexec.c2
-rw-r--r--sv.c18
-rw-r--r--toke.c88
16 files changed, 165 insertions, 168 deletions
diff --git a/deb.c b/deb.c
index 58b49a61e6..4bb91add40 100644
--- a/deb.c
+++ b/deb.c
@@ -149,7 +149,7 @@ Perl_debstack(pTHX)
#ifdef DEBUGGING
-static char * si_names[] = {
+static const char * si_names[] = {
"UNKNOWN",
"UNDEF",
"MAIN",
diff --git a/dump.c b/dump.c
index 00f989f5fe..0ae1a440dc 100644
--- a/dump.c
+++ b/dump.c
@@ -887,7 +887,7 @@ Perl_gv_dump(pTHX_ GV *gv)
* (with the PERL_MAGIC_ prefixed stripped)
*/
-static struct { char type; char *name; } magic_names[] = {
+static struct { const char type; const char *name; } magic_names[] = {
{ PERL_MAGIC_sv, "sv(\\0)" },
{ PERL_MAGIC_arylen, "arylen(#)" },
{ PERL_MAGIC_glob, "glob(*)" },
@@ -938,8 +938,8 @@ Perl_do_magic_dump(pTHX_ I32 level, PerlIO *file, MAGIC *mg, I32 nest, I32 maxne
Perl_dump_indent(aTHX_ level, file,
" MAGIC = 0x%"UVxf"\n", PTR2UV(mg));
if (mg->mg_virtual) {
- MGVTBL *v = mg->mg_virtual;
- char *s = 0;
+ const MGVTBL * const v = mg->mg_virtual;
+ const char *s = 0;
if (v == &PL_vtbl_sv) s = "sv";
else if (v == &PL_vtbl_env) s = "env";
else if (v == &PL_vtbl_envelem) s = "envelem";
diff --git a/embed.fnc b/embed.fnc
index fe771393e2..18d2973dec 100644
--- a/embed.fnc
+++ b/embed.fnc
@@ -157,8 +157,8 @@ Ap |I32 |debstack
Ap |I32 |debstackptrs
Ap |char* |delimcpy |char* to|char* toend|char* from \
|char* fromend|int delim|I32* retlen
-p |void |deprecate |char* s
-p |void |deprecate_old |char* s
+p |void |deprecate |const char* s
+p |void |deprecate_old |const char* s
Afp |OP* |die |const char* pat|...
p |OP* |vdie |const char* pat|va_list* args
p |OP* |die_where |const char* message|STRLEN msglen
@@ -502,7 +502,7 @@ Ap |OP* |newRANGE |I32 flags|OP* left|OP* right
Ap |OP* |newSLICEOP |I32 flags|OP* subscript|OP* listop
Ap |OP* |newSTATEOP |I32 flags|char* label|OP* o
Ap |CV* |newSUB |I32 floor|OP* o|OP* proto|OP* block
-Apd |CV* |newXS |char* name|XSUBADDR_t f|char* filename
+Apd |CV* |newXS |const char* name|XSUBADDR_t f|const char* filename
Apd |AV* |newAV
Ap |OP* |newAVREF |OP* o
Ap |OP* |newBINOP |I32 type|I32 flags|OP* first|OP* last
@@ -538,7 +538,7 @@ Ap |OP* |newWHILEOP |I32 flags|I32 debuggable|LOOP* loop \
|I32 whileline|OP* expr|OP* block|OP* cont
Ap |PERL_SI*|new_stackinfo|I32 stitems|I32 cxitems
-Ap |char* |scan_vstring |char *vstr|SV *sv
+Ap |char* |scan_vstring |const char *vstr|SV *sv
Apd |char* |scan_version |char *vstr|SV *sv|bool qv
Apd |SV* |new_version |SV *ver
Apd |SV* |upg_version |SV *ver
@@ -683,7 +683,7 @@ p |OP* |scalarseq |OP* o
p |OP* |scalarvoid |OP* o
Apd |NV |scan_bin |char* start|STRLEN len|STRLEN* retlen
Apd |NV |scan_hex |char* start|STRLEN len|STRLEN* retlen
-Ap |char* |scan_num |char* s|YYSTYPE *lvalp
+Ap |char* |scan_num |const char* s|YYSTYPE *lvalp
Apd |NV |scan_oct |char* start|STRLEN len|STRLEN* retlen
p |OP* |scope |OP* o
Ap |char* |screaminstr |SV* bigsv|SV* littlesv|I32 start_shift \
@@ -735,7 +735,7 @@ Apd |I32 |sv_cmp_locale |SV* sv1|SV* sv2
#if defined(USE_LOCALE_COLLATE)
Apd |char* |sv_collxfrm |SV* sv|STRLEN* nxp
#endif
-Ap |OP* |sv_compile_2op |SV* sv|OP** startp|char* code|PAD** padp
+Ap |OP* |sv_compile_2op |SV* sv|OP** startp|const char* code|PAD** padp
Apd |int |getcwd_sv |SV* sv
Apd |void |sv_dec |SV* sv
Ap |void |sv_dump |SV* sv
@@ -769,7 +769,7 @@ Apd |char* |sv_pvbyten_force|SV* sv|STRLEN* lp
Apd |char* |sv_recode_to_utf8 |SV* sv|SV *encoding
Apd |bool |sv_cat_decode |SV* dsv|SV *encoding|SV *ssv|int *offset \
|char* tstr|int tlen
-Apd |char* |sv_reftype |SV* sv|int ob
+Apd |const char*|sv_reftype |const SV* sv|int ob
Apd |void |sv_replace |SV* sv|SV* nsv
Apd |void |sv_report_used
Apd |void |sv_reset |char* s|HV* stash
@@ -854,10 +854,10 @@ Ap |void |vwarner |U32 err|const char* pat|va_list* args
p |void |watch |char** addr
Ap |I32 |whichsig |const char* sig
p |void |write_to_stderr|const char* message|int msglen
-p |int |yyerror |char* s
+p |int |yyerror |const char* s
p |int |yylex
p |int |yyparse
-p |int |yywarn |char* s
+p |int |yywarn |const char* s
#if defined(MYMALLOC)
Ap |void |dump_mstats |char* s
Ap |int |get_mstats |perl_mstats_t *buf|int buflen|int level
@@ -1001,14 +1001,14 @@ s |int |magic_methcall |SV *sv|MAGIC *mg|char *meth|I32 f \
#if defined(PERL_IN_OP_C) || defined(PERL_DECL_PROT)
s |I32 |list_assignment|OP *o
-s |void |bad_type |I32 n|char *t|char *name|OP *kid
+s |void |bad_type |I32 n|const char *t|const char *name|OP *kid
s |void |cop_free |COP *cop
s |OP* |modkids |OP *o|I32 type
s |void |no_bareword_allowed|OP *o
s |OP* |no_fh_allowed |OP *o
s |OP* |scalarboolean |OP *o
-s |OP* |too_few_arguments|OP *o|char* name
-s |OP* |too_many_arguments|OP *o|char* name
+s |OP* |too_few_arguments|OP *o|const char* name
+s |OP* |too_many_arguments|OP *o|const char* name
s |OP* |newDEFSVOP
s |OP* |new_logop |I32 type|I32 flags|OP **firstp|OP **otherp
s |void |simplify_sort |OP *o
@@ -1069,7 +1069,7 @@ s |int |div128 |SV *pnum|bool *done
#if defined(PERL_IN_PP_CTL_C) || defined(PERL_DECL_PROT)
s |OP* |docatch |OP *o
s |void* |docatch_body
-s |OP* |dofindlabel |OP *o|char *label|OP **opstack|OP **oplimit
+s |OP* |dofindlabel |OP *o|const char *label|OP **opstack|OP **oplimit
s |OP* |doparseform |SV *sv
sn |bool |num_overflow |NV value|I32 fldsize|I32 frcsize
s |I32 |dopoptoeval |I32 startingblock
@@ -1129,7 +1129,7 @@ Es |void |cl_or |struct RExC_state_t*|struct regnode_charclass_class *cl \
Es |I32 |study_chunk |struct RExC_state_t*|regnode **scanp|I32 *deltap \
|regnode *last|struct scan_data_t *data \
|U32 flags|U32 depth
-Es |I32 |add_data |struct RExC_state_t*|I32 n|char *s
+Es |I32 |add_data |struct RExC_state_t*|I32 n|const char *s
rs |void|re_croak2 |const char* pat1|const char* pat2|...
Es |I32 |regpposixcc |struct RExC_state_t*|I32 value
Es |void |checkposixcc |struct RExC_state_t*
@@ -1253,14 +1253,14 @@ s |char* |scan_word |char *s|char *dest|STRLEN destlen \
|int allow_package|STRLEN *slp
s |char* |skipspace |char *s
s |char* |swallow_bom |U8 *s
-s |void |checkcomma |char *s|char *name|char *what
-s |void |force_ident |char *s|int kind
+s |void |checkcomma |char *s|char *name|const char *what
+s |void |force_ident |const char *s|int kind
s |void |incline |char *s
s |int |intuit_method |char *s|GV *gv
s |int |intuit_more |char *s
s |I32 |lop |I32 f|int x|char *s
s |void |missingterm |char *s
-s |void |no_op |char *what|char *s
+s |void |no_op |const char *what|char *s
s |void |set_csh
s |I32 |sublex_done
s |I32 |sublex_push
@@ -1270,11 +1270,11 @@ s |HV * |find_in_my_stash|const char *pkgname|I32 len
s |SV* |new_constant |const char *s|STRLEN len|const char *key|SV *sv \
|SV *pv|const char *type
# if defined(DEBUGGING)
-s |int |tokereport |char *s|I32 rv
+s |int |tokereport |const char *s|I32 rv
# endif
s |int |ao |int toketype
s |void |depcom
-s |char* |incl_perldb
+s |const char*|incl_perldb
#if 0
s |I32 |utf16_textfilter|int idx|SV *sv|int maxlen
s |I32 |utf16rev_textfilter|int idx|SV *sv|int maxlen
diff --git a/handy.h b/handy.h
index af4890e520..339653fa62 100644
--- a/handy.h
+++ b/handy.h
@@ -623,12 +623,12 @@ hopefully catches attempts to access uninitialized memory.
(v = (MEM_WRAP_CHECK(n,t), (c*)saferealloc((Malloc_t)(v),(MEM_SIZE)((n)*sizeof(t)))))
#define Safefree(d) safefree((Malloc_t)(d))
-#define Move(s,d,n,t) (MEM_WRAP_CHECK(n,t), (void)memmove((char*)(d),(char*)(s), (n) * sizeof(t)))
-#define Copy(s,d,n,t) (MEM_WRAP_CHECK(n,t), (void)memcpy((char*)(d),(char*)(s), (n) * sizeof(t)))
+#define Move(s,d,n,t) (MEM_WRAP_CHECK(n,t), (void)memmove((char*)(d),(const char*)(s), (n) * sizeof(t)))
+#define Copy(s,d,n,t) (MEM_WRAP_CHECK(n,t), (void)memcpy((char*)(d),(const char*)(s), (n) * sizeof(t)))
#define Zero(d,n,t) (MEM_WRAP_CHECK(n,t), (void)memzero((char*)(d), (n) * sizeof(t)))
-#define MoveD(s,d,n,t) (MEM_WRAP_CHECK(n,t), memmove((char*)(d),(char*)(s), (n) * sizeof(t)))
-#define CopyD(s,d,n,t) (MEM_WRAP_CHECK(n,t), memcpy((char*)(d),(char*)(s), (n) * sizeof(t)))
+#define MoveD(s,d,n,t) (MEM_WRAP_CHECK(n,t), memmove((char*)(d),(const char*)(s), (n) * sizeof(t)))
+#define CopyD(s,d,n,t) (MEM_WRAP_CHECK(n,t), memcpy((char*)(d),(const char*)(s), (n) * sizeof(t)))
#ifdef HAS_MEMSET
#define ZeroD(d,n,t) (MEM_WRAP_CHECK(n,t), memzero((char*)(d), (n) * sizeof(t)))
#else
@@ -654,12 +654,12 @@ hopefully catches attempts to access uninitialized memory.
(v = (c*)saferealloc((Malloc_t)(v),(MEM_SIZE)((n)*sizeof(t))))
#define Safefree(d) safefree((Malloc_t)(d))
-#define Move(s,d,n,t) (void)memmove((char*)(d),(char*)(s), (n) * sizeof(t))
-#define Copy(s,d,n,t) (void)memcpy((char*)(d),(char*)(s), (n) * sizeof(t))
+#define Move(s,d,n,t) (void)memmove((char*)(d),(const char*)(s), (n) * sizeof(t))
+#define Copy(s,d,n,t) (void)memcpy((char*)(d),(const char*)(s), (n) * sizeof(t))
#define Zero(d,n,t) (void)memzero((char*)(d), (n) * sizeof(t))
-#define MoveD(s,d,n,t) memmove((char*)(d),(char*)(s), (n) * sizeof(t))
-#define CopyD(s,d,n,t) memcpy((char*)(d),(char*)(s), (n) * sizeof(t))
+#define MoveD(s,d,n,t) memmove((char*)(d),(const char*)(s), (n) * sizeof(t))
+#define CopyD(s,d,n,t) memcpy((char*)(d),(const char*)(s), (n) * sizeof(t))
#ifdef HAS_MEMSET
#define ZeroD(d,n,t) memzero((char*)(d), (n) * sizeof(t))
#else
diff --git a/op.c b/op.c
index cb5be236bf..551d48bb76 100644
--- a/op.c
+++ b/op.c
@@ -176,21 +176,21 @@ S_no_fh_allowed(pTHX_ OP *o)
}
STATIC OP *
-S_too_few_arguments(pTHX_ OP *o, char *name)
+S_too_few_arguments(pTHX_ OP *o, const char *name)
{
yyerror(Perl_form(aTHX_ "Not enough arguments for %s", name));
return o;
}
STATIC OP *
-S_too_many_arguments(pTHX_ OP *o, char *name)
+S_too_many_arguments(pTHX_ OP *o, const char *name)
{
yyerror(Perl_form(aTHX_ "Too many arguments for %s", name));
return o;
}
STATIC void
-S_bad_type(pTHX_ I32 n, char *t, char *name, OP *kid)
+S_bad_type(pTHX_ I32 n, const char *t, const char *name, OP *kid)
{
yyerror(Perl_form(aTHX_ "Type of arg %d to %s must be %s (not %s)",
(int)n, name, t, OP_DESC(kid)));
@@ -518,8 +518,8 @@ Perl_linklist(pTHX_ OP *o)
OP *
Perl_scalarkids(pTHX_ OP *o)
{
- OP *kid;
if (o && o->op_flags & OPf_KIDS) {
+ OP *kid;
for (kid = cLISTOPo->op_first; kid; kid = kid->op_sibling)
scalar(kid);
}
@@ -4575,7 +4575,7 @@ Used by C<xsubpp> to hook up XSUBs as Perl subs.
*/
CV *
-Perl_newXS(pTHX_ char *name, XSUBADDR_t subaddr, char *filename)
+Perl_newXS(pTHX_ const char *name, XSUBADDR_t subaddr, const char *filename)
{
GV *gv = gv_fetchpv(name ? name :
(PL_curstash ? "__ANON__" : "__ANON__::__ANON__"),
diff --git a/opcode.h b/opcode.h
index 356145f540..85b78b674f 100644
--- a/opcode.h
+++ b/opcode.h
@@ -27,9 +27,9 @@ START_EXTERN_C
PL_op_desc[(o)->op_type])
#ifndef DOINIT
-EXT char *PL_op_name[];
+EXT const char *PL_op_name[];
#else
-EXT char *PL_op_name[] = {
+EXT const char *PL_op_name[] = {
"null",
"stub",
"scalar",
@@ -388,9 +388,9 @@ EXT char *PL_op_name[] = {
#endif
#ifndef DOINIT
-EXT char *PL_op_desc[];
+EXT const char *PL_op_desc[];
#else
-EXT char *PL_op_desc[] = {
+EXT const char *PL_op_desc[] = {
"null operation",
"stub",
"scalar",
diff --git a/opcode.pl b/opcode.pl
index d9c81b3c81..8305be99ef 100755
--- a/opcode.pl
+++ b/opcode.pl
@@ -98,9 +98,9 @@ START_EXTERN_C
PL_op_desc[(o)->op_type])
#ifndef DOINIT
-EXT char *PL_op_name[];
+EXT const char *PL_op_name[];
#else
-EXT char *PL_op_name[] = {
+EXT const char *PL_op_name[] = {
END
for (@ops) {
@@ -115,9 +115,9 @@ END
print <<END;
#ifndef DOINIT
-EXT char *PL_op_desc[];
+EXT const char *PL_op_desc[];
#else
-EXT char *PL_op_desc[] = {
+EXT const char *PL_op_desc[] = {
END
for (@ops) {
diff --git a/perl.c b/perl.c
index 7974a42eea..adc85085fd 100644
--- a/perl.c
+++ b/perl.c
@@ -2352,7 +2352,7 @@ S_usage(pTHX_ char *name) /* XXX move this out into a module ? */
/* This message really ought to be max 23 lines.
* Removed -h because the user already knows that option. Others? */
- static char *usage_msg[] = {
+ static const char *usage_msg[] = {
"-0[octal] specify record separator (\\0, if no argument)",
"-a autosplit mode with -n or -p (splits $_ into @F)",
"-C[number/list] enables the listed Unicode features",
@@ -2400,7 +2400,7 @@ NULL
int
Perl_get_debug_opts(pTHX_ char **s, bool givehelp)
{
- static char *usage_msgd[] = {
+ static const char *usage_msgd[] = {
" Debugging flag values: (see also -d)",
" p Tokenizing and parsing (with v, displays parse stack)",
" s Stack snapshots (with v, displays all stacks)",
@@ -2430,7 +2430,7 @@ Perl_get_debug_opts(pTHX_ char **s, bool givehelp)
int i = 0;
if (isALPHA(**s)) {
/* if adding extra options, remember to update DEBUG_MASK */
- static char debopts[] = "psltocPmfrxu HXDSTRJvCAq";
+ static const char debopts[] = "psltocPmfrxu HXDSTRJvCAq";
for (; isALNUM(**s); (*s)++) {
char *d = strchr(debopts,**s);
diff --git a/pod/perlapi.pod b/pod/perlapi.pod
index 3b493eaf93..f3cff4668f 100644
--- a/pod/perlapi.pod
+++ b/pod/perlapi.pod
@@ -4568,7 +4568,7 @@ Found in file sv.c
Returns a string describing what the SV is a reference to.
- char* sv_reftype(SV* sv, int ob)
+ const char* sv_reftype(const SV* sv, int ob)
=for hackers
Found in file sv.c
diff --git a/pp_ctl.c b/pp_ctl.c
index 80ca8244dc..7ba6d0a2f9 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -82,7 +82,7 @@ PP(pp_regcomp)
SV *tmpstr;
STRLEN len;
MAGIC *mg = Null(MAGIC*);
-
+
/* prevent recompiling under /o and ithreads. */
#if defined(USE_ITHREADS)
if (pm->op_pmflags & PMf_KEEP && PM_GETRE(pm)) {
@@ -199,7 +199,7 @@ PP(pp_substcont)
SV *nsv = Nullsv;
REGEXP *old = PM_GETRE(pm);
if(old != rx) {
- if(old)
+ if(old)
ReREFCNT_dec(old);
PM_SETRE(pm,rx);
}
@@ -276,7 +276,7 @@ PP(pp_substcont)
}
cx->sb_m = m = rx->startp[0] + orig;
if (m > s) {
- if (DO_UTF8(dstr) && !SvUTF8(cx->sb_targ))
+ if (DO_UTF8(dstr) && !SvUTF8(cx->sb_targ))
sv_catpvn_utf8_upgrade(dstr, s, m - s, nsv);
else
sv_catpvn(dstr, s, m-s);
@@ -412,7 +412,7 @@ PP(pp_formline)
bool targ_is_utf8 = FALSE;
SV * nsv = Nullsv;
OP * parseres = 0;
- char *fmt;
+ const char *fmt;
bool oneline;
if (!SvMAGICAL(tmpForm) || !SvCOMPILED(tmpForm)) {
@@ -439,7 +439,7 @@ PP(pp_formline)
for (;;) {
DEBUG_f( {
- char *name = "???";
+ const char *name = "???";
arg = -1;
switch (*fpc) {
case FF_LITERAL: arg = fpc[1]; name = "LITERAL"; break;
@@ -459,7 +459,7 @@ PP(pp_formline)
case FF_MORE: name = "MORE"; break;
case FF_LINEMARK: name = "LINEMARK"; break;
case FF_END: name = "END"; break;
- case FF_0DECIMAL: name = "0DECIMAL"; break;
+ case FF_0DECIMAL: name = "0DECIMAL"; break;
case FF_LINESNGL: name = "LINESNGL"; break;
}
if (arg >= 0)
@@ -738,7 +738,7 @@ PP(pp_formline)
item = s = SvPV(sv, len);
itemsize = len;
if ((item_is_utf8 = DO_UTF8(sv)))
- itemsize = sv_len_utf8(sv);
+ itemsize = sv_len_utf8(sv);
if (itemsize) {
bool chopped = FALSE;
gotsome = TRUE;
@@ -804,7 +804,7 @@ PP(pp_formline)
gotsome = TRUE;
value = SvNV(sv);
/* overflow evidence */
- if (num_overflow(value, fieldsize, arg)) {
+ if (num_overflow(value, fieldsize, arg)) {
arg = fieldsize;
while (arg--)
*t++ = '#';
@@ -970,7 +970,7 @@ PP(pp_mapwhile)
* irrelevant. --jhi */
if (shift < count)
shift = count; /* Avoid shifting too often --Ben Tilly */
-
+
EXTEND(SP,shift);
src = SP;
dst = (SP += shift);
@@ -985,7 +985,7 @@ PP(pp_mapwhile)
while (items-- > 0)
*dst-- = SvTEMP(TOPs) ? POPs : sv_mortalcopy(POPs);
}
- else {
+ else {
/* scalar context: we don't care about which values map returns
* (we use undef here). And so we certainly don't want to do mortal
* copies of meaningless values. */
@@ -1061,9 +1061,9 @@ PP(pp_flip)
else {
dTOPss;
SV *targ = PAD_SV(PL_op->op_targ);
- int flip = 0;
+ int flip = 0;
- if (PL_op->op_private & OPpFLIP_LINENUM) {
+ if (PL_op->op_private & OPpFLIP_LINENUM) {
if (GvIO(PL_last_in_gv)) {
flip = SvIV(sv) == (IV)IoLINES(GvIOp(PL_last_in_gv));
}
@@ -1071,10 +1071,10 @@ PP(pp_flip)
GV *gv = gv_fetchpv(".", TRUE, SVt_PV);
if (gv && GvSV(gv)) flip = SvIV(sv) == SvIV(GvSV(gv));
}
- } else {
- flip = SvTRUE(sv);
- }
- if (flip) {
+ } else {
+ flip = SvTRUE(sv);
+ }
+ if (flip) {
sv_setiv(PAD_SV(cUNOP->op_first->op_targ), 1);
if (PL_op->op_flags & OPf_SPECIAL) {
sv_setiv(targ, 1);
@@ -1184,7 +1184,7 @@ PP(pp_flop)
/* Control. */
-static char *context_name[] = {
+static const char *context_name[] = {
"pseudo-block",
"subroutine",
"eval",
@@ -1403,7 +1403,7 @@ Perl_die_where(pTHX_ const char *message, STRLEN msglen)
if (message) {
if (PL_in_eval & EVAL_KEEPERR) {
- static char prefix[] = "\t(in cleanup) ";
+ static const char prefix[] = "\t(in cleanup) ";
SV *err = ERRSV;
char *e = Nullch;
if (!SvPOK(err))
@@ -1714,7 +1714,7 @@ PP(pp_caller)
PP(pp_reset)
{
dSP;
- char *tmps;
+ const char *tmps;
STRLEN n_a;
if (MAXARG < 1)
@@ -2185,11 +2185,11 @@ PP(pp_redo)
}
STATIC OP *
-S_dofindlabel(pTHX_ OP *o, char *label, OP **opstack, OP **oplimit)
+S_dofindlabel(pTHX_ OP *o, const char *label, OP **opstack, OP **oplimit)
{
OP *kid = Nullop;
OP **ops = opstack;
- static char too_deep[] = "Target of goto is too deeply nested";
+ static const char too_deep[] = "Target of goto is too deeply nested";
if (ops >= oplimit)
Perl_croak(aTHX_ too_deep);
@@ -2245,11 +2245,10 @@ PP(pp_goto)
register PERL_CONTEXT *cx;
#define GOTO_DEPTH 64
OP *enterops[GOTO_DEPTH];
- char *label;
- int do_dump = (PL_op->op_type == OP_DUMP);
- static char must_have_label[] = "goto must have label";
+ const char *label = 0;
+ const bool do_dump = (PL_op->op_type == OP_DUMP);
+ static const char must_have_label[] = "goto must have label";
- label = 0;
if (PL_op->op_flags & OPf_STACKED) {
SV *sv = POPs;
STRLEN n_a;
@@ -2298,7 +2297,7 @@ PP(pp_goto)
if (CxTYPE(cx) == CXt_SUB && cx->blk_sub.hasargs) {
/* put @_ back onto stack */
AV* av = cx->blk_sub.argarray;
-
+
items = AvFILLp(av) + 1;
EXTEND(SP, items+1); /* @_ could have been extended. */
Copy(AvARRAY(av), SP + 1, items, SV*);
@@ -2435,7 +2434,7 @@ PP(pp_goto)
*/
SV *sv = GvSV(PL_DBsub);
CV *gotocv;
-
+
if (PERLDB_SUB_NN) {
(void)SvUPGRADE(sv, SVt_PVIV);
(void)SvIOK_on(sv);
@@ -2734,7 +2733,7 @@ S_docatch(pTHX_ OP *o)
}
OP *
-Perl_sv_compile_2op(pTHX_ SV *sv, OP** startop, char *code, PAD** padp)
+Perl_sv_compile_2op(pTHX_ SV *sv, OP** startop, const char *code, PAD** padp)
/* sv Text to convert to OP tree. */
/* startop op_free() this to undo. */
/* code Short string id of the caller. */
@@ -2924,7 +2923,7 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 seq)
PERL_CONTEXT *cx = &cxstack[cxstack_ix];
I32 optype = 0; /* Might be reset by POPEVAL. */
STRLEN n_a;
-
+
PL_op = saveop;
if (PL_eval_root) {
op_free(PL_eval_root);
@@ -3358,7 +3357,7 @@ PP(pp_require)
PL_encoding = Nullsv;
op = DOCATCH(doeval(gimme, NULL, Nullcv, PL_curcop->cop_seq));
-
+
/* Restore encoding. */
PL_encoding = encoding;
@@ -3805,7 +3804,7 @@ S_doparseform(pTHX_ SV *sv)
sv_magic(sv, Nullsv, PERL_MAGIC_fm, Nullch, 0);
SvCOMPILED_on(sv);
- if (unchopnum && repeat)
+ if (unchopnum && repeat)
DIE(aTHX_ "Repeated format line will never terminate (~~ and @#)");
return 0;
}
diff --git a/pp_sys.c b/pp_sys.c
index e5d27f10cd..12c3684167 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -4531,9 +4531,9 @@ PP(pp_gmtime)
{
dSP;
Time_t when;
- struct tm *tmbuf;
- static char *dayname[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
- static char *monname[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ const struct tm *tmbuf;
+ static const char *dayname[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
+ static const char *monname[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
if (MAXARG < 1)
diff --git a/proto.h b/proto.h
index 21f23a495a..8e91ccd8f1 100644
--- a/proto.h
+++ b/proto.h
@@ -146,8 +146,8 @@ PERL_CALLCONV I32 Perl_debop(pTHX_ OP* o);
PERL_CALLCONV I32 Perl_debstack(pTHX);
PERL_CALLCONV I32 Perl_debstackptrs(pTHX);
PERL_CALLCONV char* Perl_delimcpy(pTHX_ char* to, char* toend, char* from, char* fromend, int delim, I32* retlen);
-PERL_CALLCONV void Perl_deprecate(pTHX_ char* s);
-PERL_CALLCONV void Perl_deprecate_old(pTHX_ char* s);
+PERL_CALLCONV void Perl_deprecate(pTHX_ const char* s);
+PERL_CALLCONV void Perl_deprecate_old(pTHX_ const char* s);
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);
@@ -479,7 +479,7 @@ PERL_CALLCONV OP* Perl_newRANGE(pTHX_ I32 flags, OP* left, OP* right);
PERL_CALLCONV OP* Perl_newSLICEOP(pTHX_ I32 flags, OP* subscript, OP* listop);
PERL_CALLCONV OP* Perl_newSTATEOP(pTHX_ I32 flags, char* label, OP* o);
PERL_CALLCONV CV* Perl_newSUB(pTHX_ I32 floor, OP* o, OP* proto, OP* block);
-PERL_CALLCONV CV* Perl_newXS(pTHX_ char* name, XSUBADDR_t f, char* filename);
+PERL_CALLCONV CV* Perl_newXS(pTHX_ const char* name, XSUBADDR_t f, const char* filename);
PERL_CALLCONV AV* Perl_newAV(pTHX);
PERL_CALLCONV OP* Perl_newAVREF(pTHX_ OP* o);
PERL_CALLCONV OP* Perl_newBINOP(pTHX_ I32 type, I32 flags, OP* first, OP* last);
@@ -515,7 +515,7 @@ PERL_CALLCONV OP* Perl_newUNOP(pTHX_ I32 type, I32 flags, OP* first);
PERL_CALLCONV OP* Perl_newWHILEOP(pTHX_ I32 flags, I32 debuggable, LOOP* loop, I32 whileline, OP* expr, OP* block, OP* cont);
PERL_CALLCONV PERL_SI* Perl_new_stackinfo(pTHX_ I32 stitems, I32 cxitems);
-PERL_CALLCONV char* Perl_scan_vstring(pTHX_ char *vstr, SV *sv);
+PERL_CALLCONV char* Perl_scan_vstring(pTHX_ const char *vstr, SV *sv);
PERL_CALLCONV char* Perl_scan_version(pTHX_ char *vstr, SV *sv, bool qv);
PERL_CALLCONV SV* Perl_new_version(pTHX_ SV *ver);
PERL_CALLCONV SV* Perl_upg_version(pTHX_ SV *ver);
@@ -652,7 +652,7 @@ PERL_CALLCONV OP* Perl_scalarseq(pTHX_ OP* o);
PERL_CALLCONV OP* Perl_scalarvoid(pTHX_ OP* o);
PERL_CALLCONV NV Perl_scan_bin(pTHX_ char* start, STRLEN len, STRLEN* retlen);
PERL_CALLCONV NV Perl_scan_hex(pTHX_ char* start, STRLEN len, STRLEN* retlen);
-PERL_CALLCONV char* Perl_scan_num(pTHX_ char* s, YYSTYPE *lvalp);
+PERL_CALLCONV char* Perl_scan_num(pTHX_ const char* s, YYSTYPE *lvalp);
PERL_CALLCONV NV Perl_scan_oct(pTHX_ char* start, STRLEN len, STRLEN* retlen);
PERL_CALLCONV OP* Perl_scope(pTHX_ OP* o);
PERL_CALLCONV char* Perl_screaminstr(pTHX_ SV* bigsv, SV* littlesv, I32 start_shift, I32 end_shift, I32 *state, I32 last);
@@ -704,7 +704,7 @@ PERL_CALLCONV I32 Perl_sv_cmp_locale(pTHX_ SV* sv1, SV* sv2);
#if defined(USE_LOCALE_COLLATE)
PERL_CALLCONV char* Perl_sv_collxfrm(pTHX_ SV* sv, STRLEN* nxp);
#endif
-PERL_CALLCONV OP* Perl_sv_compile_2op(pTHX_ SV* sv, OP** startp, char* code, PAD** padp);
+PERL_CALLCONV OP* Perl_sv_compile_2op(pTHX_ SV* sv, OP** startp, const char* code, PAD** padp);
PERL_CALLCONV int Perl_getcwd_sv(pTHX_ SV* sv);
PERL_CALLCONV void Perl_sv_dec(pTHX_ SV* sv);
PERL_CALLCONV void Perl_sv_dump(pTHX_ SV* sv);
@@ -734,7 +734,7 @@ PERL_CALLCONV char* Perl_sv_pvutf8n_force(pTHX_ SV* sv, STRLEN* lp);
PERL_CALLCONV char* Perl_sv_pvbyten_force(pTHX_ SV* sv, STRLEN* lp);
PERL_CALLCONV char* Perl_sv_recode_to_utf8(pTHX_ SV* sv, SV *encoding);
PERL_CALLCONV bool Perl_sv_cat_decode(pTHX_ SV* dsv, SV *encoding, SV *ssv, int *offset, char* tstr, int tlen);
-PERL_CALLCONV char* Perl_sv_reftype(pTHX_ SV* sv, int ob);
+PERL_CALLCONV const char* Perl_sv_reftype(pTHX_ const SV* sv, int ob);
PERL_CALLCONV void Perl_sv_replace(pTHX_ SV* sv, SV* nsv);
PERL_CALLCONV void Perl_sv_report_used(pTHX);
PERL_CALLCONV void Perl_sv_reset(pTHX_ char* s, HV* stash);
@@ -816,10 +816,10 @@ 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_ 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_yyerror(pTHX_ const char* s);
PERL_CALLCONV int Perl_yylex(pTHX);
PERL_CALLCONV int Perl_yyparse(pTHX);
-PERL_CALLCONV int Perl_yywarn(pTHX_ char* s);
+PERL_CALLCONV int Perl_yywarn(pTHX_ const char* s);
#if defined(MYMALLOC)
PERL_CALLCONV void Perl_dump_mstats(pTHX_ char* s);
PERL_CALLCONV int Perl_get_mstats(pTHX_ perl_mstats_t *buf, int buflen, int level);
@@ -960,14 +960,14 @@ STATIC int S_magic_methcall(pTHX_ SV *sv, MAGIC *mg, char *meth, I32 f, int n, S
#if defined(PERL_IN_OP_C) || defined(PERL_DECL_PROT)
STATIC I32 S_list_assignment(pTHX_ OP *o);
-STATIC void S_bad_type(pTHX_ I32 n, char *t, char *name, OP *kid);
+STATIC void S_bad_type(pTHX_ I32 n, const char *t, const char *name, OP *kid);
STATIC void S_cop_free(pTHX_ COP *cop);
STATIC OP* S_modkids(pTHX_ OP *o, I32 type);
STATIC void S_no_bareword_allowed(pTHX_ OP *o);
STATIC OP* S_no_fh_allowed(pTHX_ OP *o);
STATIC OP* S_scalarboolean(pTHX_ OP *o);
-STATIC OP* S_too_few_arguments(pTHX_ OP *o, char* name);
-STATIC OP* S_too_many_arguments(pTHX_ OP *o, char* name);
+STATIC OP* S_too_few_arguments(pTHX_ OP *o, const char* name);
+STATIC OP* S_too_many_arguments(pTHX_ OP *o, const char* name);
STATIC OP* S_newDEFSVOP(pTHX);
STATIC OP* S_new_logop(pTHX_ I32 type, I32 flags, OP **firstp, OP **otherp);
STATIC void S_simplify_sort(pTHX_ OP *o);
@@ -1028,7 +1028,7 @@ STATIC int S_div128(pTHX_ SV *pnum, bool *done);
#if defined(PERL_IN_PP_CTL_C) || defined(PERL_DECL_PROT)
STATIC OP* S_docatch(pTHX_ OP *o);
STATIC void* S_docatch_body(pTHX);
-STATIC OP* S_dofindlabel(pTHX_ OP *o, char *label, OP **opstack, OP **oplimit);
+STATIC OP* S_dofindlabel(pTHX_ OP *o, const char *label, OP **opstack, OP **oplimit);
STATIC OP* S_doparseform(pTHX_ SV *sv);
STATIC bool S_num_overflow(NV value, I32 fldsize, I32 frcsize);
STATIC I32 S_dopoptoeval(pTHX_ I32 startingblock);
@@ -1083,7 +1083,7 @@ STATIC void S_cl_init_zero(pTHX_ struct RExC_state_t*, struct regnode_charclass_
STATIC void S_cl_and(pTHX_ struct regnode_charclass_class *cl, struct regnode_charclass_class *and_with);
STATIC void S_cl_or(pTHX_ struct RExC_state_t*, struct regnode_charclass_class *cl, struct regnode_charclass_class *or_with);
STATIC I32 S_study_chunk(pTHX_ struct RExC_state_t*, regnode **scanp, I32 *deltap, regnode *last, struct scan_data_t *data, U32 flags, U32 depth);
-STATIC I32 S_add_data(pTHX_ struct RExC_state_t*, I32 n, char *s);
+STATIC I32 S_add_data(pTHX_ struct RExC_state_t*, I32 n, const char *s);
STATIC void S_re_croak2(pTHX_ const char* pat1, const char* pat2, ...) __attribute__((noreturn));
STATIC I32 S_regpposixcc(pTHX_ struct RExC_state_t*, I32 value);
STATIC void S_checkposixcc(pTHX_ struct RExC_state_t*);
@@ -1201,14 +1201,14 @@ STATIC char* S_scan_trans(pTHX_ char *start);
STATIC char* S_scan_word(pTHX_ char *s, char *dest, STRLEN destlen, int allow_package, STRLEN *slp);
STATIC char* S_skipspace(pTHX_ char *s);
STATIC char* S_swallow_bom(pTHX_ U8 *s);
-STATIC void S_checkcomma(pTHX_ char *s, char *name, char *what);
-STATIC void S_force_ident(pTHX_ char *s, int kind);
+STATIC void S_checkcomma(pTHX_ char *s, char *name, const char *what);
+STATIC void S_force_ident(pTHX_ const char *s, int kind);
STATIC void S_incline(pTHX_ char *s);
STATIC int S_intuit_method(pTHX_ char *s, GV *gv);
STATIC int S_intuit_more(pTHX_ char *s);
STATIC I32 S_lop(pTHX_ I32 f, int x, char *s);
STATIC void S_missingterm(pTHX_ char *s);
-STATIC void S_no_op(pTHX_ char *what, char *s);
+STATIC void S_no_op(pTHX_ const char *what, char *s);
STATIC void S_set_csh(pTHX);
STATIC I32 S_sublex_done(pTHX);
STATIC I32 S_sublex_push(pTHX);
@@ -1217,11 +1217,11 @@ STATIC char * S_filter_gets(pTHX_ SV *sv, PerlIO *fp, STRLEN append);
STATIC HV * S_find_in_my_stash(pTHX_ const char *pkgname, I32 len);
STATIC SV* S_new_constant(pTHX_ const char *s, STRLEN len, const char *key, SV *sv, SV *pv, const char *type);
# if defined(DEBUGGING)
-STATIC int S_tokereport(pTHX_ char *s, I32 rv);
+STATIC int S_tokereport(pTHX_ const char *s, I32 rv);
# endif
STATIC int S_ao(pTHX_ int toketype);
STATIC void S_depcom(pTHX);
-STATIC char* S_incl_perldb(pTHX);
+STATIC const char* S_incl_perldb(pTHX);
#if 0
STATIC I32 S_utf16_textfilter(pTHX_ int idx, SV *sv, int maxlen);
STATIC I32 S_utf16rev_textfilter(pTHX_ int idx, SV *sv, int maxlen);
diff --git a/regcomp.c b/regcomp.c
index 12bd96ba22..1f9161a4a3 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -268,7 +268,7 @@ static scan_data_t zero_scan_data = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
* "...".
*/
#define FAIL(msg) STMT_START { \
- char *ellipses = ""; \
+ const char *ellipses = ""; \
IV len = RExC_end - RExC_precomp; \
\
if (!SIZE_ONLY) \
@@ -288,7 +288,7 @@ static scan_data_t zero_scan_data = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
* "...".
*/
#define FAIL2(pat,msg) STMT_START { \
- char *ellipses = ""; \
+ const char *ellipses = ""; \
IV len = RExC_end - RExC_precomp; \
\
if (!SIZE_ONLY) \
@@ -1646,8 +1646,8 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
*/
char *s0 = STRING(scan), *s, *t;
char *s1 = s0 + STR_LEN(scan) - 1, *s2 = s1 - 4;
- char *t0 = "\xcc\x88\xcc\x81";
- char *t1 = t0 + 3;
+ const char *t0 = "\xcc\x88\xcc\x81";
+ const char *t1 = t0 + 3;
for (s = s0 + 2;
s < s2 && (t = ninstr(s, s1, t0, t1));
@@ -2097,7 +2097,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
}
flags &= ~SCF_DO_STCLASS;
}
- else if (strchr((char*)PL_varies,OP(scan))) {
+ else if (strchr((const char*)PL_varies,OP(scan))) {
I32 mincount, maxcount, minnext, deltanext, fl = 0;
I32 f = flags, pos_before = 0;
regnode *oscan = scan;
@@ -2241,7 +2241,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
/* Skip open. */
nxt = regnext(nxt);
- if (!strchr((char*)PL_simple,OP(nxt))
+ if (!strchr((const char*)PL_simple,OP(nxt))
&& !(PL_regkind[(U8)OP(nxt)] == EXACT
&& STR_LEN(nxt) == 1))
goto nogo;
@@ -2446,7 +2446,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
break;
}
}
- else if (strchr((char*)PL_simple,OP(scan))) {
+ else if (strchr((const char*)PL_simple,OP(scan))) {
int value = 0;
if (flags & SCF_DO_SUBSTR) {
@@ -2754,7 +2754,7 @@ S_study_chunk(pTHX_ RExC_state_t *pRExC_state, regnode **scanp, I32 *deltap, reg
}
STATIC I32
-S_add_data(pTHX_ RExC_state_t *pRExC_state, I32 n, char *s)
+S_add_data(pTHX_ RExC_state_t *pRExC_state, I32 n, const char *s)
{
if (RExC_rx->data) {
Renewc(RExC_rx->data,
@@ -2975,7 +2975,7 @@ Perl_pregcomp(pTHX_ char *exp, char *xend, PMOP *pm)
else if ((OP(first) == EXACTF || OP(first) == EXACTFL))
r->regstclass = first;
}
- else if (strchr((char*)PL_simple,OP(first)))
+ else if (strchr((const char*)PL_simple,OP(first)))
r->regstclass = first;
else if (PL_regkind[(U8)OP(first)] == BOUND ||
PL_regkind[(U8)OP(first)] == NBOUND)
@@ -3588,8 +3588,8 @@ S_reg(pTHX_ RExC_state_t *pRExC_state, I32 paren, I32 *flagp)
}
{
- char *p;
- static char parens[] = "=!<,>";
+ const char *p;
+ static const char parens[] = "=!<,>";
if (paren && (p = strchr(parens, paren))) {
U8 node = ((p - parens) % 2) ? UNLESSM : IFMATCH;
@@ -5911,7 +5911,7 @@ Perl_regprop(pTHX_ SV *sv, regnode *o)
/* It would be nice to FAIL() here, but this may be called from
regexec.c, and it would be hard to supply pRExC_state. */
Perl_croak(aTHX_ "Corrupted regexp opcode");
- sv_catpv(sv, (char*)reg_name[OP(o)]); /* Take off const! */
+ sv_catpv(sv, reg_name[OP(o)]); /* Take off const! */
k = PL_regkind[(U8)OP(o)];
diff --git a/regexec.c b/regexec.c
index 192396f467..62c48dd8d0 100644
--- a/regexec.c
+++ b/regexec.c
@@ -141,7 +141,7 @@
#define HOP3c(pos,off,lim) ((char*)HOP3(pos,off,lim))
#define HOPMAYBE3c(pos,off,lim) ((char*)HOPMAYBE3(pos,off,lim))
-#define LOAD_UTF8_CHARCLASS(a,b) STMT_START { if (!CAT2(PL_utf8_,a)) { ENTER; save_re_context(); (void)CAT2(is_utf8_, a)((U8*)b); LEAVE; } } STMT_END
+#define LOAD_UTF8_CHARCLASS(a,b) STMT_START { if (!CAT2(PL_utf8_,a)) { ENTER; save_re_context(); (void)CAT2(is_utf8_, a)((const U8*)b); LEAVE; } } STMT_END
/* for use after a quantifier and before an EXACT-like node -- japhy */
#define JUMPABLE(rn) ( \
diff --git a/sv.c b/sv.c
index b62969cd9e..b704fac55b 100644
--- a/sv.c
+++ b/sv.c
@@ -682,7 +682,7 @@ S_find_array_subscript(pTHX_ AV *av, SV* val)
#define FUV_SUBSCRIPT_WITHIN 4 /* "within @foo" */
STATIC SV*
-S_varname(pTHX_ GV *gv, char *gvtype, PADOFFSET targ,
+S_varname(pTHX_ GV *gv, const char *gvtype, PADOFFSET targ,
SV* keyname, I32 aindex, int subscript_type)
{
AV *av;
@@ -696,15 +696,13 @@ S_varname(pTHX_ GV *gv, char *gvtype, PADOFFSET targ,
* XXX get rid of all this if gv_fullnameX() ever supports this
* directly */
- char *p;
+ const char *p;
HV *hv = GvSTASH(gv);
sv_setpv(name, gvtype);
if (!hv)
p = "???";
- else if (!HvNAME(hv))
+ else if (!(p=HvNAME(hv)))
p = "__ANON__";
- else
- p = HvNAME(hv);
if (strNE(p, "main")) {
sv_catpv(name,p);
sv_catpvn(name,"::", 2);
@@ -2114,14 +2112,14 @@ Perl_sv_grow(pTHX_ register SV *sv, register STRLEN newlen)
#endif
Renew(s,newlen,char);
}
- else {
+ else {
New(703, s, newlen, char);
if (SvPVX(sv) && SvCUR(sv)) {
Move(SvPVX(sv), s, (newlen < SvCUR(sv)) ? newlen : SvCUR(sv), char);
}
}
SvPV_set(sv, s);
- SvLEN_set(sv, newlen);
+ SvLEN_set(sv, newlen);
}
return s;
}
@@ -8398,11 +8396,11 @@ Returns a string describing what the SV is a reference to.
=cut
*/
-char *
-Perl_sv_reftype(pTHX_ SV *sv, int ob)
+const char *
+Perl_sv_reftype(pTHX_ const SV *sv, int ob)
{
if (ob && SvOBJECT(sv)) {
- char *name = HvNAME(SvSTASH(sv));
+ const char *name = HvNAME(SvSTASH(sv));
return name ? name : "__ANON__";
}
else {
diff --git a/toke.c b/toke.c
index 6783148094..e131eb2542 100644
--- a/toke.c
+++ b/toke.c
@@ -26,9 +26,9 @@
#define yychar (*PL_yycharp)
#define yylval (*PL_yylvalp)
-static char ident_too_long[] = "Identifier too long";
-static char c_without_g[] = "Use of /c modifier is meaningless without /g";
-static char c_in_subst[] = "Use of /c modifier is meaningless in s///";
+static char const ident_too_long[] = "Identifier too long";
+static char const c_without_g[] = "Use of /c modifier is meaningless without /g";
+static char const c_in_subst[] = "Use of /c modifier is meaningless in s///";
static void restore_rsfp(pTHX_ void *f);
#ifndef PERL_NO_UTF16_FILTER
@@ -76,7 +76,7 @@ static I32 utf16rev_textfilter(pTHX_ int idx, SV *sv, int maxlen);
#define LEX_KNOWNEXT 0
#ifdef DEBUGGING
-static char* lex_state_names[] = {
+static char const* lex_state_names[] = {
"KNOWNEXT",
"FORMLINE",
"INTERPCONST",
@@ -199,7 +199,7 @@ enum token_type {
TOKENTYPE_GVVAL
};
-static struct debug_tokens { int token, type; char *name;} debug_tokens[] =
+static struct debug_tokens { const int token, type; const char *name; } debug_tokens[] =
{
{ ADDOP, TOKENTYPE_OPNUM, "ADDOP" },
{ ANDAND, TOKENTYPE_NONE, "ANDAND" },
@@ -269,13 +269,13 @@ static struct debug_tokens { int token, type; char *name;} debug_tokens[] =
/* dump the returned token in rv, plus any optional arg in yylval */
STATIC int
-S_tokereport(pTHX_ char* s, I32 rv)
+S_tokereport(pTHX_ const char* s, I32 rv)
{
if (DEBUG_T_TEST) {
- char *name = Nullch;
+ const char *name = Nullch;
enum token_type type = TOKENTYPE_NONE;
struct debug_tokens *p;
- SV* report = newSVpvn("<== ", 4);
+ SV* report = newSVpvn("<== ", 4);
for (p = debug_tokens; p->token; p++) {
if (p->token == (int)rv) {
@@ -365,7 +365,7 @@ S_ao(pTHX_ int toketype)
*/
STATIC void
-S_no_op(pTHX_ char *what, char *s)
+S_no_op(pTHX_ const char *what, char *s)
{
char *oldbp = PL_bufptr;
bool is_first = (PL_oldbufptr == PL_linestart);
@@ -441,14 +441,14 @@ S_missingterm(pTHX_ char *s)
*/
void
-Perl_deprecate(pTHX_ char *s)
+Perl_deprecate(pTHX_ const char *s)
{
if (ckWARN(WARN_DEPRECATED))
Perl_warner(aTHX_ packWARN(WARN_DEPRECATED), "Use of %s is deprecated", s);
}
void
-Perl_deprecate_old(pTHX_ char *s)
+Perl_deprecate_old(pTHX_ const char *s)
{
/* This function should NOT be called for any new deprecated warnings */
/* Use Perl_deprecate instead */
@@ -459,7 +459,7 @@ Perl_deprecate_old(pTHX_ char *s)
/* in its own right. */
if (ckWARN2(WARN_DEPRECATED, WARN_SYNTAX))
- Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX),
+ Perl_warner(aTHX_ packWARN2(WARN_DEPRECATED, WARN_SYNTAX),
"Use of %s is deprecated", s);
}
@@ -873,7 +873,7 @@ STATIC SV *
S_newSV_maybe_utf8(pTHX_ const char *start, STRLEN len)
{
SV *sv = newSVpvn(start,len);
- if (UTF && !IN_BYTES && is_utf8_string((U8*)start, len))
+ if (UTF && !IN_BYTES && is_utf8_string((const U8*)start, len))
SvUTF8_on(sv);
return sv;
}
@@ -936,10 +936,10 @@ S_force_word(pTHX_ register char *start, int token, int check_keyword, int allow
*/
STATIC void
-S_force_ident(pTHX_ register char *s, int kind)
+S_force_ident(pTHX_ register const char *s, int kind)
{
if (s && *s) {
- OP* o = (OP*)newSVOP(OP_CONST, 0, newSVpv(s,0));
+ OP* const o = (OP*)newSVOP(OP_CONST, 0, newSVpv(s,0));
PL_nextval[PL_nexttoke].opval = o;
force_next(WORD);
if (kind) {
@@ -1549,7 +1549,7 @@ S_scan_const(pTHX_ char *start)
default:
{
if (ckWARN(WARN_MISC) &&
- isALNUM(*s) &&
+ isALNUM(*s) &&
*s != '_')
Perl_warner(aTHX_ packWARN(WARN_MISC),
"Unrecognized escape \\%c passed through",
@@ -2091,11 +2091,11 @@ S_intuit_method(pTHX_ char *start, GV *gv)
* compile-time require of perl5db.pl.
*/
-STATIC char*
+STATIC const char*
S_incl_perldb(pTHX)
{
if (PL_perldb) {
- char *pdb = PerlEnv_getenv("PERL5DB");
+ const char *pdb = PerlEnv_getenv("PERL5DB");
if (pdb)
return pdb;
@@ -2272,7 +2272,7 @@ S_find_in_my_stash(pTHX_ const char *pkgname, I32 len)
}
#ifdef DEBUGGING
- static char* exp_name[] =
+ static char const* exp_name[] =
{ "OPERATOR", "TERM", "REF", "STATE", "BLOCK", "ATTRBLOCK",
"ATTRTERM", "TERMBLOCK", "TERMORDORDOR"
};
@@ -2734,7 +2734,7 @@ Perl_yylex(pTHX)
d = s + 2;
#ifdef ALTERNATE_SHEBANG
else {
- static char as[] = ALTERNATE_SHEBANG;
+ static char const as[] = ALTERNATE_SHEBANG;
if (*s == as[0] && strnEQ(s, as, sizeof(as) - 1))
d = s + (sizeof(as) - 1);
}
@@ -3178,7 +3178,7 @@ Perl_yylex(pTHX)
#else
; /* skip to avoid loading attributes.pm */
#endif
- else
+ else
Perl_croak(aTHX_ "The 'unique' attribute may only be applied to 'our' variables");
}
@@ -4275,7 +4275,7 @@ Perl_yylex(pTHX)
while (*proto == ';')
proto++;
if (*proto == '&' && *s == '{') {
- sv_setpv(PL_subname, PL_curstash ?
+ sv_setpv(PL_subname, PL_curstash ?
"__ANON__" : "__ANON__::__ANON__");
PREBLOCK(LSTOPSUB);
}
@@ -4338,7 +4338,7 @@ Perl_yylex(pTHX)
/*SUPPRESS 560*/
if (PL_rsfp && (!PL_in_eval || PL_tokenbuf[2] == 'D')) {
- char *pname = "main";
+ const char *pname = "main";
if (PL_tokenbuf[2] == 'D')
pname = HvNAME(PL_curstash ? PL_curstash : PL_defstash);
gv = gv_fetchpv(Perl_form(aTHX_ "%s::DATA", pname), TRUE, SVt_PVIO);
@@ -4405,7 +4405,7 @@ Perl_yylex(pTHX)
SPAGAIN;
name = POPs;
PUTBACK;
- PerlIO_apply_layers(aTHX_ PL_rsfp, NULL,
+ PerlIO_apply_layers(aTHX_ PL_rsfp, NULL,
Perl_form(aTHX_ ":encoding(%"SVf")",
name));
FREETMPS;
@@ -8887,7 +8887,7 @@ unknown:
}
STATIC void
-S_checkcomma(pTHX_ register char *s, char *name, char *what)
+S_checkcomma(pTHX_ register char *s, char *name, const char *what)
{
char *w;
@@ -9270,7 +9270,7 @@ S_scan_pat(pTHX_ char *start, I32 type)
pmflag(&pm->op_pmflags,*s++);
}
/* issue a warning if /c is specified,but /g is not */
- if (ckWARN(WARN_REGEXP) &&
+ if (ckWARN(WARN_REGEXP) &&
(pm->op_pmflags & PMf_CONTINUE) && !(pm->op_pmflags & PMf_GLOBAL))
{
Perl_warner(aTHX_ packWARN(WARN_REGEXP), c_without_g);
@@ -10113,16 +10113,16 @@ S_scan_str(pTHX_ char *start, int keep_quoted, int keep_delims)
*/
char *
-Perl_scan_num(pTHX_ char *start, YYSTYPE* lvalp)
+Perl_scan_num(pTHX_ const char *start, YYSTYPE* lvalp)
{
- register char *s = start; /* current position in buffer */
+ register const char *s = start; /* current position in buffer */
register char *d; /* destination in temp buffer */
register char *e; /* end of temp buffer */
NV nv; /* number read, as a double */
SV *sv = Nullsv; /* place to put the converted number */
bool floatit; /* boolean: int or float? */
- char *lastub = 0; /* position of last underbar */
- static char number_too_long[] = "Number too long";
+ const char *lastub = 0; /* position of last underbar */
+ static char const number_too_long[] = "Number too long";
/* We use the first character to decide what type of number this is */
@@ -10150,16 +10150,16 @@ Perl_scan_num(pTHX_ char *start, YYSTYPE* lvalp)
bool overflowed = FALSE;
bool just_zero = TRUE; /* just plain 0 or binary number? */
static NV nvshift[5] = { 1.0, 2.0, 4.0, 8.0, 16.0 };
- static char* bases[5] = { "", "binary", "", "octal",
+ static char const* bases[5] = { "", "binary", "", "octal",
"hexadecimal" };
- static char* Bases[5] = { "", "Binary", "", "Octal",
+ static char const* Bases[5] = { "", "Binary", "", "Octal",
"Hexadecimal" };
- static char *maxima[5] = { "",
+ static char const *maxima[5] = { "",
"0b11111111111111111111111111111111",
"",
"037777777777",
"0xffffffff" };
- char *base, *Base, *max;
+ const char *base, *Base, *max;
/* check for hex */
if (s[1] == 'x') {
@@ -10301,7 +10301,7 @@ Perl_scan_num(pTHX_ char *start, YYSTYPE* lvalp)
sv_setuv(sv, u);
}
if (just_zero && (PL_hints & HINT_NEW_INTEGER))
- sv = new_constant(start, s - start, "integer",
+ sv = new_constant(start, s - start, "integer",
sv, Nullsv, NULL);
else if (PL_hints & HINT_NEW_BINARY)
sv = new_constant(start, s - start, "binary", sv, Nullsv, NULL);
@@ -10625,7 +10625,7 @@ Perl_start_subparse(pTHX_ I32 is_format, U32 flags)
#pragma segment Perl_yylex
#endif
int
-Perl_yywarn(pTHX_ char *s)
+Perl_yywarn(pTHX_ const char *s)
{
PL_in_eval |= EVAL_WARNONLY;
yyerror(s);
@@ -10634,10 +10634,10 @@ Perl_yywarn(pTHX_ char *s)
}
int
-Perl_yyerror(pTHX_ char *s)
+Perl_yyerror(pTHX_ const char *s)
{
- char *where = NULL;
- char *context = NULL;
+ const char *where = NULL;
+ const char *context = NULL;
int contlen = -1;
SV *msg;
@@ -10900,16 +10900,16 @@ passed in, for performance reasons.
*/
char *
-Perl_scan_vstring(pTHX_ char *s, SV *sv)
+Perl_scan_vstring(pTHX_ const char *s, SV *sv)
{
- char *pos = s;
- char *start = s;
+ const char *pos = s;
+ const char *start = s;
if (*pos == 'v') pos++; /* get past 'v' */
while (pos < PL_bufend && (isDIGIT(*pos) || *pos == '_'))
pos++;
if ( *pos != '.') {
/* this may not be a v-string if followed by => */
- char *next = pos;
+ const char *next = pos;
while (next < PL_bufend && isSPACE(*next))
++next;
if ((PL_bufend - next) >= 2 && *next == '=' && next[1] == '>' ) {
@@ -10932,7 +10932,7 @@ Perl_scan_vstring(pTHX_ char *s, SV *sv)
rev = 0;
{
/* this is atoi() that tolerates underscores */
- char *end = pos;
+ const char *end = pos;
UV mult = 1;
while (--end >= s) {
UV orev;