X-Git-Url: https://git.sesse.net/?p=remoteglot;a=blobdiff_plain;f=remoteglot.pl;h=6b423f691573fafa8c85761e5e4abc41cb6e0754;hp=28bebd25cfcf57de6e1685b83b202e9c03ebb70f;hb=d3db57677e015c6e3371df0acb7549447a9db771;hpb=9dd7122b75bf598f16a18a70bc8b2eb519d0796b diff --git a/remoteglot.pl b/remoteglot.pl index 28bebd2..6b423f6 100755 --- a/remoteglot.pl +++ b/remoteglot.pl @@ -23,7 +23,7 @@ my $target = "22"; my $engine = "wine Rybkav2.3.2a.mp.w32.exe"; my $telltarget = undef; # undef to be silent my @tell_intervals = (5, 20, 60, 120, 240, 480, 960); # after each move -my $uci_assume_full_compliance = 0; # dangerous :-) +my $uci_assume_full_compliance = 1; # dangerous :-) # Program starts here $SIG{ALRM} = sub { output_screen(); }; @@ -154,7 +154,27 @@ while (1) { # any fun on the UCI channel? if ($nfound > 0 && vec($rout, fileno(UCIREAD), 1) == 1) { - my $line = ; + # + # Read until we've got a full line -- if the engine sends part of + # a line and then stops we're pretty much hosed, but that should + # never happen. + # + my $line = ''; + while ($line !~ /\n/) { + my $tmp; + my $ret = sysread UCIREAD, $tmp, 1; + + if (!defined($ret)) { + next if ($!{EINTR}); + die "error in reading from the UCI engine: $!"; + } elsif ($ret == 0) { + die "EOF from UCI engine"; + } + + $line .= $tmp; + } + + $line =~ tr/\r\n//d; handle_uci($line); $sleep = 0;