From b2b707fe1502c612ee247f098d1987f67e62017d Mon Sep 17 00:00:00 2001 From: Tim Vaughan Date: Sun, 12 Jun 2016 12:16:33 +1200 Subject: [PATCH] Abort now resets the input stream. --- src/forth.jl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/forth.jl b/src/forth.jl index f10ea04..609897a 100644 --- a/src/forth.jl +++ b/src/forth.jl @@ -585,6 +585,14 @@ end) sources = Array{Any,1}() currentSource() = sources[length(sources)] +CLOSEFILES_CFA = defPrimWord("CLOSEFILES", () -> begin + while currentSource() != STDIN + close(pop!(sources)) + end + + return NEXT +end) + EOF_CFA = defPrimWord("\x04", () -> begin if currentSource() != STDIN close(pop!(sources)) @@ -1031,7 +1039,7 @@ QUIT_CFA = defWord("QUIT", BRANCH_CFA,-4]) ABORT_CFA = defWord("ABORT", - [PSP0_CFA, PSPSTORE_CFA, QUIT_CFA]) + [CLOSEFILES_CFA, PSP0_CFA, PSPSTORE_CFA, QUIT_CFA]) BYE_CFA = defPrimWord("BYE", () -> begin println("\nBye!") -- 2.20.1