From c3d7da33f5309ebad7255dc1987a166e71916c7f Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Fri, 24 Jan 2020 06:54:49 +0000 Subject: [PATCH] some fixes for bch mode --- hawk/lib/Hawk.cpp | 8 ++++---- hawk/lib/parse.c | 11 ++++++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/hawk/lib/Hawk.cpp b/hawk/lib/Hawk.cpp index 17c67054..3a1acfdd 100644 --- a/hawk/lib/Hawk.cpp +++ b/hawk/lib/Hawk.cpp @@ -998,8 +998,8 @@ int Hawk::Value::setIndexedStr (const Index& idx, const hawk_uch_t* str, bool nu int Hawk::Value::setIndexedStr (Run* r, const Index& idx, const hawk_uch_t* str, bool numeric) { hawk_val_t* tmp; - tmp = numeric? hawk_rtx_makenstrvalwithoocstr(r->rtx, str): - hawk_rtx_makestrvalwithoocstr(r->rtx, str); + tmp = numeric? hawk_rtx_makenstrvalwithucstr(r->rtx, str): + hawk_rtx_makestrvalwithucstr(r->rtx, str); if (tmp == HAWK_NULL) { r->hawk->retrieveError (r); @@ -1378,8 +1378,8 @@ const hawk_uch_t* Hawk::getErrorLocationFileU () const if (!this->errinf.loc.file) return HAWK_NULL; hawk_oow_t wcslen, mbslen; wcslen = HAWK_COUNTOF(this->xerrlocfile); - hawk_conv_bcstr_to_ucstr_with_cmgr (this->errinf.loc.file, &mbslen, hawk->xerrlocfile, &wcslen, this->getCmgr(), 1); - return hawk->xerrlocfile; + hawk_conv_bcstr_to_ucstr_with_cmgr (this->errinf.loc.file, &mbslen, this->xerrlocfile, &wcslen, this->getCmgr(), 1); + return this->xerrlocfile; #endif } diff --git a/hawk/lib/parse.c b/hawk/lib/parse.c index 3f1f3155..02d58e6d 100644 --- a/hawk/lib/parse.c +++ b/hawk/lib/parse.c @@ -417,7 +417,7 @@ static global_t gtab[] = { \ hawk_bch_t __xbuf[HAWK_MBLEN_MAX + 1]; \ hawk_oow_t __len, __i; \ - __len = hawk_uctoutf8(c, __xbuf, HAWK_COUNTOF(__xbuf)); /* use utf8 all the time */ \ + __len = uc_to_utf8(c, __xbuf, HAWK_COUNTOF(__xbuf)); /* use utf8 all the time */ \ for (__i = 0; __i < __len; __i++) ADD_TOKEN_CHAR(awk, tok, __xbuf[__i]); \ } \ } while (0) @@ -439,6 +439,15 @@ static global_t gtab[] = #define ADJERR_LOC(hawk,l) do { (hawk)->_gem.errloc = *(l); } while (0) +#if defined(HAWK_OOCH_IS_BCH) +static HAWK_INLINE hawk_oow_t uc_to_utf8 (hawk_uch_t uc, hawk_bch_t* buf, hawk_oow_t bsz) +{ + static hawk_cmgr_t* utf8_cmgr = HAWK_NULL; + if (!utf8_cmgr) utf8_cmgr = hawk_get_cmgr_by_id(HAWK_CMGR_UTF8); + return utf8_cmgr->uctobc(uc, buf, bsz); +} +#endif + static HAWK_INLINE int is_plain_var (hawk_nde_t* nde) { return nde->type == HAWK_NDE_GBL ||