X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2Futf8_heavy.pl;h=8649e9e07e77ebfe20dff3af16cacc2f1b1f2d3b;hb=cc8461762c7674cd719f8f7e4a4e54252a249ef9;hp=e00db32ababe1e7366bc3293440a41ac0e26db08;hpb=0fa1278611917eb19e7164fbdbdc98dab8368e2a;p=p5sagit%2Fp5-mst-13.2.git diff --git a/lib/utf8_heavy.pl b/lib/utf8_heavy.pl index e00db32..8649e9e 100644 --- a/lib/utf8_heavy.pl +++ b/lib/utf8_heavy.pl @@ -38,7 +38,7 @@ sub SWASHNEW { if ($list) { my @tmp = split(/^/m, $list); my %seen; - local $^W = 0; + no warnings; $extras = join '', grep /^[^0-9a-fA-F]/, @tmp; $list = join '', sort { hex $a <=> hex $b } @@ -69,7 +69,7 @@ sub SWASHNEW { my @extras; for my $x ($extras) { pos $x = 0; - while ($x =~ /^([^0-9a-fA-F])(.*)/mg) { + while ($x =~ /^([^0-9a-fA-F\n])(.*)/mg) { my $char = $1; my $name = $2; # print STDERR "$1 => $2\n" if $DEBUG; @@ -99,10 +99,10 @@ sub SWASHNEW { sub SWASHGET { my ($self, $start, $len) = @_; local $^D = 0 if $^D; - print STDERR "SWASHGET @_\n" if $DEBUG; my $type = $self->{TYPE}; my $bits = $self->{BITS}; my $none = $self->{NONE}; + print STDERR "SWASHGET @_ [$type/$bits/$none]\n" if $DEBUG; my $end = $start + $len; my $swatch = ""; my $key; @@ -123,8 +123,7 @@ sub SWASHGET { # print "$min $max $val\n"; if ($none) { if ($min < $start) { - $val += $start - $min; - $val = $none if $val > $none; + $val += $start - $min if $val < $none; $min = $start; } for ($key = $min; $key <= $max; $key++) { @@ -166,45 +165,43 @@ sub SWASHGET { } for my $x ($self->{EXTRAS}) { pos $x = 0; - while ($x =~ /^([^0-9a-fA-F])(.*)/mg) { + while ($x =~ /^([-+!])(.*)/mg) { my $char = $1; my $name = $2; print STDERR "INDIRECT $1 $2\n" if $DEBUG; - if ($char =~ /^[-+!]$/) { - my $otherbits = $self->{$name}->{BITS}; - croak("SWASHGET size mismatch") if $bits < $otherbits; - my $other = $self->{$name}->SWASHGET($start, $len); - if ($char eq '+') { - if ($bits == 1 and $otherbits == 1) { - $swatch |= $other; - } - else { - for ($key = 0; $key < $len; $key++) { - vec($swatch, $key, $bits) = vec($other, $key, $otherbits); - } - } + my $otherbits = $self->{$name}->{BITS}; + croak("SWASHGET size mismatch") if $bits < $otherbits; + my $other = $self->{$name}->SWASHGET($start, $len); + if ($char eq '+') { + if ($bits == 1 and $otherbits == 1) { + $swatch |= $other; } - elsif ($char eq '!') { - if ($bits == 1 and $otherbits == 1) { - $swatch |= ~$other; + else { + for ($key = 0; $key < $len; $key++) { + vec($swatch, $key, $bits) = vec($other, $key, $otherbits); } - else { - for ($key = 0; $key < $len; $key++) { - if (!vec($other, $key, $otherbits)) { - vec($swatch, $key, $bits) = 1; - } + } + } + elsif ($char eq '!') { + if ($bits == 1 and $otherbits == 1) { + $swatch |= ~$other; + } + else { + for ($key = 0; $key < $len; $key++) { + if (!vec($other, $key, $otherbits)) { + vec($swatch, $key, $bits) = 1; } } } - elsif ($char eq '-') { - if ($bits == 1 and $otherbits == 1) { - $swatch &= ~$other; - } - else { - for ($key = 0; $key < $len; $key++) { - if (vec($other, $key, $otherbits)) { - vec($swatch, $key, $bits) = 0; - } + } + elsif ($char eq '-') { + if ($bits == 1 and $otherbits == 1) { + $swatch &= ~$other; + } + else { + for ($key = 0; $key < $len; $key++) { + if (vec($other, $key, $otherbits)) { + vec($swatch, $key, $bits) = 0; } } }