ruby-changes:53825
From: duerst <ko1@a...>
Date: Wed, 28 Nov 2018 06:12:36 +0900 (JST)
Subject: [ruby-changes:53825] duerst:r66043 (trunk): declare array for sequence at start of code creating sequence
duerst 2018-11-28 06:12:29 +0900 (Wed, 28 Nov 2018) New Revision: 66043 https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=66043 Log: declare array for sequence at start of code creating sequence In function node_extended_grapheme_cluster(), move declaration up so that block encompasses all of the regular expression creation that finally makes up the sequence. Having blocks like this will be great because it directly shows the extent of code belonging to each subexpression of the regular expression being created. Modified files: trunk/regparse.c Index: regparse.c =================================================================== --- regparse.c (revision 66042) +++ regparse.c (revision 66043) @@ -5901,20 +5901,18 @@ node_extended_grapheme_cluster(Node** np https://github.com/ruby/ruby/blob/trunk/regparse.c#L5901 np1 = NULL; /* L* LVT T* */ - r = quantify_property_node(&np1, env, "Grapheme_Cluster_Break=L", 0, REPEAT_INFINITE); - if (r != 0) goto err; - r = create_property_node(&np2, env, "Grapheme_Cluster_Break=LVT"); - if (r != 0) goto err; - r = quantify_property_node(&np3, env, "Grapheme_Cluster_Break=T", 0, REPEAT_INFINITE); - if (r != 0) goto err; + { + Node* seq[4]; + + r = quantify_property_node(seq+0, env, "Grapheme_Cluster_Break=L", 0, REPEAT_INFINITE); + if (r != 0) goto err; + r = create_property_node(seq+1, env, "Grapheme_Cluster_Break=LVT"); + if (r != 0) goto err; + r = quantify_property_node(seq+2, env, "Grapheme_Cluster_Break=T", 0, REPEAT_INFINITE); + if (r != 0) goto err; - { /* poor man's varargs :-) */ - Node* sequence[] = { NULL_NODE, NULL_NODE, NULL_NODE, NULL_NODE }; - sequence[0] = np1; - sequence[1] = np2; - sequence[2] = np3; - create_sequence_node(&list2, sequence); - np1 = np2 = np3 = NULL; + seq[3] = NULL_NODE; + create_sequence_node(&list2, seq); } tmp = onig_node_new_alt(list2, alt); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/