diff --git a/lib/hcl-prv.h b/lib/hcl-prv.h index 64a09b4..5753528 100644 --- a/lib/hcl-prv.h +++ b/lib/hcl-prv.h @@ -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, diff --git a/lib/sym.c b/lib/sym.c index 6dccb6e..9ffe2a2 100644 --- a/lib/sym.c +++ b/lib/sym.c @@ -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 +}