Better fix for '-0x...' handling

This commit is contained in:
Tom Eastep 2009-04-21 07:08:47 -07:00
parent 846af27ebf
commit e465fea86a
2 changed files with 5 additions and 5 deletions

View File

@ -735,11 +735,13 @@ sub assert( $ ) {
# Convert value to decimal number # Convert value to decimal number
# #
sub numeric_value ( $ ) { sub numeric_value ( $ ) {
no warnings;
my $mark = lc $_[0]; my $mark = lc $_[0];
return undef unless $mark =~ /^-?(0x[a-f0-9]+|0[0-7]*|[1-9]\d*)$/; my $negative = ( $mark =~ s/^-// );
$mark =~ /^0/ ? oct $mark : $mark; return undef unless $mark =~ /^(0x[a-f0-9]+|0[0-7]*|[1-9]\d*)$/;
no warnings;
$mark = ( $mark =~ /^0/ ? oct $mark : $mark );
use warnings; use warnings;
$negative ? - $mark : $mark;
} }
sub numeric_value1 ( $ ) { sub numeric_value1 ( $ ) {

View File

@ -316,14 +316,12 @@ sub process_tc_rule( $$$$$$$$$$$$ ) {
if ( defined $m1 && $m1 ne '' ) { if ( defined $m1 && $m1 ne '' ) {
$val = numeric_value ($m1); $val = numeric_value ($m1);
fatal_error "Invalid Mask ($m1)" if $m1 =~ /^-0x/;
fatal_error "Invalid Mask ($m1)" unless defined $val && $val && $val <= 0xffffffff; fatal_error "Invalid Mask ($m1)" unless defined $val && $val && $val <= 0xffffffff;
$mask1 = $m1; $mask1 = $m1;
} }
if ( defined $m2 && $m2 ne '' ) { if ( defined $m2 && $m2 ne '' ) {
$val = numeric_value ($m2); $val = numeric_value ($m2);
fatal_error "Invalid Mask ($m2)" if $m2 =~ /^-0x/;
fatal_error "Invalid Mask ($m2)" unless defined $val && $val <= 0xffffffff; fatal_error "Invalid Mask ($m2)" unless defined $val && $val <= 0xffffffff;
$mask2 = $m2; $mask2 = $m2;
} }