]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
improve regular expression to parse Jerusalem timezone files
authorRussell Treleaven <rtreleaven@bunnykick.ca>
Thu, 25 Sep 2014 17:18:07 +0000 (13:18 -0400)
committerRussell Treleaven <rtreleaven@bunnykick.ca>
Thu, 25 Sep 2014 17:24:21 +0000 (13:24 -0400)
The previous regular expression failed to parse 32 timezone files
including Jersusalem. All timezone files are parsed(hopefully correctly)
by this regular expression.
fs-4762 paritally address.

scripts/perl/timezone-gen.pl

index 281f88556ca63dc8754ea6a678e08920068a0aab..6127005062252c2cf87ae29e8801ea7cc43ea321 100755 (executable)
@@ -55,16 +55,13 @@ foreach my $name ( sort( keys(%name_to_file) ) ) {
     my $data = join( "", <$in> );
     close($in);
 
-    if ( $data !~ /^TZif/o ) {
+    my @strings = $data =~ (m/[ -~]{4,}/g);
+    if ( shift(@strings) !~ /^TZif/o ) {
         $debug && print "Skipped $file\n";
         next;
     }
 
-    my $tmp = $data;
-    $tmp =~ s/\n$//s;
-    $tmp =~ s/.*\n//sgmo;
-
-    $zones{$name} = $tmp;
+    $zones{$name} = pop(@strings);
 }
 
 open( my $out, ">$output" );