regcomp.c: Rework static function call; comments
authorKarl Williamson <public@khwilliamson.com>
Wed, 14 Aug 2013 16:01:53 +0000 (10:01 -0600)
committerKarl Williamson <public@khwilliamson.com>
Tue, 24 Sep 2013 17:36:13 +0000 (11:36 -0600)
The previous commit just extracted out code into a function.  This
commit renames a parameter for clarity, combines two parameters to make
the interface cleaner, and adds and moves comments around.

embed.fnc
embed.h
proto.h
regcomp.c

index e34af13..c328e3a 100644 (file)
--- a/embed.fnc
+++ b/embed.fnc
@@ -2005,10 +2005,9 @@ Es       |regnode*|regbranch     |NN struct RExC_state_t *pRExC_state \
 Es     |STRLEN |reguni         |NN const struct RExC_state_t *pRExC_state \
                                |UV uv|NN char *s
 Es     |void    |set_ANYOF_arg |NN struct RExC_state_t* const pRExC_state \
-                               |NN regnode* const ret                     \
+                               |NN regnode* const node                    \
                                |NULLOK SV* const cp_list                  \
-                               |NN SV* const listsv                       \
-                               |const STRLEN initial_listsv_len           \
+                               |NULLOK SV* const runtime_defns            \
                                |NULLOK SV* const swash                    \
                                |const bool has_user_defined_property
 Es     |regnode*|regclass      |NN struct RExC_state_t *pRExC_state \
diff --git a/embed.h b/embed.h
index 0a7087d..a0ce45c 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define reguni(a,b,c)          S_reguni(aTHX_ a,b,c)
 #define regwhite               S_regwhite
 #define scan_commit(a,b,c,d)   S_scan_commit(aTHX_ a,b,c,d)
-#define set_ANYOF_arg(a,b,c,d,e,f,g)   S_set_ANYOF_arg(aTHX_ a,b,c,d,e,f,g)
+#define set_ANYOF_arg(a,b,c,d,e,f)     S_set_ANYOF_arg(aTHX_ a,b,c,d,e,f)
 #define study_chunk(a,b,c,d,e,f,g,h,i,j,k)     S_study_chunk(aTHX_ a,b,c,d,e,f,g,h,i,j,k)
 #  endif
 #  if defined(PERL_IN_REGCOMP_C) || defined (PERL_IN_DUMP_C)
diff --git a/proto.h b/proto.h
index 6f41f4f..81fb87f 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -6835,12 +6835,11 @@ STATIC void     S_scan_commit(pTHX_ const struct RExC_state_t *pRExC_state, struct s
 #define PERL_ARGS_ASSERT_SCAN_COMMIT   \
        assert(pRExC_state); assert(data); assert(minlenp)
 
-STATIC void    S_set_ANYOF_arg(pTHX_ struct RExC_state_t* const pRExC_state, regnode* const ret, SV* const cp_list, SV* const listsv, const STRLEN initial_listsv_len, SV* const swash, const bool has_user_defined_property)
+STATIC void    S_set_ANYOF_arg(pTHX_ struct RExC_state_t* const pRExC_state, regnode* const node, SV* const cp_list, SV* const runtime_defns, SV* const swash, const bool has_user_defined_property)
                        __attribute__nonnull__(pTHX_1)
-                       __attribute__nonnull__(pTHX_2)
-                       __attribute__nonnull__(pTHX_4);
+                       __attribute__nonnull__(pTHX_2);
 #define PERL_ARGS_ASSERT_SET_ANYOF_ARG \
-       assert(pRExC_state); assert(ret); assert(listsv)
+       assert(pRExC_state); assert(node)
 
 STATIC SSize_t S_study_chunk(pTHX_ struct RExC_state_t *pRExC_state, regnode **scanp, SSize_t *minlenp, SSize_t *deltap, regnode *last, struct scan_data_t *data, I32 stopparen, U8* recursed, regnode_ssc *and_withp, U32 flags, U32 depth)
                        __attribute__nonnull__(pTHX_1)
index 538cf32..581d4a4 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -14029,52 +14029,57 @@ parseit:
     }
 
     set_ANYOF_arg(pRExC_state, ret, cp_list,
-                  listsv, initial_listsv_len,
+                  (HAS_NONLOCALE_RUNTIME_PROPERTY_DEFINITION)
+                   ? listsv : NULL,
                   swash, has_user_defined_property);
 
     *flagp |= HASWIDTH|SIMPLE;
     return ret;
 }
 
