X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?p=ypp-sc-tools.main.git;a=blobdiff_plain;f=yarrg%2Fweb%2Fcheck_capacitystring;h=b958dff46745e2ee4c4b3b8efdbaffce92c07c8b;hp=321d7540fcf31e9bf953c8574e30015de32351d4;hb=2aa3a575e41e6c9ed3b58e822dde0cf73502012b;hpb=02dade0af9916f9ab2102312900443a4f1c3a6fb diff --git a/yarrg/web/check_capacitystring b/yarrg/web/check_capacitystring index 321d754..b958dff 100644 --- a/yarrg/web/check_capacitystring +++ b/yarrg/web/check_capacitystring @@ -96,9 +96,9 @@ my $parse_values= sub { FROM commods WHERE commodname LIKE ?"); my ($emsg,$commod,@umv)= dbw_lookup_string($spec,$commodsth,1,0,0, - "No commodity or unit matches \`$spec'", - "Ambiguous commodity (or unit) \`$spec'", - undef); + "No commodity or unit matches ".escerrq($spec), + "Ambiguous commodity (or unit) ".escerrq($spec), + undef); expected_error($emsg) if defined $emsg; $debugf->("VALUE COMMOD FOUND '$commod' @umv"); foreach my $mvi (0,1) { @@ -109,7 +109,8 @@ my $parse_values= sub { push @canon, $commod; } else { s/\s+$//; - expected_error("Did not understand value \`$_'"); + expected_error("Did not understand value ". + escerrq($_)); } } }; @@ -131,14 +132,15 @@ my $parse_term= sub { push @canon, sprintf "%g%%", $pct; } elsif (!m/[^a-z]/i) { $debugf->("TERM NAME"); - expected_error("Name (should be unit or commodity) \`$_'". + expected_error("Name (should be unit or commodity)". + escerrq($_). " without preceding quantity") unless $first_term; my $sth= $dbh->prepare("SELECT name,mass,volume". " FROM vessels WHERE name LIKE ?"); my ($emsg,$ship,@smv)= dbw_lookup_string($_,$sth,1,1,2, - "Ship name `$_' not understood.", + "Ship name ".escerrq($_)." not understood.", "Too many matching ship types.", sub { "Ambiguous - could be $_[1]" }); expected_error($emsg) if defined $emsg; @@ -152,7 +154,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;