Change 29981 by [EMAIL PROTECTED] on 2007/01/25 21:31:37
Integrate:
[ 28205]
Subject: [PATCH] refactoring out S_regoptail
From: [EMAIL PROTECTED] (Andy Lester)
Date: Sun, 14 May 2006 23:15:18 -0500
Message-ID: <[EMAIL PROTECTED]>
[ 28206]
Subject: [PATCH] Refactoring reghops
From: [EMAIL PROTECTED] (Andy Lester)
Date: Mon, 15 May 2006 08:54:24 -0500
Message-ID: <[EMAIL PROTECTED]>
[ 28209]
Subject: Re: [PATCH] upgrade bytes_to_uni
From: SADAHIRO Tomoyuki <[EMAIL PROTECTED]>
Date: Mon, 15 May 2006 22:39:58 +0900
Message-Id: <[EMAIL PROTECTED]>
[ 28236]
strlen(foo) rather than strchr(foo, 0) makes simpler code, and is
likely to be a more efficient implementation.
[ 28237]
Subject: [PATCH] strlcat aaargh
From: Jarkko Hietaniemi <[EMAIL PROTECTED]>
Date: Fri, 19 May 2006 20:44:46 +0300
Message-ID: <[EMAIL PROTECTED]>
[ 28246]
There is no STASH type.
Affected files ...
... //depot/maint-5.8/perl/doio.c#94 integrate
... //depot/maint-5.8/perl/embed.fnc#191 integrate
... //depot/maint-5.8/perl/embed.h#144 integrate
... //depot/maint-5.8/perl/perlio.c#92 integrate
... //depot/maint-5.8/perl/pp_pack.c#51 integrate
... //depot/maint-5.8/perl/proto.h#181 integrate
... //depot/maint-5.8/perl/regcomp.c#90 integrate
... //depot/maint-5.8/perl/regexec.c#79 integrate
... //depot/maint-5.8/perl/sv.h#73 integrate
Differences ...
==== //depot/maint-5.8/perl/doio.c#94 (text) ====
Index: perl/doio.c
--- perl/doio.c#93~29974~ 2007-01-25 09:04:16.000000000 -0800
+++ perl/doio.c 2007-01-25 13:31:37.000000000 -0800
@@ -75,7 +75,7 @@
bool was_fdopen = FALSE;
bool in_raw = 0, in_crlf = 0, out_raw = 0, out_crlf = 0;
char *type = NULL;
- char mode[PERL_MODE_MAX]; /* stdio file mode ("r\0", "rb\0", "r+b\0"
etc.) */
+ char mode[PERL_MODE_MAX]; /* file mode ("r\0", "rb\0", "ab\0" etc.) */
SV *namesv;
Zero(mode,sizeof(mode),char);
@@ -260,9 +260,9 @@
writing = 1;
#ifdef HAS_STRLCAT
if (out_raw)
- strlcat(mode, "b", PERL_MODE_MAX);
+ strlcat(mode, "b", PERL_MODE_MAX - 1);
else if (out_crlf)
- strlcat(mode, "t", PERL_MODE_MAX);
+ strlcat(mode, "t", PERL_MODE_MAX - 1);
#else
if (out_raw)
strcat(mode, "b");
@@ -298,9 +298,9 @@
#ifdef HAS_STRLCAT
if (out_raw)
- strlcat(mode, "b", PERL_MODE_MAX);
+ strlcat(mode, "b", PERL_MODE_MAX - 1);
else if (out_crlf)
- strlcat(mode, "t", PERL_MODE_MAX);
+ strlcat(mode, "t", PERL_MODE_MAX - 1);
#else
if (out_raw)
strcat(mode, "b");
@@ -431,9 +431,9 @@
mode[0] = 'r';
#ifdef HAS_STRLCAT
if (in_raw)
- strlcat(mode, "b", PERL_MODE_MAX);
+ strlcat(mode, "b", PERL_MODE_MAX - 1);
else if (in_crlf)
- strlcat(mode, "t", PERL_MODE_MAX);
+ strlcat(mode, "t", PERL_MODE_MAX - 1);
#else
if (in_raw)
strcat(mode, "b");
@@ -492,9 +492,9 @@
#ifdef HAS_STRLCAT
if (in_raw)
- strlcat(mode, "b", PERL_MODE_MAX);
+ strlcat(mode, "b", PERL_MODE_MAX - 1);
else if (in_crlf)
- strlcat(mode, "t", PERL_MODE_MAX);
+ strlcat(mode, "t", PERL_MODE_MAX - 1);
#else
if (in_raw)
strcat(mode, "b");
@@ -530,9 +530,9 @@
#ifdef HAS_STRLCAT
if (in_raw)
- strlcat(mode, "b", PERL_MODE_MAX);
+ strlcat(mode, "b", PERL_MODE_MAX - 1);
else if (in_crlf)
- strlcat(mode, "t", PERL_MODE_MAX);
+ strlcat(mode, "t", PERL_MODE_MAX - 1);
#else
if (in_raw)
strcat(mode, "b");
@@ -1483,7 +1483,7 @@
if (*s == 'f') {
s++;
#ifdef HAS_STRLCPY
- strlcat(flags, "f", PERL_FLAGS_MAX);
+ strlcat(flags, "f", PERL_FLAGS_MAX - 2);
#else
strcat(flags,"f");
#endif
==== //depot/maint-5.8/perl/embed.fnc#191 (text) ====
Index: perl/embed.fnc
--- perl/embed.fnc#190~29980~ 2007-01-25 13:15:39.000000000 -0800
+++ perl/embed.fnc 2007-01-25 13:31:37.000000000 -0800
@@ -1244,7 +1244,6 @@
Es |regnode*|reg_node |NN struct RExC_state_t *state|U8 op
Es |regnode*|regpiece |NN struct RExC_state_t *state|NN I32 *flagp
Es |void |reginsert |NN struct RExC_state_t *state|U8 op|NN regnode
*opnd
-Es |void |regoptail |NN const struct RExC_state_t *state|NN regnode
*p|NN const regnode *val
Es |void |regtail |NN const struct RExC_state_t *state|NN regnode
*p|NN const regnode *val
EsRn |char* |regwhite |NN char *p|NN const char *e
Es |char* |nextchar |NN struct RExC_state_t *state
@@ -1281,8 +1280,8 @@
Es |CHECKPOINT|regcppush |I32 parenfloor
Es |char*|regcppop
Es |void |cache_re |NN regexp *prog
-ERsn |U8* |reghop3 |NN U8 *pos|I32 off|NN U8 *lim
-ERsn |U8* |reghopmaybe3 |NN U8 *pos|I32 off|NN U8 *lim
+ERsn |U8* |reghop3 |NN U8 *pos|I32 off|NN const U8 *lim
+ERsn |U8* |reghopmaybe3 |NN U8 *pos|I32 off|NN const U8 *lim
ERs |char* |find_byclass |NN regexp * prog|NN const regnode *c|NN char
*s|NN const char *strend|I32 norun
Es |void |to_utf8_substr |NN regexp * prog
Es |void |to_byte_substr |NN regexp * prog
==== //depot/maint-5.8/perl/embed.h#144 (text+w) ====
Index: perl/embed.h
--- perl/embed.h#143~29980~ 2007-01-25 13:15:39.000000000 -0800
+++ perl/embed.h 2007-01-25 13:31:37.000000000 -0800
@@ -1265,7 +1265,6 @@
#define reg_node S_reg_node
#define regpiece S_regpiece
#define reginsert S_reginsert
-#define regoptail S_regoptail
#define regtail S_regtail
#define regwhite S_regwhite
#define nextchar S_nextchar
@@ -3350,7 +3349,6 @@
#define reg_node(a,b) S_reg_node(aTHX_ a,b)
#define regpiece(a,b) S_regpiece(aTHX_ a,b)
#define reginsert(a,b,c) S_reginsert(aTHX_ a,b,c)
-#define regoptail(a,b,c) S_regoptail(aTHX_ a,b,c)
#define regtail(a,b,c) S_regtail(aTHX_ a,b,c)
#define regwhite S_regwhite
#define nextchar(a) S_nextchar(aTHX_ a)
==== //depot/maint-5.8/perl/perlio.c#92 (text) ====
Index: perl/perlio.c
--- perl/perlio.c#91~29967~ 2007-01-25 02:34:50.000000000 -0800
+++ perl/perlio.c 2007-01-25 13:31:37.000000000 -0800
@@ -1411,11 +1411,11 @@
type = SvPV_const(layers, len);
if (type && mode[0] != 'r') {
/*
- * Skip to write part
+ * Skip to write part, which is separated by a '\0'
*/
- const char * const s = strchr(type, 0);
- if (s && (STRLEN)(s - type) < len) {
- type = s + 1;
+ STRLEN read_len = strlen(type);
+ if (read_len < len) {
+ type += read_len + 1;
}
}
}
==== //depot/maint-5.8/perl/pp_pack.c#51 (text) ====
Index: perl/pp_pack.c
--- perl/pp_pack.c#50~29980~ 2007-01-25 13:15:39.000000000 -0800
+++ perl/pp_pack.c 2007-01-25 13:31:37.000000000 -0800
@@ -721,20 +721,12 @@
const U8 * const end = start + len;
while (start < end) {
- U8 buffer[UTF8_MAXLEN];
- const int length =
- uvuni_to_utf8_flags(buffer, NATIVE_TO_UNI(*start), 0) - buffer;
- switch(length) {
- case 1:
- *dest++ = buffer[0];
- break;
- case 2:
- *dest++ = buffer[0];
- *dest++ = buffer[1];
- break;
- default:
- Perl_croak(aTHX_ "Perl bug: value %d UTF-8 expands to %d bytes",
- *start, length);
+ const UV uv = NATIVE_TO_ASCII(*start);
+ if (UNI_IS_INVARIANT(uv))
+ *dest++ = (char)(U8)UTF_TO_NATIVE(uv);
+ else {
+ *dest++ = (char)(U8)UTF8_EIGHT_BIT_HI(uv);
+ *dest++ = (char)(U8)UTF8_EIGHT_BIT_LO(uv);
}
start++;
}
==== //depot/maint-5.8/perl/proto.h#181 (text+w) ====
Index: perl/proto.h
--- perl/proto.h#180~29980~ 2007-01-25 13:15:39.000000000 -0800
+++ perl/proto.h 2007-01-25 13:31:37.000000000 -0800
@@ -1819,7 +1819,6 @@
STATIC regnode* S_reg_node(pTHX_ struct RExC_state_t *state, U8 op);
STATIC regnode* S_regpiece(pTHX_ struct RExC_state_t *state, I32
*flagp);
STATIC void S_reginsert(pTHX_ struct RExC_state_t *state, U8 op, regnode
*opnd);
-STATIC void S_regoptail(pTHX_ const struct RExC_state_t *state, regnode *p,
const regnode *val);
STATIC void S_regtail(pTHX_ const struct RExC_state_t *state, regnode *p,
const regnode *val);
STATIC char* S_regwhite(char *p, const char *e)
__attribute__warn_unused_result__;
@@ -1865,10 +1864,10 @@
STATIC CHECKPOINT S_regcppush(pTHX_ I32 parenfloor);
STATIC char* S_regcppop(pTHX);
STATIC void S_cache_re(pTHX_ regexp *prog);
-STATIC U8* S_reghop3(U8 *pos, I32 off, U8 *lim)
+STATIC U8* S_reghop3(U8 *pos, I32 off, const U8 *lim)
__attribute__warn_unused_result__;
-STATIC U8* S_reghopmaybe3(U8 *pos, I32 off, U8 *lim)
+STATIC U8* S_reghopmaybe3(U8 *pos, I32 off, const U8 *lim)
__attribute__warn_unused_result__;
STATIC char* S_find_byclass(pTHX_ regexp * prog, const regnode *c, char *s,
const char *strend, I32 norun)
==== //depot/maint-5.8/perl/regcomp.c#90 (text) ====
Index: perl/regcomp.c
--- perl/regcomp.c#89~29980~ 2007-01-25 13:15:39.000000000 -0800
+++ perl/regcomp.c 2007-01-25 13:31:37.000000000 -0800
@@ -2478,10 +2478,16 @@
}
regtail(pRExC_state, lastbr, ender);
- if (have_branch) {
+ if (have_branch && !SIZE_ONLY) {
/* Hook the tails of the branches to the closing node. */
- for (br = ret; br != NULL; br = regnext(br)) {
- regoptail(pRExC_state, br, ender);
+ for (br = ret; br; br = regnext(br)) {
+ const U8 op = PL_regkind[OP(br)];
+ if (op == BRANCH) {
+ regtail(pRExC_state, NEXTOPER(br), ender);
+ }
+ else if (op == BRANCHJ) {
+ regtail(pRExC_state, NEXTOPER(NEXTOPER(br)), ender);
+ }
}
}
}
@@ -4524,26 +4530,6 @@
}
/*
-- regoptail - regtail on operand of first argument; nop if operandless
-*/
-/* TODO: All three parms should be const */
-STATIC void
-S_regoptail(pTHX_ const RExC_state_t *pRExC_state, regnode *p, const regnode
*val)
-{
- /* "Operandless" and "op != BRANCH" are synonymous in practice. */
- if (p == NULL || SIZE_ONLY)
- return;
- if (PL_regkind[(U8)OP(p)] == BRANCH) {
- regtail(pRExC_state, NEXTOPER(p), val);
- }
- else if ( PL_regkind[(U8)OP(p)] == BRANCHJ) {
- regtail(pRExC_state, NEXTOPER(NEXTOPER(p)), val);
- }
- else
- return;
-}
-
-/*
- regcurly - a little FSA that accepts {\d+,?\d*}
*/
STATIC I32
==== //depot/maint-5.8/perl/regexec.c#79 (text) ====
Index: perl/regexec.c
--- perl/regexec.c#78~29964~ 2007-01-24 15:53:28.000000000 -0800
+++ perl/regexec.c 2007-01-25 13:31:37.000000000 -0800
@@ -127,7 +127,6 @@
: (U8*)NULL) \
)
-#define reghopmaybe3_c(pos,off,lim) ((char*)reghopmaybe3((U8*)pos, off,
(U8*)lim))
#define HOP3(pos,off,lim) (PL_reg_match_utf8 ? reghop3((U8*)pos, off,
(U8*)lim) : (U8*)(pos + off))
#define HOP3c(pos,off,lim) ((char*)HOP3(pos,off,lim))
@@ -600,7 +599,7 @@
t = s - prog->check_offset_max;
if (s - strpos > prog->check_offset_max /* signed-corrected t
> strpos */
&& (!do_utf8
- || ((t = reghopmaybe3_c(s, -(prog->check_offset_max),
strpos))
+ || ((t = (char*)reghopmaybe3((U8*)s,
-(prog->check_offset_max), (U8*)strpos))
&& t > strpos)))
NOOP;
else
@@ -721,7 +720,7 @@
t = s - prog->check_offset_max;
if (s - strpos > prog->check_offset_max /* signed-corrected t > strpos */
&& (!do_utf8
- || ((t = reghopmaybe3_c(s, -prog->check_offset_max, strpos))
+ || ((t = (char*)reghopmaybe3((U8*)s, -prog->check_offset_max,
(U8*)strpos))
&& t > strpos))) {
/* Fixed substring is found far enough so that the match
cannot start at strpos. */
@@ -4486,7 +4485,7 @@
}
STATIC U8 *
-S_reghop3(U8 *s, I32 off, U8* lim)
+S_reghop3(U8 *s, I32 off, const U8* lim)
{
if (off >= 0) {
while (off-- && s < lim) {
@@ -4510,7 +4509,7 @@
}
STATIC U8 *
-S_reghopmaybe3(U8* s, I32 off, U8* lim)
+S_reghopmaybe3(U8* s, I32 off, const U8* lim)
{
if (off >= 0) {
while (off-- && s < lim) {
==== //depot/maint-5.8/perl/sv.h#73 (text) ====
Index: perl/sv.h
--- perl/sv.h#72~29951~ 2007-01-24 08:24:04.000000000 -0800
+++ perl/sv.h 2007-01-25 13:31:37.000000000 -0800
@@ -687,7 +687,7 @@
=for apidoc Am|void|SvMAGIC_set|SV* sv|MAGIC* val
Set the value of the MAGIC pointer in sv to val. See C<SvIV_set>.
-=for apidoc Am|void|SvSTASH_set|SV* sv|STASH* val
+=for apidoc Am|void|SvSTASH_set|SV* sv|HV* val
Set the value of the STASH pointer in sv to val. See C<SvIV_set>.
=for apidoc Am|void|SvCUR_set|SV* sv|STRLEN len
End of Patch.