summaryrefslogtreecommitdiff
path: root/ext/Opcode
diff options
context:
space:
mode:
authorAndy Lester <andy@petdance.com>2005-05-28 19:19:06 -0500
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2005-05-30 07:45:09 +0000
commit5d7488b2fd9fa6515201f39bec25777d9fccd7db (patch)
treea657f5ce875a7991aff4b680574bdb785fc5f34a /ext/Opcode
parent0b4b7f425bbb7f4f6f4a885d16efb0978cf3643f (diff)
downloadperl-5d7488b2fd9fa6515201f39bec25777d9fccd7db.tar.gz
[PATCH] Minor warning squashings
Date: Sun, 29 May 2005 00:19:06 -0500 Message-Id: <740ea3aca85400c6d03e945323badad4@petdance.com> Subject: [PATCH] Consting in Opcode.xs From: Andy Lester <andy@petdance.com> Date: Sun, 29 May 2005 11:23:50 -0500 Message-ID: <20050529162350.GA13965@petdance.com> Subject: [PATCH] consting attrs.xs From: Andy Lester <andy@petdance.com> Date: Sun, 29 May 2005 14:15:46 -0500 Message-ID: <20050529191546.GA15581@petdance.com> Subject: [PATCH] consting B.xs From: Andy Lester <andy@petdance.com> Date: Sun, 29 May 2005 15:09:24 -0500 Message-ID: <20050529200924.GA15873@petdance.com> p4raw-id: //depot/perl@24622
Diffstat (limited to 'ext/Opcode')
-rw-r--r--ext/Opcode/Opcode.xs65
1 files changed, 32 insertions, 33 deletions
diff --git a/ext/Opcode/Opcode.xs b/ext/Opcode/Opcode.xs
index 78c7605331..62b4d059d8 100644
--- a/ext/Opcode/Opcode.xs
+++ b/ext/Opcode/Opcode.xs
@@ -25,9 +25,9 @@ START_MY_CXT
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.
@@ -50,8 +50,7 @@ op_names_init(pTHX)
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);
}
@@ -75,7 +74,7 @@ op_names_init(pTHX)
*/
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;
@@ -98,7 +97,7 @@ put_op_bitspec(pTHX_ char *optag, STRLEN len, SV *mask)
*/
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;
@@ -146,7 +145,7 @@ new_opset(pTHX_ SV *old_opset)
static int
verify_opset(pTHX_ SV *opset, int fatal)
{
- char *err = Nullch;
+ const char *err = Nullch;
dMY_CXT;
if (!SvOK(opset)) err = "undefined";
@@ -160,14 +159,14 @@ verify_opset(pTHX_ SV *opset, int fatal)
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)
@@ -181,7 +180,7 @@ set_opset_bits(pTHX_ char *bitmap, SV *bitspec, int on, char *opname)
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)
@@ -213,7 +212,7 @@ opmask_add(pTHX_ SV *opset) /* THE ONLY FUNCTION TO EDIT PL_op_mask ITSELF */
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;
@@ -261,7 +260,7 @@ BOOT:
void
_safe_pkg_prep(Package)
- char * Package
+ const char *Package
PPCODE:
HV *hv;
ENTER;
@@ -359,13 +358,13 @@ PPCODE:
{
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)));
@@ -378,14 +377,13 @@ void
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)";
@@ -412,9 +410,9 @@ ALIAS:
deny_only = 2
deny = 3
CODE:
- int i, on;
+ int i;
SV *bitspec, *mask;
- char *bitmap, *opname;
+ char *bitmap;
STRLEN len;
dMY_CXT;
@@ -427,7 +425,8 @@ CODE:
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);
@@ -447,7 +446,7 @@ CODE:
void
opdesc(...)
PPCODE:
- int i, myopcode;
+ int i;
STRLEN len;
SV **args;
char **op_desc = get_op_descs();
@@ -457,10 +456,10 @@ PPCODE:
/* 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)));
@@ -468,10 +467,10 @@ PPCODE:
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)));
@@ -489,7 +488,7 @@ define_optag(optagsv, mask)
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;
@@ -530,7 +529,7 @@ opmask()
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])