From bc010ceffee1c91b7e9ac6024423fb6eb3a8e177 Mon Sep 17 00:00:00 2001 From: tipaul Date: Tue, 10 Feb 2004 13:51:20 +0000 Subject: [PATCH] improving handling of (,),.,* ... in translator tool. --- misc/translator/tmpl_process.pl | 72 +++++++++------------------------ 1 file changed, 18 insertions(+), 54 deletions(-) diff --git a/misc/translator/tmpl_process.pl b/misc/translator/tmpl_process.pl index 49021bc974..a7aaa9a2c2 100755 --- a/misc/translator/tmpl_process.pl +++ b/misc/translator/tmpl_process.pl @@ -119,25 +119,6 @@ sub install_strhash my $starttime = time(); $out_dir =~ s/\/$//; # chops the trailing / if any. - foreach my $text (keys %{$strhash}) - { - # escaping \|()[{}^$*+?. - %{$strhash}->{$text} =~ s/\\/\\\\/g; -# %{$strhash}->{$text} =~ s/\//\\\//g; - %{$strhash}->{$text} =~ s/\|/\\\|/g; - %{$strhash}->{$text} =~ s/\(/\\\(/g; - %{$strhash}->{$text} =~ s/\)/\\\)/g; - %{$strhash}->{$text} =~ s/\[/\\\[/g; - %{$strhash}->{$text} =~ s/\]/\\\]/g; - %{$strhash}->{$text} =~ s/\{/\\\{/g; - %{$strhash}->{$text} =~ s/\}/\\\}/g; - %{$strhash}->{$text} =~ s/\^/\\\^/g; - %{$strhash}->{$text} =~ s/\$/\\\$/g; - %{$strhash}->{$text} =~ s/\*/\\\*/g; - %{$strhash}->{$text} =~ s/\+/\\\+/g; - %{$strhash}->{$text} =~ s/\?/\\\?/g; -# %{$strhash}->{$text} =~ s/\./\\\./g; - } # Processes every entry found. foreach my $file (@{$in_files}) { @@ -199,53 +180,36 @@ sub install_strhash if( %{$strhash}->{$text} != 1) { # Does the file contains text that needs to be changed ? - if( $lines =~ /$text/ && %{$strhash}->{$text} ne "IGNORE" ) + # escaping \|()[{}^$*+?. + my $subst = %{$strhash}->{$text}; + $text =~ s/\\/\\\\/g; + $text =~ s/\//\\\//g; + $text =~ s/\|/\\\|/g; + $text =~ s/\(/\\\(/g; + $text =~ s/\)/\\\)/g; + $text =~ s/\[/\\\[/g; + $text =~ s/\]/\\\]/g; + $text =~ s/\{/\\\{/g; + $text =~ s/\}/\\\}/g; + $text =~ s/\^/\\\^/g; + $text =~ s/\$/\\\$/g; + $text =~ s/\*/\\\*/g; + $text =~ s/\+/\\\+/g; + $text =~ s/\?/\\\?/g; + $text =~ s/\./\\\./g; + if(%{$strhash}->{$text} ne "IGNORE" ) { if (%{$strhash}->{$text} =~ "LIMITED") { # changing text - my $subst = %{$strhash}->{$text}; $subst =~ s/UNUSED;//; - # escaping \|()[{}^$*+?. - $text =~ s/\\/\\\\/g; - $text =~ s/\//\\\//g; - $text =~ s/\|/\\\|/g; - $text =~ s/\(/\\\(/g; - $text =~ s/\)/\\\)/g; - $text =~ s/\[/\\\[/g; - $text =~ s/\]/\\\]/g; - $text =~ s/\{/\\\{/g; - $text =~ s/\}/\\\}/g; - $text =~ s/\^/\\\^/g; - $text =~ s/\$/\\\$/g; - $text =~ s/\*/\\\*/g; - $text =~ s/\+/\\\+/g; - $text =~ s/\?/\\\?/g; - $text =~ s/\./\\\./g; $subst =~ s/^LIMITED;//g; $lines =~ s/(.*)>$text(\W)/$1>$subst$2/g; $lines =~ s/(.*) title="$text/$1 title="$subst/g; $lines =~ s/(.*) alt="$text/$1 alt="$subst/g; } else { # changing text - my $subst = %{$strhash}->{$text}; $subst =~ s/UNUSED;//; - # escaping \|()[{}^$*+?. - $text =~ s/\\/\\\\/g; - $text =~ s/\//\\\//g; - $text =~ s/\|/\\\|/g; - $text =~ s/\(/\\\(/g; - $text =~ s/\)/\\\)/g; - $text =~ s/\[/\\\[/g; - $text =~ s/\]/\\\]/g; - $text =~ s/\{/\\\{/g; - $text =~ s/\}/\\\}/g; - $text =~ s/\^/\\\^/g; - $text =~ s/\$/\\\$/g; - $text =~ s/\*/\\\*/g; - $text =~ s/\+/\\\+/g; - $text =~ s/\?/\\\?/g; - $text =~ s/\./\\\./g; $lines =~ s/(\W)$text(\W)/$1$subst$2/g; } } -- 2.39.5