Author: jonathan
Date: Tue Dec 9 06:12:00 2008
New Revision: 33710
Modified:
trunk/languages/perl6/src/classes/IO.pir
Log:
[rakudo] Implement auto-chomping, as mentioned in S29.
Modified: trunk/languages/perl6/src/classes/IO.pir
==============================================================================
--- trunk/languages/perl6/src/classes/IO.pir (original)
+++ trunk/languages/perl6/src/classes/IO.pir Tue Dec 9 06:12:00 2008
@@ -36,13 +36,15 @@
=cut
.sub 'lines' :method :multi('IO')
- .local pmc PIO, res
+ .local pmc PIO, res, chomper
PIO = getattribute self, "$!PIO"
res = new 'List'
+ chomper = get_hll_global 'chomp'
loop:
$S0 = PIO.'readline'()
unless $S0 goto done
+ $S0 = chomper($S0)
res.'push'($S0)
goto loop
@@ -113,10 +115,11 @@
=cut
.sub 'readline' :method
- .local pmc PIO
+ .local pmc PIO, chomper
PIO = getattribute self, "$!PIO"
$P0 = PIO.'readline'()
- .return ($P0)
+ chomper = get_hll_global 'chomp'
+ .tailcall chomper($P0)
.end
@@ -222,22 +225,25 @@
.end
.sub 'item' :method :vtable('shift_pmc')
- .local pmc pio
+ .local pmc pio, chomper
$P0 = getattribute self, "$!IO"
pio = getattribute $P0, "$!PIO"
$P0 = pio.'readline'()
- .return($P0)
+ chomper = get_hll_global 'chomp'
+ .tailcall chomper($P0)
.end
.sub 'list' :method
- .local pmc pio, res
+ .local pmc pio, res, chomper
$P0 = getattribute self, "$!IO"
pio = getattribute $P0, "$!PIO"
res = new 'List'
+ chomper = get_hll_global 'chomp'
loop:
$S0 = pio.'readline'()
if $S0 == '' goto done
+ $S0 = chomper($S0)
res.'push'($S0)
goto loop