From ac6465ba700e55c42fa1499db9aa3f5497c98bbb Mon Sep 17 00:00:00 2001 From: "Artyom V. Poptsov" Date: Thu, 29 Oct 2015 21:37:39 +0300 Subject: node.scm (rrepl-get-result): Add a sub-procedure * modules/ssh/dist/node.scm (rrepl-get-result) : New sub-procedure. : Use it. --- modules/ssh/dist/node.scm | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'modules/ssh/dist') diff --git a/modules/ssh/dist/node.scm b/modules/ssh/dist/node.scm index ead5ebf..b579b1c 100644 --- a/modules/ssh/dist/node.scm +++ b/modules/ssh/dist/node.scm @@ -188,17 +188,18 @@ name. Throw 'node-repl-error' on an error." (loop (read-line repl-channel) (string-append result "\n" line))))) + (define (parse-result 1st-match) + (let loop ((line (read-line repl-channel)) + (matches (list 1st-match))) + (if (or (eof-or-null? line) + (regexp-exec %repl-undefined-result-regexp line)) + (reverse matches) + (loop (read-line repl-channel) + (cons (regexp-exec %repl-result-2-regexp line) matches))))) + (define (read-result match) - (let* ((matches - (let loop ((line (read-line repl-channel)) - (matches (list match))) - (if (or (eof-or-null? line) - (regexp-exec %repl-undefined-result-regexp line)) - (reverse matches) - (loop (read-line repl-channel) - (cons (regexp-exec %repl-result-2-regexp line) - matches))))) - (len (length matches))) + (let* ((matches (parse-result match)) + (len (length matches))) (if (= len 1) (let ((m (car matches))) (values (read-string (match:substring m 4)) -- cgit v1.2.3