added hcl_makesymbolwithucstr()
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
hyung-hwan 2024-04-06 16:21:31 +09:00
parent b1d62105a5
commit 50bf4a1c0c
2 changed files with 28 additions and 1 deletions

View File

@ -1516,6 +1516,16 @@ hcl_oop_t hcl_makesymbol (
hcl_oow_t len
);
hcl_oop_t hcl_makesymbolwithbcstr (
hcl_t* hcl,
const hcl_bch_t* ptr
);
hcl_oop_t hcl_makesymbolwithucstr (
hcl_t* hcl,
const hcl_uch_t* ptr
);
hcl_oop_t hcl_findsymbol (
hcl_t* hcl,
const hcl_ooch_t* ptr,

View File

@ -184,7 +184,7 @@ hcl_oop_t hcl_findsymbol (hcl_t* hcl, const hcl_ooch_t* ptr, hcl_oow_t len)
return find_or_make_symbol(hcl, ptr, len, 0);
}
hcl_oop_t hcl_makesymbolwithbcstr (hcl_t* hcl, const hcl_ooch_t* ptr)
hcl_oop_t hcl_makesymbolwithbcstr (hcl_t* hcl, const hcl_bch_t* ptr)
{
#if defined(HCL_OOCH_IS_UCH)
hcl_uch_t* ucsptr;
@ -200,3 +200,20 @@ hcl_oop_t hcl_makesymbolwithbcstr (hcl_t* hcl, const hcl_ooch_t* ptr)
return hcl_makesymbol(hcl, ptr, hcl_count_bcstr(ptr));
#endif
}
hcl_oop_t hcl_makesymbolwithucstr (hcl_t* hcl, const hcl_uch_t* ptr)
{
#if defined(HCL_OOCH_IS_UCH)
return hcl_makesymbol(hcl, ptr, hcl_count_bcstr(ptr));
#else
hcl_uch_t* bcsptr;
hcl_oow_t bcslen;
hcl_oop_t v;
/* TODO: no duplication? */
bcsptr = hcl_duputobcstr(hcl, ptr, &bcslen);
if (HCL_UNLIKELY(!bcsptr)) return HCL_NULL;
v = hcl_makesymbol(hcl, bcsptr, bcslen);
hcl_freemem (hcl, bcsptr);
return v;
#endif
}