switched to use fgetc() instead of fread() because fread() doesn't stop when a new line is enountered. fgets() is not a good candidate either.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
d5c47e5a9a
commit
44fd446274
22
bin/main.c
22
bin/main.c
@ -455,8 +455,6 @@ static int on_fed_cnode_in_interactive_mode (hcl_t* hcl, hcl_cnode_t* obj)
|
|||||||
static int feed_loop (hcl_t* hcl, xtn_t* xtn, int verbose)
|
static int feed_loop (hcl_t* hcl, xtn_t* xtn, int verbose)
|
||||||
{
|
{
|
||||||
FILE* fp = HCL_NULL;
|
FILE* fp = HCL_NULL;
|
||||||
hcl_bch_t buf[1024];
|
|
||||||
hcl_oow_t xlen;
|
|
||||||
int is_tty;
|
int is_tty;
|
||||||
|
|
||||||
fp = fopen(xtn->cci_path, FOPEN_R_FLAGS);
|
fp = fopen(xtn->cci_path, FOPEN_R_FLAGS);
|
||||||
@ -479,6 +477,10 @@ static int feed_loop (hcl_t* hcl, xtn_t* xtn, int verbose)
|
|||||||
/* [NOTE] it isn't a very nice idea to get this internal data and use it with read_input() */
|
/* [NOTE] it isn't a very nice idea to get this internal data and use it with read_input() */
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
#if 0
|
||||||
|
hcl_bch_t buf[1024];
|
||||||
|
hcl_oow_t xlen;
|
||||||
|
|
||||||
xlen = fread(buf, HCL_SIZEOF(buf[0]), HCL_COUNTOF(buf), fp);
|
xlen = fread(buf, HCL_SIZEOF(buf[0]), HCL_COUNTOF(buf), fp);
|
||||||
if (xlen > 0 && hcl_feedbchars(hcl, buf, xlen) <= -1) goto feed_error;
|
if (xlen > 0 && hcl_feedbchars(hcl, buf, xlen) <= -1) goto feed_error;
|
||||||
if (xlen < HCL_COUNTOF(buf))
|
if (xlen < HCL_COUNTOF(buf))
|
||||||
@ -490,6 +492,22 @@ static int feed_loop (hcl_t* hcl, xtn_t* xtn, int verbose)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
hcl_bch_t bch;
|
||||||
|
int ch = fgetc(fp);
|
||||||
|
if (ch == EOF)
|
||||||
|
{
|
||||||
|
if (ferror(fp))
|
||||||
|
{
|
||||||
|
hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: failed to read - %hs - %hs\n", xtn->cci_path, strerror(errno));
|
||||||
|
goto oops;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
bch = ch;
|
||||||
|
if (hcl_feedbchars(hcl, &bch, 1) <= -1) goto feed_error;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hcl_endfeed(hcl) <= -1)
|
if (hcl_endfeed(hcl) <= -1)
|
||||||
|
15
lib/read.c
15
lib/read.c
@ -669,6 +669,16 @@ static HCL_INLINE hcl_cnode_t* leave_list (hcl_t* hcl, int* flagv, int* oldflagv
|
|||||||
return hcl_makecnodeelist(hcl, &loc, concode);
|
return hcl_makecnodeelist(hcl, &loc, concode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static HCL_INLINE int is_at_block_beginning (hcl_t* hcl)
|
||||||
|
{
|
||||||
|
hcl_rstl_t* rstl;
|
||||||
|
|
||||||
|
HCL_ASSERT (hcl, hcl->c->r.st != HCL_NULL);
|
||||||
|
rstl = hcl->c->r.st;
|
||||||
|
|
||||||
|
return (LIST_FLAG_GET_CONCODE(rstl->flagv) == HCL_CONCODE_BLOCK && rstl->count <= 0);
|
||||||
|
}
|
||||||
|
|
||||||
static HCL_INLINE int can_dot_list (hcl_t* hcl)
|
static HCL_INLINE int can_dot_list (hcl_t* hcl)
|
||||||
{
|
{
|
||||||
hcl_rstl_t* rstl;
|
hcl_rstl_t* rstl;
|
||||||
@ -1038,6 +1048,11 @@ static int feed_process_token (hcl_t* hcl)
|
|||||||
frd->expect_include_file = 1;
|
frd->expect_include_file = 1;
|
||||||
goto ok;
|
goto ok;
|
||||||
|
|
||||||
|
case HCL_TOK_PRAGMA:
|
||||||
|
/* TODO: implement this */
|
||||||
|
hcl_setsynerr (hcl, HCL_SYNERR_ILTOK, TOKEN_LOC(hcl), TOKEN_NAME(hcl));
|
||||||
|
goto oops;
|
||||||
|
|
||||||
case HCL_TOK_VBAR:
|
case HCL_TOK_VBAR:
|
||||||
if (frd->expect_vlist_item)
|
if (frd->expect_vlist_item)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user