renamed some function names for naming consistency

This commit is contained in:
hyung-hwan 2018-04-07 15:54:16 +00:00
parent 746dceff43
commit e92407221f
16 changed files with 270 additions and 330 deletions

View File

@ -127,7 +127,7 @@ static hcl_oop_cons_t find_or_upsert (hcl_t* hcl, hcl_oop_dic_t dic, hcl_oop_t k
HCL_ASSERT (hcl, HCL_IS_SYMBOL(hcl,ass->car)); HCL_ASSERT (hcl, HCL_IS_SYMBOL(hcl,ass->car));
if (HCL_OBJ_GET_SIZE(key) == HCL_OBJ_GET_SIZE(ass->car) && if (HCL_OBJ_GET_SIZE(key) == HCL_OBJ_GET_SIZE(ass->car) &&
hcl_equaloochars(key->slot, ((hcl_oop_char_t)ass->car)->slot, HCL_OBJ_GET_SIZE(key))) hcl_equal_oochars(key->slot, ((hcl_oop_char_t)ass->car)->slot, HCL_OBJ_GET_SIZE(key)))
{ {
/* the value of HCL_NULL indicates no insertion or update. */ /* the value of HCL_NULL indicates no insertion or update. */
if (value) ass->cdr = value; /* update */ if (value) ass->cdr = value; /* update */
@ -300,7 +300,7 @@ int hcl_zapatdic (hcl_t* hcl, hcl_oop_dic_t dic, hcl_oop_t key)
HCL_ASSERT (hcl, HCL_IS_SYMBOL(hcl,ass->car)); HCL_ASSERT (hcl, HCL_IS_SYMBOL(hcl,ass->car));
if (HCL_OBJ_GET_SIZE(key) == HCL_OBJ_GET_SIZE(ass->car) && if (HCL_OBJ_GET_SIZE(key) == HCL_OBJ_GET_SIZE(ass->car) &&
hcl_equaloochars(HCL_OBJ_GET_CHAR_SLOT(key), HCL_OBJ_GET_CHAR_SLOT(ass->car), HCL_OBJ_GET_SIZE(key))) hcl_equal_oochars(HCL_OBJ_GET_CHAR_SLOT(key), HCL_OBJ_GET_CHAR_SLOT(ass->car), HCL_OBJ_GET_SIZE(key)))
{ {
/* the value of HCL_NULL indicates no insertion or update. */ /* the value of HCL_NULL indicates no insertion or update. */
goto found; goto found;

View File

@ -336,7 +336,7 @@ const hcl_ooch_t* hcl_geterrmsg (hcl_t* hcl)
const hcl_ooch_t* hcl_backuperrmsg (hcl_t* hcl) const hcl_ooch_t* hcl_backuperrmsg (hcl_t* hcl)
{ {
hcl_copyoocstr (hcl->errmsg.tmpbuf.ooch, HCL_COUNTOF(hcl->errmsg.tmpbuf.ooch), hcl_geterrmsg(hcl)); hcl_copy_oocstr (hcl->errmsg.tmpbuf.ooch, HCL_COUNTOF(hcl->errmsg.tmpbuf.ooch), hcl_geterrmsg(hcl));
return hcl->errmsg.tmpbuf.ooch; return hcl->errmsg.tmpbuf.ooch;
} }

View File

@ -150,7 +150,7 @@ static void syserrstrb (hcl_t* hcl, int syserr, hcl_bch_t* buf, hcl_oow_t len)
strerror_r (syserr, buf, len); strerror_r (syserr, buf, len);
#else #else
/* this may not be thread safe */ /* this may not be thread safe */
hcl_copybcstr (buf, len, strerror(syserr)); hcl_copy_bcstr (buf, len, strerror(syserr));
#endif #endif
} }
@ -211,7 +211,7 @@ static int add_to_reply_token (hcl_client_t* client, hcl_ooch_t ch)
static HCL_INLINE int is_token (hcl_client_t* client, const hcl_bch_t* str) static HCL_INLINE int is_token (hcl_client_t* client, const hcl_bch_t* str)
{ {
return hcl_compoocharsbcstr(client->rep.tok.ptr, client->rep.tok.len, str) == 0; return hcl_comp_oochars_bcstr(client->rep.tok.ptr, client->rep.tok.len, str) == 0;
} }
static HCL_INLINE int is_token_integer (hcl_client_t* client, hcl_oow_t* value) static HCL_INLINE int is_token_integer (hcl_client_t* client, hcl_oow_t* value)
@ -473,7 +473,7 @@ static int handle_char (hcl_client_t* client, hcl_ooci_t c, hcl_oow_t nbytes)
client->rep.last_attr_key.capa = client->rep.tok.capa; client->rep.last_attr_key.capa = client->rep.tok.capa;
} }
hcl_copyoochars (client->rep.last_attr_key.ptr, client->rep.tok.ptr, client->rep.tok.len); hcl_copy_oochars (client->rep.last_attr_key.ptr, client->rep.tok.ptr, client->rep.tok.len);
client->rep.last_attr_key.len = client->rep.tok.len; client->rep.last_attr_key.len = client->rep.tok.len;
client->state = HCL_CLIENT_STATE_IN_ATTR_VALUE_START; client->state = HCL_CLIENT_STATE_IN_ATTR_VALUE_START;
@ -766,7 +766,7 @@ static int feed_reply_data (hcl_client_t* client, const hcl_bch_t* data, hcl_oow
bcslen = end - ptr; bcslen = end - ptr;
ucslen = 1; ucslen = 1;
n = hcl_conv_bcsn_to_ucsn_with_cmgr(ptr, &bcslen, &uc, &ucslen, client->cmgr, 0); n = hcl_conv_bchars_to_uchars_with_cmgr(ptr, &bcslen, &uc, &ucslen, client->cmgr, 0);
if (n <= -1) if (n <= -1)
{ {
if (n == -3) if (n == -3)
@ -950,7 +950,7 @@ void hcl_client_seterrbfmt (hcl_client_t* client, hcl_errnum_t errnum, const hcl
HCL_ASSERT (client->dummy_hcl, HCL_COUNTOF(client->errmsg.buf) == HCL_COUNTOF(client->dummy_hcl->errmsg.buf)); HCL_ASSERT (client->dummy_hcl, HCL_COUNTOF(client->errmsg.buf) == HCL_COUNTOF(client->dummy_hcl->errmsg.buf));
client->errnum = errnum; client->errnum = errnum;
hcl_copyoochars (client->errmsg.buf, client->dummy_hcl->errmsg.buf, HCL_COUNTOF(client->errmsg.buf)); hcl_copy_oochars (client->errmsg.buf, client->dummy_hcl->errmsg.buf, HCL_COUNTOF(client->errmsg.buf));
client->errmsg.len = client->dummy_hcl->errmsg.len; client->errmsg.len = client->dummy_hcl->errmsg.len;
} }
@ -964,7 +964,7 @@ void hcl_client_seterrufmt (hcl_client_t* client, hcl_errnum_t errnum, const hcl
HCL_ASSERT (client->dummy_hcl, HCL_COUNTOF(client->errmsg.buf) == HCL_COUNTOF(client->dummy_hcl->errmsg.buf)); HCL_ASSERT (client->dummy_hcl, HCL_COUNTOF(client->errmsg.buf) == HCL_COUNTOF(client->dummy_hcl->errmsg.buf));
client->errnum = errnum; client->errnum = errnum;
hcl_copyoochars (client->errmsg.buf, client->dummy_hcl->errmsg.buf, HCL_COUNTOF(client->errmsg.buf)); hcl_copy_oochars (client->errmsg.buf, client->dummy_hcl->errmsg.buf, HCL_COUNTOF(client->errmsg.buf));
client->errmsg.len = client->dummy_hcl->errmsg.len; client->errmsg.len = client->dummy_hcl->errmsg.len;
} }

View File

@ -393,7 +393,7 @@ static HCL_INLINE int open_input (hcl_t* hcl, hcl_ioinarg_t* arg)
#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_countbcstr(arg->name); bcslen = hcl_count_bcstr(arg->name);
#endif #endif
fn = ((bb_t*)arg->includer->handle)->fn; fn = ((bb_t*)arg->includer->handle)->fn;
@ -402,7 +402,7 @@ static HCL_INLINE int open_input (hcl_t* hcl, hcl_ioinarg_t* arg)
#if defined(HCL_OOCH_IS_UCH) #if defined(HCL_OOCH_IS_UCH)
if (hcl_convootobcstr(hcl, server->cfg.script_include_path, &ucslen, HCL_NULL, &parlen) <= -1) goto oops; if (hcl_convootobcstr(hcl, server->cfg.script_include_path, &ucslen, HCL_NULL, &parlen) <= -1) goto oops;
#else #else
parlen = hcl_countbcstr(server->cfg.script_include_path); parlen = hcl_count_bcstr(server->cfg.script_include_path);
#endif #endif
} }
else else
@ -420,19 +420,19 @@ static HCL_INLINE int open_input (hcl_t* hcl, hcl_ioinarg_t* arg)
#if defined(HCL_OOCH_IS_UCH) #if defined(HCL_OOCH_IS_UCH)
hcl_convootobcstr (hcl, server->cfg.script_include_path, &ucslen, bb->fn, &parlen); hcl_convootobcstr (hcl, server->cfg.script_include_path, &ucslen, bb->fn, &parlen);
#else #else
hcl_copybchars (bb->fn, server->cfg.script_include_path, parlen); hcl_copy_bchars (bb->fn, server->cfg.script_include_path, parlen);
#endif #endif
if (!IS_PATH_SEP(bb->fn[parlen])) bb->fn[parlen++] = PATH_SEP_CHAR; /* +2 was used in hcl_callocmem() for this (+1 for this, +1 for '\0' */ if (!IS_PATH_SEP(bb->fn[parlen])) bb->fn[parlen++] = PATH_SEP_CHAR; /* +2 was used in hcl_callocmem() for this (+1 for this, +1 for '\0' */
} }
else else
{ {
hcl_copybchars (bb->fn, fn, parlen); hcl_copy_bchars (bb->fn, fn, parlen);
} }
#if defined(HCL_OOCH_IS_UCH) #if defined(HCL_OOCH_IS_UCH)
hcl_convootobcstr (hcl, arg->name, &ucslen, &bb->fn[parlen], &bcslen); hcl_convootobcstr (hcl, arg->name, &ucslen, &bb->fn[parlen], &bcslen);
#else #else
hcl_copybcstr (&bb->fn[parlen], bcslen + 1, arg->name); hcl_copy_bcstr (&bb->fn[parlen], bcslen + 1, arg->name);
#endif #endif
bb->fd = open(bb->fn, O_RDONLY, 0); bb->fd = open(bb->fn, O_RDONLY, 0);
} }
@ -445,7 +445,7 @@ static HCL_INLINE int open_input (hcl_t* hcl, hcl_ioinarg_t* arg)
/* copy ane empty string as a main stream's name */ /* copy ane empty string as a main stream's name */
bb->fn = (hcl_bch_t*)(bb + 1); bb->fn = (hcl_bch_t*)(bb + 1);
hcl_copybcstr (bb->fn, pathlen + 1, ""); hcl_copy_bcstr (bb->fn, pathlen + 1, "");
bb->fd = xtn->proto->worker->sck; bb->fd = xtn->proto->worker->sck;
} }
@ -571,7 +571,7 @@ static HCL_INLINE int read_input (hcl_t* hcl, hcl_ioinarg_t* arg)
#else #else
bcslen = (bb->len < HCL_COUNTOF(arg->buf))? bb->len: HCL_COUNTOF(arg->buf); bcslen = (bb->len < HCL_COUNTOF(arg->buf))? bb->len: HCL_COUNTOF(arg->buf);
ucslen = bcslen; ucslen = bcslen;
hcl_copybchars (arg->buf, bb->buf, bcslen); hcl_copy_bchars (arg->buf, bb->buf, bcslen);
#endif #endif
remlen = bb->len - bcslen; remlen = bb->len - bcslen;
@ -727,7 +727,7 @@ static void syserrstrb (hcl_t* hcl, int syserr, hcl_bch_t* buf, hcl_oow_t len)
strerror_r (syserr, buf, len); strerror_r (syserr, buf, len);
#else #else
/* this may not be thread safe */ /* this may not be thread safe */
hcl_copybcstr (buf, len, strerror(syserr)); hcl_copy_bcstr (buf, len, strerror(syserr));
#endif #endif
} }
@ -746,7 +746,7 @@ static void* dl_open (hcl_t* hcl, const hcl_ooch_t* name, int flags)
* and HCL_COUNTOF(HCL_DEFAULT_PFMODPOSTIFX) include the terminating nulls. Never mind about * and HCL_COUNTOF(HCL_DEFAULT_PFMODPOSTIFX) include the terminating nulls. Never mind about
* the extra 2 characters. */ * the extra 2 characters. */
#else #else
bufcapa = hcl_countbcstr(name); bufcapa = hcl_count_bcstr(name);
#endif #endif
bufcapa += HCL_COUNTOF(HCL_DEFAULT_PFMODPREFIX) + HCL_COUNTOF(HCL_DEFAULT_PFMODPOSTFIX) + 1; bufcapa += HCL_COUNTOF(HCL_DEFAULT_PFMODPREFIX) + HCL_COUNTOF(HCL_DEFAULT_PFMODPOSTFIX) + 1;
@ -762,13 +762,13 @@ static void* dl_open (hcl_t* hcl, const hcl_ooch_t* name, int flags)
hcl_oow_t len, i, xlen; hcl_oow_t len, i, xlen;
/* opening a primitive function module - mostly libhcl-xxxx */ /* opening a primitive function module - mostly libhcl-xxxx */
len = hcl_copybcstr(bufptr, bufcapa, HCL_DEFAULT_PFMODPREFIX); len = hcl_copy_bcstr(bufptr, bufcapa, HCL_DEFAULT_PFMODPREFIX);
bcslen = bufcapa - len; bcslen = bufcapa - len;
#if defined(HCL_OOCH_IS_UCH) #if defined(HCL_OOCH_IS_UCH)
hcl_convootobcstr(hcl, name, &ucslen, &bufptr[len], &bcslen); hcl_convootobcstr(hcl, name, &ucslen, &bufptr[len], &bcslen);
#else #else
bcslen = hcl_copybcstr(&bufptr[len], bcslen, name); bcslen = hcl_copy_bcstr(&bufptr[len], bcslen, name);
#endif #endif
/* length including the prefix and the name. but excluding the postfix */ /* length including the prefix and the name. but excluding the postfix */
@ -781,7 +781,7 @@ static void* dl_open (hcl_t* hcl, const hcl_ooch_t* name, int flags)
} }
retry: retry:
hcl_copybcstr (&bufptr[xlen], bufcapa - xlen, HCL_DEFAULT_PFMODPOSTFIX); hcl_copy_bcstr (&bufptr[xlen], bufcapa - xlen, HCL_DEFAULT_PFMODPOSTFIX);
/* both prefix and postfix attached. for instance, libhcl-xxx */ /* both prefix and postfix attached. for instance, libhcl-xxx */
handle = sys_dl_openext(bufptr); handle = sys_dl_openext(bufptr);
@ -800,7 +800,7 @@ static void* dl_open (hcl_t* hcl, const hcl_ooch_t* name, int flags)
HCL_DEBUG3 (hcl, "Failed to open(ext) DL %hs[%js] - %hs\n", &bufptr[len], name, dl_errstr); HCL_DEBUG3 (hcl, "Failed to open(ext) DL %hs[%js] - %hs\n", &bufptr[len], name, dl_errstr);
hcl_seterrbfmt (hcl, HCL_ESYSERR, "unable to open(ext) DL %js - %hs", name, dl_errstr); hcl_seterrbfmt (hcl, HCL_ESYSERR, "unable to open(ext) DL %js - %hs", name, dl_errstr);
dash = hcl_rfindbchar(bufptr, hcl_countbcstr(bufptr), '-'); dash = hcl_rfind_bchar(bufptr, hcl_count_bcstr(bufptr), '-');
if (dash) if (dash)
{ {
/* remove a segment at the back. /* remove a segment at the back.
@ -828,10 +828,10 @@ static void* dl_open (hcl_t* hcl, const hcl_ooch_t* name, int flags)
bcslen = bufcapa; bcslen = bufcapa;
hcl_convootobcstr(hcl, name, &ucslen, bufptr, &bcslen); hcl_convootobcstr(hcl, name, &ucslen, bufptr, &bcslen);
#else #else
bcslen = hcl_copybcstr(bufptr, bufcapa, name); bcslen = hcl_copy_bcstr(bufptr, bufcapa, name);
#endif #endif
if (hcl_findbchar(bufptr, bcslen, '.')) if (hcl_find_bchar(bufptr, bcslen, '.'))
{ {
handle = sys_dl_open(bufptr); handle = sys_dl_open(bufptr);
if (!handle) if (!handle)
@ -893,7 +893,7 @@ static void* dl_getsym (hcl_t* hcl, void* handle, const hcl_ooch_t* name)
#if defined(HCL_OOCH_IS_UCH) #if defined(HCL_OOCH_IS_UCH)
if (hcl_convootobcstr(hcl, name, &ucslen, HCL_NULL, &bcslen) <= -1) return HCL_NULL; if (hcl_convootobcstr(hcl, name, &ucslen, HCL_NULL, &bcslen) <= -1) return HCL_NULL;
#else #else
bcslen = hcl_countbcstr (name); bcslen = hcl_count_bcstr (name);
#endif #endif
if (bcslen >= HCL_COUNTOF(stabuf) - 2) if (bcslen >= HCL_COUNTOF(stabuf) - 2)
@ -912,7 +912,7 @@ static void* dl_getsym (hcl_t* hcl, void* handle, const hcl_ooch_t* name)
#if defined(HCL_OOCH_IS_UCH) #if defined(HCL_OOCH_IS_UCH)
hcl_convootobcstr (hcl, name, &ucslen, &bufptr[1], &bcslen); hcl_convootobcstr (hcl, name, &ucslen, &bufptr[1], &bcslen);
#else #else
bcslen = hcl_copybcstr(&bufptr[1], bcslen, name); bcslen = hcl_copy_bcstr(&bufptr[1], bcslen, name);
#endif #endif
/* convert a period(.) to an underscore(_) */ /* convert a period(.) to an underscore(_) */
@ -1252,7 +1252,7 @@ int hcl_server_proto_end_reply (hcl_server_proto_t* proto, const hcl_ooch_t* fai
simple_error: simple_error:
if (hcl_server_proto_feed_reply(proto, err1, 8, 0) <= -1 || if (hcl_server_proto_feed_reply(proto, err1, 8, 0) <= -1 ||
hcl_server_proto_feed_reply(proto, failmsg, hcl_countoocstr(failmsg), 1) <= -1 || hcl_server_proto_feed_reply(proto, failmsg, hcl_count_oocstr(failmsg), 1) <= -1 ||
hcl_server_proto_feed_reply(proto, err2, 2, 0) <= -1) return -1; hcl_server_proto_feed_reply(proto, err2, 2, 0) <= -1) return -1;
if (write_reply_chunk(proto) <= -1) return -1; if (write_reply_chunk(proto) <= -1) return -1;
@ -1394,7 +1394,7 @@ static void classify_current_ident_token (hcl_server_proto_t* proto)
for (i = 0; i < HCL_COUNTOF(tab); i++) for (i = 0; i < HCL_COUNTOF(tab); i++)
{ {
if (hcl_compoocharsoocstr(proto->tok.ptr, proto->tok.len, tab[i].name) == 0) if (hcl_comp_oochars_oocstr(proto->tok.ptr, proto->tok.len, tab[i].name) == 0)
{ {
SET_TOKEN_TYPE (proto, tab[i].type); SET_TOKEN_TYPE (proto, tab[i].type);
break; break;
@ -2264,13 +2264,13 @@ static void set_err_with_syserr (hcl_server_t* server, int syserr, const char* b
va_end (ap); va_end (ap);
#if defined(HCL_OOCH_IS_UCH) #if defined(HCL_OOCH_IS_UCH)
hcl->errmsg.len += hcl_copyucstr(&hcl->errmsg.buf[hcl->errmsg.len], HCL_COUNTOF(hcl->errmsg.buf) - hcl->errmsg.len, u_dash); hcl->errmsg.len += hcl_copy_ucstr(&hcl->errmsg.buf[hcl->errmsg.len], HCL_COUNTOF(hcl->errmsg.buf) - hcl->errmsg.len, u_dash);
tmplen2 = HCL_COUNTOF(hcl->errmsg.buf) - hcl->errmsg.len; tmplen2 = HCL_COUNTOF(hcl->errmsg.buf) - hcl->errmsg.len;
hcl_convbtoucstr (hcl, hcl->errmsg.tmpbuf.bch, &tmplen, &hcl->errmsg.buf[hcl->errmsg.len], &tmplen2); hcl_convbtoucstr (hcl, hcl->errmsg.tmpbuf.bch, &tmplen, &hcl->errmsg.buf[hcl->errmsg.len], &tmplen2);
hcl->errmsg.len += tmplen2; /* ignore conversion errors */ hcl->errmsg.len += tmplen2; /* ignore conversion errors */
#else #else
hcl->errmsg.len += hcl_copybcstr(&hcl->errmsg.buf[hcl->errmsg.len], HCL_COUNTOF(hcl->errmsg.buf) - hcl->errmsg.len, b_dash); hcl->errmsg.len += hcl_copy_bcstr(&hcl->errmsg.buf[hcl->errmsg.len], HCL_COUNTOF(hcl->errmsg.buf) - hcl->errmsg.len, b_dash);
hcl->errmsg.len += hcl_copybcstr(&hcl->errmsg.buf[hcl->errmsg.len], HCL_COUNTOF(hcl->errmsg.buf) - hcl->errmsg.len, hcl->errmsg.tmpbuf.bch); hcl->errmsg.len += hcl_copy_bcstr(&hcl->errmsg.buf[hcl->errmsg.len], HCL_COUNTOF(hcl->errmsg.buf) - hcl->errmsg.len, hcl->errmsg.tmpbuf.bch);
#endif #endif
} }
@ -2285,10 +2285,10 @@ static void set_err_with_syserr (hcl_server_t* server, int syserr, const char* b
va_end (ap); va_end (ap);
#if defined(HCL_OOCH_IS_UCH) #if defined(HCL_OOCH_IS_UCH)
hcl->errmsg.len += hcl_copyucstr(&hcl->errmsg.buf[hcl->errmsg.len], HCL_COUNTOF(hcl->errmsg.buf) - hcl->errmsg.len, u_dash); hcl->errmsg.len += hcl_copy_ucstr(&hcl->errmsg.buf[hcl->errmsg.len], HCL_COUNTOF(hcl->errmsg.buf) - hcl->errmsg.len, u_dash);
hcl->errmsg.len += hcl_copyucstr(&hcl->errmsg.buf[hcl->errmsg.len], HCL_COUNTOF(hcl->errmsg.buf) - hcl->errmsg.len, hcl->errmsg.tmpbuf.uch); hcl->errmsg.len += hcl_copy_ucstr(&hcl->errmsg.buf[hcl->errmsg.len], HCL_COUNTOF(hcl->errmsg.buf) - hcl->errmsg.len, hcl->errmsg.tmpbuf.uch);
#else #else
hcl->errmsg.len += hcl_copybcstr(&hcl->errmsg.buf[hcl->errmsg.len], HCL_COUNTOF(hcl->errmsg.buf) - hcl->errmsg.len, b_dash); hcl->errmsg.len += hcl_copy_bcstr(&hcl->errmsg.buf[hcl->errmsg.len], HCL_COUNTOF(hcl->errmsg.buf) - hcl->errmsg.len, b_dash);
tmplen2 = HCL_COUNTOF(hcl->errmsg.buf) - hcl->errmsg.len; tmplen2 = HCL_COUNTOF(hcl->errmsg.buf) - hcl->errmsg.len;
hcl_convutobcstr (hcl, hcl->errmsg.tmpbuf.uch, &tmplen, &hcl->errmsg.buf[hcl->errmsg.len], &tmplen2); hcl_convutobcstr (hcl, hcl->errmsg.tmpbuf.uch, &tmplen, &hcl->errmsg.buf[hcl->errmsg.len], &tmplen2);
hcl->errmsg.len += tmplen2; /* ignore conversion errors */ hcl->errmsg.len += tmplen2; /* ignore conversion errors */
@ -2296,7 +2296,7 @@ static void set_err_with_syserr (hcl_server_t* server, int syserr, const char* b
} }
server->errnum = errnum; server->errnum = errnum;
hcl_copyoochars (server->errmsg.buf, server->dummy_hcl->errmsg.buf, HCL_COUNTOF(server->errmsg.buf)); hcl_copy_oochars (server->errmsg.buf, server->dummy_hcl->errmsg.buf, HCL_COUNTOF(server->errmsg.buf));
server->errmsg.len = server->dummy_hcl->errmsg.len; server->errmsg.len = server->dummy_hcl->errmsg.len;
} }
@ -2363,8 +2363,8 @@ static int setup_listeners (hcl_server_t* server, const hcl_bch_t* addrs)
hcl_oow_t addr_len; hcl_oow_t addr_len;
hcl_server_listener_t* listener; hcl_server_listener_t* listener;
comma = hcl_findbcharinbcstr(addr_ptr, ','); comma = hcl_find_bchar_in_bcstr(addr_ptr, ',');
addr_len = comma? comma - addr_ptr: hcl_countbcstr(addr_ptr); addr_len = comma? comma - addr_ptr: hcl_count_bcstr(addr_ptr);
/* [NOTE] no whitespaces are allowed before and after a comma */ /* [NOTE] no whitespaces are allowed before and after a comma */
sck_fam = hcl_bchars_to_sckaddr(addr_ptr, addr_len, &srv_addr, &srv_len); sck_fam = hcl_bchars_to_sckaddr(addr_ptr, addr_len, &srv_addr, &srv_len);
@ -2642,7 +2642,7 @@ int hcl_server_setoption (hcl_server_t* server, hcl_server_option_t id, const vo
return 0; return 0;
case HCL_SERVER_SCRIPT_INCLUDE_PATH: case HCL_SERVER_SCRIPT_INCLUDE_PATH:
hcl_copyoocstr (server->cfg.script_include_path, HCL_COUNTOF(server->cfg.script_include_path), (const hcl_ooch_t*)value); hcl_copy_oocstr (server->cfg.script_include_path, HCL_COUNTOF(server->cfg.script_include_path), (const hcl_ooch_t*)value);
return 0; return 0;
} }
@ -2744,7 +2744,7 @@ void hcl_server_seterrbfmt (hcl_server_t* server, hcl_errnum_t errnum, const hcl
HCL_ASSERT (server->dummy_hcl, HCL_COUNTOF(server->errmsg.buf) == HCL_COUNTOF(server->dummy_hcl->errmsg.buf)); HCL_ASSERT (server->dummy_hcl, HCL_COUNTOF(server->errmsg.buf) == HCL_COUNTOF(server->dummy_hcl->errmsg.buf));
server->errnum = errnum; server->errnum = errnum;
hcl_copyoochars (server->errmsg.buf, server->dummy_hcl->errmsg.buf, HCL_COUNTOF(server->errmsg.buf)); hcl_copy_oochars (server->errmsg.buf, server->dummy_hcl->errmsg.buf, HCL_COUNTOF(server->errmsg.buf));
server->errmsg.len = server->dummy_hcl->errmsg.len; server->errmsg.len = server->dummy_hcl->errmsg.len;
} }
@ -2759,7 +2759,7 @@ void hcl_server_seterrufmt (hcl_server_t* server, hcl_errnum_t errnum, const hcl
HCL_ASSERT (server->dummy_hcl, HCL_COUNTOF(server->errmsg.buf) == HCL_COUNTOF(server->dummy_hcl->errmsg.buf)); HCL_ASSERT (server->dummy_hcl, HCL_COUNTOF(server->errmsg.buf) == HCL_COUNTOF(server->dummy_hcl->errmsg.buf));
server->errnum = errnum; server->errnum = errnum;
server->errnum = errnum; server->errnum = errnum;
hcl_copyoochars (server->errmsg.buf, server->dummy_hcl->errmsg.buf, HCL_COUNTOF(server->errmsg.buf)); hcl_copy_oochars (server->errmsg.buf, server->dummy_hcl->errmsg.buf, HCL_COUNTOF(server->errmsg.buf));
server->errmsg.len = server->dummy_hcl->errmsg.len; server->errmsg.len = server->dummy_hcl->errmsg.len;
} }

View File

@ -183,7 +183,7 @@ typedef struct hcl_sckaddr_t hcl_sckaddr_t;
extern "C" { extern "C" {
#endif #endif
HCL_EXPORT hcl_oow_t hcl_hashbytes ( HCL_EXPORT hcl_oow_t hcl_hash_bytes (
const hcl_oob_t* ptr, const hcl_oob_t* ptr,
hcl_oow_t len hcl_oow_t len
); );
@ -191,28 +191,28 @@ HCL_EXPORT hcl_oow_t hcl_hashbytes (
#if defined(HCL_HAVE_INLINE) #if defined(HCL_HAVE_INLINE)
static HCL_INLINE hcl_oow_t hcl_hashbchars (const hcl_bch_t* ptr, hcl_oow_t len) static HCL_INLINE hcl_oow_t hcl_hashbchars (const hcl_bch_t* ptr, hcl_oow_t len)
{ {
return hcl_hashbytes((const hcl_oob_t*)ptr, len * HCL_SIZEOF(hcl_bch_t)); return hcl_hash_bytes((const hcl_oob_t*)ptr, len * HCL_SIZEOF(hcl_bch_t));
} }
static HCL_INLINE hcl_oow_t hcl_hashuchars (const hcl_uch_t* ptr, hcl_oow_t len) static HCL_INLINE hcl_oow_t hcl_hashuchars (const hcl_uch_t* ptr, hcl_oow_t len)
{ {
return hcl_hashbytes((const hcl_oob_t*)ptr, len * HCL_SIZEOF(hcl_uch_t)); return hcl_hash_bytes((const hcl_oob_t*)ptr, len * HCL_SIZEOF(hcl_uch_t));
} }
static HCL_INLINE hcl_oow_t hcl_hashwords (const hcl_oow_t* ptr, hcl_oow_t len) static HCL_INLINE hcl_oow_t hcl_hashwords (const hcl_oow_t* ptr, hcl_oow_t len)
{ {
return hcl_hashbytes((const hcl_oob_t*)ptr, len * HCL_SIZEOF(hcl_oow_t)); return hcl_hash_bytes((const hcl_oob_t*)ptr, len * HCL_SIZEOF(hcl_oow_t));
} }
static HCL_INLINE hcl_oow_t hcl_hashhalfwords (const hcl_oohw_t* ptr, hcl_oow_t len) static HCL_INLINE hcl_oow_t hcl_hashhalfwords (const hcl_oohw_t* ptr, hcl_oow_t len)
{ {
return hcl_hashbytes((const hcl_oob_t*)ptr, len * HCL_SIZEOF(hcl_oohw_t)); return hcl_hash_bytes((const hcl_oob_t*)ptr, len * HCL_SIZEOF(hcl_oohw_t));
} }
#else #else
# define hcl_hashbchars(ptr,len) hcl_hashbytes((const hcl_oob_t*)ptr, len * HCL_SIZEOF(hcl_bch_t)) # define hcl_hashbchars(ptr,len) hcl_hash_bytes((const hcl_oob_t*)ptr, len * HCL_SIZEOF(hcl_bch_t))
# define hcl_hashuchars(ptr,len) hcl_hashbytes((const hcl_oob_t*)ptr, len * HCL_SIZEOF(hcl_uch_t)) # define hcl_hashuchars(ptr,len) hcl_hash_bytes((const hcl_oob_t*)ptr, len * HCL_SIZEOF(hcl_uch_t))
# define hcl_hashwords(ptr,len) hcl_hashbytes((const hcl_oob_t*)ptr, len * HCL_SIZEOF(hcl_oow_t)) # define hcl_hashwords(ptr,len) hcl_hash_bytes((const hcl_oob_t*)ptr, len * HCL_SIZEOF(hcl_oow_t))
# define hcl_hashhalfwords(ptr,len) hcl_hashbytes((const hcl_oob_t*)ptr, len * HCL_SIZEOF(hcl_oohw_t)) # define hcl_hashhalfwords(ptr,len) hcl_hash_bytes((const hcl_oob_t*)ptr, len * HCL_SIZEOF(hcl_oohw_t))
#endif #endif
#if defined(HCL_OOCH_IS_UCH) #if defined(HCL_OOCH_IS_UCH)
@ -222,199 +222,180 @@ HCL_EXPORT hcl_oow_t hcl_hashbytes (
#endif #endif
/** /**
* The hcl_equaluchars() function determines equality of two strings * The hcl_equal_uchars() function determines equality of two strings
* of the same length \a len. * of the same length \a len.
*/ */
HCL_EXPORT int hcl_equaluchars ( HCL_EXPORT int hcl_equal_uchars (
const hcl_uch_t* str1, const hcl_uch_t* str1,
const hcl_uch_t* str2, const hcl_uch_t* str2,
hcl_oow_t len hcl_oow_t len
); );
HCL_EXPORT int hcl_equalbchars ( HCL_EXPORT int hcl_equal_bchars (
const hcl_bch_t* str1, const hcl_bch_t* str1,
const hcl_bch_t* str2, const hcl_bch_t* str2,
hcl_oow_t len hcl_oow_t len
); );
HCL_EXPORT int hcl_compuchars ( HCL_EXPORT int hcl_comp_uchars (
const hcl_uch_t* str1, const hcl_uch_t* str1,
hcl_oow_t len1, hcl_oow_t len1,
const hcl_uch_t* str2, const hcl_uch_t* str2,
hcl_oow_t len2 hcl_oow_t len2
); );
HCL_EXPORT int hcl_compbchars ( HCL_EXPORT int hcl_comp_bchars (
const hcl_bch_t* str1, const hcl_bch_t* str1,
hcl_oow_t len1, hcl_oow_t len1,
const hcl_bch_t* str2, const hcl_bch_t* str2,
hcl_oow_t len2 hcl_oow_t len2
); );
HCL_EXPORT int hcl_compucstr ( HCL_EXPORT int hcl_comp_ucstr (
const hcl_uch_t* str1, const hcl_uch_t* str1,
const hcl_uch_t* str2 const hcl_uch_t* str2
); );
HCL_EXPORT int hcl_compbcstr ( HCL_EXPORT int hcl_comp_bcstr (
const hcl_bch_t* str1, const hcl_bch_t* str1,
const hcl_bch_t* str2 const hcl_bch_t* str2
); );
HCL_EXPORT int hcl_compucbcstr ( HCL_EXPORT int hcl_comp_ucstr_bcstr (
const hcl_uch_t* str1, const hcl_uch_t* str1,
const hcl_bch_t* str2 const hcl_bch_t* str2
); );
HCL_EXPORT int hcl_compucharsucstr ( HCL_EXPORT int hcl_comp_uchars_ucstr (
const hcl_uch_t* str1, const hcl_uch_t* str1,
hcl_oow_t len, hcl_oow_t len,
const hcl_uch_t* str2 const hcl_uch_t* str2
); );
HCL_EXPORT int hcl_compucharsbcstr ( HCL_EXPORT int hcl_comp_uchars_bcstr (
const hcl_uch_t* str1, const hcl_uch_t* str1,
hcl_oow_t len, hcl_oow_t len,
const hcl_bch_t* str2 const hcl_bch_t* str2
); );
HCL_EXPORT int hcl_compbcharsbcstr ( HCL_EXPORT int hcl_comp_bchars_bcstr (
const hcl_bch_t* str1, const hcl_bch_t* str1,
hcl_oow_t len, hcl_oow_t len,
const hcl_bch_t* str2 const hcl_bch_t* str2
); );
HCL_EXPORT int hcl_compbcharsucstr ( HCL_EXPORT int hcl_comp_bchars_ucstr (
const hcl_bch_t* str1, const hcl_bch_t* str1,
hcl_oow_t len, hcl_oow_t len,
const hcl_uch_t* str2 const hcl_uch_t* str2
); );
HCL_EXPORT void hcl_copyuchars ( HCL_EXPORT void hcl_copy_uchars (
hcl_uch_t* dst, hcl_uch_t* dst,
const hcl_uch_t* src, const hcl_uch_t* src,
hcl_oow_t len hcl_oow_t len
); );
HCL_EXPORT void hcl_copybchars ( HCL_EXPORT void hcl_copy_bchars (
hcl_bch_t* dst, hcl_bch_t* dst,
const hcl_bch_t* src, const hcl_bch_t* src,
hcl_oow_t len hcl_oow_t len
); );
HCL_EXPORT void hcl_copybtouchars ( HCL_EXPORT void hcl_copy_bchars_to_uchars (
hcl_uch_t* dst, hcl_uch_t* dst,
const hcl_bch_t* src, const hcl_bch_t* src,
hcl_oow_t len hcl_oow_t len
); );
HCL_EXPORT hcl_oow_t hcl_copyucstr ( HCL_EXPORT hcl_oow_t hcl_copy_ucstr (
hcl_uch_t* dst, hcl_uch_t* dst,
hcl_oow_t len, hcl_oow_t len,
const hcl_uch_t* src const hcl_uch_t* src
); );
HCL_EXPORT hcl_oow_t hcl_copybcstr ( HCL_EXPORT hcl_oow_t hcl_copy_bcstr (
hcl_bch_t* dst, hcl_bch_t* dst,
hcl_oow_t len, hcl_oow_t len,
const hcl_bch_t* src const hcl_bch_t* src
); );
HCL_EXPORT hcl_uch_t* hcl_finduchar ( HCL_EXPORT hcl_uch_t* hcl_find_uchar (
const hcl_uch_t* ptr, const hcl_uch_t* ptr,
hcl_oow_t len, hcl_oow_t len,
hcl_uch_t c hcl_uch_t c
); );
HCL_EXPORT hcl_bch_t* hcl_findbchar ( HCL_EXPORT hcl_bch_t* hcl_find_bchar (
const hcl_bch_t* ptr, const hcl_bch_t* ptr,
hcl_oow_t len, hcl_oow_t len,
hcl_bch_t c hcl_bch_t c
); );
HCL_EXPORT hcl_uch_t* hcl_rfinduchar ( HCL_EXPORT hcl_uch_t* hcl_rfind_uchar (
const hcl_uch_t* ptr, const hcl_uch_t* ptr,
hcl_oow_t len, hcl_oow_t len,
hcl_uch_t c hcl_uch_t c
); );
HCL_EXPORT hcl_bch_t* hcl_rfindbchar ( HCL_EXPORT hcl_bch_t* hcl_rfind_bchar (
const hcl_bch_t* ptr, const hcl_bch_t* ptr,
hcl_oow_t len, hcl_oow_t len,
hcl_bch_t c hcl_bch_t c
); );
HCL_EXPORT hcl_uch_t* hcl_finducharinucstr ( HCL_EXPORT hcl_uch_t* hcl_find_uchar_in_ucstr (
const hcl_uch_t* ptr, const hcl_uch_t* ptr,
hcl_uch_t c hcl_uch_t c
); );
HCL_EXPORT hcl_bch_t* hcl_findbcharinbcstr ( HCL_EXPORT hcl_bch_t* hcl_find_bchar_in_bcstr (
const hcl_bch_t* ptr, const hcl_bch_t* ptr,
hcl_bch_t c hcl_bch_t c
); );
HCL_EXPORT hcl_oow_t hcl_countucstr ( HCL_EXPORT hcl_oow_t hcl_count_ucstr (
const hcl_uch_t* str const hcl_uch_t* str
); );
HCL_EXPORT hcl_oow_t hcl_countbcstr ( HCL_EXPORT hcl_oow_t hcl_count_bcstr (
const hcl_bch_t* str const hcl_bch_t* str
); );
#if defined(HCL_OOCH_IS_UCH) #if defined(HCL_OOCH_IS_UCH)
# define hcl_equaloochars(str1,str2,len) hcl_equaluchars(str1,str2,len) # define hcl_equal_oochars(str1,str2,len) hcl_equal_uchars(str1,str2,len)
# define hcl_compoochars(str1,len1,str2,len2) hcl_compuchars(str1,len1,str2,len2) # define hcl_comp_oochars(str1,len1,str2,len2) hcl_comp_uchars(str1,len1,str2,len2)
# define hcl_compoocbcstr(str1,str2) hcl_compucbcstr(str1,str2) # define hcl_comp_oocstr_bcstr(str1,str2) hcl_comp_ucstr_bcstr(str1,str2)
# define hcl_compoocharsbcstr(str1,len1,str2) hcl_compucharsbcstr(str1,len1,str2) # define hcl_comp_oochars_bcstr(str1,len1,str2) hcl_comp_uchars_bcstr(str1,len1,str2)
# define hcl_compoocharsucstr(str1,len1,str2) hcl_compucharsucstr(str1,len1,str2) # define hcl_comp_oochars_ucstr(str1,len1,str2) hcl_comp_uchars_ucstr(str1,len1,str2)
# define hcl_compoocharsoocstr(str1,len1,str2) hcl_compucharsucstr(str1,len1,str2) # define hcl_comp_oochars_oocstr(str1,len1,str2) hcl_comp_uchars_ucstr(str1,len1,str2)
# define hcl_compoocstr(str1,str2) hcl_compucstr(str1,str2) # define hcl_comp_oocstr(str1,str2) hcl_comp_ucstr(str1,str2)
# define hcl_copyoochars(dst,src,len) hcl_copyuchars(dst,src,len) # define hcl_copy_oochars(dst,src,len) hcl_copy_uchars(dst,src,len)
# define hcl_copybctooochars(dst,src,len) hcl_copybtouchars(dst,src,len) # define hcl_copy_bchars_to_oochars(dst,src,len) hcl_copy_bchars_to_uchars(dst,src,len)
# define hcl_copyoocstr(dst,len,src) hcl_copyucstr(dst,len,src) # define hcl_copy_oocstr(dst,len,src) hcl_copy_ucstr(dst,len,src)
# define hcl_findoochar(ptr,len,c) hcl_finduchar(ptr,len,c) # define hcl_find_oochar(ptr,len,c) hcl_find_uchar(ptr,len,c)
# define hcl_rfindoochar(ptr,len,c) hcl_rfinduchar(ptr,len,c) # define hcl_rfind_oochar(ptr,len,c) hcl_rfind_uchar(ptr,len,c)
# define hcl_findoocharinoocstr(ptr,c) hcl_finducharinucstr(ptr,c) # define hcl_find_oochar_in_oocstr(ptr,c) hcl_find_uchar_in_ucstr(ptr,c)
# define hcl_countoocstr(str) hcl_countucstr(str) # define hcl_count_oocstr(str) hcl_count_ucstr(str)
#else #else
# define hcl_equaloochars(str1,str2,len) hcl_equalbchars(str1,str2,len) # define hcl_equal_oochars(str1,str2,len) hcl_equal_bchars(str1,str2,len)
# define hcl_compoochars(str1,len1,str2,len2) hcl_compbchars(str1,len1,str2,len2) # define hcl_comp_oochars(str1,len1,str2,len2) hcl_comp_bchars(str1,len1,str2,len2)
# define hcl_compoocbcstr(str1,str2) hcl_compbcstr(str1,str2) # define hcl_comp_oocstr_bcstr(str1,str2) hcl_comp_bcstr(str1,str2)
# define hcl_compoocharsbcstr(str1,len1,str2) hcl_compbcharsbcstr(str1,len1,str2) # define hcl_comp_oochars_bcstr(str1,len1,str2) hcl_comp_bchars_bcstr(str1,len1,str2)
# define hcl_compoocharsucstr(str1,len1,str2) hcl_compbcharsucstr(str1,len1,str2) # define hcl_comp_oochars_ucstr(str1,len1,str2) hcl_comp_bchars_ucstr(str1,len1,str2)
# define hcl_compoocharsoocstr(str1,len1,str2) hcl_compbcharsbcstr(str1,len1,str2) # define hcl_comp_oochars_oocstr(str1,len1,str2) hcl_comp_bchars_bcstr(str1,len1,str2)
# define hcl_compoocstr(str1,str2) hcl_compbcstr(str1,str2) # define hcl_comp_oocstr(str1,str2) hcl_comp_bcstr(str1,str2)
# define hcl_copyoochars(dst,src,len) hcl_copybchars(dst,src,len) # define hcl_copy_oochars(dst,src,len) hcl_copy_bchars(dst,src,len)
# define hcl_copybctooochars(dst,src,len) hcl_copybchars(dst,src,len) # define hcl_copy_bchars_to_oochars(dst,src,len) hcl_copy_bchars(dst,src,len)
# define hcl_copyoocstr(dst,len,src) hcl_copybcstr(dst,len,src) # define hcl_copy_oocstr(dst,len,src) hcl_copy_bcstr(dst,len,src)
# define hcl_findoochar(ptr,len,c) hcl_findbchar(ptr,len,c) # define hcl_find_oochar(ptr,len,c) hcl_find_bchar(ptr,len,c)
# define hcl_rfindoochar(ptr,len,c) hcl_rfindbchar(ptr,len,c) # define hcl_rfind_oochar(ptr,len,c) hcl_rfind_bchar(ptr,len,c)
# define hcl_findoocharinoocstr(ptr,c) hcl_findbcharinbcstr(ptr,c) # define hcl_find_oochar_in_oocstr(ptr,c) hcl_find_bchar_in_bcstr(ptr,c)
# define hcl_countoocstr(str) hcl_countbcstr(str) # define hcl_count_oocstr(str) hcl_count_bcstr(str)
#endif #endif
HCL_EXPORT int hcl_copyoocstrtosbuf (
hcl_t* hcl,
const hcl_ooch_t* str,
int id
);
HCL_EXPORT int hcl_concatoocstrtosbuf (
hcl_t* hcl,
const hcl_ooch_t* str,
int id
);
#if defined(HCL_OOCH_IS_UCH)
# define hcl_conv_oocs_to_bcs_with_cmgr(oocs,oocslen,bcs,bcslen,cmgr) hcl_conv_ucs_to_bcs_with_cmgr(oocs,oocslen,bcs,bcslen,cmgr)
# define hcl_conv_oocsn_to_bcsn_with_cmgr(oocs,oocslen,bcs,bcslen,cmgr) hcl_conv_ucsn_to_bcsn_with_cmgr(oocs,oocslen,bcs,bcslen,cmgr)
#else
# define hcl_conv_oocs_to_ucs_with_cmgr(oocs,oocslen,ucs,ucslen,cmgr) hcl_conv_bcs_to_ucs_with_cmgr(oocs,oocslen,ucs,ucslen,cmgr,0)
# define hcl_conv_oocsn_to_ucsn_with_cmgr(oocs,oocslen,ucs,ucslen,cmgr) hcl_conv_bcsn_to_ucsn_with_cmgr(oocs,oocslen,ucs,ucslen,cmgr,0)
#endif
HCL_EXPORT int hcl_conv_bcs_to_ucs_with_cmgr ( HCL_EXPORT int hcl_conv_bcs_to_ucs_with_cmgr (
@ -426,7 +407,7 @@ HCL_EXPORT int hcl_conv_bcs_to_ucs_with_cmgr (
int all int all
); );
HCL_EXPORT int hcl_conv_bcsn_to_ucsn_with_cmgr ( HCL_EXPORT int hcl_conv_bchars_to_uchars_with_cmgr (
const hcl_bch_t* bcs, const hcl_bch_t* bcs,
hcl_oow_t* bcslen, hcl_oow_t* bcslen,
hcl_uch_t* ucs, hcl_uch_t* ucs,
@ -443,7 +424,7 @@ HCL_EXPORT int hcl_conv_ucs_to_bcs_with_cmgr (
hcl_cmgr_t* cmgr hcl_cmgr_t* cmgr
); );
HCL_EXPORT int hcl_conv_ucsn_to_bcsn_with_cmgr ( HCL_EXPORT int hcl_conv_uchars_to_bchars_with_cmgr (
const hcl_uch_t* ucs, const hcl_uch_t* ucs,
hcl_oow_t* ucslen, hcl_oow_t* ucslen,
hcl_bch_t* bcs, hcl_bch_t* bcs,
@ -451,6 +432,14 @@ HCL_EXPORT int hcl_conv_ucsn_to_bcsn_with_cmgr (
hcl_cmgr_t* cmgr hcl_cmgr_t* cmgr
); );
#if defined(HCL_OOCH_IS_UCH)
# define hcl_conv_oocs_to_bcs_with_cmgr(oocs,oocslen,bcs,bcslen,cmgr) hcl_conv_ucs_to_bcs_with_cmgr(oocs,oocslen,bcs,bcslen,cmgr)
# define hcl_conv_oochars_to_bchars_with_cmgr(oocs,oocslen,bcs,bcslen,cmgr) hcl_conv_uchars_to_bchars_with_cmgr(oocs,oocslen,bcs,bcslen,cmgr)
#else
# define hcl_conv_oocs_to_ucs_with_cmgr(oocs,oocslen,ucs,ucslen,cmgr) hcl_conv_bcs_to_ucs_with_cmgr(oocs,oocslen,ucs,ucslen,cmgr,0)
# define hcl_conv_oochars_to_uchars_with_cmgr(oocs,oocslen,ucs,ucslen,cmgr) hcl_conv_bchars_to_uchars_with_cmgr(oocs,oocslen,ucs,ucslen,cmgr,0)
#endif
HCL_EXPORT hcl_cmgr_t* hcl_get_utf8_cmgr ( HCL_EXPORT hcl_cmgr_t* hcl_get_utf8_cmgr (
void void
); );

View File

@ -533,7 +533,7 @@ hcl_mod_data_t* hcl_openmod (hcl_t* hcl, const hcl_ooch_t* name, hcl_oow_t namel
/* copy instead of encoding conversion. MOD_PREFIX must not /* copy instead of encoding conversion. MOD_PREFIX must not
* include a character that requires encoding conversion. * include a character that requires encoding conversion.
* note the terminating null isn't needed in buf here. */ * note the terminating null isn't needed in buf here. */
hcl_copybctooochars (buf, MOD_PREFIX, MOD_PREFIX_LEN); hcl_copy_bchars_to_oochars (buf, MOD_PREFIX, MOD_PREFIX_LEN);
if (namelen > HCL_COUNTOF(buf) - (MOD_PREFIX_LEN + 1 + 1)) if (namelen > HCL_COUNTOF(buf) - (MOD_PREFIX_LEN + 1 + 1))
{ {
@ -542,7 +542,7 @@ hcl_mod_data_t* hcl_openmod (hcl_t* hcl, const hcl_ooch_t* name, hcl_oow_t namel
return HCL_NULL; return HCL_NULL;
} }
hcl_copyoochars (&buf[MOD_PREFIX_LEN], name, namelen); hcl_copy_oochars (&buf[MOD_PREFIX_LEN], name, namelen);
buf[MOD_PREFIX_LEN + namelen] = '\0'; buf[MOD_PREFIX_LEN + namelen] = '\0';
#if defined(HCL_ENABLE_STATIC_MODULE) #if defined(HCL_ENABLE_STATIC_MODULE)
@ -551,7 +551,7 @@ hcl_mod_data_t* hcl_openmod (hcl_t* hcl, const hcl_ooch_t* name, hcl_oow_t namel
/* TODO: binary search ... */ /* TODO: binary search ... */
for (n = 0; n < HCL_COUNTOF(static_modtab); n++) for (n = 0; n < HCL_COUNTOF(static_modtab); n++)
{ {
if (hcl_compoocharsbcstr(name, namelen, static_modtab[n].modname) == 0) if (hcl_comp_oochars_bcstr(name, namelen, static_modtab[n].modname) == 0)
{ {
load = static_modtab[n].modload; load = static_modtab[n].modload;
break; break;
@ -563,7 +563,7 @@ hcl_mod_data_t* hcl_openmod (hcl_t* hcl, const hcl_ooch_t* name, hcl_oow_t namel
/* found the module in the staic module table */ /* found the module in the staic module table */
HCL_MEMSET (&md, 0, HCL_SIZEOF(md)); HCL_MEMSET (&md, 0, HCL_SIZEOF(md));
hcl_copyoochars ((hcl_ooch_t*)md.mod.name, name, namelen); hcl_copy_oochars ((hcl_ooch_t*)md.mod.name, name, namelen);
/* Note md.handle is HCL_NULL for a static module */ /* Note md.handle is HCL_NULL for a static module */
/* i copy-insert 'md' into the table before calling 'load'. /* i copy-insert 'md' into the table before calling 'load'.
@ -605,7 +605,7 @@ hcl_mod_data_t* hcl_openmod (hcl_t* hcl, const hcl_ooch_t* name, hcl_oow_t namel
/* attempt to find a dynamic external module */ /* attempt to find a dynamic external module */
HCL_MEMSET (&md, 0, HCL_SIZEOF(md)); HCL_MEMSET (&md, 0, HCL_SIZEOF(md));
hcl_copyoochars((hcl_ooch_t*)md.mod.name, name, namelen); hcl_copy_oochars((hcl_ooch_t*)md.mod.name, name, namelen);
if (hcl->vmprim.dl_open && hcl->vmprim.dl_getsym && hcl->vmprim.dl_close) if (hcl->vmprim.dl_open && hcl->vmprim.dl_getsym && hcl->vmprim.dl_close)
{ {
md.handle = hcl->vmprim.dl_open(hcl, &buf[MOD_PREFIX_LEN], HCL_VMPRIM_OPENDL_PFMOD); md.handle = hcl->vmprim.dl_open(hcl, &buf[MOD_PREFIX_LEN], HCL_VMPRIM_OPENDL_PFMOD);
@ -678,7 +678,7 @@ void hcl_closemod (hcl_t* hcl, hcl_mod_data_t* mdp)
if (mdp->pair) if (mdp->pair)
{ {
/*mdp->pair = HCL_NULL;*/ /* this reset isn't needed as the area will get freed by hcl_rbt_delete()) */ /*mdp->pair = HCL_NULL;*/ /* this reset isn't needed as the area will get freed by hcl_rbt_delete()) */
hcl_rbt_delete (&hcl->modtab, mdp->mod.name, hcl_countoocstr(mdp->mod.name)); hcl_rbt_delete (&hcl->modtab, mdp->mod.name, hcl_count_oocstr(mdp->mod.name));
} }
} }
@ -695,7 +695,7 @@ hcl_pfbase_t* hcl_querymod (hcl_t* hcl, const hcl_ooch_t* pfid, hcl_oow_t pfidle
hcl_oow_t mod_name_len; hcl_oow_t mod_name_len;
hcl_pfbase_t* pfbase; hcl_pfbase_t* pfbase;
sep = hcl_rfindoochar (pfid, pfidlen, '.'); sep = hcl_rfind_oochar (pfid, pfidlen, '.');
if (!sep) if (!sep)
{ {
/* i'm writing a conservative code here. the compiler should /* i'm writing a conservative code here. the compiler should
@ -756,7 +756,7 @@ hcl_pfbase_t* hcl_findpfbase (hcl_t* hcl, hcl_pfinfo_t* pfinfo, hcl_oow_t pfcoun
/*mid = (left + right) / 2;*/ /*mid = (left + right) / 2;*/
mid = left + ((right - left) / 2); mid = left + ((right - left) / 2);
n = hcl_compoocharsoocstr (name, namelen, pfinfo[mid].mthname); n = hcl_comp_oochars_oocstr (name, namelen, pfinfo[mid].mthname);
if (n < 0) right = mid - 1; /* this substraction can make right negative. so i can't use hcl_oow_t for the variable */ if (n < 0) right = mid - 1; /* this substraction can make right negative. so i can't use hcl_oow_t for the variable */
else if (n > 0) left = mid + 1; else if (n > 0) left = mid + 1;
else return &pfinfo[mid].base; else return &pfinfo[mid].base;
@ -768,7 +768,7 @@ hcl_pfbase_t* hcl_findpfbase (hcl_t* hcl, hcl_pfinfo_t* pfinfo, hcl_oow_t pfcoun
for (base = 0, lim = pfcount; lim > 0; lim >>= 1) for (base = 0, lim = pfcount; lim > 0; lim >>= 1)
{ {
mid = base + (lim >> 1); mid = base + (lim >> 1);
n = hcl_compoocharsoocstr (name, namelen, pfinfo[mid].mthname); n = hcl_comp_oochars_oocstr (name, namelen, pfinfo[mid].mthname);
if (n == 0) return &pfinfo[mid].base; if (n == 0) return &pfinfo[mid].base;
if (n > 0) { base = mid + 1; lim--; } if (n > 0) { base = mid + 1; lim--; }
} }

View File

@ -1032,15 +1032,6 @@ struct hcl_mod_data_t
}; };
typedef struct hcl_mod_data_t hcl_mod_data_t; typedef struct hcl_mod_data_t hcl_mod_data_t;
struct hcl_sbuf_t
{
hcl_ooch_t* ptr;
hcl_oow_t len;
hcl_oow_t capa;
};
typedef struct hcl_sbuf_t hcl_sbuf_t;
/* ========================================================================= /* =========================================================================
* HCL VM * HCL VM
* ========================================================================= */ * ========================================================================= */
@ -1206,8 +1197,6 @@ struct hcl_t
} xbuf; /* buffer to support sprintf */ } xbuf; /* buffer to support sprintf */
} sprintf; } sprintf;
hcl_sbuf_t sbuf[64];
struct struct
{ {
struct struct

View File

@ -166,7 +166,7 @@ static int logfmtv (hcl_t* hcl, const fmtchar_t* fmt, hcl_fmtout_t* data, va_lis
ucslen = 1; ucslen = 1;
bcslen = HCL_COUNTOF(bcsbuf); bcslen = HCL_COUNTOF(bcsbuf);
/*if (hcl_convutooochars(hcl, &fch, &ucslen, bcsbuf, &bcslen) <= -1) goto oops;*/ /*if (hcl_convutooochars(hcl, &fch, &ucslen, bcsbuf, &bcslen) <= -1) goto oops;*/
if (hcl_conv_ucsn_to_bcsn_with_cmgr( &fch, &ucslen, bcsbuf, &bcslen, hcl->cmgr) <= -1) goto oops; if (hcl_conv_uchars_to_bchars_with_cmgr( &fch, &ucslen, bcsbuf, &bcslen, hcl->cmgr) <= -1) goto oops;
PUT_OOCS (bcsbuf, bcslen); PUT_OOCS (bcsbuf, bcslen);
} }
#endif #endif
@ -469,7 +469,7 @@ static int logfmtv (hcl_t* hcl, const fmtchar_t* fmt, hcl_fmtout_t* data, va_lis
for (bslen = 0; bsp[bslen]; bslen++); for (bslen = 0; bsp[bslen]; bslen++);
/*if (hcl_convbtooochars(hcl, bsp, &bslen, HCL_NULL, &slen) <= -1) goto oops;*/ /*if (hcl_convbtooochars(hcl, bsp, &bslen, HCL_NULL, &slen) <= -1) goto oops;*/
if (hcl_conv_bcsn_to_ucsn_with_cmgr(bsp, &bslen, HCL_NULL, &slen, hcl->cmgr, 0) <= -1) goto oops; if (hcl_conv_bchars_to_uchars_with_cmgr(bsp, &bslen, HCL_NULL, &slen, hcl->cmgr, 0) <= -1) goto oops;
/* slen holds the length after conversion */ /* slen holds the length after conversion */
n = slen; n = slen;
@ -490,7 +490,7 @@ static int logfmtv (hcl_t* hcl, const fmtchar_t* fmt, hcl_fmtout_t* data, va_lis
/* this must not fail since the dry-run above was successful */ /* this must not fail since the dry-run above was successful */
/*hcl_convbtooochars (hcl, &bsp[tot_len], &src_len, conv_buf, &conv_len);*/ /*hcl_convbtooochars (hcl, &bsp[tot_len], &src_len, conv_buf, &conv_len);*/
hcl_conv_bcsn_to_ucsn_with_cmgr (&bsp[tot_len], &src_len, conv_buf, &conv_len, hcl->cmgr, 0); hcl_conv_bchars_to_uchars_with_cmgr (&bsp[tot_len], &src_len, conv_buf, &conv_len, hcl->cmgr, 0);
tot_len += src_len; tot_len += src_len;
if (conv_len > n) conv_len = n; if (conv_len > n) conv_len = n;
@ -540,7 +540,7 @@ static int logfmtv (hcl_t* hcl, const fmtchar_t* fmt, hcl_fmtout_t* data, va_lis
for (uslen = 0; usp[uslen]; uslen++); for (uslen = 0; usp[uslen]; uslen++);
/*if (hcl_convutooochars(hcl, usp, &uslen, HCL_NULL, &slen) <= -1) goto oops;*/ /*if (hcl_convutooochars(hcl, usp, &uslen, HCL_NULL, &slen) <= -1) goto oops;*/
if (hcl_conv_ucsn_to_bcsn_with_cmgr(usp, &uslen, HCL_NULL, &slen, hcl->cmgr) <= -1) goto oops; if (hcl_conv_uchars_to_bchars_with_cmgr(usp, &uslen, HCL_NULL, &slen, hcl->cmgr) <= -1) goto oops;
/* slen holds the length after conversion */ /* slen holds the length after conversion */
n = slen; n = slen;
@ -560,7 +560,7 @@ static int logfmtv (hcl_t* hcl, const fmtchar_t* fmt, hcl_fmtout_t* data, va_lis
/* this must not fail since the dry-run above was successful */ /* this must not fail since the dry-run above was successful */
/*hcl_convutooochars (hcl, &usp[tot_len], &src_len, conv_buf, &conv_len);*/ /*hcl_convutooochars (hcl, &usp[tot_len], &src_len, conv_buf, &conv_len);*/
hcl_conv_ucsn_to_bcsn_with_cmgr (hcl, &usp[tot_len], &src_len, conv_buf, &conv_len, hcl->cmgr); hcl_conv_uchars_to_bchars_with_cmgr (hcl, &usp[tot_len], &src_len, conv_buf, &conv_len, hcl->cmgr);
tot_len += src_len; tot_len += src_len;
if (conv_len > n) conv_len = n; if (conv_len > n) conv_len = n;

View File

@ -264,7 +264,7 @@ static void log_write (hcl_client_t* client, unsigned int mask, const hcl_ooch_t
ucslen = len; ucslen = len;
bcslen = HCL_COUNTOF(buf); bcslen = HCL_COUNTOF(buf);
n = hcl_conv_oocsn_to_bcsn_with_cmgr(&msg[msgidx], &ucslen, buf, &bcslen, hcl_get_utf8_cmgr()); n = hcl_conv_oochars_to_bchars_with_cmgr(&msg[msgidx], &ucslen, buf, &bcslen, hcl_get_utf8_cmgr());
if (n == 0 || n == -2) if (n == 0 || n == -2)
{ {
/* n = 0: /* n = 0:
@ -365,7 +365,7 @@ static int handle_logopt (hcl_client_t* client, const hcl_bch_t* str)
xtn = (client_xtn_t*)hcl_client_getxtn(client); xtn = (client_xtn_t*)hcl_client_getxtn(client);
cm = hcl_findbcharinbcstr(xstr, ','); cm = hcl_find_bchar_in_bcstr(xstr, ',');
if (cm) if (cm)
{ {
/* i duplicate this string for open() below as open() doesn't /* i duplicate this string for open() below as open() doesn't
@ -377,7 +377,7 @@ static int handle_logopt (hcl_client_t* client, const hcl_bch_t* str)
return -1; return -1;
} }
cm = hcl_findbcharinbcstr(xstr, ','); cm = hcl_find_bchar_in_bcstr(xstr, ',');
*cm = '\0'; *cm = '\0';
logmask = xtn->logmask; logmask = xtn->logmask;
@ -385,28 +385,28 @@ static int handle_logopt (hcl_client_t* client, const hcl_bch_t* str)
{ {
flt = cm + 1; flt = cm + 1;
cm = hcl_findbcharinbcstr(flt, ','); cm = hcl_find_bchar_in_bcstr(flt, ',');
if (cm) *cm = '\0'; if (cm) *cm = '\0';
if (hcl_compbcstr(flt, "app") == 0) logmask |= HCL_LOG_APP; if (hcl_comp_bcstr(flt, "app") == 0) logmask |= HCL_LOG_APP;
else if (hcl_compbcstr(flt, "compiler") == 0) logmask |= HCL_LOG_COMPILER; else if (hcl_comp_bcstr(flt, "compiler") == 0) logmask |= HCL_LOG_COMPILER;
else if (hcl_compbcstr(flt, "vm") == 0) logmask |= HCL_LOG_VM; else if (hcl_comp_bcstr(flt, "vm") == 0) logmask |= HCL_LOG_VM;
else if (hcl_compbcstr(flt, "mnemonic") == 0) logmask |= HCL_LOG_MNEMONIC; else if (hcl_comp_bcstr(flt, "mnemonic") == 0) logmask |= HCL_LOG_MNEMONIC;
else if (hcl_compbcstr(flt, "gc") == 0) logmask |= HCL_LOG_GC; else if (hcl_comp_bcstr(flt, "gc") == 0) logmask |= HCL_LOG_GC;
else if (hcl_compbcstr(flt, "ic") == 0) logmask |= HCL_LOG_IC; else if (hcl_comp_bcstr(flt, "ic") == 0) logmask |= HCL_LOG_IC;
else if (hcl_compbcstr(flt, "primitive") == 0) logmask |= HCL_LOG_PRIMITIVE; else if (hcl_comp_bcstr(flt, "primitive") == 0) logmask |= HCL_LOG_PRIMITIVE;
else if (hcl_compbcstr(flt, "fatal") == 0) logmask |= HCL_LOG_FATAL; else if (hcl_comp_bcstr(flt, "fatal") == 0) logmask |= HCL_LOG_FATAL;
else if (hcl_compbcstr(flt, "error") == 0) logmask |= HCL_LOG_ERROR; else if (hcl_comp_bcstr(flt, "error") == 0) logmask |= HCL_LOG_ERROR;
else if (hcl_compbcstr(flt, "warn") == 0) logmask |= HCL_LOG_WARN; else if (hcl_comp_bcstr(flt, "warn") == 0) logmask |= HCL_LOG_WARN;
else if (hcl_compbcstr(flt, "info") == 0) logmask |= HCL_LOG_INFO; else if (hcl_comp_bcstr(flt, "info") == 0) logmask |= HCL_LOG_INFO;
else if (hcl_compbcstr(flt, "debug") == 0) logmask |= HCL_LOG_DEBUG; else if (hcl_comp_bcstr(flt, "debug") == 0) logmask |= HCL_LOG_DEBUG;
else if (hcl_compbcstr(flt, "fatal+") == 0) logmask |= HCL_LOG_FATAL; else if (hcl_comp_bcstr(flt, "fatal+") == 0) logmask |= HCL_LOG_FATAL;
else if (hcl_compbcstr(flt, "error+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR; else if (hcl_comp_bcstr(flt, "error+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR;
else if (hcl_compbcstr(flt, "warn+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN; else if (hcl_comp_bcstr(flt, "warn+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN;
else if (hcl_compbcstr(flt, "info+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN | HCL_LOG_INFO; else if (hcl_comp_bcstr(flt, "info+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN | HCL_LOG_INFO;
else if (hcl_compbcstr(flt, "debug+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN | HCL_LOG_INFO | HCL_LOG_DEBUG; else if (hcl_comp_bcstr(flt, "debug+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN | HCL_LOG_INFO | HCL_LOG_DEBUG;
else else
{ {
@ -462,7 +462,7 @@ static int start_reply (hcl_client_t* client, hcl_client_reply_type_t type, cons
hcl_bch_t bcs[256]; hcl_bch_t bcs[256];
hcl_oow_t bcslen; hcl_oow_t bcslen;
hcl_conv_ucsn_to_bcsn_with_cmgr (dptr, &dlen, bcs, &bcslen, hcl_client_getcmgr(client)); hcl_conv_uchars_to_bchars_with_cmgr (dptr, &dlen, bcs, &bcslen, hcl_client_getcmgr(client));
printf ("\nERROR - [%.*s]\n", (int)bcslen, bcs); printf ("\nERROR - [%.*s]\n", (int)bcslen, bcs);
#else #else
printf ("\nERROR - [%.*s]\n", (int)dlen, dptr); printf ("\nERROR - [%.*s]\n", (int)dlen, dptr);
@ -734,11 +734,11 @@ int main (int argc, char* argv[])
break; break;
case '\0': case '\0':
if (hcl_compbcstr(opt.lngopt, "reuseaddr") == 0) if (hcl_comp_bcstr(opt.lngopt, "reuseaddr") == 0)
{ {
reuse_addr = 1; reuse_addr = 1;
} }
else if (hcl_compbcstr(opt.lngopt, "shutwr") == 0) else if (hcl_comp_bcstr(opt.lngopt, "shutwr") == 0)
{ {
shut_wr_after_req = 1; shut_wr_after_req = 1;
} }

View File

@ -265,7 +265,7 @@ static void log_write (hcl_server_t* server, hcl_oow_t wid, unsigned int mask, c
ucslen = len; ucslen = len;
bcslen = HCL_COUNTOF(buf); bcslen = HCL_COUNTOF(buf);
n = hcl_conv_oocsn_to_bcsn_with_cmgr(&msg[msgidx], &ucslen, buf, &bcslen, hcl_get_utf8_cmgr()); n = hcl_conv_oochars_to_bchars_with_cmgr(&msg[msgidx], &ucslen, buf, &bcslen, hcl_get_utf8_cmgr());
if (n == 0 || n == -2) if (n == 0 || n == -2)
{ {
/* n = 0: /* n = 0:
@ -366,7 +366,7 @@ static int handle_logopt (hcl_server_t* server, const hcl_bch_t* str)
xtn = (server_xtn_t*)hcl_server_getxtn(server); xtn = (server_xtn_t*)hcl_server_getxtn(server);
cm = hcl_findbcharinbcstr(xstr, ','); cm = hcl_find_bchar_in_bcstr(xstr, ',');
if (cm) if (cm)
{ {
/* i duplicate this string for open() below as open() doesn't /* i duplicate this string for open() below as open() doesn't
@ -378,7 +378,7 @@ static int handle_logopt (hcl_server_t* server, const hcl_bch_t* str)
return -1; return -1;
} }
cm = hcl_findbcharinbcstr(xstr, ','); cm = hcl_find_bchar_in_bcstr(xstr, ',');
*cm = '\0'; *cm = '\0';
logmask = xtn->logmask; logmask = xtn->logmask;
@ -386,28 +386,28 @@ static int handle_logopt (hcl_server_t* server, const hcl_bch_t* str)
{ {
flt = cm + 1; flt = cm + 1;
cm = hcl_findbcharinbcstr(flt, ','); cm = hcl_find_bchar_in_bcstr(flt, ',');
if (cm) *cm = '\0'; if (cm) *cm = '\0';
if (hcl_compbcstr(flt, "app") == 0) logmask |= HCL_LOG_APP; if (hcl_comp_bcstr(flt, "app") == 0) logmask |= HCL_LOG_APP;
else if (hcl_compbcstr(flt, "compiler") == 0) logmask |= HCL_LOG_COMPILER; else if (hcl_comp_bcstr(flt, "compiler") == 0) logmask |= HCL_LOG_COMPILER;
else if (hcl_compbcstr(flt, "vm") == 0) logmask |= HCL_LOG_VM; else if (hcl_comp_bcstr(flt, "vm") == 0) logmask |= HCL_LOG_VM;
else if (hcl_compbcstr(flt, "mnemonic") == 0) logmask |= HCL_LOG_MNEMONIC; else if (hcl_comp_bcstr(flt, "mnemonic") == 0) logmask |= HCL_LOG_MNEMONIC;
else if (hcl_compbcstr(flt, "gc") == 0) logmask |= HCL_LOG_GC; else if (hcl_comp_bcstr(flt, "gc") == 0) logmask |= HCL_LOG_GC;
else if (hcl_compbcstr(flt, "ic") == 0) logmask |= HCL_LOG_IC; else if (hcl_comp_bcstr(flt, "ic") == 0) logmask |= HCL_LOG_IC;
else if (hcl_compbcstr(flt, "primitive") == 0) logmask |= HCL_LOG_PRIMITIVE; else if (hcl_comp_bcstr(flt, "primitive") == 0) logmask |= HCL_LOG_PRIMITIVE;
else if (hcl_compbcstr(flt, "fatal") == 0) logmask |= HCL_LOG_FATAL; else if (hcl_comp_bcstr(flt, "fatal") == 0) logmask |= HCL_LOG_FATAL;
else if (hcl_compbcstr(flt, "error") == 0) logmask |= HCL_LOG_ERROR; else if (hcl_comp_bcstr(flt, "error") == 0) logmask |= HCL_LOG_ERROR;
else if (hcl_compbcstr(flt, "warn") == 0) logmask |= HCL_LOG_WARN; else if (hcl_comp_bcstr(flt, "warn") == 0) logmask |= HCL_LOG_WARN;
else if (hcl_compbcstr(flt, "info") == 0) logmask |= HCL_LOG_INFO; else if (hcl_comp_bcstr(flt, "info") == 0) logmask |= HCL_LOG_INFO;
else if (hcl_compbcstr(flt, "debug") == 0) logmask |= HCL_LOG_DEBUG; else if (hcl_comp_bcstr(flt, "debug") == 0) logmask |= HCL_LOG_DEBUG;
else if (hcl_compbcstr(flt, "fatal+") == 0) logmask |= HCL_LOG_FATAL; else if (hcl_comp_bcstr(flt, "fatal+") == 0) logmask |= HCL_LOG_FATAL;
else if (hcl_compbcstr(flt, "error+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR; else if (hcl_comp_bcstr(flt, "error+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR;
else if (hcl_compbcstr(flt, "warn+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN; else if (hcl_comp_bcstr(flt, "warn+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN;
else if (hcl_compbcstr(flt, "info+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN | HCL_LOG_INFO; else if (hcl_comp_bcstr(flt, "info+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN | HCL_LOG_INFO;
else if (hcl_compbcstr(flt, "debug+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN | HCL_LOG_INFO | HCL_LOG_DEBUG; else if (hcl_comp_bcstr(flt, "debug+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN | HCL_LOG_INFO | HCL_LOG_DEBUG;
else else
{ {
@ -457,10 +457,10 @@ static int handle_dbgopt (hcl_server_t* server, const char* str)
{ {
flt = cm + 1; flt = cm + 1;
cm = hcl_findbcharinbcstr(flt, ','); cm = hcl_find_bchar_in_bcstr(flt, ',');
len = cm? (cm - flt): hcl_countbcstr(flt); len = cm? (cm - flt): hcl_count_bcstr(flt);
if (hcl_compbcharsbcstr(flt, len, "gc") == 0) trait |= HCL_SERVER_TRAIT_DEBUG_GC; if (hcl_comp_bchars_bcstr(flt, len, "gc") == 0) trait |= HCL_SERVER_TRAIT_DEBUG_GC;
else if (hcl_compbcharsbcstr(flt, len, "bigint") == 0) trait |= HCL_SERVER_TRAIT_DEBUG_BIGINT; else if (hcl_comp_bchars_bcstr(flt, len, "bigint") == 0) trait |= HCL_SERVER_TRAIT_DEBUG_BIGINT;
else else
{ {
fprintf (stderr, "ERROR: unknown debug option value - %.*s\n", (int)len, flt); fprintf (stderr, "ERROR: unknown debug option value - %.*s\n", (int)len, flt);
@ -556,33 +556,33 @@ int main (int argc, char* argv[])
break; break;
case '\0': case '\0':
if (hcl_compbcstr(opt.lngopt, "large-pages") == 0) if (hcl_comp_bcstr(opt.lngopt, "large-pages") == 0)
{ {
large_pages = 1; large_pages = 1;
} }
else if (hcl_compbcstr(opt.lngopt, "worker-max-count") == 0) else if (hcl_comp_bcstr(opt.lngopt, "worker-max-count") == 0)
{ {
worker_max_count = strtoul(opt.arg, HCL_NULL, 0); worker_max_count = strtoul(opt.arg, HCL_NULL, 0);
} }
else if (hcl_compbcstr(opt.lngopt, "worker-stack-size") == 0) else if (hcl_comp_bcstr(opt.lngopt, "worker-stack-size") == 0)
{ {
worker_stack_size = strtoul(opt.arg, HCL_NULL, 0); worker_stack_size = strtoul(opt.arg, HCL_NULL, 0);
if (worker_stack_size <= MIN_WORKER_STACK_SIZE) worker_stack_size = MIN_WORKER_STACK_SIZE; if (worker_stack_size <= MIN_WORKER_STACK_SIZE) worker_stack_size = MIN_WORKER_STACK_SIZE;
} }
else if (hcl_compbcstr(opt.lngopt, "worker-idle-timeout") == 0) else if (hcl_comp_bcstr(opt.lngopt, "worker-idle-timeout") == 0)
{ {
worker_idle_timeout.sec = strtoul(opt.arg, HCL_NULL, 0); worker_idle_timeout.sec = strtoul(opt.arg, HCL_NULL, 0);
} }
else if (hcl_compbcstr(opt.lngopt, "actor-max-runtime") == 0) else if (hcl_comp_bcstr(opt.lngopt, "actor-max-runtime") == 0)
{ {
actor_max_runtime.sec = strtoul(opt.arg, HCL_NULL, 0); actor_max_runtime.sec = strtoul(opt.arg, HCL_NULL, 0);
} }
else if (hcl_compbcstr(opt.lngopt, "script-include-path") == 0) else if (hcl_comp_bcstr(opt.lngopt, "script-include-path") == 0)
{ {
incpath = opt.arg; incpath = opt.arg;
} }
#if defined(HCL_BUILD_DEBUG) #if defined(HCL_BUILD_DEBUG)
else if (hcl_compbcstr(opt.lngopt, "debug") == 0) else if (hcl_comp_bcstr(opt.lngopt, "debug") == 0)
{ {
dbgopt = opt.arg; dbgopt = opt.arg;
} }

View File

@ -224,7 +224,7 @@ static HCL_INLINE int open_input (hcl_t* hcl, hcl_ioinarg_t* arg)
#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_countbcstr (arg->name); bcslen = hcl_count_bcstr (arg->name);
#endif #endif
fn = ((bb_t*)arg->includer->handle)->fn; fn = ((bb_t*)arg->includer->handle)->fn;
@ -236,11 +236,11 @@ static HCL_INLINE int open_input (hcl_t* hcl, hcl_ioinarg_t* arg)
if (!bb) goto oops; if (!bb) goto oops;
bb->fn = (hcl_bch_t*)(bb + 1); bb->fn = (hcl_bch_t*)(bb + 1);
hcl_copybchars (bb->fn, fn, parlen); hcl_copy_bchars (bb->fn, fn, parlen);
#if defined(HCL_OOCH_IS_UCH) #if defined(HCL_OOCH_IS_UCH)
hcl_convootobcstr (hcl, arg->name, &ucslen, &bb->fn[parlen], &bcslen); hcl_convootobcstr (hcl, arg->name, &ucslen, &bb->fn[parlen], &bcslen);
#else #else
hcl_copybcstr (&bb->fn[parlen], bcslen + 1, arg->name); hcl_copy_bcstr (&bb->fn[parlen], bcslen + 1, arg->name);
#endif #endif
} }
else else
@ -248,13 +248,13 @@ 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_countbcstr (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);
hcl_copybcstr (bb->fn, pathlen + 1, xtn->read_path); hcl_copy_bcstr (bb->fn, pathlen + 1, xtn->read_path);
} }
#if defined(__DOS__) || defined(_WIN32) || defined(__OS2__) #if defined(__DOS__) || defined(_WIN32) || defined(__OS2__)
@ -339,7 +339,7 @@ static HCL_INLINE int read_input (hcl_t* hcl, hcl_ioinarg_t* arg)
#else #else
bcslen = (bb->len < HCL_COUNTOF(arg->buf))? bb->len: HCL_COUNTOF(arg->buf); bcslen = (bb->len < HCL_COUNTOF(arg->buf))? bb->len: HCL_COUNTOF(arg->buf);
ucslen = bcslen; ucslen = bcslen;
hcl_copybchars (arg->buf, bb->buf, bcslen); hcl_copy_bchars (arg->buf, bb->buf, bcslen);
#endif #endif
remlen = bb->len - bcslen; remlen = bb->len - bcslen;
@ -427,7 +427,7 @@ static HCL_INLINE int write_output (hcl_t* hcl, hcl_iooutarg_t* arg)
ucslen = arg->len - donelen; ucslen = arg->len - donelen;
if (ucslen > bcslen) ucslen = bcslen; if (ucslen > bcslen) ucslen = bcslen;
else if (ucslen < bcslen) bcslen = ucslen; else if (ucslen < bcslen) bcslen = ucslen;
hcl_copybchars (bcsbuf, &arg->ptr[donelen], bcslen); hcl_copy_bchars (bcsbuf, &arg->ptr[donelen], bcslen);
#endif #endif
if (fwrite(bcsbuf, HCL_SIZEOF(bcsbuf[0]), bcslen, (FILE*)arg->handle) < bcslen) if (fwrite(bcsbuf, HCL_SIZEOF(bcsbuf[0]), bcslen, (FILE*)arg->handle) < bcslen)
@ -758,7 +758,7 @@ static void syserrstrb (hcl_t* hcl, int syserr, hcl_bch_t* buf, hcl_oow_t len)
strerror_r (syserr, buf, len); strerror_r (syserr, buf, len);
#else #else
/* this may not be thread safe */ /* this may not be thread safe */
hcl_copybcstr (buf, len, strerror(syserr)); hcl_copy_bcstr (buf, len, strerror(syserr));
#endif #endif
} }
@ -777,7 +777,7 @@ static void* dl_open (hcl_t* hcl, const hcl_ooch_t* name, int flags)
* and HCL_COUNTOF(HCL_DEFAULT_PFMODPOSTIFX) include the terminating nulls. Never mind about * and HCL_COUNTOF(HCL_DEFAULT_PFMODPOSTIFX) include the terminating nulls. Never mind about
* the extra 2 characters. */ * the extra 2 characters. */
#else #else
bufcapa = hcl_countbcstr(name); bufcapa = hcl_count_bcstr(name);
#endif #endif
bufcapa += HCL_COUNTOF(HCL_DEFAULT_PFMODPREFIX) + HCL_COUNTOF(HCL_DEFAULT_PFMODPOSTFIX) + 1; bufcapa += HCL_COUNTOF(HCL_DEFAULT_PFMODPREFIX) + HCL_COUNTOF(HCL_DEFAULT_PFMODPOSTFIX) + 1;
@ -793,13 +793,13 @@ static void* dl_open (hcl_t* hcl, const hcl_ooch_t* name, int flags)
hcl_oow_t len, i, xlen; hcl_oow_t len, i, xlen;
/* opening a primitive function module - mostly libhcl-xxxx */ /* opening a primitive function module - mostly libhcl-xxxx */
len = hcl_copybcstr(bufptr, bufcapa, HCL_DEFAULT_PFMODPREFIX); len = hcl_copy_bcstr(bufptr, bufcapa, HCL_DEFAULT_PFMODPREFIX);
bcslen = bufcapa - len; bcslen = bufcapa - len;
#if defined(HCL_OOCH_IS_UCH) #if defined(HCL_OOCH_IS_UCH)
hcl_convootobcstr(hcl, name, &ucslen, &bufptr[len], &bcslen); hcl_convootobcstr(hcl, name, &ucslen, &bufptr[len], &bcslen);
#else #else
bcslen = hcl_copybcstr(&bufptr[len], bcslen, name); bcslen = hcl_copy_bcstr(&bufptr[len], bcslen, name);
#endif #endif
/* length including the prefix and the name. but excluding the postfix */ /* length including the prefix and the name. but excluding the postfix */
@ -812,7 +812,7 @@ static void* dl_open (hcl_t* hcl, const hcl_ooch_t* name, int flags)
} }
retry: retry:
hcl_copybcstr (&bufptr[xlen], bufcapa - xlen, HCL_DEFAULT_PFMODPOSTFIX); hcl_copy_bcstr (&bufptr[xlen], bufcapa - xlen, HCL_DEFAULT_PFMODPOSTFIX);
/* both prefix and postfix attached. for instance, libhcl-xxx */ /* both prefix and postfix attached. for instance, libhcl-xxx */
handle = sys_dl_openext(bufptr); handle = sys_dl_openext(bufptr);
@ -831,7 +831,7 @@ static void* dl_open (hcl_t* hcl, const hcl_ooch_t* name, int flags)
HCL_DEBUG3 (hcl, "Failed to open(ext) DL %hs[%js] - %hs\n", &bufptr[len], name, dl_errstr); HCL_DEBUG3 (hcl, "Failed to open(ext) DL %hs[%js] - %hs\n", &bufptr[len], name, dl_errstr);
hcl_seterrbfmt (hcl, HCL_ESYSERR, "unable to open(ext) DL %js - %hs", name, dl_errstr); hcl_seterrbfmt (hcl, HCL_ESYSERR, "unable to open(ext) DL %js - %hs", name, dl_errstr);
dash = hcl_rfindbchar(bufptr, hcl_countbcstr(bufptr), '-'); dash = hcl_rfind_bchar(bufptr, hcl_count_bcstr(bufptr), '-');
if (dash) if (dash)
{ {
/* remove a segment at the back. /* remove a segment at the back.
@ -859,10 +859,10 @@ static void* dl_open (hcl_t* hcl, const hcl_ooch_t* name, int flags)
bcslen = bufcapa; bcslen = bufcapa;
hcl_convootobcstr(hcl, name, &ucslen, bufptr, &bcslen); hcl_convootobcstr(hcl, name, &ucslen, bufptr, &bcslen);
#else #else
bcslen = hcl_copybcstr(bufptr, bufcapa, name); bcslen = hcl_copy_bcstr(bufptr, bufcapa, name);
#endif #endif
if (hcl_findbchar(bufptr, bcslen, '.')) if (hcl_find_bchar(bufptr, bcslen, '.'))
{ {
handle = sys_dl_open(bufptr); handle = sys_dl_open(bufptr);
if (!handle) if (!handle)
@ -924,7 +924,7 @@ static void* dl_getsym (hcl_t* hcl, void* handle, const hcl_ooch_t* name)
#if defined(HCL_OOCH_IS_UCH) #if defined(HCL_OOCH_IS_UCH)
if (hcl_convootobcstr(hcl, name, &ucslen, HCL_NULL, &bcslen) <= -1) return HCL_NULL; if (hcl_convootobcstr(hcl, name, &ucslen, HCL_NULL, &bcslen) <= -1) return HCL_NULL;
#else #else
bcslen = hcl_countbcstr (name); bcslen = hcl_count_bcstr (name);
#endif #endif
if (bcslen >= HCL_COUNTOF(stabuf) - 2) if (bcslen >= HCL_COUNTOF(stabuf) - 2)
@ -943,7 +943,7 @@ static void* dl_getsym (hcl_t* hcl, void* handle, const hcl_ooch_t* name)
#if defined(HCL_OOCH_IS_UCH) #if defined(HCL_OOCH_IS_UCH)
hcl_convootobcstr (hcl, name, &ucslen, &bufptr[1], &bcslen); hcl_convootobcstr (hcl, name, &ucslen, &bufptr[1], &bcslen);
#else #else
bcslen = hcl_copybcstr(&bufptr[1], bcslen, name); bcslen = hcl_copy_bcstr(&bufptr[1], bcslen, name);
#endif #endif
/* convert a period(.) to an underscore(_) */ /* convert a period(.) to an underscore(_) */
@ -1336,19 +1336,19 @@ static int handle_logopt (hcl_t* hcl, const hcl_bch_t* str)
hcl_bch_t* cm, * flt; hcl_bch_t* cm, * flt;
unsigned int logmask; unsigned int logmask;
cm = hcl_findbcharinbcstr (xstr, ','); cm = hcl_find_bchar_in_bcstr (xstr, ',');
if (cm) if (cm)
{ {
/* i duplicate this string for open() below as open() doesn't /* i duplicate this string for open() below as open() doesn't
* accept a length-bounded string */ * accept a length-bounded string */
xstr = hcl_dupbchars (hcl, str, hcl_countbcstr(str)); xstr = hcl_dupbchars (hcl, str, hcl_count_bcstr(str));
if (!xstr) if (!xstr)
{ {
fprintf (stderr, "ERROR: out of memory in duplicating %s\n", str); fprintf (stderr, "ERROR: out of memory in duplicating %s\n", str);
return -1; return -1;
} }
cm = hcl_findbcharinbcstr(xstr, ','); cm = hcl_find_bchar_in_bcstr(xstr, ',');
*cm = '\0'; *cm = '\0';
logmask = xtn->logmask; logmask = xtn->logmask;
@ -1356,28 +1356,28 @@ static int handle_logopt (hcl_t* hcl, const hcl_bch_t* str)
{ {
flt = cm + 1; flt = cm + 1;
cm = hcl_findbcharinbcstr(flt, ','); cm = hcl_find_bchar_in_bcstr(flt, ',');
if (cm) *cm = '\0'; if (cm) *cm = '\0';
if (hcl_compbcstr(flt, "app") == 0) logmask |= HCL_LOG_APP; if (hcl_comp_bcstr(flt, "app") == 0) logmask |= HCL_LOG_APP;
else if (hcl_compbcstr(flt, "compiler") == 0) logmask |= HCL_LOG_COMPILER; else if (hcl_comp_bcstr(flt, "compiler") == 0) logmask |= HCL_LOG_COMPILER;
else if (hcl_compbcstr(flt, "vm") == 0) logmask |= HCL_LOG_VM; else if (hcl_comp_bcstr(flt, "vm") == 0) logmask |= HCL_LOG_VM;
else if (hcl_compbcstr(flt, "mnemonic") == 0) logmask |= HCL_LOG_MNEMONIC; else if (hcl_comp_bcstr(flt, "mnemonic") == 0) logmask |= HCL_LOG_MNEMONIC;
else if (hcl_compbcstr(flt, "gc") == 0) logmask |= HCL_LOG_GC; else if (hcl_comp_bcstr(flt, "gc") == 0) logmask |= HCL_LOG_GC;
else if (hcl_compbcstr(flt, "ic") == 0) logmask |= HCL_LOG_IC; else if (hcl_comp_bcstr(flt, "ic") == 0) logmask |= HCL_LOG_IC;
else if (hcl_compbcstr(flt, "primitive") == 0) logmask |= HCL_LOG_PRIMITIVE; else if (hcl_comp_bcstr(flt, "primitive") == 0) logmask |= HCL_LOG_PRIMITIVE;
else if (hcl_compbcstr(flt, "fatal") == 0) logmask |= HCL_LOG_FATAL; else if (hcl_comp_bcstr(flt, "fatal") == 0) logmask |= HCL_LOG_FATAL;
else if (hcl_compbcstr(flt, "error") == 0) logmask |= HCL_LOG_ERROR; else if (hcl_comp_bcstr(flt, "error") == 0) logmask |= HCL_LOG_ERROR;
else if (hcl_compbcstr(flt, "warn") == 0) logmask |= HCL_LOG_WARN; else if (hcl_comp_bcstr(flt, "warn") == 0) logmask |= HCL_LOG_WARN;
else if (hcl_compbcstr(flt, "info") == 0) logmask |= HCL_LOG_INFO; else if (hcl_comp_bcstr(flt, "info") == 0) logmask |= HCL_LOG_INFO;
else if (hcl_compbcstr(flt, "debug") == 0) logmask |= HCL_LOG_DEBUG; else if (hcl_comp_bcstr(flt, "debug") == 0) logmask |= HCL_LOG_DEBUG;
else if (hcl_compbcstr(flt, "fatal+") == 0) logmask |= HCL_LOG_FATAL; else if (hcl_comp_bcstr(flt, "fatal+") == 0) logmask |= HCL_LOG_FATAL;
else if (hcl_compbcstr(flt, "error+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR; else if (hcl_comp_bcstr(flt, "error+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR;
else if (hcl_compbcstr(flt, "warn+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN; else if (hcl_comp_bcstr(flt, "warn+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN;
else if (hcl_compbcstr(flt, "info+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN | HCL_LOG_INFO; else if (hcl_comp_bcstr(flt, "info+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN | HCL_LOG_INFO;
else if (hcl_compbcstr(flt, "debug+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN | HCL_LOG_INFO | HCL_LOG_DEBUG; else if (hcl_comp_bcstr(flt, "debug+") == 0) logmask |= HCL_LOG_FATAL | HCL_LOG_ERROR | HCL_LOG_WARN | HCL_LOG_INFO | HCL_LOG_DEBUG;
else else
{ {
@ -1431,10 +1431,10 @@ static int handle_dbgopt (hcl_t* hcl, const hcl_bch_t* str)
{ {
flt = cm + 1; flt = cm + 1;
cm = hcl_findbcharinbcstr(flt, ','); cm = hcl_find_bchar_in_bcstr(flt, ',');
len = cm? (cm - flt): hcl_countbcstr(flt); len = cm? (cm - flt): hcl_count_bcstr(flt);
if (hcl_compbcharsbcstr (flt, len, "gc") == 0) dbgopt |= HCL_DEBUG_GC; if (hcl_comp_bchars_bcstr (flt, len, "gc") == 0) dbgopt |= HCL_DEBUG_GC;
else if (hcl_compbcharsbcstr (flt, len, "bigint") == 0) dbgopt |= HCL_DEBUG_BIGINT; else if (hcl_comp_bchars_bcstr (flt, len, "bigint") == 0) dbgopt |= HCL_DEBUG_BIGINT;
else else
{ {
fprintf (stderr, "ERROR: unknown debug option value - %.*s\n", (int)len, flt); fprintf (stderr, "ERROR: unknown debug option value - %.*s\n", (int)len, flt);
@ -1717,13 +1717,13 @@ int main (int argc, char* argv[])
break; break;
case '\0': case '\0':
if (hcl_compbcstr(opt.lngopt, "large-pages") == 0) if (hcl_comp_bcstr(opt.lngopt, "large-pages") == 0)
{ {
large_pages = 1; large_pages = 1;
break; break;
} }
#if defined(HCL_BUILD_DEBUG) #if defined(HCL_BUILD_DEBUG)
else if (hcl_compbcstr(opt.lngopt, "debug") == 0) else if (hcl_comp_bcstr(opt.lngopt, "debug") == 0)
{ {
dbgopt = opt.arg; dbgopt = opt.arg;
break; break;

View File

@ -473,7 +473,7 @@ int hcl_hashobj (hcl_t* hcl, hcl_oop_t obj, hcl_oow_t* xhv)
switch (type) switch (type)
{ {
case HCL_OBJ_TYPE_BYTE: case HCL_OBJ_TYPE_BYTE:
hv = hcl_hashbytes(((hcl_oop_byte_t)obj)->slot, HCL_OBJ_GET_SIZE(obj)); hv = hcl_hash_bytes(((hcl_oop_byte_t)obj)->slot, HCL_OBJ_GET_SIZE(obj));
break; break;
case HCL_OBJ_TYPE_CHAR: case HCL_OBJ_TYPE_CHAR:

View File

@ -51,8 +51,8 @@ static hcl_bch_t EMSG_BCH[] = { '\0' };
#define xopt_t hcl_uopt_t #define xopt_t hcl_uopt_t
#define xopt_lng_t hcl_uopt_lng_t #define xopt_lng_t hcl_uopt_lng_t
#define xgetopt hcl_getuopt #define xgetopt hcl_getuopt
#define xcompcharscstr hcl_compucharsucstr #define xcompcharscstr hcl_comp_uchars_ucstr
#define xfindcharincstr hcl_finducharinucstr #define xfindcharincstr hcl_find_uchar_in_ucstr
#define XCI_EOF HCL_BCI_EOF #define XCI_EOF HCL_BCI_EOF
#include "opt-impl.h" #include "opt-impl.h"
@ -74,8 +74,8 @@ static hcl_bch_t EMSG_BCH[] = { '\0' };
#define xopt_t hcl_bopt_t #define xopt_t hcl_bopt_t
#define xopt_lng_t hcl_bopt_lng_t #define xopt_lng_t hcl_bopt_lng_t
#define xgetopt hcl_getbopt #define xgetopt hcl_getbopt
#define xcompcharscstr hcl_compbcharsbcstr #define xcompcharscstr hcl_comp_bchars_bcstr
#define xfindcharincstr hcl_findbcharinbcstr #define xfindcharincstr hcl_find_bchar_in_bcstr
#define XCI_EOF HCL_UCI_EOF #define XCI_EOF HCL_UCI_EOF
#include "opt-impl.h" #include "opt-impl.h"

View File

@ -349,7 +349,7 @@ static int copy_string_to (hcl_t* hcl, const hcl_oocs_t* src, hcl_oocs_t* dst, h
} }
if (append && add_delim) dst->ptr[pos++] = add_delim; if (append && add_delim) dst->ptr[pos++] = add_delim;
hcl_copyoochars (&dst->ptr[pos], src->ptr, src->len); hcl_copy_oochars (&dst->ptr[pos], src->ptr, src->len);
dst->len = len; dst->len = len;
return 0; return 0;
} }
@ -404,7 +404,7 @@ static HCL_INLINE int add_token_str (hcl_t* hcl, const hcl_ooch_t* ptr, hcl_oow_
static HCL_INLINE int does_token_name_match (hcl_t* hcl, voca_id_t id) static HCL_INLINE int does_token_name_match (hcl_t* hcl, voca_id_t id)
{ {
return hcl->c->tok.name.len == vocas[id].len && return hcl->c->tok.name.len == vocas[id].len &&
hcl_equaloochars(hcl->c->tok.name.ptr, vocas[id].str, vocas[id].len); hcl_equal_oochars(hcl->c->tok.name.ptr, vocas[id].str, vocas[id].len);
} }
static HCL_INLINE int add_token_char (hcl_t* hcl, hcl_ooch_t c) static HCL_INLINE int add_token_char (hcl_t* hcl, hcl_ooch_t c)
@ -995,7 +995,7 @@ static hcl_iotok_type_t classify_ident_token (hcl_t* hcl, const hcl_oocs_t* v)
for (i = 0; i < HCL_COUNTOF(tab); i++) for (i = 0; i < HCL_COUNTOF(tab); i++)
{ {
if (hcl_compoochars(v->ptr, v->len, tab[i].name, tab[i].len) == 0) return tab[i].type; if (hcl_comp_oochars(v->ptr, v->len, tab[i].name, tab[i].len) == 0) return tab[i].type;
} }
return HCL_IOTOK_IDENT; return HCL_IOTOK_IDENT;
@ -1300,7 +1300,7 @@ static const hcl_ooch_t* add_io_name (hcl_t* hcl, const hcl_oocs_t* name)
ptr = (hcl_ooch_t*)(link + 1); ptr = (hcl_ooch_t*)(link + 1);
hcl_copyoochars (ptr, name->ptr, name->len); hcl_copy_oochars (ptr, name->ptr, name->len);
ptr[name->len] = '\0'; ptr[name->len] = '\0';
link->link = hcl->c->io_names; link->link = hcl->c->io_names;

View File

@ -106,7 +106,7 @@ static hcl_oop_t find_or_make_symbol (hcl_t* hcl, const hcl_ooch_t* ptr, hcl_oow
HCL_ASSERT (hcl, HCL_IS_SYMBOL(hcl, symbol)); HCL_ASSERT (hcl, HCL_IS_SYMBOL(hcl, symbol));
if (len == HCL_OBJ_GET_SIZE(symbol) && if (len == HCL_OBJ_GET_SIZE(symbol) &&
hcl_equaloochars (ptr, symbol->slot, len)) hcl_equal_oochars (ptr, symbol->slot, len))
{ {
return (hcl_oop_t)symbol; return (hcl_oop_t)symbol;
} }

106
lib/utl.c
View File

@ -35,7 +35,7 @@
* utobcstr -> ucstr to bcstr * utobcstr -> ucstr to bcstr
*/ */
hcl_oow_t hcl_hashbytes (const hcl_oob_t* ptr, hcl_oow_t len) hcl_oow_t hcl_hash_bytes (const hcl_oob_t* ptr, hcl_oow_t len)
{ {
hcl_oow_t h = 0; hcl_oow_t h = 0;
const hcl_uint8_t* bp, * be; const hcl_uint8_t* bp, * be;
@ -48,7 +48,7 @@ hcl_oow_t hcl_hashbytes (const hcl_oob_t* ptr, hcl_oow_t len)
return h % ((hcl_oow_t)HCL_SMOOI_MAX + 1); return h % ((hcl_oow_t)HCL_SMOOI_MAX + 1);
} }
int hcl_equaluchars (const hcl_uch_t* str1, const hcl_uch_t* str2, hcl_oow_t len) int hcl_equal_uchars (const hcl_uch_t* str1, const hcl_uch_t* str2, hcl_oow_t len)
{ {
hcl_oow_t i; hcl_oow_t i;
@ -63,7 +63,7 @@ int hcl_equaluchars (const hcl_uch_t* str1, const hcl_uch_t* str2, hcl_oow_t len
return 1; return 1;
} }
int hcl_equalbchars (const hcl_bch_t* str1, const hcl_bch_t* str2, hcl_oow_t len) int hcl_equal_bchars (const hcl_bch_t* str1, const hcl_bch_t* str2, hcl_oow_t len)
{ {
hcl_oow_t i; hcl_oow_t i;
@ -78,7 +78,7 @@ int hcl_equalbchars (const hcl_bch_t* str1, const hcl_bch_t* str2, hcl_oow_t len
return 1; return 1;
} }
int hcl_compuchars (const hcl_uch_t* str1, hcl_oow_t len1, const hcl_uch_t* str2, hcl_oow_t len2) int hcl_comp_uchars (const hcl_uch_t* str1, hcl_oow_t len1, const hcl_uch_t* str2, hcl_oow_t len2)
{ {
hcl_uchu_t c1, c2; hcl_uchu_t c1, c2;
const hcl_uch_t* end1 = str1 + len1; const hcl_uch_t* end1 = str1 + len1;
@ -100,7 +100,7 @@ int hcl_compuchars (const hcl_uch_t* str1, hcl_oow_t len1, const hcl_uch_t* str2
return (str2 < end2)? -1: 0; return (str2 < end2)? -1: 0;
} }
int hcl_compbchars (const hcl_bch_t* str1, hcl_oow_t len1, const hcl_bch_t* str2, hcl_oow_t len2) int hcl_comp_bchars (const hcl_bch_t* str1, hcl_oow_t len1, const hcl_bch_t* str2, hcl_oow_t len2)
{ {
hcl_bchu_t c1, c2; hcl_bchu_t c1, c2;
const hcl_bch_t* end1 = str1 + len1; const hcl_bch_t* end1 = str1 + len1;
@ -122,7 +122,7 @@ int hcl_compbchars (const hcl_bch_t* str1, hcl_oow_t len1, const hcl_bch_t* str2
return (str2 < end2)? -1: 0; return (str2 < end2)? -1: 0;
} }
int hcl_compucstr (const hcl_uch_t* str1, const hcl_uch_t* str2) int hcl_comp_ucstr (const hcl_uch_t* str1, const hcl_uch_t* str2)
{ {
while (*str1 == *str2) while (*str1 == *str2)
{ {
@ -133,7 +133,7 @@ int hcl_compucstr (const hcl_uch_t* str1, const hcl_uch_t* str2)
return ((hcl_uchu_t)*str1 > (hcl_uchu_t)*str2)? 1: -1; return ((hcl_uchu_t)*str1 > (hcl_uchu_t)*str2)? 1: -1;
} }
int hcl_compbcstr (const hcl_bch_t* str1, const hcl_bch_t* str2) int hcl_comp_bcstr (const hcl_bch_t* str1, const hcl_bch_t* str2)
{ {
while (*str1 == *str2) while (*str1 == *str2)
{ {
@ -144,7 +144,7 @@ int hcl_compbcstr (const hcl_bch_t* str1, const hcl_bch_t* str2)
return ((hcl_bchu_t)*str1 > (hcl_bchu_t)*str2)? 1: -1; return ((hcl_bchu_t)*str1 > (hcl_bchu_t)*str2)? 1: -1;
} }
int hcl_compucbcstr (const hcl_uch_t* str1, const hcl_bch_t* str2) int hcl_comp_ucstr_bcstr (const hcl_uch_t* str1, const hcl_bch_t* str2)
{ {
while (*str1 == *str2) while (*str1 == *str2)
{ {
@ -155,7 +155,7 @@ int hcl_compucbcstr (const hcl_uch_t* str1, const hcl_bch_t* str2)
return ((hcl_uchu_t)*str1 > (hcl_bchu_t)*str2)? 1: -1; return ((hcl_uchu_t)*str1 > (hcl_bchu_t)*str2)? 1: -1;
} }
int hcl_compucharsucstr (const hcl_uch_t* str1, hcl_oow_t len, const hcl_uch_t* str2) int hcl_comp_uchars_ucstr (const hcl_uch_t* str1, hcl_oow_t len, const hcl_uch_t* str2)
{ {
/* for "abc\0" of length 4 vs "abc", the fourth character /* for "abc\0" of length 4 vs "abc", the fourth character
* of the first string is equal to the terminating null of * of the first string is equal to the terminating null of
@ -170,7 +170,7 @@ int hcl_compucharsucstr (const hcl_uch_t* str1, hcl_oow_t len, const hcl_uch_t*
return (str1 < end)? 1: (*str2 == '\0'? 0: -1); return (str1 < end)? 1: (*str2 == '\0'? 0: -1);
} }
int hcl_compucharsbcstr (const hcl_uch_t* str1, hcl_oow_t len, const hcl_bch_t* str2) int hcl_comp_uchars_bcstr (const hcl_uch_t* str1, hcl_oow_t len, const hcl_bch_t* str2)
{ {
const hcl_uch_t* end = str1 + len; const hcl_uch_t* end = str1 + len;
while (str1 < end && *str2 != '\0') while (str1 < end && *str2 != '\0')
@ -181,7 +181,7 @@ int hcl_compucharsbcstr (const hcl_uch_t* str1, hcl_oow_t len, const hcl_bch_t*
return (str1 < end)? 1: (*str2 == '\0'? 0: -1); return (str1 < end)? 1: (*str2 == '\0'? 0: -1);
} }
int hcl_compbcharsbcstr (const hcl_bch_t* str1, hcl_oow_t len, const hcl_bch_t* str2) int hcl_comp_bchars_bcstr (const hcl_bch_t* str1, hcl_oow_t len, const hcl_bch_t* str2)
{ {
const hcl_bch_t* end = str1 + len; const hcl_bch_t* end = str1 + len;
while (str1 < end && *str2 != '\0') while (str1 < end && *str2 != '\0')
@ -192,7 +192,7 @@ int hcl_compbcharsbcstr (const hcl_bch_t* str1, hcl_oow_t len, const hcl_bch_t*
return (str1 < end)? 1: (*str2 == '\0'? 0: -1); return (str1 < end)? 1: (*str2 == '\0'? 0: -1);
} }
int hcl_compbcharsucstr (const hcl_bch_t* str1, hcl_oow_t len, const hcl_uch_t* str2) int hcl_comp_bchars_ucstr (const hcl_bch_t* str1, hcl_oow_t len, const hcl_uch_t* str2)
{ {
const hcl_bch_t* end = str1 + len; const hcl_bch_t* end = str1 + len;
while (str1 < end && *str2 != '\0') while (str1 < end && *str2 != '\0')
@ -203,21 +203,21 @@ int hcl_compbcharsucstr (const hcl_bch_t* str1, hcl_oow_t len, const hcl_uch_t*
return (str1 < end)? 1: (*str2 == '\0'? 0: -1); return (str1 < end)? 1: (*str2 == '\0'? 0: -1);
} }
void hcl_copyuchars (hcl_uch_t* dst, const hcl_uch_t* src, hcl_oow_t len) void hcl_copy_uchars (hcl_uch_t* dst, const hcl_uch_t* src, hcl_oow_t len)
{ {
/* take note of no forced null termination */ /* take note of no forced null termination */
hcl_oow_t i; hcl_oow_t i;
for (i = 0; i < len; i++) dst[i] = src[i]; for (i = 0; i < len; i++) dst[i] = src[i];
} }
void hcl_copybchars (hcl_bch_t* dst, const hcl_bch_t* src, hcl_oow_t len) void hcl_copy_bchars (hcl_bch_t* dst, const hcl_bch_t* src, hcl_oow_t len)
{ {
/* take note of no forced null termination */ /* take note of no forced null termination */
hcl_oow_t i; hcl_oow_t i;
for (i = 0; i < len; i++) dst[i] = src[i]; for (i = 0; i < len; i++) dst[i] = src[i];
} }
void hcl_copybtouchars (hcl_uch_t* dst, const hcl_bch_t* src, hcl_oow_t len) void hcl_copy_bchars_to_uchars (hcl_uch_t* dst, const hcl_bch_t* src, hcl_oow_t len)
{ {
/* copy without conversions. /* copy without conversions.
* use hcl_bctouchars() for conversion encoding */ * use hcl_bctouchars() for conversion encoding */
@ -225,7 +225,7 @@ void hcl_copybtouchars (hcl_uch_t* dst, const hcl_bch_t* src, hcl_oow_t len)
for (i = 0; i < len; i++) dst[i] = src[i]; for (i = 0; i < len; i++) dst[i] = src[i];
} }
hcl_oow_t hcl_copyucstr (hcl_uch_t* dst, hcl_oow_t len, const hcl_uch_t* src) hcl_oow_t hcl_copy_ucstr (hcl_uch_t* dst, hcl_oow_t len, const hcl_uch_t* src)
{ {
hcl_uch_t* p, * p2; hcl_uch_t* p, * p2;
@ -241,7 +241,7 @@ hcl_oow_t hcl_copyucstr (hcl_uch_t* dst, hcl_oow_t len, const hcl_uch_t* src)
return p - dst; return p - dst;
} }
hcl_oow_t hcl_copybcstr (hcl_bch_t* dst, hcl_oow_t len, const hcl_bch_t* src) hcl_oow_t hcl_copy_bcstr (hcl_bch_t* dst, hcl_oow_t len, const hcl_bch_t* src)
{ {
hcl_bch_t* p, * p2; hcl_bch_t* p, * p2;
@ -257,21 +257,21 @@ hcl_oow_t hcl_copybcstr (hcl_bch_t* dst, hcl_oow_t len, const hcl_bch_t* src)
return p - dst; return p - dst;
} }
hcl_oow_t hcl_countucstr (const hcl_uch_t* str) hcl_oow_t hcl_count_ucstr (const hcl_uch_t* str)
{ {
const hcl_uch_t* ptr = str; const hcl_uch_t* ptr = str;
while (*ptr != '\0') ptr++; while (*ptr != '\0') ptr++;
return ptr - str; return ptr - str;
} }
hcl_oow_t hcl_countbcstr (const hcl_bch_t* str) hcl_oow_t hcl_count_bcstr (const hcl_bch_t* str)
{ {
const hcl_bch_t* ptr = str; const hcl_bch_t* ptr = str;
while (*ptr != '\0') ptr++; while (*ptr != '\0') ptr++;
return ptr - str; return ptr - str;
} }
hcl_uch_t* hcl_finduchar (const hcl_uch_t* ptr, hcl_oow_t len, hcl_uch_t c) hcl_uch_t* hcl_find_uchar (const hcl_uch_t* ptr, hcl_oow_t len, hcl_uch_t c)
{ {
const hcl_uch_t* end; const hcl_uch_t* end;
@ -285,7 +285,7 @@ hcl_uch_t* hcl_finduchar (const hcl_uch_t* ptr, hcl_oow_t len, hcl_uch_t c)
return HCL_NULL; return HCL_NULL;
} }
hcl_bch_t* hcl_findbchar (const hcl_bch_t* ptr, hcl_oow_t len, hcl_bch_t c) hcl_bch_t* hcl_find_bchar (const hcl_bch_t* ptr, hcl_oow_t len, hcl_bch_t c)
{ {
const hcl_bch_t* end; const hcl_bch_t* end;
@ -299,7 +299,7 @@ hcl_bch_t* hcl_findbchar (const hcl_bch_t* ptr, hcl_oow_t len, hcl_bch_t c)
return HCL_NULL; return HCL_NULL;
} }
hcl_uch_t* hcl_rfinduchar (const hcl_uch_t* ptr, hcl_oow_t len, hcl_uch_t c) hcl_uch_t* hcl_rfind_uchar (const hcl_uch_t* ptr, hcl_oow_t len, hcl_uch_t c)
{ {
const hcl_uch_t* cur; const hcl_uch_t* cur;
@ -313,7 +313,7 @@ hcl_uch_t* hcl_rfinduchar (const hcl_uch_t* ptr, hcl_oow_t len, hcl_uch_t c)
return HCL_NULL; return HCL_NULL;
} }
hcl_bch_t* hcl_rfindbchar (const hcl_bch_t* ptr, hcl_oow_t len, hcl_bch_t c) hcl_bch_t* hcl_rfind_bchar (const hcl_bch_t* ptr, hcl_oow_t len, hcl_bch_t c)
{ {
const hcl_bch_t* cur; const hcl_bch_t* cur;
@ -327,7 +327,7 @@ hcl_bch_t* hcl_rfindbchar (const hcl_bch_t* ptr, hcl_oow_t len, hcl_bch_t c)
return HCL_NULL; return HCL_NULL;
} }
hcl_uch_t* hcl_finducharinucstr (const hcl_uch_t* ptr, hcl_uch_t c) hcl_uch_t* hcl_find_uchar_in_ucstr (const hcl_uch_t* ptr, hcl_uch_t c)
{ {
while (*ptr != '\0') while (*ptr != '\0')
{ {
@ -338,7 +338,7 @@ hcl_uch_t* hcl_finducharinucstr (const hcl_uch_t* ptr, hcl_uch_t c)
return HCL_NULL; return HCL_NULL;
} }
hcl_bch_t* hcl_findbcharinbcstr (const hcl_bch_t* ptr, hcl_bch_t c) hcl_bch_t* hcl_find_bchar_in_bcstr (const hcl_bch_t* ptr, hcl_bch_t c)
{ {
while (*ptr != '\0') while (*ptr != '\0')
{ {
@ -351,45 +351,7 @@ hcl_bch_t* hcl_findbcharinbcstr (const hcl_bch_t* ptr, hcl_bch_t c)
/* ----------------------------------------------------------------------- */ /* ----------------------------------------------------------------------- */
int hcl_concatoocstrtosbuf (hcl_t* hcl, const hcl_ooch_t* str, int id) HCL_INLINE int hcl_conv_bchars_to_uchars_with_cmgr (
{
hcl_sbuf_t* p;
hcl_oow_t len;
p = &hcl->sbuf[id];
len = hcl_countoocstr (str);
if (len > p->capa - p->len)
{
hcl_oow_t newcapa;
hcl_ooch_t* tmp;
newcapa = HCL_ALIGN(p->len + len, 512); /* TODO: adjust this capacity */
/* +1 to handle line ending injection more easily */
tmp = (hcl_ooch_t*)hcl_reallocmem(hcl, p->ptr, (newcapa + 1) * HCL_SIZEOF(*tmp));
if (!tmp) return -1;
p->ptr = tmp;
p->capa = newcapa;
}
hcl_copyoochars (&p->ptr[p->len], str, len);
p->len += len;
p->ptr[p->len] = '\0';
return 0;
}
int hcl_copyoocstrtosbuf (hcl_t* hcl, const hcl_ooch_t* str, int id)
{
hcl->sbuf[id].len = 0;;
return hcl_concatoocstrtosbuf (hcl, str, id);
}
/* ----------------------------------------------------------------------- */
HCL_INLINE int hcl_conv_bcsn_to_ucsn_with_cmgr (
const hcl_bch_t* bcs, hcl_oow_t* bcslen, const hcl_bch_t* bcs, hcl_oow_t* bcslen,
hcl_uch_t* ucs, hcl_oow_t* ucslen, hcl_cmgr_t* cmgr, int all) hcl_uch_t* ucs, hcl_oow_t* ucslen, hcl_cmgr_t* cmgr, int all)
{ {
@ -521,7 +483,7 @@ HCL_INLINE int hcl_conv_bcs_to_ucs_with_cmgr (
for (bp = bcs; *bp != '\0'; bp++) /* nothing */ ; for (bp = bcs; *bp != '\0'; bp++) /* nothing */ ;
mlen = bp - bcs; wlen = *ucslen; mlen = bp - bcs; wlen = *ucslen;
n = hcl_conv_bcsn_to_ucsn_with_cmgr (bcs, &mlen, ucs, &wlen, cmgr, all); n = hcl_conv_bchars_to_uchars_with_cmgr (bcs, &mlen, ucs, &wlen, cmgr, all);
if (ucs) if (ucs)
{ {
/* null-terminate the target buffer if it has room for it. */ /* null-terminate the target buffer if it has room for it. */
@ -533,7 +495,7 @@ HCL_INLINE int hcl_conv_bcs_to_ucs_with_cmgr (
return n; return n;
} }
HCL_INLINE int hcl_conv_ucsn_to_bcsn_with_cmgr ( HCL_INLINE int hcl_conv_uchars_to_bchars_with_cmgr (
const hcl_uch_t* ucs, hcl_oow_t* ucslen, const hcl_uch_t* ucs, hcl_oow_t* ucslen,
hcl_bch_t* bcs, hcl_oow_t* bcslen, hcl_cmgr_t* cmgr) hcl_bch_t* bcs, hcl_oow_t* bcslen, hcl_cmgr_t* cmgr)
{ {
@ -699,13 +661,13 @@ hcl_cmgr_t* hcl_get_utf8_cmgr (void)
int hcl_conv_utf8_to_uchars (const hcl_bch_t* bcs, hcl_oow_t* bcslen, hcl_uch_t* ucs, hcl_oow_t* ucslen) int hcl_conv_utf8_to_uchars (const hcl_bch_t* bcs, hcl_oow_t* bcslen, hcl_uch_t* ucs, hcl_oow_t* ucslen)
{ {
/* the source is length bound */ /* the source is length bound */
return hcl_conv_bcsn_to_ucsn_with_cmgr(bcs, bcslen, ucs, ucslen, &utf8_cmgr, 0); return hcl_conv_bchars_to_uchars_with_cmgr(bcs, bcslen, ucs, ucslen, &utf8_cmgr, 0);
} }
int hcl_conv_uchars_to_utf8 (const hcl_uch_t* ucs, hcl_oow_t* ucslen, hcl_bch_t* bcs, hcl_oow_t* bcslen) int hcl_conv_uchars_to_utf8 (const hcl_uch_t* ucs, hcl_oow_t* ucslen, hcl_bch_t* bcs, hcl_oow_t* bcslen)
{ {
/* length bound */ /* length bound */
return hcl_conv_ucsn_to_bcsn_with_cmgr(ucs, ucslen, bcs, bcslen, &utf8_cmgr); return hcl_conv_uchars_to_bchars_with_cmgr(ucs, ucslen, bcs, bcslen, &utf8_cmgr);
} }
int hcl_conv_utf8_to_ucstr (const hcl_bch_t* bcs, hcl_oow_t* bcslen, hcl_uch_t* ucs, hcl_oow_t* ucslen) int hcl_conv_utf8_to_ucstr (const hcl_bch_t* bcs, hcl_oow_t* bcslen, hcl_uch_t* ucs, hcl_oow_t* ucslen)
@ -727,7 +689,7 @@ int hcl_convbtouchars (hcl_t* hcl, const hcl_bch_t* bcs, hcl_oow_t* bcslen, hcl_
/* length bound */ /* length bound */
int n; int n;
n = hcl_conv_bcsn_to_ucsn_with_cmgr(bcs, bcslen, ucs, ucslen, hcl->cmgr, 0); n = hcl_conv_bchars_to_uchars_with_cmgr(bcs, bcslen, ucs, ucslen, hcl->cmgr, 0);
if (n <= -1) if (n <= -1)
{ {
@ -743,7 +705,7 @@ int hcl_convutobchars (hcl_t* hcl, const hcl_uch_t* ucs, hcl_oow_t* ucslen, hcl_
/* length bound */ /* length bound */
int n; int n;
n = hcl_conv_ucsn_to_bcsn_with_cmgr(ucs, ucslen, bcs, bcslen, hcl->cmgr); n = hcl_conv_uchars_to_bchars_with_cmgr(ucs, ucslen, bcs, bcslen, hcl->cmgr);
if (n <= -1) if (n <= -1)
{ {
@ -910,7 +872,7 @@ hcl_uch_t* hcl_dupuchars (hcl_t* hcl, const hcl_uch_t* ucs, hcl_oow_t ucslen)
ptr = (hcl_uch_t*)hcl_allocmem (hcl, (ucslen + 1) * HCL_SIZEOF(hcl_uch_t)); ptr = (hcl_uch_t*)hcl_allocmem (hcl, (ucslen + 1) * HCL_SIZEOF(hcl_uch_t));
if (!ptr) return HCL_NULL; if (!ptr) return HCL_NULL;
hcl_copyuchars (ptr, ucs, ucslen); hcl_copy_uchars (ptr, ucs, ucslen);
ptr[ucslen] = '\0'; ptr[ucslen] = '\0';
return ptr; return ptr;
} }
@ -922,7 +884,7 @@ hcl_bch_t* hcl_dupbchars (hcl_t* hcl, const hcl_bch_t* bcs, hcl_oow_t bcslen)
ptr = (hcl_bch_t*)hcl_allocmem (hcl, (bcslen + 1) * HCL_SIZEOF(hcl_bch_t)); ptr = (hcl_bch_t*)hcl_allocmem (hcl, (bcslen + 1) * HCL_SIZEOF(hcl_bch_t));
if (!ptr) return HCL_NULL; if (!ptr) return HCL_NULL;
hcl_copybchars (ptr, bcs, bcslen); hcl_copy_bchars (ptr, bcs, bcslen);
ptr[bcslen] = '\0'; ptr[bcslen] = '\0';
return ptr; return ptr;
} }