regcomp.c: Centralize assignment
authorKarl Williamson <public@khwilliamson.com>
Sun, 21 Jul 2013 14:21:34 +0000 (08:21 -0600)
committerKarl Williamson <public@khwilliamson.com>
Tue, 24 Sep 2013 17:36:11 +0000 (11:36 -0600)
It's better to do something in one common place than two.  This properly
initializes the regex opcode for the synthetic start class when it is
created, rather than at the end where the code has to be repeated to get
all instances.

regcomp.c

index 5218395..3a17cc6 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -860,6 +860,7 @@ S_cl_init(const RExC_state_t *pRExC_state, struct regnode_charclass_class *cl)
     cl->type = ANYOF;
     cl_anything(pRExC_state, cl);
     ARG_SET(cl, ANYOF_NONBITMAP_EMPTY);
+    OP(cl) = ANYOF_SYNTHETIC;
 }
 
 /* These two functions currently do the exact same thing */
@@ -6307,7 +6308,6 @@ reStudy:
            && !cl_is_anything(data.start_class))
        {
            const U32 n = add_data(pRExC_state, 1, "f");
-           OP(data.start_class) = ANYOF_SYNTHETIC;
 
            Newx(RExC_rxi->data->data[n], 1,
                struct regnode_charclass_class);
@@ -6380,7 +6380,6 @@ reStudy:
            && !cl_is_anything(data.start_class))
        {
            const U32 n = add_data(pRExC_state, 1, "f");
-           OP(data.start_class) = ANYOF_SYNTHETIC;
 
            Newx(RExC_rxi->data->data[n], 1,
                struct regnode_charclass_class);