summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2011-07-01 09:31:18 -0600
committerKarl Williamson <public@khwilliamson.com>2011-07-03 14:05:49 -0600
commit77f9f1269361fb5553d7dde5338d210cedd76e80 (patch)
tree75e7f5f37dde49ee7a996e1b153f7d638e79b9fa /utf8.c
parentd73c39c516d283552da40a4edb8a2139e3e48da4 (diff)
downloadperl-77f9f1269361fb5553d7dde5338d210cedd76e80.tar.gz
utf8.c: Accept INVERT_IT in swash
This allows a swash to return a list, along with an extra key in the hash which says that the list should be inverted. A future commit will generate such keys.
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/utf8.c b/utf8.c
index e437ce53cc..797c8112e9 100644
--- a/utf8.c
+++ b/utf8.c
@@ -2358,7 +2358,7 @@ STATIC SV*
S_swash_get(pTHX_ SV* swash, UV start, UV span)
{
SV *swatch;
- U8 *l, *lend, *x, *xend, *s;
+ U8 *l, *lend, *x, *xend, *s, *send;
STRLEN lcur, xcur, scur;
HV *const hv = MUTABLE_HV(SvRV(swash));
@@ -2369,6 +2369,7 @@ S_swash_get(pTHX_ SV* swash, UV start, UV span)
SV** const bitssvp = hv_fetchs(hv, "BITS", FALSE);
SV** const nonesvp = hv_fetchs(hv, "NONE", FALSE);
SV** const extssvp = hv_fetchs(hv, "EXTRAS", FALSE);
+ SV** const invert_it_svp = hv_fetchs(hv, "INVERT_IT", FALSE);
const U8* const typestr = (U8*)SvPV_nolen(*typesvp);
const STRLEN bits = SvUV(*bitssvp);
const STRLEN octets = bits >> 3; /* if bits == 1, then octets == 0 */
@@ -2471,6 +2472,15 @@ S_swash_get(pTHX_ SV* swash, UV start, UV span)
} /* while */
go_out_list:
+ /* Invert if the data says it should be */
+ if (invert_it_svp && SvUV(*invert_it_svp)) {
+ send = s + scur;
+ while (s < send) {
+ *s = ~(*s);
+ s++;
+ }
+ }
+
/* read $swash->{EXTRAS}
* This code also copied to swash_to_invlist() below */
x = (U8*)SvPV(*extssvp, xcur);
@@ -2891,6 +2901,7 @@ Perl__swash_to_invlist(pTHX_ SV* const swash)
SV** const typesvp = hv_fetchs(hv, "TYPE", FALSE);
SV** const bitssvp = hv_fetchs(hv, "BITS", FALSE);
SV** const extssvp = hv_fetchs(hv, "EXTRAS", FALSE);
+ SV** const invert_it_svp = hv_fetchs(hv, "INVERT_IT", FALSE);
const U8* const typestr = (U8*)SvPV_nolen(*typesvp);
const STRLEN bits = SvUV(*bitssvp);
@@ -2948,6 +2959,11 @@ Perl__swash_to_invlist(pTHX_ SV* const swash)
_append_range_to_invlist(invlist, start, end);
}
+ /* Invert if the data says it should be */
+ if (invert_it_svp && SvUV(*invert_it_svp)) {
+ _invlist_invert(invlist);
+ }
+
/* This code is copied from swash_get()
* read $swash->{EXTRAS} */
x = (U8*)SvPV(*extssvp, xcur);