fixed a bug in compile_do()

This commit is contained in:
hyung-hwan 2022-08-01 06:31:33 +00:00
parent 1bf908e6ba
commit e8acc7cd5b
3 changed files with 12 additions and 17 deletions

View File

@ -1911,8 +1911,8 @@ static int compile_do (hcl_t* hcl, hcl_cnode_t* src)
HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(src)); HCL_ASSERT (hcl, HCL_CNODE_IS_CONS(src));
HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(src), HCL_SYNCODE_DO)); HCL_ASSERT (hcl, HCL_CNODE_IS_SYMBOL_SYNCODED(HCL_CNODE_CONS_CAR(src), HCL_SYNCODE_DO));
cmd = HCL_CNODE_CONS_CDR(src); cmd = HCL_CNODE_CONS_CAR(src); /* do itself */
obj = HCL_CNODE_CONS_CDR(src); obj = HCL_CNODE_CONS_CDR(src); /* expression list after it */
if (!obj) if (!obj)
{ {

View File

@ -422,7 +422,6 @@ static HCL_INLINE int close_input (hcl_t* hcl, hcl_ioinarg_t* arg)
return 0; return 0;
} }
static HCL_INLINE int read_input (hcl_t* hcl, hcl_ioinarg_t* arg) static HCL_INLINE int read_input (hcl_t* hcl, hcl_ioinarg_t* arg)
{ {
worker_hcl_xtn_t* xtn = (worker_hcl_xtn_t*)hcl_getxtn(hcl); worker_hcl_xtn_t* xtn = (worker_hcl_xtn_t*)hcl_getxtn(hcl);
@ -494,7 +493,8 @@ static HCL_INLINE int read_input (hcl_t* hcl, hcl_ioinarg_t* arg)
x = read(bb->fd, &bb->buf[bb->len], HCL_COUNTOF(bb->buf) - bb->len); x = read(bb->fd, &bb->buf[bb->len], HCL_COUNTOF(bb->buf) - bb->len);
if (x <= -1) if (x <= -1)
{ {
hcl_seterrnum (hcl, HCL_EIOERR); /* TODO: if (errno == EINTR) retry? */
hcl_seterrwithsyserr (hcl, 0, errno);
return -1; return -1;
} }
@ -504,7 +504,7 @@ static HCL_INLINE int read_input (hcl_t* hcl, hcl_ioinarg_t* arg)
#if defined(HCL_OOCH_IS_UCH) #if defined(HCL_OOCH_IS_UCH)
bcslen = bb->len; bcslen = bb->len;
ucslen = HCL_COUNTOF(arg->buf); ucslen = HCL_COUNTOF(arg->buf);
x = hcl_convbtooochars (hcl, bb->buf, &bcslen, arg->buf, &ucslen); x = hcl_convbtooochars(hcl, bb->buf, &bcslen, arg->buf, &ucslen);
if (x <= -1 && ucslen <= 0) return -1; if (x <= -1 && ucslen <= 0) return -1;
/* if ucslen is greater than 0, i see that some characters have been /* if ucslen is greater than 0, i see that some characters have been
* converted properly */ * converted properly */
@ -515,7 +515,7 @@ static HCL_INLINE int read_input (hcl_t* hcl, hcl_ioinarg_t* arg)
#endif #endif
remlen = bb->len - bcslen; remlen = bb->len - bcslen;
if (remlen > 0) memmove (bb->buf, &bb->buf[bcslen], remlen); if (remlen > 0) HCL_MEMMOVE (bb->buf, &bb->buf[bcslen], remlen);
bb->len = remlen; bb->len = remlen;
arg->xlen = ucslen; arg->xlen = ucslen;
@ -528,13 +528,13 @@ static int read_handler (hcl_t* hcl, hcl_iocmd_t cmd, void* arg)
switch (cmd) switch (cmd)
{ {
case HCL_IO_OPEN: case HCL_IO_OPEN:
return open_input (hcl, (hcl_ioinarg_t*)arg); return open_input(hcl, (hcl_ioinarg_t*)arg);
case HCL_IO_CLOSE: case HCL_IO_CLOSE:
return close_input (hcl, (hcl_ioinarg_t*)arg); return close_input(hcl, (hcl_ioinarg_t*)arg);
case HCL_IO_READ: case HCL_IO_READ:
return read_input (hcl, (hcl_ioinarg_t*)arg); return read_input(hcl, (hcl_ioinarg_t*)arg);
default: default:
hcl_seterrnum (hcl, HCL_EINTERN); hcl_seterrnum (hcl, HCL_EINTERN);

View File

@ -3715,13 +3715,8 @@ static int feed_from_included (hcl_t* hcl)
if (hcl->c->curinp->xlen <= 0) if (hcl->c->curinp->xlen <= 0)
{ {
/* got EOF from an included stream */ /* got EOF from an included stream */
#if 0
x = feed_char(hcl, HCL_OOCI_EOF); /* TODO: or call feed_end_include? */
if (x <= -1) return -1;
#else
feed_end_include (hcl); feed_end_include (hcl);
continue; continue;
#endif
} }
hcl->c->curinp->b.pos = 0; hcl->c->curinp->b.pos = 0;