Ticket #9156: 9156.patch

File 9156.patch, 1.7 KB (added by AlfonZ, 6 years ago)
  • i18n/convstyle.pl

     
    55
    66use strict;
    77
     8my $rule_cond; # cumulated conditions from current rule
     9
    810# This is a simple conversion and in no way a complete XML parser
    911# but it works with a default Perl installation
    1012
     
    2022  {
    2123    print "/* mappaint style named $1 */ tr($1);\n";
    2224  }
     25  elsif($line =~ /<rule\s*>/)
     26  {
     27    $rule_cond = "";
     28    print "/* $line */\n";
     29  }
     30  elsif($line =~ /<condition.*\s+k="([^"]*)"/)
     31  {
     32    my $cond_k = $1; # according to schema, k is always present
     33    my $cond_v = ($line =~ /\s+v="([^"]*)"/) ? $1 : "";
     34    my $cond_b = ($line =~ /\s+b="([^"]*)"/) ? $1 : "";
     35    print STDERR "$0: Found both v=\"$cond_v\" and b=\"$cond_b\" for k=\"$cond_k\" at line $.\n" if ($cond_v && $cond_b);
     36    my $cond = ($cond_v || $cond_b) ? "$cond_k=$cond_v$cond_b" : "$cond_k"; # v and b shouldn't appear both
     37    if ($rule_cond)
     38    {
     39      $rule_cond .= ", " . $cond;
     40    }
     41    else
     42    {
     43      $rule_cond = $cond;
     44    }
     45    print "/* $line */\n";
     46  }
    2347  elsif($line =~ /colour="([^"]+)#/)
    2448  {
    25     my $c = $1;
    26     my $co = $1;
    27     $c =~ s/[^a-z0-9]+/./g;
    28     print "/* color $co */ tr(\"$c\");\n";
     49    if ($line =~ /\s+colour="([^"]+)#/)
     50    {
     51      my $c = $1;
     52      my $co = $1;
     53      $c =~ s/[^a-z0-9]+/./g;
     54      print "/* color $co (applied for \"$rule_cond\") */ tr(\"$c\");";
     55    }
     56    if ($line =~ /\s+dashedcolour="([^"]+)#/)
     57    {
     58      my $c = $1;
     59      my $co = $1;
     60      $c =~ s/[^a-z0-9]+/./g;
     61      print "/* color $co (applied for \"$rule_cond\") */ tr(\"$c\");";
     62    }
     63    print "\n";
    2964  }
    3065  else
    3166  {