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