Change 29958 by [EMAIL PROTECTED] on 2007/01/24 19:49:21
Integrate:
[ 27943]
Subject: [PATCH] doop.c consting, take 2
From: [EMAIL PROTECTED] (Andy Lester)
Date: Sun, 23 Apr 2006 20:45:09 -0500
Message-ID: <[EMAIL PROTECTED]>
[ 27958]
Subject: [PATCH] use NOOP macro
From: [EMAIL PROTECTED] (Andy Lester)
Date: Mon, 24 Apr 2006 13:44:51 -0500
Message-ID: <[EMAIL PROTECTED]>
Affected files ...
... //depot/maint-5.8/perl/doop.c#47 integrate
... //depot/maint-5.8/perl/embed.fnc#185 integrate
... //depot/maint-5.8/perl/gv.c#88 integrate
... //depot/maint-5.8/perl/gv.h#20 integrate
... //depot/maint-5.8/perl/hv.c#104 integrate
... //depot/maint-5.8/perl/op.c#173 integrate
... //depot/maint-5.8/perl/pad.c#61 integrate
... //depot/maint-5.8/perl/perl.h#136 integrate
... //depot/maint-5.8/perl/perlio.c#88 integrate
... //depot/maint-5.8/perl/pp.c#123 integrate
... //depot/maint-5.8/perl/pp_ctl.c#153 integrate
... //depot/maint-5.8/perl/pp_hot.c#119 integrate
... //depot/maint-5.8/perl/proto.h#174 integrate
... //depot/maint-5.8/perl/regcomp.c#86 integrate
... //depot/maint-5.8/perl/regexec.c#75 integrate
... //depot/maint-5.8/perl/sv.c#312 integrate
... //depot/maint-5.8/perl/toke.c#142 integrate
... //depot/maint-5.8/perl/utf8.c#69 integrate
Differences ...
==== //depot/maint-5.8/perl/doop.c#47 (text) ====
Index: perl/doop.c
--- perl/doop.c#46~29952~ 2007-01-24 08:46:32.000000000 -0800
+++ perl/doop.c 2007-01-24 11:49:21.000000000 -0800
@@ -26,23 +26,17 @@
#endif
STATIC I32
-S_do_trans_simple(pTHX_ SV *sv)
+S_do_trans_simple(pTHX_ SV * const sv)
{
- U8 *s;
- U8 *d;
- const U8 *send;
- U8 *dstart;
I32 matches = 0;
- const I32 grows = PL_op->op_private & OPpTRANS_GROWS;
STRLEN len;
+ U8 *s = (U8*)SvPV(sv,len);
+ U8 * const send = s+len;
const short * const tbl = (short*)cPVOP->op_pv;
if (!tbl)
Perl_croak(aTHX_ "panic: do_trans_simple line %d",__LINE__);
- s = (U8*)SvPV(sv, len);
- send = s + len;
-
/* First, take care of non-UTF-8 input strings, because they're easy */
if (!SvUTF8(sv)) {
while (s < send) {
@@ -54,65 +48,67 @@
s++;
}
SvSETMAGIC(sv);
- return matches;
}
+ else {
+ const I32 grows = PL_op->op_private & OPpTRANS_GROWS;
+ U8 *d;
+ U8 *dstart;
- /* Allow for expansion: $_="a".chr(400); tr/a/\xFE/, FE needs encoding */
- if (grows)
- Newx(d, len*2+1, U8);
- else
- d = s;
- dstart = d;
- while (s < send) {
- STRLEN ulen;
- I32 ch;
+ /* Allow for expansion: $_="a".chr(400); tr/a/\xFE/, FE needs encoding
*/
+ if (grows)
+ Newx(d, len*2+1, U8);
+ else
+ d = s;
+ dstart = d;
+ while (s < send) {
+ STRLEN ulen;
+ I32 ch;
- /* Need to check this, otherwise 128..255 won't match */
- const UV c = utf8n_to_uvchr(s, send - s, &ulen, 0);
- if (c < 0x100 && (ch = tbl[c]) >= 0) {
- matches++;
- d = uvchr_to_utf8(d, ch);
- s += ulen;
- }
- else { /* No match -> copy */
- Move(s, d, ulen, U8);
- d += ulen;
- s += ulen;
- }
- }
- if (grows) {
- sv_setpvn(sv, (char*)dstart, d - dstart);
- Safefree(dstart);
- }
- else {
- *d = '\0';
- SvCUR_set(sv, d - dstart);
+ /* Need to check this, otherwise 128..255 won't match */
+ const UV c = utf8n_to_uvchr(s, send - s, &ulen, 0);
+ if (c < 0x100 && (ch = tbl[c]) >= 0) {
+ matches++;
+ d = uvchr_to_utf8(d, ch);
+ s += ulen;
+ }
+ else { /* No match -> copy */
+ Move(s, d, ulen, U8);
+ d += ulen;
+ s += ulen;
+ }
+ }
+ if (grows) {
+ sv_setpvn(sv, (char*)dstart, d - dstart);
+ Safefree(dstart);
+ }
+ else {
+ *d = '\0';
+ SvCUR_set(sv, d - dstart);
+ }
+ SvUTF8_on(sv);
+ SvSETMAGIC(sv);
}
- SvUTF8_on(sv);
- SvSETMAGIC(sv);
return matches;
}
STATIC I32
-S_do_trans_count(pTHX_ SV *sv)
+S_do_trans_count(pTHX_ SV * const sv)
{
- const U8 *s;
- const U8 *send;
- I32 matches = 0;
STRLEN len;
+ const U8 *s = (const U8*)SvPV_const(sv, len);
+ const U8 * const send = s + len;
+ I32 matches = 0;
const short * const tbl = (short*)cPVOP->op_pv;
if (!tbl)
Perl_croak(aTHX_ "panic: do_trans_count line %d",__LINE__);
- s = (const U8*)SvPV_const(sv, len);
- send = s + len;
-
- if (!SvUTF8(sv))
+ if (!SvUTF8(sv)) {
while (s < send) {
if (tbl[*s++] >= 0)
matches++;
}
+ }
else {
const I32 complement = PL_op->op_private & OPpTRANS_COMPLEMENT;
while (s < send) {
@@ -131,26 +127,21 @@
}
STATIC I32
-S_do_trans_complex(pTHX_ SV *sv)
+S_do_trans_complex(pTHX_ SV * const sv)
{
- U8 *s;
- U8 *send;
- U8 *d;
- U8 *dstart;
- I32 isutf8;
+ STRLEN len;
+ U8 *s = (U8*)SvPV(sv, len);
+ U8 * const send = s+len;
I32 matches = 0;
- STRLEN len, rlen = 0;
const short * const tbl = (short*)cPVOP->op_pv;
if (!tbl)
Perl_croak(aTHX_ "panic: do_trans_complex line %d",__LINE__);
- s = (U8*)SvPV(sv, len);
- isutf8 = SvUTF8(sv);
- send = s + len;
+ if (!SvUTF8(sv)) {
+ U8 *d = s;
+ U8 * const dstart = d;
- if (!isutf8) {
- dstart = d = s;
if (PL_op->op_private & OPpTRANS_SQUASH) {
const U8* p = send;
while (s < send) {
@@ -185,10 +176,13 @@
*d = '\0';
SvCUR_set(sv, d - dstart);
}
- else { /* isutf8 */
+ else { /* is utf8 */
const I32 complement = PL_op->op_private & OPpTRANS_COMPLEMENT;
const I32 grows = PL_op->op_private & OPpTRANS_GROWS;
const I32 del = PL_op->op_private & OPpTRANS_DELETE;
+ U8 *d;
+ U8 *dstart;
+ STRLEN rlen = 0;
if (grows)
Newx(d, len*2+1, U8);
@@ -296,7 +290,7 @@
}
STATIC I32
-S_do_trans_simple_utf8(pTHX_ SV *sv)
+S_do_trans_simple_utf8(pTHX_ SV * const sv)
{
U8 *s;
U8 *send;
@@ -313,12 +307,10 @@
const UV none = svp ? SvUV(*svp) : 0x7fffffff;
const UV extra = none + 1;
UV final = 0;
- I32 isutf8;
U8 hibit = 0;
s = (U8*)SvPV(sv, len);
- isutf8 = SvUTF8(sv);
- if (!isutf8) {
+ if (!SvUTF8(sv)) {
const U8 *t = s;
const U8 * const e = s + len;
while (t < e) {
@@ -396,7 +388,7 @@
}
STATIC I32
-S_do_trans_count_utf8(pTHX_ SV *sv)
+S_do_trans_count_utf8(pTHX_ SV * const sv)
{
const U8 *s;
const U8 *start = NULL;
@@ -439,7 +431,7 @@
}
STATIC I32
-S_do_trans_complex_utf8(pTHX_ SV *sv)
+S_do_trans_complex_utf8(pTHX_ SV * const sv)
{
U8 *start, *send;
U8 *d;
@@ -459,8 +451,7 @@
U8 hibit = 0;
U8 *s = (U8*)SvPV(sv, len);
- const I32 isutf8 = SvUTF8(sv);
- if (!isutf8) {
+ if (!SvUTF8(sv)) {
const U8 *t = s;
const U8 * const e = s + len;
while (t < e) {
@@ -1288,8 +1279,8 @@
default:
if (sv == left || sv == right)
Safefree(dcorig);
- Perl_croak(aTHX_ "panic: do_vop called for op %u (%s)", optype,
- PL_op_name[optype]);
+ Perl_croak(aTHX_ "panic: do_vop called for op %u (%s)",
+ (unsigned)optype, PL_op_name[optype]);
}
SvUTF8_on(sv);
goto finish;
==== //depot/maint-5.8/perl/embed.fnc#185 (text) ====
Index: perl/embed.fnc
--- perl/embed.fnc#184~29955~ 2007-01-24 10:58:36.000000000 -0800
+++ perl/embed.fnc 2007-01-24 11:49:21.000000000 -0800
@@ -1051,12 +1051,12 @@
#endif
#if defined(PERL_IN_DOOP_C) || defined(PERL_DECL_PROT)
-sR |I32 |do_trans_simple |NN SV *sv
-sR |I32 |do_trans_count |NN SV *sv
-sR |I32 |do_trans_complex |NN SV *sv
-sR |I32 |do_trans_simple_utf8 |NN SV *sv
-sR |I32 |do_trans_count_utf8 |NN SV *sv
-sR |I32 |do_trans_complex_utf8 |NN SV *sv
+sR |I32 |do_trans_simple |NN SV * const sv
+sR |I32 |do_trans_count |NN SV * const sv
+sR |I32 |do_trans_complex |NN SV * const sv
+sR |I32 |do_trans_simple_utf8 |NN SV * const sv
+sR |I32 |do_trans_count_utf8 |NN SV * const sv
+sR |I32 |do_trans_complex_utf8 |NN SV * const sv
#endif
#if defined(PERL_IN_GV_C) || defined(PERL_DECL_PROT)
==== //depot/maint-5.8/perl/gv.c#88 (text) ====
Index: perl/gv.c
--- perl/gv.c#87~29926~ 2007-01-22 14:47:32.000000000 -0800
+++ perl/gv.c 2007-01-24 11:49:21.000000000 -0800
@@ -980,7 +980,7 @@
if (len > 1) {
#ifndef EBCDIC
if (*name > 'V' ) {
- /*EMPTY*/;
+ NOOP;
/* Nothing else to do.
The compiler will probably turn the switch statement into a
branch table. Make sure we avoid even that small overhead for
@@ -1477,7 +1477,7 @@
lim = DESTROY_amg; /* Skip overloading entries. */
#ifdef PERL_DONT_CREATE_GVSV
else if (!sv) {
- /*EMPTY*/; /* Equivalent to !SvTRUE and !SvOK */
+ NOOP; /* Equivalent to !SvTRUE and !SvOK */
}
#endif
else if (SvTRUE(sv))
==== //depot/maint-5.8/perl/hv.c#104 (text) ====
Index: perl/hv.c
--- perl/hv.c#103~29949~ 2007-01-24 07:28:38.000000000 -0800
+++ perl/hv.c 2007-01-24 11:49:21.000000000 -0800
@@ -2125,7 +2125,7 @@
real++;
/* sanity check the keys */
if (HeSVKEY(entry)) {
- /*EMPTY*/ /* Don't know what to check on SV keys. */
+ NOOP; /* Don't know what to check on SV keys. */
} else if (HeKUTF8(entry)) {
withflags++;
if (HeKWASUTF8(entry)) {
==== //depot/maint-5.8/perl/op.c#173 (text) ====
Index: perl/op.c
--- perl/op.c#172~29955~ 2007-01-24 10:58:36.000000000 -0800
+++ perl/op.c 2007-01-24 11:49:21.000000000 -0800
@@ -533,7 +533,7 @@
SvREFCNT_dec(cop->cop_warnings);
if (! specialCopIO(cop->cop_io)) {
#ifdef USE_ITHREADS
- /*EMPTY*/
+ NOOP;
#else
SvREFCNT_dec(cop->cop_io);
#endif
@@ -1608,7 +1608,7 @@
/* Don't force the C<use> if we don't need it. */
SV * const * const svp = hv_fetchs(GvHVn(PL_incgv), ATTRSMODULE_PM,
FALSE);
if (svp && *svp != &PL_sv_undef)
- /*EMPTY*/; /* already in %INC */
+ NOOP; /* already in %INC */
else
Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT,
newSVpvs(ATTRSMODULE), NULL);
@@ -2026,7 +2026,7 @@
#if 0
list(o);
#else
- /*EMPTY*/;
+ NOOP;
#endif
else {
if ( PL_bufptr > PL_oldbufptr && PL_bufptr[-1] == ','
@@ -2958,7 +2958,7 @@
repl_has_vars = 1;
}
else if (curop->op_type == OP_PUSHRE)
- /*EMPTY*/; /* Okay here, dangerous in newASSIGNOP */
+ NOOP; /* Okay here, dangerous in newASSIGNOP */
else
break;
}
@@ -5384,7 +5384,7 @@
const I32 type = o->op_type;
if (o->op_flags & OPf_REF) {
- /*EMPTY*/;
+ NOOP;
}
else if (o->op_flags & OPf_KIDS && cUNOPo->op_first->op_type != OP_STUB) {
SVOP * const kid = (SVOP*)cUNOPo->op_first;
@@ -7285,7 +7285,7 @@
{
dXSARGS;
if (items != 0) {
- /*EMPTY*/;
+ NOOP;
#if 0
Perl_croak(aTHX_ "usage: %s::%s()",
HvNAME_get(GvSTASH(CvGV(cv))), GvNAME(CvGV(cv)));
==== //depot/maint-5.8/perl/perl.h#136 (text) ====
Index: perl/perl.h
--- perl/perl.h#135~29949~ 2007-01-24 07:28:38.000000000 -0800
+++ perl/perl.h 2007-01-24 11:49:21.000000000 -0800
@@ -206,8 +206,8 @@
# define PERL_UNUSED_CONTEXT
#endif
-#define NOOP (void)0
-#define dNOOP extern int Perl___notused PERL_UNUSED_DECL
+#define NOOP /*EMPTY*/(void)0
+#define dNOOP extern int /[EMAIL PROTECTED]@*/ Perl___notused PERL_UNUSED_DECL
#ifndef pTHX
/* Don't bother defining tTHX and sTHX; using them outside
==== //depot/maint-5.8/perl/perlio.c#88 (text) ====
Index: perl/perlio.c
--- perl/perlio.c#87~29949~ 2007-01-24 07:28:38.000000000 -0800
+++ perl/perlio.c 2007-01-24 11:49:21.000000000 -0800
@@ -2499,7 +2499,7 @@
}
else {
if (f) {
- /*EMPTY*/;
+ NOOP;
/*
* FIXME: pop layers ???
*/
@@ -2876,7 +2876,7 @@
goto set_this;
}
else {
- /*EMPTY*/;
+ NOOP;
/* FIXME: To avoid messy error recovery if dup fails
re-use the existing stdio as though flag was not set
*/
@@ -3163,7 +3163,7 @@
return PerlSIO_fflush(stdio);
}
else {
- /*EMPTY*/;
+ NOOP;
#if 0
/*
* FIXME: This discards ungetc() and pre-read stuff which is not
@@ -4304,7 +4304,7 @@
ptr -= cnt;
}
else {
- /*EMPTY*/;
+ NOOP;
#if 0
/*
* Test code - delete when it works ...
==== //depot/maint-5.8/perl/pp.c#123 (text) ====
Index: perl/pp.c
--- perl/pp.c#122~29952~ 2007-01-24 08:46:32.000000000 -0800
+++ perl/pp.c 2007-01-24 11:49:21.000000000 -0800
@@ -1119,7 +1119,7 @@
bhigh = blow >> (4 * sizeof (UV));
blow &= botmask;
if (ahigh && bhigh) {
- /*EMPTY*/;
+ NOOP;
/* eg 32 bit is at least 0x10000 * 0x10000 == 0x100000000
which is overflow. Drop to NVs below. */
} else if (!ahigh && !bhigh) {
==== //depot/maint-5.8/perl/pp_ctl.c#153 (text) ====
Index: perl/pp_ctl.c
--- perl/pp_ctl.c#152~29947~ 2007-01-24 05:54:09.000000000 -0800
+++ perl/pp_ctl.c 2007-01-24 11:49:21.000000000 -0800
@@ -1782,7 +1782,7 @@
TAINT_NOT;
if (gimme == G_VOID)
- /*EMPTY*/; /* do nothing */
+ NOOP;
else if (gimme == G_SCALAR) {
if (mark < SP)
*++newsp = sv_mortalcopy(*SP);
==== //depot/maint-5.8/perl/pp_hot.c#119 (text) ====
Index: perl/pp_hot.c
--- perl/pp_hot.c#118~29943~ 2007-01-24 04:06:54.000000000 -0800
+++ perl/pp_hot.c 2007-01-24 11:49:21.000000000 -0800
@@ -2475,7 +2475,7 @@
EXTEND_MORTAL(SP - newsp);
for (mark = newsp + 1; mark <= SP; mark++) {
if (SvTEMP(*mark))
- /*EMPTY*/;
+ NOOP;
else if (SvFLAGS(*mark) & (SVs_PADTMP | SVf_READONLY))
*mark = sv_mortalcopy(*mark);
else {
==== //depot/maint-5.8/perl/proto.h#174 (text+w) ====
Index: perl/proto.h
--- perl/proto.h#173~29955~ 2007-01-24 10:58:36.000000000 -0800
+++ perl/proto.h 2007-01-24 11:49:21.000000000 -0800
@@ -1547,22 +1547,22 @@
#endif
#if defined(PERL_IN_DOOP_C) || defined(PERL_DECL_PROT)
-STATIC I32 S_do_trans_simple(pTHX_ SV *sv)
+STATIC I32 S_do_trans_simple(pTHX_ SV * const sv)
__attribute__warn_unused_result__;
-STATIC I32 S_do_trans_count(pTHX_ SV *sv)
+STATIC I32 S_do_trans_count(pTHX_ SV * const sv)
__attribute__warn_unused_result__;
-STATIC I32 S_do_trans_complex(pTHX_ SV *sv)
+STATIC I32 S_do_trans_complex(pTHX_ SV * const sv)
__attribute__warn_unused_result__;
-STATIC I32 S_do_trans_simple_utf8(pTHX_ SV *sv)
+STATIC I32 S_do_trans_simple_utf8(pTHX_ SV * const sv)
__attribute__warn_unused_result__;
-STATIC I32 S_do_trans_count_utf8(pTHX_ SV *sv)
+STATIC I32 S_do_trans_count_utf8(pTHX_ SV * const sv)
__attribute__warn_unused_result__;
-STATIC I32 S_do_trans_complex_utf8(pTHX_ SV *sv)
+STATIC I32 S_do_trans_complex_utf8(pTHX_ SV * const sv)
__attribute__warn_unused_result__;
#endif
==== //depot/maint-5.8/perl/regcomp.c#86 (text) ====
Index: perl/regcomp.c
--- perl/regcomp.c#85~29953~ 2007-01-24 09:01:34.000000000 -0800
+++ perl/regcomp.c 2007-01-24 11:49:21.000000000 -0800
@@ -1876,7 +1876,7 @@
again:
if (PL_regkind[(U8)OP(first)] == EXACT) {
if (OP(first) == EXACT)
- /*EMPTY*/; /* Empty, get anchored substr later. */
+ NOOP; /* Empty, get anchored substr later. */
else if ((OP(first) == EXACTF || OP(first) == EXACTFL))
r->regstclass = first;
}
==== //depot/maint-5.8/perl/regexec.c#75 (text) ====
Index: perl/regexec.c
--- perl/regexec.c#74~29957~ 2007-01-24 11:17:41.000000000 -0800
+++ perl/regexec.c 2007-01-24 11:49:21.000000000 -0800
@@ -602,7 +602,7 @@
&& (!do_utf8
|| ((t = reghopmaybe3_c(s, -(prog->check_offset_max),
strpos))
&& t > strpos)))
- /* EMPTY */;
+ NOOP;
else
t = strpos;
t = HOP3c(t, prog->anchored_offset, strend);
==== //depot/maint-5.8/perl/sv.c#312 (text) ====
Index: perl/sv.c
--- perl/sv.c#311~29955~ 2007-01-24 10:58:36.000000000 -0800
+++ perl/sv.c 2007-01-24 11:49:21.000000000 -0800
@@ -35,13 +35,13 @@
* lib/utf8.t lib/Unicode/Collate/t/index.t
* --jhi
*/
-#define ASSERT_UTF8_CACHE(cache) \
+# define ASSERT_UTF8_CACHE(cache) \
STMT_START { if (cache) { assert((cache)[0] <= (cache)[1]); \
assert((cache)[2] <= (cache)[3]); \
assert((cache)[3] <= (cache)[1]);} \
} STMT_END
#else
-#define ASSERT_UTF8_CACHE(cache) NOOP
+# define ASSERT_UTF8_CACHE(cache) NOOP
#endif
/* ============================================================================
@@ -1998,7 +1998,7 @@
if ((NV)(SvIVX(sv)) == SvNVX(sv)) {
SvIOK_on(sv);
} else {
- /*EMPTY*/; /* Integer is imprecise. NOK, IOKp */
+ NOOP; /* Integer is imprecise. NOK, IOKp */
}
/* UV will not work better than IV */
} else {
@@ -2013,7 +2013,7 @@
if ((NV)(SvUVX(sv)) == SvNVX(sv)) {
SvIOK_on(sv);
} else {
- /*EMPTY*/; /* Integer is imprecise. NOK, IOKp, is UV
*/
+ NOOP; /* Integer is imprecise. NOK, IOKp, is UV */
}
}
SvIsUV_on(sv);
@@ -3196,7 +3196,7 @@
it was a const and its value changed. */
if (CvCONST(cv) && CvCONST((CV*)sref)
&& cv_const_sv(cv) == cv_const_sv((CV*)sref)) {
- /*EMPTY*/
+ NOOP;
/* They are 2 constant subroutines generated from
the same constant. This probably means that
they are really the "same" proxy subroutine
@@ -9430,7 +9430,7 @@
case SVt_PVGV:
if (GvUNIQUE((GV*)sstr)) {
- /*EMPTY*/; /* Do sharing here, and fall through */
+ NOOP; /* Do sharing here, and fall through */
}
case SVt_PVIO:
case SVt_PVFM:
@@ -9529,7 +9529,7 @@
if (IoDIRP(dstr)) {
IoDIRP(dstr) = dirp_dup(IoDIRP(dstr));
} else {
- /*EMPTY*/;
+ NOOP;
/* IoDIRP(dstr) is already a copy of IoDIRP(sstr) */
}
}
==== //depot/maint-5.8/perl/utf8.c#69 (text) ====
Index: perl/utf8.c
--- perl/utf8.c#68~29929~ 2007-01-22 15:29:42.000000000 -0800
+++ perl/utf8.c 2007-01-24 11:49:21.000000000 -0800
@@ -2001,7 +2001,7 @@
}
if (opc == '+' && otherval)
- /*EMPTY*/; /* replace with otherval */
+ NOOP; /* replace with otherval */
else if (opc == '!' && !otherval)
otherval = 1;
else if (opc == '-' && otherval)
End of Patch.