|
|
|
@ -233,6 +233,7 @@ static enum fh_error fh_handle_quoted_string( |
|
|
|
|
if (fh->state == FH_STATE_INTERPRET) { |
|
|
|
|
switch (fh->substate) { |
|
|
|
|
case FH_SUBSTATE_S_QUOTE: |
|
|
|
|
addr = fh->here; |
|
|
|
|
TRY(fh_heap_put(fh, start, len)); |
|
|
|
|
TRY(ds_push(fh, addr)); |
|
|
|
|
TRY(ds_push(fh, len)); |
|
|
|
@ -461,27 +462,36 @@ static inline bool isnl(char c) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** Process a line read from input */ |
|
|
|
|
enum fh_error fh_process_line(struct fh_thread_s *fh, const char *linebuf) |
|
|
|
|
enum fh_error fh_process_line(struct fh_thread_s *fh, const char *linebuf, size_t len) |
|
|
|
|
{ |
|
|
|
|
enum fh_error rv; |
|
|
|
|
const char *rp = linebuf; |
|
|
|
|
|
|
|
|
|
#define ReadPtr ((char*)(&fh->heap[INPUTBUF_ADDR + fh->inputptr])) |
|
|
|
|
#define ReadPos (fh->inputptr) |
|
|
|
|
#define ReadLen (fh->inputlen) |
|
|
|
|
|
|
|
|
|
fh_fill_input_buffer(fh, linebuf, len); |
|
|
|
|
|
|
|
|
|
char c; |
|
|
|
|
|
|
|
|
|
if (!fh_globals.interactive) { |
|
|
|
|
LOGI("%s", linebuf); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
while (0 != (c = *rp) && fh->state != FH_STATE_SHUTDOWN) { |
|
|
|
|
while (ReadPos < ReadLen && fh->state != FH_STATE_SHUTDOWN) { |
|
|
|
|
c = *ReadPtr; |
|
|
|
|
/* end on newline */ |
|
|
|
|
if (isnl(c)) { |
|
|
|
|
goto done; |
|
|
|
|
} |
|
|
|
|
/* skip whitespace */ |
|
|
|
|
if (isspace(c)) { |
|
|
|
|
rp++; |
|
|
|
|
ReadPos++; |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const char * const rp = ReadPtr; |
|
|
|
|
|
|
|
|
|
char *end; |
|
|
|
|
size_t length; |
|
|
|
|
switch (fh->substate) { |
|
|
|
@ -520,7 +530,7 @@ enum fh_error fh_process_line(struct fh_thread_s *fh, const char *linebuf) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (end) { |
|
|
|
|
rp = end + 1; |
|
|
|
|
ReadPos += length + 1; |
|
|
|
|
} else { |
|
|
|
|
goto done; |
|
|
|
|
} |
|
|
|
@ -534,7 +544,7 @@ enum fh_error fh_process_line(struct fh_thread_s *fh, const char *linebuf) |
|
|
|
|
LOG("Quoted string: \"%.*s\"", (int) length, rp); |
|
|
|
|
TRY(fh_handle_quoted_string(fh, rp, length)); |
|
|
|
|
fh_setsubstate(fh, FH_SUBSTATE_NONE); |
|
|
|
|
rp = end + 1; |
|
|
|
|
ReadPos += length + 1; |
|
|
|
|
} else { |
|
|
|
|
/* no end. this is weird. */ |
|
|
|
|
LOGE("Unterminated quoted string!"); |
|
|
|
@ -545,9 +555,10 @@ enum fh_error fh_process_line(struct fh_thread_s *fh, const char *linebuf) |
|
|
|
|
case FH_SUBSTATE_PAREN_COMMENT: |
|
|
|
|
end = strchr(rp, ')'); |
|
|
|
|
if (end) { |
|
|
|
|
length = end - rp; |
|
|
|
|
LOG("Discard inline comment"); |
|
|
|
|
fh_setsubstate(fh, FH_SUBSTATE_NONE); |
|
|
|
|
rp = end + 1; |
|
|
|
|
ReadPos += length + 1; |
|
|
|
|
} else { |
|
|
|
|
/* no end, discard all */ |
|
|
|
|
LOGE("Unterminated parenthesis comment"); |
|
|
|
|