summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorkarl williamson <public@khwilliamson.com>2008-11-05 11:42:16 -0700
committerDavid Mitchell <davem@iabyn.com>2009-01-05 20:59:43 +0000
commit223f428994e176e66ea910f6fc1c59be58c44497 (patch)
treee441370b48f6606bab2097650980daabc27af893 /regcomp.c
parente2e39fcceab23a76ef1286d497aae405e36e4efc (diff)
downloadperl-223f428994e176e66ea910f6fc1c59be58c44497.tar.gz
Reolve perlbug #59328: In re's, \N{U+...} doesn't match for ... > 256
Subject: PATCH [perl #59328] In re's, \N{U+...} doesn't match for ... > 256 Message-ID: <49124B78.2000907@khwilliamson.com> Date: Wed, 05 Nov 2008 18:42:16 -0700 p4raw-id: //depot/perl@34747 (cherry picked from commit a4893424bce3ee5da2b2e8e1c256b806c74bfb50)
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/regcomp.c b/regcomp.c
index fcc97252a1..caa94f08a2 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -6529,20 +6529,30 @@ S_reg_namedseq(pTHX_ RExC_state_t *pRExC_state, UV *valuep)
| PERL_SCAN_DISALLOW_PREFIX
| (SIZE_ONLY ? PERL_SCAN_SILENT_ILLDIGIT : 0);
UV cp;
- char string;
len = (STRLEN)(endbrace - name - 2);
cp = grok_hex(name + 2, &len, &fl, NULL);
if ( len != (STRLEN)(endbrace - name - 2) ) {
cp = 0xFFFD;
}
- if (cp > 0xff)
- RExC_utf8 = 1;
if ( valuep ) {
+ if (cp > 0xff) RExC_utf8 = 1;
*valuep = cp;
return NULL;
}
- string = (char)cp;
- sv_str= newSVpvn(&string, 1);
+
+ /* Need to convert to utf8 if either: won't fit into a byte, or the re
+ * is going to be in utf8 and the representation changes under utf8. */
+ if (cp > 0xff || (RExC_utf8 && ! UNI_IS_INVARIANT(cp))) {
+ U8 string[UTF8_MAXBYTES+1];
+ U8 *tmps;
+ RExC_utf8 = 1;
+ tmps = uvuni_to_utf8(string, cp);
+ sv_str = newSVpvn_utf8((char*)string, tmps - string, TRUE);
+ } else { /* Otherwise, no need for utf8, can skip that step */
+ char string;
+ string = (char)cp;
+ sv_str= newSVpvn(&string, 1);
+ }
} else {
/* fetch the charnames handler for this scope */
HV * const table = GvHV(PL_hintgv);
@@ -6721,7 +6731,7 @@ S_reg_namedseq(pTHX_ RExC_state_t *pRExC_state, UV *valuep)
Set_Node_Cur_Length(ret); /* MJD */
RExC_parse--;
nextchar(pRExC_state);
- } else {
+ } else { /* zero length */
ret = reg_node(pRExC_state,NOTHING);
}
if (!cached) {