From a10bb7062ae5ca43734cc842e4ecbb7604c30e36 Mon Sep 17 00:00:00 2001 From: acli Date: Fri, 13 Feb 2004 03:49:26 +0000 Subject: [PATCH] Handle leading or trailing  's as leading or trailing spaces. Make sure they are all trimmed off. $re_end_entity is now used (by the above); there are  's (no ;) in our templates. --- misc/translator/text-extract2.pl | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/misc/translator/text-extract2.pl b/misc/translator/text-extract2.pl index 513a1407a9..250ac25658 100755 --- a/misc/translator/text-extract2.pl +++ b/misc/translator/text-extract2.pl @@ -224,6 +224,15 @@ sub debug_dump (*) { # for testing only ############################################################################### +sub trim ($) { + my($s) = @_; + $s =~ s/^(?:\s|\ $re_end_entity)+//os; + $s =~ s/(?:\s|\ $re_end_entity)+$//os; + return $s; +} + +############################################################################### + sub text_extract (*) { my($h) = @_; my %text = (); @@ -232,7 +241,7 @@ sub text_extract (*) { last unless defined $s; my($kind, $t, $attr) = @$s; # FIXME if ($kind eq KIND_TEXT) { - $t =~ s/\s+$//s; + $t = trim $t; $text{$t} = 1 if $t =~ /\S/s; } elsif ($kind eq KIND_TAG && %$attr) { # value [tag=input], meta @@ -243,7 +252,7 @@ sub text_extract (*) { next if $a eq 'value' && ($tag ne 'input' || (ref $attr->{'type'} && $attr->{'type'}->[1] eq 'hidden')); # FIXME my($key, $val, $val_orig, $order) = @{$attr->{$a}}; #FIXME - $val =~ s/\s+$//s; + $val = trim $val; $text{$val} = 1 if $val =~ /\S/s; } } @@ -251,7 +260,8 @@ sub text_extract (*) { } # Emit all extracted strings. Don't emit pure whitespace or pure numbers. for my $t (keys %text) { - printf "%s\n", $t unless $t =~ /^(?:\s|\ )*$/s || $t =~ /^\d+$/; + printf "%s\n", $t + unless $t =~ /^(?:\s|\ $re_end_entity)*$/os || $t =~ /^\d+$/; } } -- 2.39.5