Permalink
Browse files

Merge branch 'fix-socket-get-2' of https://github.com/gerdr/rakudo in…

…to nom
  • Loading branch information...
moritz committed Mar 12, 2013
2 parents 8104125 + f54e210 commit a98aa70e787a3e4ff9bf48d81f71798517fcb4ad
Showing with 21 additions and 10 deletions.
  1. +21 −10 src/core/IO/Socket/INET.pm
View
@@ -91,20 +91,31 @@ my class IO::Socket::INET does IO::Socket {
}
method get() {
++$!ins;
my Mu $PIO := nqp::getattr(self, $?CLASS, '$!PIO');
$PIO.encoding(nqp::unbox_s(PARROT_ENCODING(self.encoding)));
my str $line = $PIO.readline(nqp::unbox_s($!input-line-separator));
my str $sep = $!input-line-separator;
my int $len = nqp::chars($line);
my str $encoding = nqp::unbox_s(PARROT_ENCODING($!encoding));
my str $sep = pir::trans_encoding__SSI(
nqp::unbox_s($!input-line-separator),
pir::find_encoding__IS($encoding));
my int $sep-len = nqp::chars($sep);
$len >= $sep-len && nqp::substr($line, $len - $sep-len) eq nqp::unbox_s($sep)
?? nqp::p6box_s(nqp::substr($line, 0, $len - $sep-len))
!! nqp::p6box_s($line);
my Mu $PIO := nqp::getattr(self, $?CLASS, '$!PIO');
$PIO.encoding($encoding);
my str $line = $PIO.readline($sep);
my int $len = nqp::chars($line);
if $len == 0 { Str }
else {
++$!ins;
$len >= $sep-len && nqp::substr($line, $len - $sep-len) eq $sep
?? nqp::p6box_s(nqp::substr($line, 0, $len - $sep-len))
!! nqp::p6box_s($line);
}
}
method lines() {
gather { take self.get() };
gather while (my $line = self.get()).defined {
take $line;
}
}
method accept() {

0 comments on commit a98aa70

Please sign in to comment.