From 2632f748b18d67da12c2c2b94591f128a29f81e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sat, 27 Nov 2021 17:51:42 +0100 Subject: [PATCH] fix more bugs --- src/fh_builtins_mem.c | 2 +- src/fh_parse.c | 6 ++++-- testfiles/combinedtest.f | 3 +-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/fh_builtins_mem.c b/src/fh_builtins_mem.c index 04a9320..528e7a4 100644 --- a/src/fh_builtins_mem.c +++ b/src/fh_builtins_mem.c @@ -212,7 +212,7 @@ static enum fh_error w_c_fetch(struct fh_thread_s *fh, const struct fh_word_s *w char value = 0; TRY(fh_fetch_char(fh, addr, &value)); - TRY(ds_push(fh, (uint32_t) value)); + TRY(ds_push(fh, (uint32_t) (value&0xFF))); return FH_OK; } diff --git a/src/fh_parse.c b/src/fh_parse.c index d76158e..e650ad4 100644 --- a/src/fh_parse.c +++ b/src/fh_parse.c @@ -156,9 +156,9 @@ enum fh_error fh_input_read_quotedstring(struct fh_thread_s *fh, bool escaped, c if (isdigit(c)) { hex |= c - '0'; } else if (c >= 'a' && c <= 'f') { - hex |= c - 'a'; + hex |= 10 + (c - 'a'); } else if (c >= 'A' && c <= 'F') { - hex |= c - 'A'; + hex |= 10 + (c - 'A'); } else { LOGE("Bad hex escape"); return FH_ERR_SYNTAX; @@ -167,6 +167,8 @@ enum fh_error fh_input_read_quotedstring(struct fh_thread_s *fh, bool escaped, c if (hexdigits == 0) { c = (char) hex; goto append; + } else { + goto skip; } } diff --git a/testfiles/combinedtest.f b/testfiles/combinedtest.f index 1dba314..63d55cc 100644 --- a/testfiles/combinedtest.f +++ b/testfiles/combinedtest.f @@ -1802,7 +1802,6 @@ TESTING S\" (Forth 2012 compilation mode) \ interpretation semantics. S\" in interpretation mode is tested in the tests on \ the File-Access word set -1 debug T{ : SSQ1 S\" abc" S" abc" S= ; -> }T \ No escapes T{ SSQ1 -> TRUE }T T{ : SSQ2 S\" " ; SSQ2 SWAP DROP -> 0 }T \ Empty string @@ -1835,7 +1834,7 @@ T{ SSQ3 DROP 19 CHARS + C@ -> 92 }T \ \\ \ Back Slash CR .( The next test should display:) CR .( One line...) CR .( another line) -T{ : SSQ4 S\" \nOne line...\nanotherLine\n" TYPE ; SSQ4 -> }T +T{ : SSQ4 S\" \nOne line...\nanother line\n" TYPE ; SSQ4 -> }T \ Test bare escapable characters appear as themselves T{ : SSQ5 S\" abeflmnqrtvxz" S" abeflmnqrtvxz" S= ; SSQ5 -> TRUE }T