removed some unneeded code.
changed the source input handler to set the name field for the main stream
This commit is contained in:
parent
db9e0f5248
commit
0568cb0ae3
20
bin/main.c
20
bin/main.c
@ -223,6 +223,18 @@ static HCL_INLINE int open_input (hcl_t* hcl, hcl_ioinarg_t* arg)
|
||||
}
|
||||
|
||||
arg->handle = bb;
|
||||
|
||||
/* HACK */
|
||||
if (!arg->includer)
|
||||
{
|
||||
HCL_ASSERT (hcl, arg->name == HCL_NULL);
|
||||
arg->name = hcl_dupbtooocstr(hcl, xtn->read_path, HCL_NULL);
|
||||
/* ignore duplication failure */
|
||||
/* TODO: change the type of arg->name from const hcl_ooch_t* to hcl_ooch_t*.
|
||||
* change its specification from [IN] only to [INOUT] in hcl_ioinarg_t. */
|
||||
}
|
||||
/* END HACK */
|
||||
|
||||
return 0;
|
||||
|
||||
oops:
|
||||
@ -242,6 +254,14 @@ static HCL_INLINE int close_input (hcl_t* hcl, hcl_ioinarg_t* arg)
|
||||
bb = (bb_t*)arg->handle;
|
||||
HCL_ASSERT (hcl, bb != HCL_NULL && bb->fp != HCL_NULL);
|
||||
|
||||
/* HACK */
|
||||
if (!arg->includer && arg->name)
|
||||
{
|
||||
hcl_freemem (hcl, arg->name);
|
||||
arg->name = HCL_NULL;
|
||||
}
|
||||
/* END HACK */
|
||||
|
||||
fclose (bb->fp);
|
||||
hcl_freemem (hcl, bb);
|
||||
|
||||
|
31
lib/exec.c
31
lib/exec.c
@ -3387,37 +3387,6 @@ else
|
||||
HCL_STACK_PUSH (hcl, t);
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (b1 == 1 || b1 == 3)
|
||||
{
|
||||
if (t3 == hcl->_nil)
|
||||
{
|
||||
((hcl_oop_oop_t)t2)->slot[0] = t1;
|
||||
if (b1 == 1) HCL_STACK_PUSH (hcl, t2); /* push self again */
|
||||
}
|
||||
else
|
||||
{
|
||||
hcl_oop_t t;
|
||||
|
||||
t = hcl_makecons(hcl, t1, hcl->_nil);
|
||||
if (HCL_UNLIKELY(!t)) goto oops;
|
||||
|
||||
((hcl_oop_oop_t)t3)->slot[1] = t;
|
||||
if (b1 == 1) HCL_STACK_PUSH (hcl, t);
|
||||
}
|
||||
}
|
||||
else if (b1 == 2)
|
||||
{
|
||||
if (t3 == hcl->_nil)
|
||||
{
|
||||
((hcl_oop_oop_t)t2)->slot[1] = t1;
|
||||
}
|
||||
else
|
||||
{
|
||||
((hcl_oop_oop_t)t3)->slot[1] = t1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1167,7 +1167,7 @@ struct hcl_ioinarg_t
|
||||
/**
|
||||
* [OUT] place data here for #HCL_IO_READ
|
||||
*/
|
||||
hcl_ooch_t buf[2048];
|
||||
hcl_ooch_t buf[2048]; /* TODO: resize this if necessary */
|
||||
|
||||
/**
|
||||
* [OUT] place the number of characters read here for #HCL_IO_READ
|
||||
|
39
lib/read.c
39
lib/read.c
@ -2066,6 +2066,26 @@ hcl_cnode_t* hcl_read (hcl_t* hcl)
|
||||
return read_object(hcl);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
hcl_iolxc_t* hcl_readchar (hcl_t* hcl)
|
||||
{
|
||||
int n = get_char(hcl);
|
||||
if (n <= -1) return HCL_NULL;
|
||||
return &hcl->c->lxc;
|
||||
}
|
||||
|
||||
int hcl_unreadchar (hcl_t* hcl, const hcl_iolxc_t* c)
|
||||
{
|
||||
if (hcl->c->nungots >= HCL_COUNTOF(hcl->c->ungot))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EBUFFULL, "character unread buffer full");
|
||||
return -1;
|
||||
}
|
||||
|
||||
unget_char (hcl, c);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* TODO:
|
||||
hcl_cnodetoobj (hcl_t* hcl, hcl_cnode_t* x)
|
||||
@ -2075,6 +2095,7 @@ hcl_cnodetoobj (hcl_t* hcl, hcl_cnode_t* x)
|
||||
}
|
||||
*/
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
|
||||
/* TODO: rename compiler to something else that can include reader, printer, and compiler
|
||||
* move compiler intialization/finalization here to more common place */
|
||||
@ -2297,21 +2318,3 @@ void hcl_detachio (hcl_t* hcl)
|
||||
}
|
||||
}
|
||||
|
||||
hcl_iolxc_t* hcl_readchar (hcl_t* hcl)
|
||||
{
|
||||
int n = get_char(hcl);
|
||||
if (n <= -1) return HCL_NULL;
|
||||
return &hcl->c->lxc;
|
||||
}
|
||||
|
||||
int hcl_unreadchar (hcl_t* hcl, const hcl_iolxc_t* c)
|
||||
{
|
||||
if (hcl->c->nungots >= HCL_COUNTOF(hcl->c->ungot))
|
||||
{
|
||||
hcl_seterrbfmt (hcl, HCL_EBUFFULL, "character unread buffer full");
|
||||
return -1;
|
||||
}
|
||||
|
||||
unget_char (hcl, c);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user