From 3d1cf4b93cda8c8e31631ba174722c629da7b5ad Mon Sep 17 00:00:00 2001 From: Brad Nelson Date: Tue, 3 Jan 2023 21:01:51 -0800 Subject: [PATCH] Making [IF] [THEN] work at console, bumping version. --- Makefile | 2 +- common/conditionals.fs | 7 +++++-- common/core.h | 3 +++ web/web.template.js | 3 +++ 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index c3e0647..70473e4 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.7.4 +VERSION=7.0.7.5 STABLE_VERSION=7.0.6.19 OLD_STABLE_VERSION=7.0.5.4 REVISION=$(shell git rev-parse HEAD | head -c 20) diff --git a/common/conditionals.fs b/common/conditionals.fs index f876235..a123919 100644 --- a/common/conditionals.fs +++ b/common/conditionals.fs @@ -15,9 +15,12 @@ ( Interpret time conditionals ) : DEFINED? ( "name" -- xt|0 ) - bl parse find state @ if aliteral then ; immediate + begin bl parse dup 0= while 2drop refill 0= throw repeat + find state @ if aliteral then ; immediate defer [SKIP] -: [THEN] ; : [ELSE] [SKIP] ; : [IF] 0= if [SKIP] then ; +: [THEN] ; immediate +: [ELSE] [SKIP] ; immediate +: [IF] 0= if [SKIP] then ; immediate : [SKIP]' 0 begin postpone defined? dup if dup ['] [IF] = if swap 1+ swap then dup ['] [ELSE] = if swap dup 0 <= if 2drop exit then swap then diff --git a/common/core.h b/common/core.h index d49ac96..6b3a24e 100644 --- a/common/core.h +++ b/common/core.h @@ -109,6 +109,9 @@ static cell_t same(const char *a, const char *b, cell_t len) { } static cell_t find(const char *name, cell_t len) { + if (len == 0) { + return 0; + } for (cell_t ***voc = g_sys->context; *voc; ++voc) { cell_t xt = (cell_t) **voc; while (xt) { diff --git a/web/web.template.js b/web/web.template.js index 99859d1..ed8fe49 100644 --- a/web/web.template.js +++ b/web/web.template.js @@ -117,6 +117,9 @@ function BUILTIN_CODE(i) { } function Find(name) { + if (name.length === 0) { + return 0; + } name = name.toUpperCase(); var raw = unescape(encodeURIComponent(name)); for (var voc = i32[g_sys_context>>2]; i32[voc>>2]; voc += 4) {