[Pkg-gnupg-commit] [gnupg2] 23/292: tests: Refine the repl function.
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Mon Nov 21 06:31:22 UTC 2016
This is an automated email from the git hooks/post-receive script.
dkg pushed a commit to branch master
in repository gnupg2.
commit 884e78efe1f3ba50513bf81c8b4804d22b25eac4
Author: Justus Winter <justus at g10code.com>
Date: Mon Sep 19 18:45:44 2016 +0200
tests: Refine the repl function.
* tests/gpgscm/repl.scm (repl): Add an argument 'environment'.
(interactive-repl): Add an optional argument 'environment'.
--
With this change, we can drop
(interactive-repl (current-environment))
anywhere into the code and do some interactive debugging.
Signed-off-by: Justus Winter <justus at g10code.com>
---
tests/gpgscm/repl.scm | 42 +++++++++++++++++++++---------------------
1 file changed, 21 insertions(+), 21 deletions(-)
diff --git a/tests/gpgscm/repl.scm b/tests/gpgscm/repl.scm
index 896554f..78b8151 100644
--- a/tests/gpgscm/repl.scm
+++ b/tests/gpgscm/repl.scm
@@ -20,25 +20,24 @@
;; Interactive repl using 'prompt' function. P must be a function
;; that given the current entered prefix returns the prompt to
;; display.
-(define (repl p)
- (let ((repl-environment (make-environment)))
- (call/cc
- (lambda (exit)
- (let loop ((prefix ""))
- (let ((line (prompt (p prefix))))
- (if (and (not (eof-object? line)) (= 0 (string-length line)))
- (exit (loop prefix)))
- (if (not (eof-object? line))
- (let* ((next (string-append prefix line))
- (c (catch (begin (echo "Parse error:" *error*)
- (loop prefix))
- (read (open-input-string next)))))
- (if (not (eof-object? c))
- (begin
- (catch (echo "Error:" *error*)
- (echo " ===>" (eval c repl-environment)))
- (exit (loop ""))))
- (exit (loop next))))))))))
+(define (repl p environment)
+ (call/cc
+ (lambda (exit)
+ (let loop ((prefix ""))
+ (let ((line (prompt (p prefix))))
+ (if (and (not (eof-object? line)) (= 0 (string-length line)))
+ (exit (loop prefix)))
+ (if (not (eof-object? line))
+ (let* ((next (string-append prefix line))
+ (c (catch (begin (echo "Parse error:" *error*)
+ (loop prefix))
+ (read (open-input-string next)))))
+ (if (not (eof-object? c))
+ (begin
+ (catch (echo "Error:" *error*)
+ (echo " ===>" (eval c environment)))
+ (exit (loop ""))))
+ (exit (loop next)))))))))
(define (prompt-append-prefix prompt prefix)
(string-append prompt (if (> (string-length prefix) 0)
@@ -46,5 +45,6 @@
"> ")))
;; Default repl run by main.c.
-(define (interactive-repl)
- (repl (lambda (p) (prompt-append-prefix "gpgscm " p))))
+(define (interactive-repl . environment)
+ (repl (lambda (p) (prompt-append-prefix "gpgscm " p))
+ (if (null? environment) (interaction-environment) (car environment))))
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gnupg/gnupg2.git
More information about the Pkg-gnupg-commit
mailing list