X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;f=yarrg%2Fweb%2Fcheck_capacitystring;h=52eab28264836ca8208e49a82a16db9beb8e3597;hb=9d1a4c0589b1588ef4cbabaae70e19946de7212b;hp=3c779727ea005d2ce3e6766a59702bbb1c937890;hpb=422fab9f34f08090bca02f67cb41bba31f816c7e;p=ypp-sc-tools.db-test.git diff --git a/yarrg/web/check_capacitystring b/yarrg/web/check_capacitystring index 3c77972..52eab28 100644 --- a/yarrg/web/check_capacitystring +++ b/yarrg/web/check_capacitystring @@ -85,9 +85,12 @@ my $parse_values= sub { elsif (s/^( $fqtyrex ) \s* t \s+ //xo) { $def->(0, $1 * 1000.0 ); } elsif (s/^( $fqtyrex ) \s* l \s+ //xo) { $def->(1, $1 ); } elsif (s/^( $fqtyrex ) \s* kl \s+ //xo) { $def->(1, $1 * 1000.0 ); } - elsif (s/^( $iqtyrex ) \s* ([a-z ]+) \s+ //xo) { + elsif (s/^( $iqtyrex ) \s* ([a-z ]+) \s+ //ixo) { my ($qty,$spec) = ($1,$2); $debugf->("VALUE COMMOD $qty '$spec'"); + expected_error("Capacity specification must start with". + " ship size or amount with units") + if $first_term; $commodsth ||= $dbh->prepare("SELECT commodname,unitmass,unitvolume FROM commods WHERE commodname LIKE ?"); @@ -126,7 +129,7 @@ my $parse_term= sub { $_ *= $pct / 100.0; } push @canon, sprintf "%g%%", $pct; - } elsif (!m/[^a-z]/) { + } elsif (!m/[^a-z]/i) { $debugf->("TERM NAME"); expected_error("Name (should be unit or commodity) \`$_'". " without preceding quantity") @@ -137,7 +140,7 @@ my $parse_term= sub { dbw_lookup_string($_,$sth,1,1,2, "Ship name `$_' not understood.", "Too many matching ship types.", - sub { "Ambiguous - could be $_[0]" }); + sub { "Ambiguous - could be $_[1]" }); expected_error($emsg) if defined $emsg; $debugf->("TERM NAME SHIP '$ship' @smv"); $show_answer= 1; @@ -149,7 +152,7 @@ my $parse_term= sub { $first_term= 0; }; -while ($string =~ s/^(.*?)(\bminus\b|-|\bplus\b|\+)//) { +while ($string =~ s/^(.*?)(\bminus\b|-|\bplus\b|\+)//i) { my ($lhs)= ($1); my @nextsign= $2 =~ m/^p|^\+/ ? (+1,'+') : (-1,'-'); $show_answer= 1;