diff --git a/src/fh_builtins_meta.c b/src/fh_builtins_meta.c index 43538fb..446b96b 100644 --- a/src/fh_builtins_meta.c +++ b/src/fh_builtins_meta.c @@ -601,7 +601,6 @@ static enum fh_error w_evaluate(struct fh_thread_s *fh, const struct fh_word_s * enum fh_error rv; uint32_t addr, count; TRY(ds_pop_addr_len(fh, &addr, &count)); - fh_runtime_start(fh, fh_create_input_from_string(fh_str_at(fh, addr), count, fh->input->cwd)); return FH_OK; } diff --git a/src/fh_input.c b/src/fh_input.c index 6480fee..e183e77 100644 --- a/src/fh_input.c +++ b/src/fh_input.c @@ -20,6 +20,7 @@ enum fh_error fh_push_input(struct fh_thread_s *fh, struct fh_input_spec_s *newi newinput->previous = oldinput; } + fh->execptr = MAGICADDR_EXEC_INTERACTIVE; fh->inputlen = 0; fh->inputptr = 0; @@ -86,17 +87,17 @@ void fh_input_memmove_leftovers(struct fh_thread_s *fh) // something is left uint32_t remains = fh->inputlen - fh->inputptr; if (remains > 0) { - LOG("Refill, reuse %d bytes left in buffer", remains); + //LOG("Refill, reuse %d bytes left in buffer", remains); memmove(inputbuf_at(fh, 0), inputbuf_at(fh, fh->inputptr), remains); fh->inputptr = 0; fh->inputlen = remains; } else { - LOG("Refill, nothing reused (1)"); + //LOG("Refill, nothing reused (1)"); fh->inputptr = 0; fh->inputlen = 0; } } else { - LOG("Refill, nothing reused (2)"); + //LOG("Refill, nothing reused (2)"); fh->inputptr = 0; fh->inputlen = 0; } @@ -108,11 +109,11 @@ static bool file_refill(struct fh_thread_s *fh, struct fh_input_spec_s *spec) fh_input_memmove_leftovers(fh); uint32_t space_left = INPUT_BUFFER_SIZE - fh->inputlen - 1; char *wp = (char *) inputbuf_at(fh, fh->inputptr); - LOG("spec %p, fgets %d", spec, space_left); + //LOG("spec %p, fgets %d", spec, space_left); if (fgets(wp, (int) space_left, fis->file)) { spec->linenum++; fh->inputlen = strnlen(wp, INPUT_BUFFER_SIZE); - LOG("read %d bytes from file", fh->inputlen); + //LOG("read %d bytes from file", fh->inputlen); return true; } else { return fh->inputptr > fh->inputlen; // return false only if there is nothing left @@ -174,6 +175,7 @@ struct fh_input_spec_s *fh_create_input_from_filestruct(FILE *f, const char *cwd return NULL; } + LOG("Input for FILE, cwd: %s", cwd); fis->spec.free_self = free_filespec; fis->spec.refill_input_buffer = file_refill; fis->file = f; @@ -221,6 +223,8 @@ struct fh_input_spec_s *fh_create_input_from_string(char *str, size_t len, const return NULL; } + LOG("Evaluating: \"%.*s\"", (int)len, str); + sis->spec.free_self = free_strspec; sis->spec.refill_input_buffer = str_refill; sis->str = str; diff --git a/src/fh_parse.c b/src/fh_parse.c index c167b8e..6346327 100644 --- a/src/fh_parse.c +++ b/src/fh_parse.c @@ -234,7 +234,7 @@ enum fh_error fh_runtime_start(struct fh_thread_s *fh, struct fh_input_spec_s *i } while (1) { - LOG("Refill input buffer"); + //LOG("Refill input buffer"); if (fh->input->refill_input_buffer(fh, fh->input)) { // discard spaces at the end while (isspace(fh->heap[INPUTBUF_ADDR + fh->inputlen - 1]) && fh->inputlen > 0) { diff --git a/testfiles/combinedtest.f b/testfiles/combinedtest.f index debb741..3368e6e 100644 --- a/testfiles/combinedtest.f +++ b/testfiles/combinedtest.f @@ -870,10 +870,8 @@ T{ 2 SCANS ! 345 RESCAN? -> 345 345 }T -1 debug : GS2 5 SCANS ! S" 123 RESCAN?" EVALUATE ; T{ GS2 -> 123 123 123 123 123 }T -xx : GS3 WORD COUNT SWAP C@ ; T{ BL GS3 HELLO -> 5 CHAR H }T diff --git a/testfiles/rescan.f b/testfiles/rescan.f new file mode 100644 index 0000000..1dfff21 --- /dev/null +++ b/testfiles/rescan.f @@ -0,0 +1,7 @@ +VARIABLE SCANS +: RESCAN? -1 SCANS +! SCANS @ IF 0 >IN ! THEN ; + +1 debug +: GS2 1 SCANS ! S" 123 RESCAN?" EVALUATE ; +GS2 +??