Patch against trunk attached.
Index: tcp.scm
===================================================================
--- tcp.scm     (revision 13272)
+++ tcp.scm     (working copy)
@@ -414,28 +414,33 @@
                              m
                              (loop n m start) ) ) ) ) )
               (lambda (p limit)        ; read-line
-                (let loop ((str #f))
+                (let loop ((str #f)
+                           (limit (or limit (##sys#fudge 21))))
                   (cond ((fx< bufindex buflen)
                          (##sys#scan-buffer-line
                           buf 
-                          buflen
+                          (fxmin buflen limit)
                           bufindex
                           (lambda (pos2 next)
-                            (let ((dest (##sys#make-string (fx- pos2 
bufindex))))
+                            (let* ((len (fx- pos2 bufindex))
+                                   (dest (##sys#make-string len)))
                               (##core#inline "C_substring_copy" buf dest 
bufindex pos2 0)
                               (set! bufindex next)
-                              (cond ((eq? pos2 next) ; no line-terminator 
encountered
+                              (cond ((eq? pos2 limit) ; no line-terminator, 
hit limit
+                                     (if str (##sys#string-append str dest) 
dest))
+                                    ((eq? pos2 next)  ; no line-terminator, 
hit buflen
                                      (read-input)
                                      (if (fx>= bufindex buflen)
                                          (or str "")
-                                         (loop (if str (##sys#string-append 
str dest) dest)) ) )
+                                         (loop (if str (##sys#string-append 
str dest) dest)
+                                               (fx- limit len)) ) )
                                     (else 
                                      (##sys#setislot p 4 (fx+ (##sys#slot p 4) 
1))
                                      (if str (##sys#string-append str dest) 
dest)) ) ) ) ) )
                         (else
                          (read-input)
                          (if (fx< bufindex buflen)
-                             (loop str)
+                             (loop str limit)
                              #!eof) ) ) ) ) ) )
             (output
              (lambda (s)
_______________________________________________
Chicken-hackers mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/chicken-hackers

Reply via email to