chiark / gitweb /
commodity ordering: new "commodsinorder" mode
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 31 Oct 2009 15:51:30 +0000 (15:51 +0000)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sat, 31 Oct 2009 15:51:30 +0000 (15:51 +0000)
yarrg/commod-results-processor

index 36804d35d64c34f25f07fbb22a0de06ad8ee9454..de65f1b903be775ea4e331e46206bc552b0b7ceb 100755 (executable)
@@ -39,7 +39,7 @@ use Commods;
 # $commod{'Hemp'}{Hold}
 
 our @v;
-our ($commod,$stall,%commod);
+our ($commod,$stall,%commod,@commods_inorder);
 
 @ARGV==1 or die "You probably don't want to run this program directly.\n";
 our ($mode) = shift @ARGV;
@@ -64,6 +64,7 @@ while (<>) {
     @v= split /\t/;
 #print STDERR "[".join("|",@v)."]\n";
     ($commod,$stall) = @v;
+    push @commods_inorder, $commod unless exists $commod{$commod};
     bs_read(Buy,  2);
     bs_read(Sell, 4);
     $commod{$commod}{Hold}= $v[6]+0 if @v>6;
@@ -226,6 +227,28 @@ sub main__tsv () {
     write_tsv(\*STDOUT);
 }
 
+sub main__commodsinorder () {
+    parse_info_serverside();
+    my $last_ov;
+    foreach my $commod (@commods_inorder) {
+       my $ov= $commods{$commod}{Ordval};
+       printf("found\t%-40s %10s",
+              $commod,
+              defined $ov ? $ov : '?')
+           or die $!;
+       if (defined $ov) {
+           if (defined $last_ov && $ov <= $last_ov) {
+               print " out-of-order" or die $!;
+           }
+           $last_ov= $ov;
+       }
+       print "\n" or die $!;
+    }
+    foreach my $commod (sort keys %commods) {
+       next if exists $commod{$commod};
+       printf "missing\t%s\n", $commod or die $!;
+    }
+}
 
 our ($pctb) = $ENV{'YPPSC_YARRG_PCTB'};