changed the hcl_ioimpl_t prototype to return 'int' instead of 'hcl_ooi_t'.

changed the io arguments to have a new 'xlen' field that holds the result of IO operations where 0 means end of stream
This commit is contained in:
2018-03-09 05:05:09 +00:00
parent a60bd0c898
commit 3acdae2cdf
4 changed files with 128 additions and 98 deletions

View File

@ -393,7 +393,6 @@ static HCL_INLINE void unget_char (hcl_t* hcl, const hcl_iolxc_t* c)
static int get_char (hcl_t* hcl)
{
hcl_ooi_t n;
hcl_ooci_t lc;
if (hcl->c->nungots > 0)
@ -416,10 +415,9 @@ static int get_char (hcl_t* hcl)
if (hcl->c->curinp->b.pos >= hcl->c->curinp->b.len)
{
n = hcl->c->reader (hcl, HCL_IO_READ, hcl->c->curinp);
if (n <= -1) return -1;
if (n == 0)
if (hcl->c->reader(hcl, HCL_IO_READ, hcl->c->curinp) <= -1) return -1;
if (hcl->c->curinp->xlen <= 0)
{
return_eof:
hcl->c->curinp->lxc.c = HCL_OOCI_EOF;
@ -433,7 +431,7 @@ static int get_char (hcl_t* hcl)
}
hcl->c->curinp->b.pos = 0;
hcl->c->curinp->b.len = n;
hcl->c->curinp->b.len = hcl->c->curinp->xlen;
}
if (hcl->c->curinp->lxc.c == '\n' || hcl->c->curinp->lxc.c == '\r')