diff --git a/ueforth/common/base_tests.fs b/ueforth/common/base_tests.fs index 552bbdd..dd163b8 100644 --- a/ueforth/common/base_tests.fs +++ b/ueforth/common/base_tests.fs @@ -117,3 +117,8 @@ e: test-compiler-off : test [ 123 111 + literal ] ; test 234 = assert ;e + +e: test-empty-string + : test s" " ; + test 0 = assert drop +;e diff --git a/ueforth/common/core.h b/ueforth/common/core.h index cd575a9..a36a80c 100644 --- a/ueforth/common/core.h +++ b/ueforth/common/core.h @@ -136,8 +136,10 @@ static int match(char sep, char ch) { } static cell_t parse(cell_t sep, cell_t *ret) { - while (g_sys.tin < g_sys.ntib && - match(sep, g_sys.tib[g_sys.tin])) { ++g_sys.tin; } + if (sep == ' ') { + while (g_sys.tin < g_sys.ntib && + match(sep, g_sys.tib[g_sys.tin])) { ++g_sys.tin; } + } *ret = (cell_t) (g_sys.tib + g_sys.tin); while (g_sys.tin < g_sys.ntib && !match(sep, g_sys.tib[g_sys.tin])) { ++g_sys.tin; } diff --git a/ueforth/common/utils_tests.fs b/ueforth/common/utils_tests.fs index a769f94..8c6ee6c 100644 --- a/ueforth/common/utils_tests.fs +++ b/ueforth/common/utils_tests.fs @@ -70,3 +70,33 @@ e: test-see-fornext see test out: : test >R DONEXT ; ;e + +e: test-string-strides + : test0 1 if ." " then ; + : test1 1 if ." >" then ; + : test2 1 if ." ->" then ; + : test3 1 if ." -->" then ; + : test4 1 if ." --->" then ; + : test5 1 if ." ---->" then ; + : test6 1 if ." ----->" then ; + : test7 1 if ." ------>" then ; + : test8 1 if ." ------->" then ; + see test0 + out: : test0 1 0BRANCH s" " type ; + see test1 + out: : test1 1 0BRANCH s" >" type ; + see test2 + out: : test2 1 0BRANCH s" ->" type ; + see test3 + out: : test3 1 0BRANCH s" -->" type ; + see test4 + out: : test4 1 0BRANCH s" --->" type ; + see test5 + out: : test5 1 0BRANCH s" ---->" type ; + see test6 + out: : test6 1 0BRANCH s" ----->" type ; + see test7 + out: : test7 1 0BRANCH s" ------>" type ; + see test8 + out: : test8 1 0BRANCH s" ------->" type ; +;e