cleaned up a bit

This commit is contained in:
hyung-hwan 2021-01-29 17:24:13 +00:00
parent 7fc4262d01
commit db9e0f5248
3 changed files with 15 additions and 15 deletions

View File

@ -169,7 +169,7 @@ static HCL_INLINE int open_input (hcl_t* hcl, hcl_ioinarg_t* arg)
const hcl_bch_t* fn, * fb; const hcl_bch_t* fn, * fb;
#if defined(HCL_OOCH_IS_UCH) #if defined(HCL_OOCH_IS_UCH)
if (hcl_convootobcstr (hcl, arg->name, &ucslen, HCL_NULL, &bcslen) <= -1) goto oops; if (hcl_convootobcstr(hcl, arg->name, &ucslen, HCL_NULL, &bcslen) <= -1) goto oops;
#else #else
bcslen = hcl_count_bcstr (arg->name); bcslen = hcl_count_bcstr (arg->name);
#endif #endif
@ -195,9 +195,9 @@ static HCL_INLINE int open_input (hcl_t* hcl, hcl_ioinarg_t* arg)
/* main stream */ /* main stream */
hcl_oow_t pathlen; hcl_oow_t pathlen;
pathlen = hcl_count_bcstr (xtn->read_path); pathlen = hcl_count_bcstr(xtn->read_path);
bb = (bb_t*)hcl_callocmem (hcl, HCL_SIZEOF(*bb) + (HCL_SIZEOF(hcl_bch_t) * (pathlen + 1))); bb = (bb_t*)hcl_callocmem(hcl, HCL_SIZEOF(*bb) + (HCL_SIZEOF(hcl_bch_t) * (pathlen + 1)));
if (!bb) goto oops; if (!bb) goto oops;
bb->fn = (hcl_bch_t*)(bb + 1); bb->fn = (hcl_bch_t*)(bb + 1);
@ -279,7 +279,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 */
@ -302,13 +302,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);
case HCL_IO_FLUSH: case HCL_IO_FLUSH:
/* no effect on an input stream */ /* no effect on an input stream */
@ -320,16 +320,16 @@ static int read_handler (hcl_t* hcl, hcl_iocmd_t cmd, void* arg)
} }
} }
static HCL_INLINE int open_output(hcl_t* hcl, hcl_iooutarg_t* arg) static HCL_INLINE int open_output (hcl_t* hcl, hcl_iooutarg_t* arg)
{ {
xtn_t* xtn = (xtn_t*)hcl_getxtn(hcl); xtn_t* xtn = (xtn_t*)hcl_getxtn(hcl);
FILE* fp; FILE* fp;
#if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__) #if defined(__MSDOS__) || defined(_WIN32) || defined(__OS2__)
if (xtn->print_path) fp = fopen (xtn->print_path, "wb"); if (xtn->print_path) fp = fopen(xtn->print_path, "wb");
else fp = stdout; else fp = stdout;
#else #else
if (xtn->print_path) fp = fopen (xtn->print_path, "w"); if (xtn->print_path) fp = fopen(xtn->print_path, "w");
else fp = stdout; else fp = stdout;
#endif #endif
if (!fp) if (!fp)
@ -1132,7 +1132,7 @@ int main (int argc, char* argv[])
if (hcl_attachio(hcl, read_handler, print_handler) <= -1) if (hcl_attachio(hcl, read_handler, print_handler) <= -1)
{ {
hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: cannot attach input stream - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl)); hcl_logbfmt (hcl, HCL_LOG_STDERR, "ERROR: cannot attach IO streams - [%d] %js\n", hcl_geterrnum(hcl), hcl_geterrmsg(hcl));
goto oops; goto oops;
} }
@ -1256,7 +1256,7 @@ count++;
else else
{ {
/* print the result in the interactive mode regardless 'verbose' */ /* print the result in the interactive mode regardless 'verbose' */
hcl_logbfmt (hcl, HCL_LOG_STDOUT, "%O\n", retv); hcl_logbfmt (hcl, HCL_LOG_STDOUT, "%O\n", retv); /* TODO: show this go to the output handler?? */
/* /*
* print the value of ERRSTR. * print the value of ERRSTR.

View File

@ -2990,14 +2990,14 @@ if (hcl->active_function->dbgi != hcl->_nil)
{ {
hcl_dbgl_t* dbgl; hcl_dbgl_t* dbgl;
hcl_ooi_t ip; hcl_ooi_t ip;
static hcl_ooch_t dash[] = { '*', '\0' }; static hcl_ooch_t dash[] = { '-', '\0' };
HCL_ASSERT (hcl, HCL_IS_BYTEARRAY(hcl, hcl->active_function->dbgi)); HCL_ASSERT (hcl, HCL_IS_BYTEARRAY(hcl, hcl->active_function->dbgi));
dbgl = (hcl_dbgl_t*)HCL_OBJ_GET_BYTE_SLOT(hcl->active_function->dbgi); dbgl = (hcl_dbgl_t*)HCL_OBJ_GET_BYTE_SLOT(hcl->active_function->dbgi);
ip = hcl->ip - 1; ip = hcl->ip - 1;
if (bcode == HCL_CODE_CALL_X) ip -= HCL_CODE_LONG_PARAM_SIZE; if (bcode == HCL_CODE_CALL_X) ip -= HCL_CODE_LONG_PARAM_SIZE;
hcl_seterrbfmt (hcl, HCL_ECALL, "cannot call %O [%js:%zu]", hcl_seterrbfmt (hcl, HCL_ECALL, "cannot call %O (%js %zu)",
rcv, (dbgl[ip].fname? dbgl[ip].fname: dash), dbgl[ip].sline); rcv, (dbgl[ip].fname? dbgl[ip].fname: dash), dbgl[ip].sline);
} }
else else

View File

@ -2185,7 +2185,7 @@ int hcl_attachio (hcl_t* hcl, hcl_ioimpl_t reader, hcl_ioimpl_t printer)
if (!cbp) return -1; if (!cbp) return -1;
hcl->c = (hcl_compiler_t*)hcl_callocmem(hcl, HCL_SIZEOF(*hcl->c)); hcl->c = (hcl_compiler_t*)hcl_callocmem(hcl, HCL_SIZEOF(*hcl->c));
if (!hcl->c) if (HCL_UNLIKELY(!hcl->c))
{ {
hcl_deregcb (hcl, cbp); hcl_deregcb (hcl, cbp);
return -1; return -1;