summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtools/genlang37
1 files changed, 21 insertions, 16 deletions
diff --git a/tools/genlang b/tools/genlang
index 19b637d237..33adb2c7e3 100755
--- a/tools/genlang
+++ b/tools/genlang
@@ -121,7 +121,23 @@ if(!$target && !$update && !$sortfile) {
121 print STDERR "Please specify a target (with -t)!\n"; 121 print STDERR "Please specify a target (with -t)!\n";
122 exit; 122 exit;
123} 123}
124my @target_parts = split ':', $target; 124
125# Build up a regex which can be applied to target wildcard lists. We only need
126# to support prefix matches, so a target parameter of foo:bar can be expanded
127# to the regex "\*|f\*|fo\*|foo|b\*|ba\*|bar" and applied to the wildcard list
128# (plus end-of-string or commas on either side). The regex engine should
129# discard any duplicates generated for us in the process of constructing the
130# state machine, so we don't bother to check.
131my $target_regex = "(?:^|,) *(?:\\*";
132foreach my $target_part (split ':', $target) {
133 for (my $c=1; $c<length $target_part; $c++) {
134 my $partial = substr $target_part, 0, $c;
135 $target_regex .= "|$partial\\*";
136 }
137 $target_regex .= "|$target_part";
138}
139$target_regex .= ") *(?:,|\$)";
140$target_regex = qr/$target_regex/;
125 141
126my $binpath = ""; 142my $binpath = "";
127if ($binary =~ m|(.*)/[^/]+|) { 143if ($binary =~ m|(.*)/[^/]+|) {
@@ -178,21 +194,10 @@ sub options {
178sub parsetarget { 194sub parsetarget {
179 my ($debug, $strref, $full, $n, $v)=@_; 195 my ($debug, $strref, $full, $n, $v)=@_;
180 my $string; 196 my $string;
181 my @all= split(" *, *", $n); 197 if ($n =~ $target_regex) {
182 my $test; 198 $string = $v;
183 for $test (@all) { 199 $$strref = $string;
184 $test =~ s/\*/.*/g; 200 return $string;
185 $test =~ s/\?/./g;
186
187# print "TEST ($debug) $target for $test\n";
188 for my $part (@target_parts) {
189 if($part =~ /^$test\z/) {
190 $string = $v;
191# print "MATCH: $test => $v\n";
192 $$strref = $string;
193 return $string;
194 }
195 }
196 } 201 }
197} 202}
198 203