#if defined(PERL_IN_PP_SYS_C) || defined(PERL_DECL_PROT)
s |OP* |doform |CV *cv|GV *gv|OP *retop
-s |int |emulate_eaccess|const char* path|Mode_t mode
+sr |int |emulate_eaccess|const char* path|Mode_t mode
# if !defined(HAS_MKDIR) || !defined(HAS_RMDIR)
s |int |dooneliner |char *cmd|char *filename
# endif
#define specialsv_list (MY_CXT.x_specialsv_list)
static opclass
-cc_opclass(pTHX_ OP *o)
+cc_opclass(pTHX_ const OP *o)
{
if (!o)
return OPc_NULL;
}
static char *
-cc_opclassname(pTHX_ OP *o)
+cc_opclassname(pTHX_ const OP *o)
{
return (char *)opclassnames[cc_opclass(aTHX_ o)];
}
cstring(pTHX_ SV *sv, bool perlstyle)
{
SV *sstr = newSVpvn("", 0);
- STRLEN len;
- char *s;
- char escbuff[5]; /* to fit backslash, 3 octals + trailing \0 */
if (!SvOK(sv))
sv_setpvn(sstr, "0", 1);
- else if (perlstyle && SvUTF8(sv))
- {
+ else if (perlstyle && SvUTF8(sv)) {
SV *tmpsv = sv_newmortal(); /* Temporary SV to feed sv_uni_display */
- len = SvCUR(sv);
- s = sv_uni_display(tmpsv, sv, 8*len, UNI_DISPLAY_QQ);
+ const STRLEN len = SvCUR(sv);
+ const char *s = sv_uni_display(tmpsv, sv, 8*len, UNI_DISPLAY_QQ);
sv_setpvn(sstr,"\"",1);
while (*s)
{
if (*s == '"')
- sv_catpv(sstr, "\\\"");
+ sv_catpvn(sstr, "\\\"", 2);
else if (*s == '$')
- sv_catpv(sstr, "\\$");
+ sv_catpvn(sstr, "\\$", 2);
else if (*s == '@')
- sv_catpv(sstr, "\\@");
+ sv_catpvn(sstr, "\\@", 2);
else if (*s == '\\')
{
if (strchr("nrftax\\",*(s+1)))
sv_catpvn(sstr, s++, 2);
else
- sv_catpv(sstr, "\\\\");
+ sv_catpvn(sstr, "\\\\", 2);
}
else /* should always be printable */
sv_catpvn(sstr, s, 1);
else
{
/* XXX Optimise? */
- s = SvPV(sv, len);
+ STRLEN len;
+ const char *s = SvPV(sv, len);
sv_catpv(sstr, "\"");
for (; len; len--, s++)
{
else if (*s == '\\')
sv_catpv(sstr, "\\\\");
/* trigraphs - bleagh */
- else if (!perlstyle && *s == '?' && len>=3 && s[1] == '?')
- {
+ else if (!perlstyle && *s == '?' && len>=3 && s[1] == '?') {
+ char escbuff[5]; /* to fit backslash, 3 octals + trailing \0 */
sprintf(escbuff, "\\%03o", '?');
sv_catpv(sstr, escbuff);
}
else
{
/* Don't want promotion of a signed -1 char in sprintf args */
- unsigned char c = (unsigned char) *s;
+ char escbuff[5]; /* to fit backslash, 3 octals + trailing \0 */
+ const unsigned char c = (unsigned char) *s;
sprintf(escbuff, "\\%03o", c);
sv_catpv(sstr, escbuff);
}
cchar(pTHX_ SV *sv)
{
SV *sstr = newSVpvn("'", 1);
- STRLEN n_a;
- char *s = SvPV(sv, n_a);
+ const char *s = SvPV_nolen(sv);
if (*s == '\'')
- sv_catpv(sstr, "\\'");
+ sv_catpvn(sstr, "\\'", 2);
else if (*s == '\\')
- sv_catpv(sstr, "\\\\");
+ sv_catpvn(sstr, "\\\\", 2);
#ifdef EBCDIC
else if (isPRINT(*s))
#else
#endif /* EBCDIC */
sv_catpvn(sstr, s, 1);
else if (*s == '\n')
- sv_catpv(sstr, "\\n");
+ sv_catpvn(sstr, "\\n", 2);
else if (*s == '\r')
- sv_catpv(sstr, "\\r");
+ sv_catpvn(sstr, "\\r", 2);
else if (*s == '\t')
- sv_catpv(sstr, "\\t");
+ sv_catpvn(sstr, "\\t", 2);
else if (*s == '\a')
- sv_catpv(sstr, "\\a");
+ sv_catpvn(sstr, "\\a", 2);
else if (*s == '\b')
- sv_catpv(sstr, "\\b");
+ sv_catpvn(sstr, "\\b", 2);
else if (*s == '\f')
- sv_catpv(sstr, "\\f");
+ sv_catpvn(sstr, "\\f", 2);
else if (*s == '\v')
- sv_catpv(sstr, "\\v");
+ sv_catpvn(sstr, "\\v", 2);
else
{
/* no trigraph support */
sprintf(escbuff, "\\%03o", c);
sv_catpv(sstr, escbuff);
}
- sv_catpv(sstr, "'");
+ sv_catpvn(sstr, "'", 1);
return sstr;
}
-void
-walkoptree(pTHX_ SV *opsv, char *method)
+static void
+walkoptree(pTHX_ SV *opsv, const char *method)
{
dSP;
OP *o, *kid;
}
}
-SV **
+static SV **
oplist(pTHX_ OP *o, SV **SP)
{
for(; o; o = o->op_next) {
void
walkoptree(opsv, method)
SV * opsv
- char * method
+ const char * method
CODE:
walkoptree(aTHX_ opsv, method);
void
opnumber(name)
-char * name
+const char * name
CODE:
{
int i;
hash(sv)
SV * sv
CODE:
- char *s;
STRLEN len;
U32 hash = 0;
char hexhash[19]; /* must fit "0xffffffffffffffff" plus trailing \0 */
- s = SvPV(sv, len);
+ const char *s = SvPV(sv, len);
PERL_HASH(hash, s, len);
sprintf(hexhash, "0x%"UVxf, (UV)hash);
ST(0) = sv_2mortal(newSVpv(hexhash, 0));
#if PERL_VERSION <= 8
# ifdef USE_5005THREADS
int i;
- STRLEN len = strlen(PL_threadsv_names);
+ const STRLEN len = strlen(PL_threadsv_names);
EXTEND(sp, len);
for (i = 0; i < len; i++)
(o->op_private & OPpTRANS_COMPLEMENT) &&
!(o->op_private & OPpTRANS_DELETE))
{
- short* tbl = (short*)o->op_pv;
- short entries = 257 + tbl[256];
+ const short* const tbl = (short*)o->op_pv;
+ const short entries = 257 + tbl[256];
ST(0) = sv_2mortal(newSVpv(o->op_pv, entries * sizeof(short)));
}
else if (o->op_type == OP_TRANS) {
CODE:
if (sizeof(IV) == 8) {
U32 wp[2];
- IV iv = SvIVX(sv);
+ const IV iv = SvIVX(sv);
/*
* The following way of spelling 32 is to stop compilers on
* 32-bit architectures from moaning about the shift count
bool
IsSTD(io,name)
B::IO io
- char* name
+ const char* name
PREINIT:
PerlIO* handle = 0;
CODE:
static SV *new_opset (pTHX_ SV *old_opset);
static int verify_opset (pTHX_ SV *opset, int fatal);
-static void set_opset_bits (pTHX_ char *bitmap, SV *bitspec, int on, char *opname);
-static void put_op_bitspec (pTHX_ char *optag, STRLEN len, SV *opset);
-static SV *get_op_bitspec (pTHX_ char *opname, STRLEN len, int fatal);
+static void set_opset_bits (pTHX_ char *bitmap, SV *bitspec, int on, const char *opname);
+static void put_op_bitspec (pTHX_ const char *optag, STRLEN len, SV *opset);
+static SV *get_op_bitspec (pTHX_ const char *opname, STRLEN len, int fatal);
/* Initialise our private op_named_bits HV.
op_named_bits = newHV();
op_names = get_op_names();
for(i=0; i < PL_maxo; ++i) {
- SV *sv;
- sv = newSViv(i);
+ SV * const sv = newSViv(i);
SvREADONLY_on(sv);
hv_store(op_named_bits, op_names[i], strlen(op_names[i]), sv, 0);
}
*/
static void
-put_op_bitspec(pTHX_ char *optag, STRLEN len, SV *mask)
+put_op_bitspec(pTHX_ const char *optag, STRLEN len, SV *mask)
{
SV **svp;
dMY_CXT;
*/
static SV *
-get_op_bitspec(pTHX_ char *opname, STRLEN len, int fatal)
+get_op_bitspec(pTHX_ const char *opname, STRLEN len, int fatal)
{
SV **svp;
dMY_CXT;
static int
verify_opset(pTHX_ SV *opset, int fatal)
{
- char *err = Nullch;
+ const char *err = Nullch;
dMY_CXT;
if (!SvOK(opset)) err = "undefined";
static void
-set_opset_bits(pTHX_ char *bitmap, SV *bitspec, int on, char *opname)
+set_opset_bits(pTHX_ char *bitmap, SV *bitspec, int on, const char *opname)
{
dMY_CXT;
if (SvIOK(bitspec)) {
- int myopcode = SvIV(bitspec);
- int offset = myopcode >> 3;
- int bit = myopcode & 0x07;
+ const int myopcode = SvIV(bitspec);
+ const int offset = myopcode >> 3;
+ const int bit = myopcode & 0x07;
if (myopcode >= PL_maxo || myopcode < 0)
croak("panic: opcode \"%s\" value %d is invalid", opname, myopcode);
if (opcode_debug >= 2)
else if (SvPOK(bitspec) && SvCUR(bitspec) == (STRLEN)opset_len) {
STRLEN len;
- char *specbits = SvPV(bitspec, len);
+ const char * const specbits = SvPV(bitspec, len);
if (opcode_debug >= 2)
warn("set_opset_bits opset %s %s\n", opname, (on)?"on":"off");
if (on)
bitmask = SvPV(opset, len);
for (i=0; i < opset_len; i++) {
- U16 bits = bitmask[i];
+ const U16 bits = bitmask[i];
if (!bits) { /* optimise for sparse masks */
myopcode += 8;
continue;
void
_safe_pkg_prep(Package)
- char * Package
+ const char *Package
PPCODE:
HV *hv;
ENTER;
{
STRLEN len;
int i, j, myopcode;
- char *bitmap = SvPV(opset, len);
+ const char * const bitmap = SvPV(opset, len);
char **names = (desc) ? get_op_descs() : get_op_names();
dMY_CXT;
verify_opset(aTHX_ opset,1);
for (myopcode=0, i=0; i < opset_len; i++) {
- U16 bits = bitmap[i];
+ const U16 bits = bitmap[i];
for (j=0; j < 8 && myopcode < PL_maxo; j++, myopcode++) {
if ( bits & (1 << j) )
XPUSHs(sv_2mortal(newSVpv(names[myopcode], 0)));
opset(...)
CODE:
int i;
- SV *bitspec, *opset;
- char *bitmap;
+ SV *bitspec;
STRLEN len, on;
- opset = sv_2mortal(new_opset(aTHX_ Nullsv));
- bitmap = SvPVX(opset);
+ SV * const opset = sv_2mortal(new_opset(aTHX_ Nullsv));
+ char * const bitmap = SvPVX(opset);
for (i = 0; i < items; i++) {
- char *opname;
+ const char *opname;
on = 1;
if (verify_opset(aTHX_ ST(i),0)) {
opname = "(opset)";
deny_only = 2
deny = 3
CODE:
- int i, on;
+ int i;
SV *bitspec, *mask;
- char *bitmap, *opname;
+ char *bitmap;
STRLEN len;
dMY_CXT;
verify_opset(aTHX_ mask,1); /* croaks */
bitmap = SvPVX(mask);
for (i = 1; i < items; i++) {
- on = PERMITING ? 0 : 1; /* deny = mask bit on */
+ const char *opname;
+ int on = PERMITING ? 0 : 1; /* deny = mask bit on */
if (verify_opset(aTHX_ ST(i),0)) { /* it's a valid mask */
opname = "(opset)";
bitspec = ST(i);
void
opdesc(...)
PPCODE:
- int i, myopcode;
+ int i;
STRLEN len;
SV **args;
char **op_desc = get_op_descs();
/* the stack faster than we read values off it if masks are used. */
args = (SV**)SvPVX(sv_2mortal(newSVpvn((char*)&ST(0), items*sizeof(SV*))));
for (i = 0; i < items; i++) {
- char *opname = SvPV(args[i], len);
+ const char * const opname = SvPV(args[i], len);
SV *bitspec = get_op_bitspec(aTHX_ opname, len, 1);
if (SvIOK(bitspec)) {
- myopcode = SvIV(bitspec);
+ const int myopcode = SvIV(bitspec);
if (myopcode < 0 || myopcode >= PL_maxo)
croak("panic: opcode %d (%s) out of range",myopcode,opname);
XPUSHs(sv_2mortal(newSVpv(op_desc[myopcode], 0)));
else if (SvPOK(bitspec) && SvCUR(bitspec) == (STRLEN)opset_len) {
int b, j;
STRLEN n_a;
- char *bitmap = SvPV(bitspec,n_a);
- myopcode = 0;
+ const char * const bitmap = SvPV(bitspec,n_a);
+ int myopcode = 0;
for (b=0; b < opset_len; b++) {
- U16 bits = bitmap[b];
+ const U16 bits = bitmap[b];
for (j=0; j < 8 && myopcode < PL_maxo; j++, myopcode++)
if (bits & (1 << j))
XPUSHs(sv_2mortal(newSVpv(op_desc[myopcode], 0)));
SV *mask
CODE:
STRLEN len;
- char *optag = SvPV(optagsv, len);
+ const char *optag = SvPV(optagsv, len);
put_op_bitspec(aTHX_ optag, len, mask); /* croaks */
ST(0) = &PL_sv_yes;
CODE:
ST(0) = sv_2mortal(new_opset(aTHX_ Nullsv));
if (PL_op_mask) {
- char *bitmap = SvPVX(ST(0));
+ char * const bitmap = SvPVX(ST(0));
int myopcode;
for(myopcode=0; myopcode < PL_maxo; ++myopcode) {
if (PL_op_mask[myopcode])
#include "XSUB.h"
static cv_flags_t
-get_flag(char *attr)
+get_flag(const char *attr)
{
if (strnEQ(attr, "method", 6))
return CVf_METHOD;
"pragma \"attrs\" is deprecated, "
"use \"sub NAME : ATTRS\" instead");
for (i = 1; i < items; i++) {
- STRLEN n_a;
- char *attr = SvPV(ST(i), n_a);
- cv_flags_t flag = get_flag(attr);
+ const char * const attr = SvPV_nolen(ST(i));
+ const cv_flags_t flag = get_flag(attr);
if (!flag)
croak("invalid attribute name %s", attr);
if (ix)
sub = Nullsv;
}
else {
- STRLEN n_a;
- char *name = SvPV(sub, n_a);
+ const char * const name = SvPV_nolen(sub);
sub = (SV*)perl_get_cv(name, FALSE);
}
if (!sub)
*/
# error "Don't know how to set FILE.fileno on your platform"
#endif
+ (void)f;
return 0;
# endif
}
STATIC int
S_emulate_eaccess(pTHX_ const char* path, Mode_t mode)
{
+ (void)path;
+ (void)mode;
Perl_croak(aTHX_ "switching effective uid is not implemented");
/*NOTREACHED*/
return -1;
#if defined(PERL_IN_PP_SYS_C) || defined(PERL_DECL_PROT)
STATIC OP* S_doform(pTHX_ CV *cv, GV *gv, OP *retop);
-STATIC int S_emulate_eaccess(pTHX_ const char* path, Mode_t mode);
+STATIC int S_emulate_eaccess(pTHX_ const char* path, Mode_t mode)
+ __attribute__noreturn__;
+
# if !defined(HAS_MKDIR) || !defined(HAS_RMDIR)
STATIC int S_dooneliner(pTHX_ char *cmd, char *filename);
# endif
DEBUG_TRIE_COMPILE_r(
PerlIO_printf( Perl_debug_log, "TRIE(%s): W:%d C:%d Uq:%d \n",
( trie->widecharmap ? "UTF8" : "NATIVE" ), trie->wordcount,
- trie->charcount, trie->uniquecharcount )
+ (int)trie->charcount, trie->uniquecharcount )
);
DEBUG_TRIE_COMPILE_MORE_r(
PerlIO_printf( Perl_debug_log,
" Alloc: %d Orig: %"IVdf" elements, Final:%"IVdf". Savings of %%%5.2f\n",
- ( ( trie->charcount + 1 ) * trie->uniquecharcount + 1 ), (IV)next_alloc, (IV)pos,
+ (int)( ( trie->charcount + 1 ) * trie->uniquecharcount + 1 ),
+ (IV)next_alloc,
+ (IV)pos,
( ( next_alloc - pos ) * 100 ) / (double)next_alloc );
);
I32 word_idx;
PerlIO_printf(Perl_debug_log,
"%*s[Words:%d Chars Stored:%d Unique Chars:%d States:%"IVdf"%s]\n",
- (int)(2*(l+3)), "",
+ (int)(2*(l+3)),
+ "",
trie->wordcount,
- trie->charcount,
+ (int)trie->charcount,
trie->uniquecharcount,
(IV)trie->laststate-1,
node->flags ? " EVAL mode" : "");
(UV)s[1], startbyte);
else
Perl_sv_catpvf(aTHX_ sv, "(unexpected non-continuation byte 0x%02"UVxf", %d byte%s after start byte 0x%02"UVxf", expected %d bytes)",
- (UV)s[1], s - s0, s - s0 > 1 ? "s" : "", startbyte, expectlen);
+ (UV)s[1], s - s0, s - s0 > 1 ? "s" : "", startbyte, (int)expectlen);
break;
case UTF8_WARN_FE_FF:
break;
case UTF8_WARN_SHORT:
Perl_sv_catpvf(aTHX_ sv, "(%d byte%s, need %d, after start byte 0x%02"UVxf")",
- curlen, curlen == 1 ? "" : "s", expectlen, startbyte);
+ (int)curlen, curlen == 1 ? "" : "s", (int)expectlen, startbyte);
expectlen = curlen; /* distance for caller to skip */
break;
case UTF8_WARN_OVERFLOW:
break;
case UTF8_WARN_LONG:
Perl_sv_catpvf(aTHX_ sv, "(%d byte%s, need %d, after start byte 0x%02"UVxf")",
- expectlen, expectlen == 1 ? "": "s", UNISKIP(uv), startbyte);
+ (int)expectlen, expectlen == 1 ? "": "s", UNISKIP(uv), startbyte);
break;
case UTF8_WARN_FFFF:
Perl_sv_catpvf(aTHX_ sv, "(character 0x%04"UVxf")", uv);