From a08eb37aafd19cb62b1d58d188547fb14b27fbb8 Mon Sep 17 00:00:00 2001 From: andi Date: Sat, 11 Jun 2005 14:10:59 +0200 Subject: spellchecker: compensate for aspell error and blocking problems Sometimes Aspell seems to output not enough blank lines to signal a line change. This patch tries to compensate for this by trying the next two lines as well. This patch also fixes a problem were reading from aspell could produce a deadlock on the socket and would cause the spellchecker to never return darcs-hash:20050611121059-9977f-c772aa52ea0e73e7b7e5537afda047fa44a22395.gz --- inc/aspell.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'inc') diff --git a/inc/aspell.php b/inc/aspell.php index 8267fb839..c0dc429bd 100644 --- a/inc/aspell.php +++ b/inc/aspell.php @@ -178,11 +178,14 @@ class Aspell{ foreach($data as $line){ fwrite($pipes[0],"^$line\n"); // aspell uses ^ to escape the line fflush($pipes[0]); + $line = ''; do{ - $r = fgets($pipes[1],8192); - $out .= $r; + $r = fread($pipes[1],1); + $line .= $r; if(feof($pipes[1])) break; - }while($r != "\n"); + if($r == "\n") break; + }while($line != "\n"); + $out .= $line; } fclose($pipes[0]); -- cgit v1.2.3