[Koha-cvs] CVS: koha/misc/translator text-extract2.pl,1.17,1.18

Ambrose Li acli at users.sourceforge.net
Fri Feb 13 04:49:29 CET 2004


Update of /cvsroot/koha/koha/misc/translator
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24697

Modified Files:
	text-extract2.pl 
Log Message:
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 &nbsp's (no ;)
in our templates.


Index: text-extract2.pl
===================================================================
RCS file: /cvsroot/koha/koha/misc/translator/text-extract2.pl,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -r1.17 -r1.18
*** text-extract2.pl	13 Feb 2004 02:42:06 -0000	1.17
--- text-extract2.pl	13 Feb 2004 03:49:26 -0000	1.18
***************
*** 225,228 ****
--- 225,237 ----
  ###############################################################################
  
+ sub trim ($) {
+     my($s) = @_;
+     $s =~ s/^(?:\s|\&nbsp$re_end_entity)+//os;
+     $s =~ s/(?:\s|\&nbsp$re_end_entity)+$//os;
+     return $s;
+ }
+ 
+ ###############################################################################
+ 
  sub text_extract (*) {
      my($h) = @_;
***************
*** 233,237 ****
  	my($kind, $t, $attr) = @$s; # FIXME
  	if ($kind eq KIND_TEXT) {
! 	    $t =~ s/\s+$//s;
  	    $text{$t} = 1 if $t =~ /\S/s;
  	} elsif ($kind eq KIND_TAG && %$attr) {
--- 242,246 ----
  	my($kind, $t, $attr) = @$s; # FIXME
  	if ($kind eq KIND_TEXT) {
! 	    $t = trim $t;
  	    $text{$t} = 1 if $t =~ /\S/s;
  	} elsif ($kind eq KIND_TAG && %$attr) {
***************
*** 244,248 ****
  			|| (ref $attr->{'type'} && $attr->{'type'}->[1] eq 'hidden')); # FIXME
  		    my($key, $val, $val_orig, $order) = @{$attr->{$a}}; #FIXME
! 		    $val =~ s/\s+$//s;
  		    $text{$val} = 1 if $val =~ /\S/s;
  		}
--- 253,257 ----
  			|| (ref $attr->{'type'} && $attr->{'type'}->[1] eq 'hidden')); # FIXME
  		    my($key, $val, $val_orig, $order) = @{$attr->{$a}}; #FIXME
! 		    $val = trim $val;
  		    $text{$val} = 1 if $val =~ /\S/s;
  		}
***************
*** 252,256 ****
      # 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+$/;
      }
  }
--- 261,266 ----
      # Emit all extracted strings. Don't emit pure whitespace or pure numbers.
      for my $t (keys %text) {
! 	printf "%s\n", $t
! 	    unless $t =~ /^(?:\s|\&nbsp$re_end_entity)*$/os || $t =~ /^\d+$/;
      }
  }





More information about the Koha-cvs mailing list