chiark / gitweb /
Add technically-missing semicolon.
[ypp-sc-tools.db-live.git] / pctb / Commods.pm
index b348c17812373ab72405c9eebdfd8a0a4c56c977..955446f402f48719943af31844cc17e9742649a1 100644 (file)
@@ -206,14 +206,14 @@ sub pipethrough_run_along ($$$@) {
     if (!$child) {
        open STDIN, "<&", $tf;
        &$childprep() if defined $childprep;
-       exec $cmd @a; die $!;
+       exec $cmd @a; die "@a $!";
     }
     return $fh;
 }
-sub pipethrough_run_finish ($) {
-    my ($fh)= @_;
+sub pipethrough_run_finish ($$) {
+    my ($fh, $what)= @_;
     $fh->error and die $!;
-    close $fh or die "$! $?";  die $? if $?;
+    close $fh or die "$what $! $?";  die $? if $?;
 }
 
 sub pipethrough_run ($$$@) {
@@ -222,7 +222,7 @@ sub pipethrough_run ($$$@) {
     my $r;
     { undef $/; $!=0; $r= <$pt>; }
     defined $r or die $!;
-    pipethrough_run_finish($pt);
+    pipethrough_run_finish($pt, "@a");
     return $r;
 }
 sub pipethrough_run_gzip ($) {
@@ -275,7 +275,6 @@ sub check_tsv_line ($$) {
     chomp($l) or &$bad_data('missing end-of-line');
 
     $l !~ m/\P{IsPrint}/ or &$bad_data('nonprinting char(s)');
-    $l !~ m/\\/ or &$bad_data('data contains backslashes');
     my @v= split /\t/, $l, -1;
     @v==6 or &$bad_data('wrong number of fields');
     my ($commod,$stall) = @v;
@@ -292,6 +291,14 @@ sub check_tsv_line ($$) {
        $f =~ m/^(|0|[1-9][0-9]{0,5}|\>1000)$/ or &$bad_data("bad field $i");
        ($i % 2) or ($f !~ m/\>/) or &$bad_data("> in field $i price");
     }
+
+    foreach my $i (2,4) {
+       &$bad_data("price with no qty or vice versa (field $i)")
+           if length($v[$i]) xor length($v[$i+1]);
+    }
+    length($v[2]) or length($v[4]) or
+       &$bad_data("commodity entry with no buy or sell offer");
+    
     return @v;
 }