regcomp.c: Fix up parsing \N{} in a string
authorKarl Williamson <khw@cpan.org>
Tue, 6 Nov 2018 17:03:00 +0000 (10:03 -0700)
committerKarl Williamson <khw@cpan.org>
Fri, 16 Nov 2018 17:48:18 +0000 (10:48 -0700)
\N{} changes /d to /u, and may require reparsing of the current node to
fix wrong assumptions.

This commit is necessary for the simplifications achieved in the next
commit.

regcomp.c

index dfcbd44..ffe4bec 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -13846,6 +13846,24 @@ S_regatom(pTHX_ RExC_state_t *pRExC_state, I32 *flagp, U32 depth)
                         if (ender > 0xff) {
                             REQUIRE_UTF8(flagp);
                         }
+
+                        /* The \N{} means the pattern, if previously /d,
+                         * becomes /u.  That means it can't be an EXACTF node,
+                         * but an EXACTFU */
+                        if (node_type == EXACTF) {
+                            node_type = EXACTFU;
+
+                            /* If the node already contains something that
+                             * differs between EXACTF and EXACTFU, reparse it
+                             * as EXACTFU */
+                            if (! maybe_exactfu) {
+                                len = 0;
+                                s = s0;
+                                maybe_exactfu = TRUE;   /* Prob. unnecessary */
+                                goto reparse;
+                            }
+                        }
+
                         break;
                    case 'r':
                        ender = '\r';