ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Coro/Coro/Handle.pm
(Generate patch)

Comparing Coro/Coro/Handle.pm (file contents):
Revision 1.50 by root, Tue Sep 30 17:12:35 2008 UTC vs.
Revision 1.51 by root, Mon Oct 6 10:05:28 2008 UTC

520 return $res; 520 return $res;
521} 521}
522 522
523sub READLINE { 523sub READLINE {
524 my $irs = @_ > 1 ? $_[1] : $/; 524 my $irs = @_ > 1 ? $_[1] : $/;
525 my $ofs;
525 526
526 while() { 527 while() {
527 if (defined $irs) { 528 if (defined $irs) {
528 my $pos = index $_[0][3], $irs; 529 my $pos = index $_[0][3], $irs, $ofs < 0 ? 0 : $ofs;
529 if ($pos >= 0) { 530 if ($pos >= 0) {
530 $pos += length $irs; 531 $pos += length $irs;
531 my $res = substr $_[0][3], 0, $pos; 532 my $res = substr $_[0][3], 0, $pos;
532 substr ($_[0][3], 0, $pos) = ""; 533 substr ($_[0][3], 0, $pos) = "";
533 return $res; 534 return $res;
534 } 535 }
536
537 $ofs = length $_[0][3] - length $irs;
535 } 538 }
536 539
537 my $r = sysread $_[0][0], $_[0][3], 8192, length $_[0][3]; 540 my $r = sysread $_[0][0], $_[0][3], 8192, length $_[0][3];
538 if (defined $r) { 541 if (defined $r) {
539 return length $_[0][3] ? delete $_[0][3] : undef unless $r; 542 return length $_[0][3] ? delete $_[0][3] : undef unless $r;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines