Author: particle
Date: Fri Dec 30 11:58:54 2005
New Revision: 10800

Modified:
   trunk/examples/pir/readline.pir
Log:
examples: fix readline example to deal with multi-char newlines

Modified: trunk/examples/pir/readline.pir
==============================================================================
--- trunk/examples/pir/readline.pir     (original)
+++ trunk/examples/pir/readline.pir     Fri Dec 30 11:58:54 2005
@@ -18,6 +18,8 @@ received the buffer is printed and the p
 
 =cut
 
+.include 'cclass.pasm'
+
 .sub "example" :main
         .local pmc stdin
         .local string buffer, line
@@ -29,6 +31,12 @@ AGAIN:
        line = readline stdin
        I1 = length line
        if I1 <= 1 goto MAINLOOP
+       # test for multi-char newlines
+       if I1 >=3 goto CONCAT
+       I2 = is_cclass .CCLASS_NEWLINE, line, 0
+       if I2, MAINLOOP
+
+CONCAT:
        concat buffer, line
        branch AGAIN
 

Reply via email to