From c2d961583315744145c4b2fe43ab19f40db99587 Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Tue, 7 Jun 2022 23:11:01 -0700 Subject: [PATCH] Bump version + refine crlf nil handling in accept more. --- Makefile | 2 +- common/base_tests.fs | 6 ++++-- common/boot.fs | 18 ++++++++++++------ common/testing.fs | 4 ++-- common/vocabulary.fs | 2 +- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index ff113d5..13dfd4a 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -VERSION=7.0.6.17 +VERSION=7.0.6.18 STABLE_VERSION=7.0.5.4 REVISION=$(shell git rev-parse HEAD | head -c 20) REVSHORT=$(shell echo $(REVISION) | head -c 7) diff --git a/common/base_tests.fs b/common/base_tests.fs index a279bbe..55376a9 100644 --- a/common/base_tests.fs +++ b/common/base_tests.fs @@ -104,13 +104,15 @@ e: test-accept pad 10 accept pad swap type cr out:\ --> 1234567890 - out:crlf + out:cr! + out:cr out: 1234567890 in: foo pad 10 accept pad swap type cr out:\ --> foo - out:crlf + out:cr! + out:cr out: foo ;e diff --git a/common/boot.fs b/common/boot.fs index 56274c4..b126941 100644 --- a/common/boot.fs +++ b/common/boot.fs @@ -115,7 +115,7 @@ defer key defer key? defer bye : emit ( n -- ) >r rp@ 1 type rdrop ; -: space bl emit ; : cr nl emit ; +: space bl emit ; : cr 13 emit nl emit ; ( Numeric Output ) variable hld @@ -158,13 +158,20 @@ variable hld ( Input ) : raw.s depth 0 max for aft sp@ r@ cells - @ . then next ; -variable echo -1 echo ! variable arrow -1 arrow ! variable wascr +variable echo -1 echo ! variable arrow -1 arrow ! 0 value wascr : *emit ( n -- ) dup emit 13 = if cr then ; : ?echo ( n -- ) echo @ if *emit else drop then ; : ?arrow. arrow @ if >r >r raw.s r> r> ." --> " then ; : *key ( -- n ) - begin key dup nl = wascr @ 0= and if drop 13 exit then dup until - dup 13 = wascr ! ; + begin + key + dup nl = if + drop wascr if 0 else 13 exit then + then + dup 13 = to wascr + dup if exit else drop then + again ; +: eat-till-cr begin *key dup 13 = if ?echo exit else drop then again ; : accept ( a n -- n ) ?arrow. 0 swap begin 2dup < while *key dup 13 = if ?echo drop nip exit then @@ -175,8 +182,7 @@ variable echo -1 echo ! variable arrow -1 arrow ! variable wascr >r rot r> over c! 1+ -rot swap 1+ swap then repeat drop nip - ( Eat rest of the line if buffer too small ) - begin *key dup 13 = if ?echo exit else drop then again + eat-till-cr ; 200 constant input-limit : tib ( -- a ) 'tib @ ; diff --git a/common/testing.fs b/common/testing.fs index 6c32d33..68d530a 100644 --- a/common/testing.fs +++ b/common/testing.fs @@ -45,8 +45,8 @@ variable expect-used variable result-used : result-type ( a n -- ) for aft dup c@ result-emit 1+ then next drop ; : expected ( -- a n ) expect-buffer expect-used @ ; : resulted ( -- a n ) result-buffer result-used @ ; -: out:cr nl expect-emit ; -: out:crlf 13 expect-emit nl expect-emit ; +: out:cr! 13 expect-emit ; +: out:cr 13 expect-emit nl expect-emit ; : out:\ ( "line" -- ) nl parse expect-type ; : out: ( "line" -- ) out:\ out:cr ; variable confirm-old-type diff --git a/common/vocabulary.fs b/common/vocabulary.fs index 4dbc967..bb72856 100644 --- a/common/vocabulary.fs +++ b/common/vocabulary.fs @@ -53,7 +53,7 @@ variable scope scope context cell - ! transfer{ xt-find& xt-hide xt-transfer voc-stack-end last-vocabulary notfound - *key *emit wascr + *key *emit wascr eat-till-cr immediate? input-buffer ?echo ?arrow. arrow evaluate-buffer aliteral value-bind leaving( )leaving leaving leaving,