diff --git a/regparse.c b/regparse.c index aa96a4c371..bba1825c57 100644 --- a/regparse.c +++ b/regparse.c @@ -5750,6 +5750,15 @@ quantify_node(Node **np, int lower, int upper) return 0; } +static int +quantify_property_node(Node **np, ScanEnv* env, const char* propname, int lower, int upper) +{ + int r; + r = create_property_node(np, env, propname); + if (r != 0) return r; + return quantify_node(np, lower, upper); +} + static int node_extended_grapheme_cluster(Node** np, ScanEnv* env) { @@ -5849,9 +5858,7 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env) /* these are equivalent, so we leave things as is for the moment */ /* T+ */ - r = create_property_node(&np1, env, "Grapheme_Cluster_Break=T"); - if (r != 0) goto err; - r = quantify_node(&np1, 1, REPEAT_INFINITE); + r = quantify_property_node(&np1, env, "Grapheme_Cluster_Break=T", 1, REPEAT_INFINITE); if (r != 0) goto err; tmp = onig_node_new_alt(np1, alt); @@ -5860,9 +5867,7 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env) np1 = NULL; /* L+ */ - r = create_property_node(&np1, env, "Grapheme_Cluster_Break=L"); - if (r != 0) goto err; - r = quantify_node(&np1, 1, REPEAT_INFINITE); + r = quantify_property_node(&np1, env, "Grapheme_Cluster_Break=L", 1, REPEAT_INFINITE); if (r != 0) goto err; tmp = onig_node_new_alt(np1, alt); @@ -5871,9 +5876,7 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env) np1 = NULL; /* L* LVT T* */ - r = create_property_node(&np1, env, "Grapheme_Cluster_Break=T"); - if (r != 0) goto err; - r = quantify_node(&np1, 0, REPEAT_INFINITE); + r = quantify_property_node(&np1, env, "Grapheme_Cluster_Break=T", 0, REPEAT_INFINITE); if (r != 0) goto err; tmp = node_new_list(np1, NULL_NODE); @@ -5889,10 +5892,7 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env) list2 = tmp; np1 = NULL; - r = create_property_node(&np1, env, "Grapheme_Cluster_Break=L"); - if (r != 0) goto err; - - r = quantify_node(&np1, 0, REPEAT_INFINITE); + r = quantify_property_node(&np1, env, "Grapheme_Cluster_Break=L", 0, REPEAT_INFINITE); if (r != 0) goto err; tmp = node_new_list(np1, list2); @@ -5906,9 +5906,7 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env) list2 = NULL; /* L* LV V* T* */ - r = create_property_node(&np1, env, "Grapheme_Cluster_Break=T"); - if (r != 0) goto err; - r = quantify_node(&np1, 0, REPEAT_INFINITE); + r = quantify_property_node(&np1, env, "Grapheme_Cluster_Break=T", 0, REPEAT_INFINITE); if (r != 0) goto err; tmp = node_new_list(np1, NULL_NODE); @@ -5916,9 +5914,7 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env) list2 = tmp; np1 = NULL; - r = create_property_node(&np1, env, "Grapheme_Cluster_Break=V"); - if (r != 0) goto err; - r = quantify_node(&np1, 0, REPEAT_INFINITE); + r = quantify_property_node(&np1, env, "Grapheme_Cluster_Break=V", 0, REPEAT_INFINITE); if (r != 0) goto err; tmp = node_new_list(np1, list2); @@ -5934,9 +5930,7 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env) list2 = tmp; np1 = NULL; - r = create_property_node(&np1, env, "Grapheme_Cluster_Break=L"); - if (r != 0) goto err; - r = quantify_node(&np1, 0, REPEAT_INFINITE); + r = quantify_property_node(&np1, env, "Grapheme_Cluster_Break=L", 0, REPEAT_INFINITE); if (r != 0) goto err; tmp = node_new_list(np1, list2); @@ -5950,9 +5944,7 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env) list2 = NULL; /* L* V+ T* */ - r = create_property_node(&np1, env, "Grapheme_Cluster_Break=T"); - if (r != 0) goto err; - r = quantify_node(&np1, 0, REPEAT_INFINITE); + r = quantify_property_node(&np1, env, "Grapheme_Cluster_Break=T", 0, REPEAT_INFINITE); if (r != 0) goto err; tmp = node_new_list(np1, NULL_NODE); @@ -5960,9 +5952,7 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env) list2 = tmp; np1 = NULL; - r = create_property_node(&np1, env, "Grapheme_Cluster_Break=V"); - if (r != 0) goto err; - r = quantify_node(&np1, 1, REPEAT_INFINITE); + r = quantify_property_node(&np1, env, "Grapheme_Cluster_Break=V", 1, REPEAT_INFINITE); if (r != 0) goto err; tmp = node_new_list(np1, list2); @@ -5970,9 +5960,7 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env) list2 = tmp; np1 = NULL; - r = create_property_node(&np1, env, "Grapheme_Cluster_Break=L"); - if (r != 0) goto err; - r = quantify_node(&np1, 0, REPEAT_INFINITE); + r = quantify_property_node(&np1, env, "Grapheme_Cluster_Break=L", 0, REPEAT_INFINITE); if (r != 0) goto err; tmp = node_new_list(np1, list2); @@ -5991,9 +5979,7 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env) * (ZWJ (Glue_After_Zwj | EBG Extend* E_Modifier?) )* */ /* ZWJ (Glue_After_Zwj | E_Base_GAZ Extend* E_Modifier?) */ - r = create_property_node(&np1, env, "Grapheme_Cluster_Break=E_Modifier"); - if (r != 0) goto err; - r = quantify_node(&np1, 0, 1); + r = quantify_property_node(&np1, env, "Grapheme_Cluster_Break=E_Modifier", 0, 1); if (r != 0) goto err; tmp = node_new_list(np1, NULL_NODE); @@ -6001,9 +5987,7 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env) list2 = tmp; np1 = NULL; - r = create_property_node(&np1, env, "Grapheme_Cluster_Break=Extend"); - if (r != 0) goto err; - r = quantify_node(&np1, 0, REPEAT_INFINITE); + r = quantify_property_node(&np1, env, "Grapheme_Cluster_Break=Extend", 0, REPEAT_INFINITE); if (r != 0) goto err; tmp = node_new_list(np1, list2); @@ -6026,9 +6010,7 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env) /* Unicode 10.0.0 */ /* Glue_After_Zwj */ - r = create_property_node(&np1, env, "Grapheme_Cluster_Break=Extend"); - if (r != 0) goto err; - r = quantify_node(&np1, 0, REPEAT_INFINITE); + r = quantify_property_node(&np1, env, "Grapheme_Cluster_Break=Extend", 0, REPEAT_INFINITE); if (r != 0) goto err; tmp = node_new_list(np1, NULL_NODE); @@ -6120,9 +6102,7 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env) np1 = NULL; /* E_Modifier? */ - r = create_property_node(&np1, env, "Grapheme_Cluster_Break=E_Modifier"); - if (r != 0) goto err; - r = quantify_node(&np1, 0, 1); + r = quantify_property_node(&np1, env, "Grapheme_Cluster_Break=E_Modifier", 0, 1); if (r != 0) goto err; tmp = node_new_list(np1, list2); @@ -6131,9 +6111,7 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env) np1 = NULL; /* Extend* */ - r = create_property_node(&np1, env, "Grapheme_Cluster_Break=Extend"); - if (r != 0) goto err; - r = quantify_node(&np1, 0, REPEAT_INFINITE); + r = quantify_property_node(&np1, env, "Grapheme_Cluster_Break=Extend", 0, REPEAT_INFINITE); if (r != 0) goto err; tmp = node_new_list(np1, list2); @@ -6171,9 +6149,7 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env) * has such examples. * http://www.unicode.org/Public/9.0.0/ucd/auxiliary/GraphemeBreakTest.html */ - r = create_property_node(&np1, env, "Grapheme_Cluster_Break=E_Modifier"); - if (r != 0) goto err; - r = quantify_node(&np1, 0, 1); + r = quantify_property_node(&np1, env, "Grapheme_Cluster_Break=E_Modifier", 0, 1); if (r != 0) goto err; tmp = node_new_list(np1, NULL_NODE); @@ -6213,9 +6189,7 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env) /* this is actually Regional_Indicator+ in Unicode 10.0.0, * but it is Regional_Indicator{2} in Unicode 11.0.0, so no need to fix */ /* RI-Sequence := Regional_Indicator{2} */ - r = create_property_node(&np1, env, "Regional_Indicator"); - if (r != 0) goto err; - r = quantify_node(&np1, 2, 2); + r = quantify_property_node(&np1, env, "Regional_Indicator", 2, 2); if (r != 0) goto err; tmp = node_new_list(np1, list2); @@ -6234,9 +6208,7 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env) alt = NULL; /* Prepend* */ - r = create_property_node(&np1, env, "Grapheme_Cluster_Break=Prepend"); - if (r != 0) goto err; - r = quantify_node(&np1, 0, REPEAT_INFINITE); + r = quantify_property_node(&np1, env, "Grapheme_Cluster_Break=Prepend", 0, REPEAT_INFINITE); if (r != 0) goto err; tmp = node_new_list(np1, list); @@ -6274,9 +6246,7 @@ node_extended_grapheme_cluster(Node** np, ScanEnv* env) list2 = tmp; np1 = NULL; - r = create_property_node(&np1, env, "Grapheme_Cluster_Break=Prepend"); - if (r != 0) goto err; - r = quantify_node(&np1, 1, REPEAT_INFINITE); + r = quantify_property_node(&np1, env, "Grapheme_Cluster_Break=Prepend", 1, REPEAT_INFINITE); if (r != 0) goto err; tmp = node_new_list(np1, list2);