summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authorKarl Williamson <public@khwilliamson.com>2011-09-27 22:14:29 -0600
committerKarl Williamson <public@khwilliamson.com>2011-10-01 09:30:40 -0600
commit89302fc2b7e207df41192d739797e3f18a46ba34 (patch)
treeaacf72b62ef3166801b37a065ef2ae9a6e22b467 /regcomp.c
parent4364919aeabf66edaa6fb40631f8fed89f4bcfe2 (diff)
downloadperl-89302fc2b7e207df41192d739797e3f18a46ba34.tar.gz
regcomp.c: Add invlist_invert_prop()
This new function inverts a Unicode property. A regular inversion doesn't work because it operates on the whole of the code space, and Unicode property inversions don't invert above-Unicode code points. This does for inversion lists, what an earlier commit did for swashes. This function is currently not called by anyone.
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/regcomp.c b/regcomp.c
index 1fa5e24541..a75f9fe587 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -6568,6 +6568,44 @@ Perl__invlist_invert(pTHX_ SV* const invlist)
(*len_pos)++;
}
}
+
+void
+Perl__invlist_invert_prop(pTHX_ SV* const invlist)
+{
+ /* Complement the input inversion list (which must be a Unicode property,
+ * all of which don't match above the Unicode maximum code point.) And
+ * Perl has chosen to not have the inversion match above that either. This
+ * adds a 0x110000 if the list didn't end with it, and removes it if it did
+ */
+
+ UV len;
+ UV* array;
+
+ PERL_ARGS_ASSERT__INVLIST_INVERT_PROP;
+
+ _invlist_invert(invlist);
+
+ len = invlist_len(invlist);
+
+ if (len != 0) { /* If empty do nothing */
+ array = invlist_array(invlist);
+ if (array[len - 1] != PERL_UNICODE_MAX + 1) {
+ /* Add 0x110000. First, grow if necessary */
+ len++;
+ if (invlist_max(invlist) < len) {
+ invlist_extend(invlist, len);
+ array = invlist_array(invlist);
+ }
+ invlist_set_len(invlist, len);
+ array[len - 1] = PERL_UNICODE_MAX + 1;
+ }
+ else { /* Remove the 0x110000 */
+ invlist_set_len(invlist, len - 1);
+ }
+ }
+
+ return;
+}
#endif
PERL_STATIC_INLINE SV*