regexec.c: Use get method instead of internals
authorKarl Williamson <public@khwilliamson.com>
Fri, 24 Aug 2012 20:38:02 +0000 (14:38 -0600)
committerKarl Williamson <public@khwilliamson.com>
Sun, 26 Aug 2012 05:21:29 +0000 (23:21 -0600)
A new get method has been written to access the internals of a swash
it's best to use it.

This also moves the error checking to the method

regcomp.c
regexec.c
utf8.c

index c856c08..5a77176 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -11602,11 +11602,7 @@ parseit:
                                              NULL, /* No inversion list */
                                              &swash_init_flags
                                             );
-                    if (   ! swash
-                        || ! SvROK(swash)
-                        || ! SvTYPE(SvRV(swash)) == SVt_PVHV
-                        || ! (invlist = _get_swash_invlist(swash)))
-                   {
+                    if (! swash || ! (invlist = _get_swash_invlist(swash))) {
                         if (swash) {
                             SvREFCNT_dec(swash);
                             swash = NULL;
index 9ddfdb4..5da40f8 100644 (file)
--- a/regexec.c
+++ b/regexec.c
@@ -6740,20 +6740,14 @@ S_core_regclass_swash(pTHX_ const regexp *prog, register const regnode* node, bo
        
     if (listsvp) {
        SV* matches_string = newSVpvn("", 0);
-       SV** invlistsvp;
 
        /* Use the swash, if any, which has to have incorporated into it all
         * possibilities */
-       if (   sw
-           && SvROK(sw)
-           && SvTYPE(SvRV(sw)) == SVt_PVHV
-           && (invlistsvp = hv_fetchs(MUTABLE_HV(SvRV(sw)), "INVLIST", FALSE)))
-       {
-           invlist = *invlistsvp;
-       }
-       else if (si && si != &PL_sv_undef) {
+       if ((! sw || (invlist = _get_swash_invlist(sw)) == NULL)
+            && (si && si != &PL_sv_undef))
+        {
 
-           /* If no swash, use the input nitialization string, if available */
+           /* If no swash, use the input initialization string, if available */
            sv_catsv(matches_string, si);
        }
 
diff --git a/utf8.c b/utf8.c
index 6c43f82..b12d82c 100644 (file)
--- a/utf8.c
+++ b/utf8.c
@@ -4142,10 +4142,16 @@ Perl__swash_to_invlist(pTHX_ SV* const swash)
 SV*
 Perl__get_swash_invlist(pTHX_ SV* const swash)
 {
-    SV** ptr = hv_fetchs(MUTABLE_HV(SvRV(swash)), "INVLIST", FALSE);
+    SV** ptr;
 
     PERL_ARGS_ASSERT__GET_SWASH_INVLIST;
 
+    if (! SvROK(swash) || SvTYPE(SvRV(swash)) != SVt_PVHV) {
+        return NULL;
+    }
+
+    ptr = hv_fetchs(MUTABLE_HV(SvRV(swash)), "INVLIST", FALSE);
+
     if (! ptr) {
         return NULL;
     }