From 3b3c2dec4044db0e00b4353a7978e601f7e0f8c0 Mon Sep 17 00:00:00 2001 From: Helmut Eller Date: Sun, 18 Dec 2016 11:57:03 +0100 Subject: [PATCH] Implememnt standard word INCLUDED * fth/system.fth (INCLUDED): Rewrite existing $INCLUDE to use addr+len strings. ($INCLUDE): Call INCLUDED. (INCLUDE.MARK.START): Also take addr+len string as argument. --- fth/system.fth | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/fth/system.fth b/fth/system.fth index b74c812..c33f40b 100644 --- a/fth/system.fth +++ b/fth/system.fth @@ -716,9 +716,9 @@ ustack 0stackp \ -------------- INCLUDE ------------------------------------------ variable TRACE-INCLUDE -: INCLUDE.MARK.START ( $filename -- , mark start of include for FILE?) +: INCLUDE.MARK.START ( c-addr u -- , mark start of include for FILE?) " ::::" pad $MOVE - count pad $APPEND + pad $APPEND pad ['] noop (:) ; @@ -726,19 +726,18 @@ variable TRACE-INCLUDE " ;;;;" ['] noop (:) ; -: $INCLUDE ( $filename -- ) -\ Print messages. +: INCLUDED ( c-addr u -- ) + \ Print messages. trace-include @ IF - >newline ." Include " dup count type cr + >newline ." Include " 2dup type cr THEN here >r - dup - count r/o open-file - IF ( -- $filename bad-fid ) - drop ." Could not find file " $type cr abort - ELSE ( -- $filename good-fid ) - swap include.mark.start + 2dup r/o open-file + IF ( -- c-addr u bad-fid ) + drop ." Could not find file " type cr abort + ELSE ( -- c-addr u good-fid ) + -rot include.mark.start depth >r include-file \ will also close the file depth 1+ r> - @@ -757,6 +756,8 @@ variable TRACE-INCLUDE rdrop ; +: $INCLUDE ( $filename -- ) count included ; + create INCLUDE-SAVE-NAME 128 allot : INCLUDE ( -- ) BL lword -- 2.20.1