+#undef HAS_NONLOCALE_RUNTIME_PROPERTY_DEFINITION
+
 STATIC void
 S_set_ANYOF_arg(pTHX_ struct RExC_state_t* const pRExC_state,
-                regnode* const ret,
+                regnode* const node,
                 SV* const cp_list,
-                SV* const listsv, const STRLEN initial_listsv_len,
+                SV* const runtime_defns,
                 SV* const swash,
                 const bool has_user_defined_property)
 {
+    /* Sets the arg field of an ANYOF-type node 'node', using information about
+     * the node passed-in.  If there is nothing outside the node's bitmap, the
+     * arg is set to ANYOF_NONBITMAP_EMPTY.  Otherwise, it sets the argument to
+     * the count returned by add_data(), having allocated and stored an array,
+     * av, that that count references, as follows:
+     *  av[0] stores the character class description in its textual form.
+     *        This is used later (regexec.c:Perl_regclass_swash()) to
+     *        initialize the appropriate swash, and is also useful for dumping
+     *        the regnode.  This is set to &PL_sv_undef if the textual
+     *        description is not needed at run-time (as happens if the other
+     *        elements completely define the class)
+     *  av[1] if &PL_sv_undef, is a placeholder to later contain the swash
+     *        computed from av[0].  But if no further computation need be done,
+     *        the swash is stored there now (and av[0] is &PL_sv_undef).
+     *  av[2] stores the cp_list inversion list for use in addition or instead
+     *        of av[0]; used only if cp_list exists and av[1] is &PL_sv_undef.
+     *        (Otherwise everything needed is already in av[0] and av[1])
+     *  av[3] is set if any component of the class is from a user-defined
+     *        property; used only if av[2] exists */
+
     UV n;
 
     PERL_ARGS_ASSERT_SET_ANYOF_ARG;
 
-    if (! cp_list
-       && ! HAS_NONLOCALE_RUNTIME_PROPERTY_DEFINITION)
-    {
-       ARG_SET(ret, ANYOF_NONBITMAP_EMPTY);
+    if (! cp_list && ! runtime_defns) {
+       ARG_SET(node, ANYOF_NONBITMAP_EMPTY);
     }
     else {
-        /* av[0] stores the character class description in its textual form.
-         *       This is used later (regexec.c:Perl_regclass_swash()) to
-         *       initialize the appropriate swash, and is also useful for
-         *       dumping the regnode.  This is set to &PL_sv_undef if the
-         *       textual description is not needed at run-time (as happens if
-         *       the other elements completely define the class)
-         * av[1] if &PL_sv_undef, is a placeholder to later contain the swash
-         *       computed from av[0].  But if no further computation need be
-         *       done, the swash is stored there now (and av[0] is
-         *       &PL_sv_undef).
-        * av[2] stores the cp_list inversion list for use in addition or
-         *       instead of av[0]; used only if cp_list exists and av[1] is
-         *       &PL_sv_undef.  (Otherwise everything needed is already in
-         *       av[0] and av[1])
-        * av[3] is set if any component of the class is from a user-defined
-        *       property; used only if av[2] exists */
        AV * const av = newAV();
        SV *rv;
 
-       av_store(av, 0, (HAS_NONLOCALE_RUNTIME_PROPERTY_DEFINITION)
-                       ? SvREFCNT_inc(listsv) : &PL_sv_undef);
+       av_store(av, 0, (runtime_defns)
+                       ? SvREFCNT_inc(runtime_defns) : &PL_sv_undef);
        if (swash) {
            av_store(av, 1, swash);
            SvREFCNT_dec_NN(cp_list);
@@ -14090,12 +14095,10 @@ S_set_ANYOF_arg(pTHX_ struct RExC_state_t* const pRExC_state,
        rv = newRV_noinc(MUTABLE_SV(av));
        n = add_data(pRExC_state, 1, "s");
        RExC_rxi->data->data[n] = (void*)rv;
-       ARG_SET(ret, n);
+       ARG_SET(node, n);
     }
 }
 
-#undef HAS_NONLOCALE_RUNTIME_PROPERTY_DEFINITION
-
 
 /* reg_skipcomment()