From 8a6e2c601c7593e4c6e7894eac222f9983a56e0f Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Sat, 7 Apr 2018 15:54:09 +0000 Subject: [PATCH] renamed some function names for naming consistency --- moo/lib/comp.c | 22 ++++---- moo/lib/dic.c | 6 +-- moo/lib/err.c | 2 +- moo/lib/exec.c | 8 +-- moo/lib/logfmtv.h | 10 ++-- moo/lib/main.c | 86 +++++++++++++++--------------- moo/lib/moo-utl.h | 132 +++++++++++++++++++++++----------------------- moo/lib/moo.c | 20 +++---- moo/lib/opt.c | 8 +-- moo/lib/sym.c | 2 +- moo/lib/utl.c | 72 ++++++++++++------------- 11 files changed, 184 insertions(+), 184 deletions(-) diff --git a/moo/lib/comp.c b/moo/lib/comp.c index e6bc29b..0448776 100644 --- a/moo/lib/comp.c +++ b/moo/lib/comp.c @@ -348,7 +348,7 @@ static MOO_INLINE int is_closing_char (moo_ooci_t c) static MOO_INLINE int is_word (const moo_oocs_t* oocs, voca_id_t id) { return oocs->len == vocas[id].len && - moo_equaloochars(oocs->ptr, vocas[id].str, vocas[id].len); + moo_equal_oochars(oocs->ptr, vocas[id].str, vocas[id].len); } static int is_reserved_word (const moo_oocs_t* ucs) @@ -444,7 +444,7 @@ static int copy_string_to (moo_t* moo, const moo_oocs_t* src, moo_oocs_t* dst, m } if (append && delim_char != '\0') dst->ptr[pos++] = delim_char; - moo_copyoochars (&dst->ptr[pos], src->ptr, src->len); + moo_copy_oochars (&dst->ptr[pos], src->ptr, src->len); dst->len = len; return 0; } @@ -758,7 +758,7 @@ static int add_to_oow_pool (moo_t* moo, moo_oow_pool_t* pool, moo_oow_t v) static MOO_INLINE int does_token_name_match (moo_t* moo, voca_id_t id) { return TOKEN_NAME_LEN(moo) == vocas[id].len && - moo_equaloochars(TOKEN_NAME_PTR(moo), vocas[id].str, vocas[id].len); + moo_equal_oochars(TOKEN_NAME_PTR(moo), vocas[id].str, vocas[id].len); } static MOO_INLINE int is_token_symbol (moo_t* moo, voca_id_t id) @@ -1970,7 +1970,7 @@ static const moo_ooch_t* add_io_name (moo_t* moo, const moo_oocs_t* name) ptr = (moo_ooch_t*)(link + 1); - moo_copyoochars (ptr, name->ptr, name->len); + moo_copy_oochars (ptr, name->ptr, name->len); ptr[name->len] = '\0'; link->link = moo->c->io_names; @@ -2597,7 +2597,7 @@ static int add_string_literal (moo_t* moo, const moo_oocs_t* str, moo_oow_t* ind if (MOO_CLASSOF(moo, lit) == moo->_string && MOO_OBJ_GET_SIZE(lit) == str->len && - moo_equaloochars(((moo_oop_char_t)lit)->slot, str->ptr, str->len)) + moo_equal_oochars(((moo_oop_char_t)lit)->slot, str->ptr, str->len)) { *index = i; return 0; @@ -3041,7 +3041,7 @@ static int preprocess_dotted_name (moo_t* moo, int flags, moo_oop_nsdic_t topdic { seg.ptr = (moo_ooch_t*)ptr; - dot = moo_findoochar (ptr, len, '.'); + dot = moo_find_oochar (ptr, len, '.'); if (dot) { if (pooldic_gotten) goto wrong_name; @@ -3858,7 +3858,7 @@ static int compile_method_pragma (moo_t* moo) * check if it is a primitive function identifier */ moo_oow_t lit_idx; - if (!moo_rfindoochar (tptr, tlen, '.')) + if (!moo_rfind_oochar (tptr, tlen, '.')) { /* wrong primitive function identifier */ moo_setsynerr (moo, MOO_SYNERR_PFIDINVAL, TOKEN_LOC(moo), TOKEN_NAME(moo)); @@ -3999,7 +3999,7 @@ static int validate_class_level_variable (moo_t* moo, var_info_t* var, const moo static moo_oow_t is_dotted_ident_prefixed (const moo_oocs_t* name, int voca_id) { if (name->len > vocas[voca_id].len && - moo_equaloochars(name->ptr, vocas[voca_id].str, vocas[voca_id].len) && + moo_equal_oochars(name->ptr, vocas[voca_id].str, vocas[voca_id].len) && name->ptr[vocas[voca_id].len] == '.') return vocas[voca_id].len; return 0; @@ -4031,7 +4031,7 @@ static MOO_INLINE int find_dotted_ident (moo_t* moo, const moo_oocs_t* name, con { /* the first word in the dotted notation is self */ - if (!moo_findoochar (name->ptr + pxlen + 1, name->len - pxlen - 1, '.')) + if (!moo_find_oochar (name->ptr + pxlen + 1, name->len - pxlen - 1, '.')) { /* the dotted name is composed of 2 segments only */ last.ptr = name->ptr + pxlen + 1; @@ -7475,7 +7475,7 @@ static int __compile_class_definition (moo_t* moo, int extend) if (TOKEN_NAME_LEN(moo) <= 0 || TOKEN_NAME_LEN(moo) > MOO_MOD_NAME_LEN_MAX || - moo_findoochar(TOKEN_NAME_PTR(moo), TOKEN_NAME_LEN(moo), '-') ) + moo_find_oochar(TOKEN_NAME_PTR(moo), TOKEN_NAME_LEN(moo), '-') ) { /* check for a bad module name. * also disallow a dash in the name - i like converting @@ -7880,7 +7880,7 @@ static moo_oop_t find_element_in_compiling_pooldic (moo_t* moo, const moo_oocs_t s = (moo_oop_char_t)moo->c->arlit.ptr[i]; MOO_ASSERT (moo, MOO_CLASSOF(moo,s) == moo->_symbol); if (MOO_OBJ_GET_SIZE(s) == name->len && - moo_equaloochars (name->ptr, MOO_OBJ_GET_CHAR_SLOT(s), name->len)) + moo_equal_oochars (name->ptr, MOO_OBJ_GET_CHAR_SLOT(s), name->len)) { return moo->c->arlit.ptr[i + 1]; } diff --git a/moo/lib/dic.c b/moo/lib/dic.c index 56367fe..24d784d 100644 --- a/moo/lib/dic.c +++ b/moo/lib/dic.c @@ -113,7 +113,7 @@ static moo_oop_association_t find_or_upsert (moo_t* moo, moo_oop_dic_t dic, moo_ if (MOO_OBJ_GET_CLASS(key) == MOO_OBJ_GET_CLASS(ass->key) && MOO_OBJ_GET_SIZE(key) == MOO_OBJ_GET_SIZE(ass->key) && - moo_equaloochars (key->slot, ((moo_oop_char_t)ass->key)->slot, MOO_OBJ_GET_SIZE(key))) + moo_equal_oochars (key->slot, ((moo_oop_char_t)ass->key)->slot, MOO_OBJ_GET_SIZE(key))) { /* the value of MOO_NULL indicates no insertion or update. */ if (value) ass->value = value; /* update */ @@ -218,7 +218,7 @@ static moo_oop_association_t lookup (moo_t* moo, moo_oop_dic_t dic, const moo_oo MOO_ASSERT (moo, MOO_OBJ_IS_CHAR_POINTER(ass->key)); if (name->len == MOO_OBJ_GET_SIZE(ass->key) && - moo_equaloochars(name->ptr, ((moo_oop_char_t)ass->key)->slot, name->len)) + moo_equal_oochars(name->ptr, ((moo_oop_char_t)ass->key)->slot, name->len)) { return ass; } @@ -292,7 +292,7 @@ int moo_deletedic (moo_t* moo, moo_oop_dic_t dic, const moo_oocs_t* name) MOO_ASSERT (moo, MOO_OBJ_IS_CHAR_POINTER(ass->key)); if (name->len == MOO_OBJ_GET_SIZE(ass->key) && - moo_equaloochars(name->ptr, ((moo_oop_char_t)ass->key)->slot, name->len)) + moo_equal_oochars(name->ptr, ((moo_oop_char_t)ass->key)->slot, name->len)) { goto found; } diff --git a/moo/lib/err.c b/moo/lib/err.c index 95363f5..ae06395 100644 --- a/moo/lib/err.c +++ b/moo/lib/err.c @@ -327,7 +327,7 @@ const moo_ooch_t* moo_geterrmsg (moo_t* moo) const moo_ooch_t* moo_backuperrmsg (moo_t* moo) { - moo_copyoocstr (moo->errmsg.tmpbuf.ooch, MOO_COUNTOF(moo->errmsg.tmpbuf.ooch), moo_geterrmsg(moo)); + moo_copy_oocstr (moo->errmsg.tmpbuf.ooch, MOO_COUNTOF(moo->errmsg.tmpbuf.ooch), moo_geterrmsg(moo)); return moo->errmsg.tmpbuf.ooch; } diff --git a/moo/lib/exec.c b/moo/lib/exec.c index e8163c1..bccbc29 100644 --- a/moo/lib/exec.c +++ b/moo/lib/exec.c @@ -1926,7 +1926,7 @@ static moo_pfrc_t pf_hash (moo_t* moo, moo_ooi_t nargs) switch (type) { case MOO_OBJ_TYPE_BYTE: - hv = moo_hashbytes(((moo_oop_byte_t)rcv)->slot, MOO_OBJ_GET_SIZE(rcv)); + hv = moo_hash_bytes(((moo_oop_byte_t)rcv)->slot, MOO_OBJ_GET_SIZE(rcv)); break; case MOO_OBJ_TYPE_CHAR: @@ -3290,7 +3290,7 @@ static moo_pfrc_t pf_error_as_string (moo_t* moo, moo_ooi_t nargs) /* TODO: error string will be mostly the same.. do i really have to call makestring every time? */ s = moo_errnum_to_errstr (ec); - ss = moo_makestring (moo, s, moo_countoocstr(s)); + ss = moo_makestring (moo, s, moo_count_oocstr(s)); if (!ss) return MOO_PF_FAILURE; MOO_STACK_SETRET (moo, nargs, ss); @@ -3547,10 +3547,10 @@ moo_pfbase_t* moo_getpfnum (moo_t* moo, const moo_ooch_t* ptr, moo_oow_t len, mo for (base = 0, lim = MOO_COUNTOF(pftab); lim > 0; lim >>= 1) { mid = base + (lim >> 1); - /* moo_compoocharsbcstr() is not aware of multibyte encoding. + /* moo_comp_oochars_bcstr() is not aware of multibyte encoding. * so the names above should be composed of the single byte * characters only */ - n = moo_compoocharsbcstr(ptr, len, pftab[mid].name); + n = moo_comp_oochars_bcstr(ptr, len, pftab[mid].name); if (n == 0) { MOO_ASSERT (moo, MOO_OOI_IN_METHOD_PREAMBLE_INDEX_RANGE(mid)); /* this must never be so big */ diff --git a/moo/lib/logfmtv.h b/moo/lib/logfmtv.h index c1db3b3..0a28693 100644 --- a/moo/lib/logfmtv.h +++ b/moo/lib/logfmtv.h @@ -166,7 +166,7 @@ static int logfmtv (moo_t* moo, const fmtchar_t* fmt, moo_fmtout_t* data, va_lis /* fmtchar is uch. ooch is bch. convert uch to bch */ ucslen = 1; bcslen = MOO_COUNTOF(bcsbuf); - if (moo_conv_ucsn_to_bcsn_with_cmgr(&fch, &ucslen, bcsbuf, &bcslen, moo->cmgr) <= -1) goto oops; + if (moo_conv_uchars_to_bchars_with_cmgr(&fch, &ucslen, bcsbuf, &bcslen, moo->cmgr) <= -1) goto oops; PUT_OOCS (bcsbuf, bcslen); } #endif @@ -467,7 +467,7 @@ static int logfmtv (moo_t* moo, const fmtchar_t* fmt, moo_fmtout_t* data, va_lis /* get the length */ for (bslen = 0; bsp[bslen]; bslen++); - if (moo_conv_bcsn_to_ucsn_with_cmgr(bsp, &bslen, MOO_NULL, &slen, moo->cmgr, 0) <= -1) goto oops; + if (moo_conv_bchars_to_uchars_with_cmgr(bsp, &bslen, MOO_NULL, &slen, moo->cmgr, 0) <= -1) goto oops; /* slen holds the length after conversion */ n = slen; @@ -487,7 +487,7 @@ static int logfmtv (moo_t* moo, const fmtchar_t* fmt, moo_fmtout_t* data, va_lis conv_len = MOO_COUNTOF(conv_buf); /* this must not fail since the dry-run above was successful */ - moo_conv_bcsn_to_ucsn_with_cmgr(&bsp[tot_len], &src_len, conv_buf, &conv_len, moo->cmgr, 0); + moo_conv_bchars_to_uchars_with_cmgr(&bsp[tot_len], &src_len, conv_buf, &conv_len, moo->cmgr, 0); tot_len += src_len; if (conv_len > n) conv_len = n; @@ -536,7 +536,7 @@ static int logfmtv (moo_t* moo, const fmtchar_t* fmt, moo_fmtout_t* data, va_lis /* get the length */ for (uslen = 0; usp[uslen]; uslen++); - if (moo_conv_ucsn_to_bcsn_with_cmgr(usp, &uslen, MOO_NULL, &slen, moo->cmgr) <= -1) goto oops; + if (moo_conv_uchars_to_bchars_with_cmgr(usp, &uslen, MOO_NULL, &slen, moo->cmgr) <= -1) goto oops; /* slen holds the length after conversion */ n = slen; @@ -555,7 +555,7 @@ static int logfmtv (moo_t* moo, const fmtchar_t* fmt, moo_fmtout_t* data, va_lis conv_len = MOO_COUNTOF(conv_buf); /* this must not fail since the dry-run above was successful */ - moo_conv_ucsn_to_bcsn_with_cmgr (&usp[tot_len], &src_len, conv_buf, &conv_len, moo->cmgr); + moo_conv_uchars_to_bchars_with_cmgr (&usp[tot_len], &src_len, conv_buf, &conv_len, moo->cmgr); tot_len += src_len; if (conv_len > n) conv_len = n; diff --git a/moo/lib/main.c b/moo/lib/main.c index bfc9cb1..6cd1e84 100644 --- a/moo/lib/main.c +++ b/moo/lib/main.c @@ -352,7 +352,7 @@ static MOO_INLINE moo_ooi_t open_input (moo_t* moo, moo_ioarg_t* arg) #if defined(MOO_OOCH_IS_UCH) if (moo_convootobcstr (moo, arg->name, &ucslen, MOO_NULL, &bcslen) <= -1) goto oops; #else - bcslen = moo_countbcstr (arg->name); + bcslen = moo_count_bcstr (arg->name); #endif fn = ((bb_t*)arg->includer->handle)->fn; @@ -364,11 +364,11 @@ static MOO_INLINE moo_ooi_t open_input (moo_t* moo, moo_ioarg_t* arg) if (!bb) goto oops; bb->fn = (moo_bch_t*)(bb + 1); - moo_copybchars (bb->fn, fn, parlen); + moo_copy_bchars (bb->fn, fn, parlen); #if defined(MOO_OOCH_IS_UCH) moo_convootobcstr (moo, arg->name, &ucslen, &bb->fn[parlen], &bcslen); #else - moo_copybcstr (&bb->fn[parlen], bcslen + 1, arg->name); + moo_copy_bcstr (&bb->fn[parlen], bcslen + 1, arg->name); #endif } else @@ -376,13 +376,13 @@ static MOO_INLINE moo_ooi_t open_input (moo_t* moo, moo_ioarg_t* arg) /* main stream */ moo_oow_t pathlen; - pathlen = moo_countbcstr (xtn->source_path); + pathlen = moo_count_bcstr (xtn->source_path); bb = moo_callocmem (moo, MOO_SIZEOF(*bb) + (MOO_SIZEOF(moo_bch_t) * (pathlen + 1))); if (!bb) goto oops; bb->fn = (moo_bch_t*)(bb + 1); - moo_copybcstr (bb->fn, pathlen + 1, xtn->source_path); + moo_copy_bcstr (bb->fn, pathlen + 1, xtn->source_path); } #if defined(__DOS__) || defined(_WIN32) || defined(__OS2__) @@ -460,7 +460,7 @@ static MOO_INLINE moo_ooi_t read_input (moo_t* moo, moo_ioarg_t* arg) #else bcslen = (bb->len < MOO_COUNTOF(arg->buf))? bb->len: MOO_COUNTOF(arg->buf); ucslen = bcslen; - moo_copybchars (arg->buf, bb->buf, bcslen); + moo_copy_bchars (arg->buf, bb->buf, bcslen); #endif remlen = bb->len - bcslen; @@ -778,7 +778,7 @@ static void syserrstrb (moo_t* moo, int syserr, moo_bch_t* buf, moo_oow_t len) strerror_r (syserr, buf, len); #else /* this is not thread safe */ - moo_copybcstr (buf, len, strerror(syserr)); + moo_copy_bcstr (buf, len, strerror(syserr)); #endif } @@ -797,7 +797,7 @@ static void* dl_open (moo_t* moo, const moo_ooch_t* name, int flags) * and MOO_COUNTOF(MOO_DEFAULT_PFMODPOSTIFX) include the terminating nulls. Never mind about * the extra 2 characters. */ #else - bufcapa = moo_countbcstr(name); + bufcapa = moo_count_bcstr(name); #endif bufcapa += MOO_COUNTOF(MOO_DEFAULT_PFMODPREFIX) + MOO_COUNTOF(MOO_DEFAULT_PFMODPOSTFIX) + 1; @@ -813,13 +813,13 @@ static void* dl_open (moo_t* moo, const moo_ooch_t* name, int flags) moo_oow_t len, i, xlen; /* opening a primitive function module - mostly libmoo-xxxx */ - len = moo_copybcstr(bufptr, bufcapa, MOO_DEFAULT_PFMODPREFIX); + len = moo_copy_bcstr(bufptr, bufcapa, MOO_DEFAULT_PFMODPREFIX); bcslen = bufcapa - len; #if defined(MOO_OOCH_IS_UCH) moo_convootobcstr(moo, name, &ucslen, &bufptr[len], &bcslen); #else - bcslen = moo_copybcstr(&bufptr[len], bcslen, name); + bcslen = moo_copy_bcstr(&bufptr[len], bcslen, name); #endif /* length including the prefix and the name. but excluding the postfix */ @@ -832,7 +832,7 @@ static void* dl_open (moo_t* moo, const moo_ooch_t* name, int flags) } retry: - moo_copybcstr (&bufptr[xlen], bufcapa - xlen, MOO_DEFAULT_PFMODPOSTFIX); + moo_copy_bcstr (&bufptr[xlen], bufcapa - xlen, MOO_DEFAULT_PFMODPOSTFIX); /* both prefix and postfix attached. for instance, libmoo-xxx */ handle = sys_dl_openext(bufptr); @@ -850,7 +850,7 @@ static void* dl_open (moo_t* moo, const moo_ooch_t* name, int flags) dl_errstr = sys_dl_error(); MOO_DEBUG3 (moo, "Failed to open(ext) DL %hs[%js] - %hs\n", &bufptr[len], name, dl_errstr); moo_seterrbfmt (moo, MOO_ESYSERR, "unable to open(ext) DL %js - %hs", name, dl_errstr); - dash = moo_rfindbchar(bufptr, moo_countbcstr(bufptr), '-'); + dash = moo_rfind_bchar(bufptr, moo_count_bcstr(bufptr), '-'); if (dash) { /* remove a segment at the back. @@ -878,10 +878,10 @@ static void* dl_open (moo_t* moo, const moo_ooch_t* name, int flags) bcslen = bufcapa; moo_convootobcstr(moo, name, &ucslen, bufptr, &bcslen); #else - bcslen = moo_copybcstr(bufptr, bufcapa, name); + bcslen = moo_copy_bcstr(bufptr, bufcapa, name); #endif - if (moo_findbchar (bufptr, bcslen, '.')) + if (moo_find_bchar (bufptr, bcslen, '.')) { handle = sys_dl_open(bufptr); if (!handle) @@ -943,7 +943,7 @@ static void* dl_getsym (moo_t* moo, void* handle, const moo_ooch_t* name) #if defined(MOO_OOCH_IS_UCH) if (moo_convootobcstr(moo, name, &ucslen, MOO_NULL, &bcslen) <= -1) return MOO_NULL; #else - bcslen = moo_countbcstr (name); + bcslen = moo_count_bcstr (name); #endif if (bcslen >= MOO_COUNTOF(stabuf) - 2) @@ -962,7 +962,7 @@ static void* dl_getsym (moo_t* moo, void* handle, const moo_ooch_t* name) #if defined(MOO_OOCH_IS_UCH) moo_convootobcstr (moo, name, &ucslen, &bufptr[1], &bcslen); #else - bcslen = moo_copybcstr(&bufptr[1], bcslen, name); + bcslen = moo_copy_bcstr(&bufptr[1], bcslen, name); #endif /* convert a period(.) to an underscore(_) */ @@ -2215,19 +2215,19 @@ static int handle_logopt (moo_t* moo, const moo_bch_t* str) moo_bch_t* cm, * flt; unsigned int logmask; - cm = moo_findbcharinbcstr (xstr, ','); + cm = moo_find_bchar_in_bcstr (xstr, ','); if (cm) { /* i duplicate this string for open() below as open() doesn't * accept a length-bounded string */ - xstr = moo_dupbchars (moo, str, moo_countbcstr(str)); + xstr = moo_dupbchars (moo, str, moo_count_bcstr(str)); if (!xstr) { fprintf (stderr, "ERROR: out of memory in duplicating %s\n", str); return -1; } - cm = moo_findbcharinbcstr(xstr, ','); + cm = moo_find_bchar_in_bcstr(xstr, ','); *cm = '\0'; logmask = xtn->logmask; @@ -2235,28 +2235,28 @@ static int handle_logopt (moo_t* moo, const moo_bch_t* str) { flt = cm + 1; - cm = moo_findbcharinbcstr(flt, ','); + cm = moo_find_bchar_in_bcstr(flt, ','); if (cm) *cm = '\0'; - if (moo_compbcstr(flt, "app") == 0) logmask |= MOO_LOG_APP; - else if (moo_compbcstr(flt, "compiler") == 0) logmask |= MOO_LOG_COMPILER; - else if (moo_compbcstr(flt, "vm") == 0) logmask |= MOO_LOG_VM; - else if (moo_compbcstr(flt, "mnemonic") == 0) logmask |= MOO_LOG_MNEMONIC; - else if (moo_compbcstr(flt, "gc") == 0) logmask |= MOO_LOG_GC; - else if (moo_compbcstr(flt, "ic") == 0) logmask |= MOO_LOG_IC; - else if (moo_compbcstr(flt, "primitive") == 0) logmask |= MOO_LOG_PRIMITIVE; + if (moo_comp_bcstr(flt, "app") == 0) logmask |= MOO_LOG_APP; + else if (moo_comp_bcstr(flt, "compiler") == 0) logmask |= MOO_LOG_COMPILER; + else if (moo_comp_bcstr(flt, "vm") == 0) logmask |= MOO_LOG_VM; + else if (moo_comp_bcstr(flt, "mnemonic") == 0) logmask |= MOO_LOG_MNEMONIC; + else if (moo_comp_bcstr(flt, "gc") == 0) logmask |= MOO_LOG_GC; + else if (moo_comp_bcstr(flt, "ic") == 0) logmask |= MOO_LOG_IC; + else if (moo_comp_bcstr(flt, "primitive") == 0) logmask |= MOO_LOG_PRIMITIVE; - else if (moo_compbcstr(flt, "fatal") == 0) logmask |= MOO_LOG_FATAL; - else if (moo_compbcstr(flt, "error") == 0) logmask |= MOO_LOG_ERROR; - else if (moo_compbcstr(flt, "warn") == 0) logmask |= MOO_LOG_WARN; - else if (moo_compbcstr(flt, "info") == 0) logmask |= MOO_LOG_INFO; - else if (moo_compbcstr(flt, "debug") == 0) logmask |= MOO_LOG_DEBUG; + else if (moo_comp_bcstr(flt, "fatal") == 0) logmask |= MOO_LOG_FATAL; + else if (moo_comp_bcstr(flt, "error") == 0) logmask |= MOO_LOG_ERROR; + else if (moo_comp_bcstr(flt, "warn") == 0) logmask |= MOO_LOG_WARN; + else if (moo_comp_bcstr(flt, "info") == 0) logmask |= MOO_LOG_INFO; + else if (moo_comp_bcstr(flt, "debug") == 0) logmask |= MOO_LOG_DEBUG; - else if (moo_compbcstr(flt, "fatal+") == 0) logmask |= MOO_LOG_FATAL; - else if (moo_compbcstr(flt, "error+") == 0) logmask |= MOO_LOG_FATAL | MOO_LOG_ERROR; - else if (moo_compbcstr(flt, "warn+") == 0) logmask |= MOO_LOG_FATAL | MOO_LOG_ERROR | MOO_LOG_WARN; - else if (moo_compbcstr(flt, "info+") == 0) logmask |= MOO_LOG_FATAL | MOO_LOG_ERROR | MOO_LOG_WARN | MOO_LOG_INFO; - else if (moo_compbcstr(flt, "debug+") == 0) logmask |= MOO_LOG_FATAL | MOO_LOG_ERROR | MOO_LOG_WARN | MOO_LOG_INFO | MOO_LOG_DEBUG; + else if (moo_comp_bcstr(flt, "fatal+") == 0) logmask |= MOO_LOG_FATAL; + else if (moo_comp_bcstr(flt, "error+") == 0) logmask |= MOO_LOG_FATAL | MOO_LOG_ERROR; + else if (moo_comp_bcstr(flt, "warn+") == 0) logmask |= MOO_LOG_FATAL | MOO_LOG_ERROR | MOO_LOG_WARN; + else if (moo_comp_bcstr(flt, "info+") == 0) logmask |= MOO_LOG_FATAL | MOO_LOG_ERROR | MOO_LOG_WARN | MOO_LOG_INFO; + else if (moo_comp_bcstr(flt, "debug+") == 0) logmask |= MOO_LOG_FATAL | MOO_LOG_ERROR | MOO_LOG_WARN | MOO_LOG_INFO | MOO_LOG_DEBUG; else { @@ -2306,10 +2306,10 @@ static int handle_dbgopt (moo_t* moo, const moo_bch_t* str) { flt = cm + 1; - cm = moo_findbcharinbcstr(flt, ','); - len = cm? (cm - flt): moo_countbcstr(flt); - if (moo_compbcharsbcstr (flt, len, "gc") == 0) dbgopt |= MOO_DEBUG_GC; - else if (moo_compbcharsbcstr (flt, len, "bigint") == 0) dbgopt |= MOO_DEBUG_BIGINT; + cm = moo_find_bchar_in_bcstr(flt, ','); + len = cm? (cm - flt): moo_count_bcstr(flt); + if (moo_comp_bchars_bcstr (flt, len, "gc") == 0) dbgopt |= MOO_DEBUG_GC; + else if (moo_comp_bchars_bcstr (flt, len, "bigint") == 0) dbgopt |= MOO_DEBUG_BIGINT; else { fprintf (stderr, "ERROR: unknown debug option value - %.*s\n", (int)len, flt); @@ -2390,13 +2390,13 @@ int main (int argc, char* argv[]) break; case '\0': - if (moo_compbcstr(opt.lngopt, "large-pages") == 0) + if (moo_comp_bcstr(opt.lngopt, "large-pages") == 0) { large_pages = 1; break; } #if defined(MOO_BUILD_DEBUG) - else if (moo_compbcstr(opt.lngopt, "debug") == 0) + else if (moo_comp_bcstr(opt.lngopt, "debug") == 0) { dbgopt = opt.arg; break; diff --git a/moo/lib/moo-utl.h b/moo/lib/moo-utl.h index 26d4bf9..997cfbb 100644 --- a/moo/lib/moo-utl.h +++ b/moo/lib/moo-utl.h @@ -120,7 +120,7 @@ extern "C" { #endif -MOO_EXPORT moo_oow_t moo_hashbytes ( +MOO_EXPORT moo_oow_t moo_hash_bytes ( const moo_oob_t* ptr, moo_oow_t len ); @@ -128,28 +128,28 @@ MOO_EXPORT moo_oow_t moo_hashbytes ( #if defined(MOO_HAVE_INLINE) static MOO_INLINE moo_oow_t moo_hashbchars (const moo_bch_t* ptr, moo_oow_t len) { - return moo_hashbytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_bch_t)); + return moo_hash_bytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_bch_t)); } static MOO_INLINE moo_oow_t moo_hashuchars (const moo_uch_t* ptr, moo_oow_t len) { - return moo_hashbytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_uch_t)); + return moo_hash_bytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_uch_t)); } static MOO_INLINE moo_oow_t moo_hashwords (const moo_oow_t* ptr, moo_oow_t len) { - return moo_hashbytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_oow_t)); + return moo_hash_bytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_oow_t)); } static MOO_INLINE moo_oow_t moo_hashhalfwords (const moo_oohw_t* ptr, moo_oow_t len) { - return moo_hashbytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_oohw_t)); + return moo_hash_bytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_oohw_t)); } #else -# define moo_hashbchars(ptr,len) moo_hashbytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_bch_t)) -# define moo_hashuchars(ptr,len) moo_hashbytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_uch_t)) -# define moo_hashwords(ptr,len) moo_hashbytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_oow_t)) -# define moo_hashhalfwords(ptr,len) moo_hashbytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_oohw_t)) +# define moo_hashbchars(ptr,len) moo_hash_bytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_bch_t)) +# define moo_hashuchars(ptr,len) moo_hash_bytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_uch_t)) +# define moo_hashwords(ptr,len) moo_hash_bytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_oow_t)) +# define moo_hashhalfwords(ptr,len) moo_hash_bytes((const moo_oob_t*)ptr, len * MOO_SIZEOF(moo_oohw_t)) #endif #if defined(MOO_OOCH_IS_UCH) @@ -159,176 +159,176 @@ MOO_EXPORT moo_oow_t moo_hashbytes ( #endif /** - * The moo_equaluchars() function determines equality of two strings + * The moo_equal_uchars() function determines equality of two strings * of the same length \a len. */ -MOO_EXPORT int moo_equaluchars ( +MOO_EXPORT int moo_equal_uchars ( const moo_uch_t* str1, const moo_uch_t* str2, moo_oow_t len ); -MOO_EXPORT int moo_equalbchars ( +MOO_EXPORT int moo_equal_bchars ( const moo_bch_t* str1, const moo_bch_t* str2, moo_oow_t len ); -MOO_EXPORT int moo_compuchars ( +MOO_EXPORT int moo_comp_uchars ( const moo_uch_t* str1, moo_oow_t len1, const moo_uch_t* str2, moo_oow_t len2 ); -MOO_EXPORT int moo_compbchars ( +MOO_EXPORT int moo_comp_bchars ( const moo_bch_t* str1, moo_oow_t len1, const moo_bch_t* str2, moo_oow_t len2 ); -MOO_EXPORT int moo_compucstr ( +MOO_EXPORT int moo_comp_ucstr ( const moo_uch_t* str1, const moo_uch_t* str2 ); -MOO_EXPORT int moo_compbcstr ( +MOO_EXPORT int moo_comp_bcstr ( const moo_bch_t* str1, const moo_bch_t* str2 ); -MOO_EXPORT int moo_compucbcstr ( +MOO_EXPORT int moo_comp_ucstr_bcstr ( const moo_uch_t* str1, const moo_bch_t* str2 ); -MOO_EXPORT int moo_compucharsucstr ( +MOO_EXPORT int moo_comp_uchars_ucstr ( const moo_uch_t* str1, moo_oow_t len, const moo_uch_t* str2 ); -MOO_EXPORT int moo_compucharsbcstr ( +MOO_EXPORT int moo_comp_uchars_bcstr ( const moo_uch_t* str1, moo_oow_t len, const moo_bch_t* str2 ); -MOO_EXPORT int moo_compbcharsbcstr ( +MOO_EXPORT int moo_comp_bchars_bcstr ( const moo_bch_t* str1, moo_oow_t len, const moo_bch_t* str2 ); -MOO_EXPORT int moo_compbcharsucstr ( +MOO_EXPORT int moo_comp_bchars_ucstr ( const moo_bch_t* str1, moo_oow_t len, const moo_uch_t* str2 ); -MOO_EXPORT void moo_copyuchars ( +MOO_EXPORT void moo_copy_uchars ( moo_uch_t* dst, const moo_uch_t* src, moo_oow_t len ); -MOO_EXPORT void moo_copybchars ( +MOO_EXPORT void moo_copy_bchars ( moo_bch_t* dst, const moo_bch_t* src, moo_oow_t len ); -MOO_EXPORT void moo_copybtouchars ( +MOO_EXPORT void moo_copy_bchars_to_uchars ( moo_uch_t* dst, const moo_bch_t* src, moo_oow_t len ); -MOO_EXPORT moo_oow_t moo_copyucstr ( +MOO_EXPORT moo_oow_t moo_copy_ucstr ( moo_uch_t* dst, moo_oow_t len, const moo_uch_t* src ); -MOO_EXPORT moo_oow_t moo_copybcstr ( +MOO_EXPORT moo_oow_t moo_copy_bcstr ( moo_bch_t* dst, moo_oow_t len, const moo_bch_t* src ); -MOO_EXPORT moo_uch_t* moo_finduchar ( +MOO_EXPORT moo_uch_t* moo_find_uchar ( const moo_uch_t* ptr, moo_oow_t len, moo_uch_t c ); -MOO_EXPORT moo_bch_t* moo_findbchar ( +MOO_EXPORT moo_bch_t* moo_find_bchar ( const moo_bch_t* ptr, moo_oow_t len, moo_bch_t c ); -MOO_EXPORT moo_uch_t* moo_rfinduchar ( +MOO_EXPORT moo_uch_t* moo_rfind_uchar ( const moo_uch_t* ptr, moo_oow_t len, moo_uch_t c ); -MOO_EXPORT moo_bch_t* moo_rfindbchar ( +MOO_EXPORT moo_bch_t* moo_rfind_bchar ( const moo_bch_t* ptr, moo_oow_t len, moo_bch_t c ); -MOO_EXPORT moo_uch_t* moo_finducharinucstr ( +MOO_EXPORT moo_uch_t* moo_find_uchar_in_ucstr ( const moo_uch_t* ptr, moo_uch_t c ); -MOO_EXPORT moo_bch_t* moo_findbcharinbcstr ( +MOO_EXPORT moo_bch_t* moo_find_bchar_in_bcstr ( const moo_bch_t* ptr, moo_bch_t c ); -MOO_EXPORT moo_oow_t moo_countucstr ( +MOO_EXPORT moo_oow_t moo_count_ucstr ( const moo_uch_t* str ); -MOO_EXPORT moo_oow_t moo_countbcstr ( +MOO_EXPORT moo_oow_t moo_count_bcstr ( const moo_bch_t* str ); #if defined(MOO_OOCH_IS_UCH) -# define moo_equaloochars(str1,str2,len) moo_equaluchars(str1,str2,len) -# define moo_compoochars(str1,len1,str2,len2) moo_compuchars(str1,len1,str2,len2) -# define moo_compoocbcstr(str1,str2) moo_compucbcstr(str1,str2) -# define moo_compoocharsbcstr(str1,len1,str2) moo_compucharsbcstr(str1,len1,str2) -# define moo_compoocharsucstr(str1,len1,str2) moo_compucharsucstr(str1,len1,str2) -# define moo_compoocharsoocstr(str1,len1,str2) moo_compucharsucstr(str1,len1,str2) -# define moo_compoocstr(str1,str2) moo_compucstr(str1,str2) -# define moo_copyoochars(dst,src,len) moo_copyuchars(dst,src,len) -# define moo_copybctooochars(dst,src,len) moo_copybtouchars(dst,src,len) -# define moo_copyoocstr(dst,len,src) moo_copyucstr(dst,len,src) -# define moo_findoochar(ptr,len,c) moo_finduchar(ptr,len,c) -# define moo_rfindoochar(ptr,len,c) moo_rfinduchar(ptr,len,c) -# define moo_findoocharinoocstr(ptr,c) moo_finducharinucstr(ptr,c) -# define moo_countoocstr(str) moo_countucstr(str) +# define moo_equal_oochars(str1,str2,len) moo_equal_uchars(str1,str2,len) +# define moo_comp_oochars(str1,len1,str2,len2) moo_comp_uchars(str1,len1,str2,len2) +# define moo_comp_oocstr_bcstr(str1,str2) moo_comp_ucstr_bcstr(str1,str2) +# define moo_comp_oochars_bcstr(str1,len1,str2) moo_comp_uchars_bcstr(str1,len1,str2) +# define moo_comp_oochars_ucstr(str1,len1,str2) moo_comp_uchars_ucstr(str1,len1,str2) +# define moo_comp_oochars_oocstr(str1,len1,str2) moo_comp_uchars_ucstr(str1,len1,str2) +# define moo_comp_oocstr(str1,str2) moo_comp_ucstr(str1,str2) +# define moo_copy_oochars(dst,src,len) moo_copy_uchars(dst,src,len) +# define moo_copy_bchars_to_oochars(dst,src,len) moo_copy_bchars_to_uchars(dst,src,len) +# define moo_copy_oocstr(dst,len,src) moo_copy_ucstr(dst,len,src) +# define moo_find_oochar(ptr,len,c) moo_find_uchar(ptr,len,c) +# define moo_rfind_oochar(ptr,len,c) moo_rfind_uchar(ptr,len,c) +# define moo_find_oochar_in_oocstr(ptr,c) moo_find_uchar_in_ucstr(ptr,c) +# define moo_count_oocstr(str) moo_count_ucstr(str) #else -# define moo_equaloochars(str1,str2,len) moo_equalbchars(str1,str2,len) -# define moo_compoochars(str1,len1,str2,len2) moo_compbchars(str1,len1,str2,len2) -# define moo_compoocbcstr(str1,str2) moo_compbcstr(str1,str2) -# define moo_compoocharsbcstr(str1,len1,str2) moo_compbcharsbcstr(str1,len1,str2) -# define moo_compoocharsucstr(str1,len1,str2) moo_compbcharsucstr(str1,len1,str2) -# define moo_compoocharsoocstr(str1,len1,str2) moo_compbcharsbcstr(str1,len1,str2) -# define moo_compoocstr(str1,str2) moo_compbcstr(str1,str2) -# define moo_copyoochars(dst,src,len) moo_copybchars(dst,src,len) -# define moo_copybctooochars(dst,src,len) moo_copybchars(dst,src,len) -# define moo_copyoocstr(dst,len,src) moo_copybcstr(dst,len,src) -# define moo_findoochar(ptr,len,c) moo_findbchar(ptr,len,c) -# define moo_rfindoochar(ptr,len,c) moo_rfindbchar(ptr,len,c) -# define moo_findoocharinoocstr(ptr,c) moo_findbcharinbcstr(ptr,c) -# define moo_countoocstr(str) moo_countbcstr(str) +# define moo_equal_oochars(str1,str2,len) moo_equal_bchars(str1,str2,len) +# define moo_comp_oochars(str1,len1,str2,len2) moo_comp_bchars(str1,len1,str2,len2) +# define moo_comp_oocstr_bcstr(str1,str2) moo_comp_bcstr(str1,str2) +# define moo_comp_oochars_bcstr(str1,len1,str2) moo_comp_bchars_bcstr(str1,len1,str2) +# define moo_comp_oochars_ucstr(str1,len1,str2) moo_comp_bchars_ucstr(str1,len1,str2) +# define moo_comp_oochars_oocstr(str1,len1,str2) moo_comp_bchars_bcstr(str1,len1,str2) +# define moo_comp_oocstr(str1,str2) moo_comp_bcstr(str1,str2) +# define moo_copy_oochars(dst,src,len) moo_copy_bchars(dst,src,len) +# define moo_copy_bchars_to_oochars(dst,src,len) moo_copy_bchars(dst,src,len) +# define moo_copy_oocstr(dst,len,src) moo_copy_bcstr(dst,len,src) +# define moo_find_oochar(ptr,len,c) moo_find_bchar(ptr,len,c) +# define moo_rfind_oochar(ptr,len,c) moo_rfind_bchar(ptr,len,c) +# define moo_find_oochar_in_oocstr(ptr,c) moo_find_bchar_in_bcstr(ptr,c) +# define moo_count_oocstr(str) moo_count_bcstr(str) #endif @@ -347,10 +347,10 @@ MOO_EXPORT int moo_concatoocstrtosbuf ( #if defined(MOO_OOCH_IS_UCH) # define moo_conv_oocs_to_bcs_with_cmgr(oocs,oocslen,bcs,bcslen,cmgr) moo_conv_ucs_to_bcs_with_cmgr(oocs,oocslen,bcs,bcslen,cmgr) -# define moo_conv_oocsn_to_bcsn_with_cmgr(oocs,oocslen,bcs,bcslen,cmgr) moo_conv_ucsn_to_bcsn_with_cmgr(oocs,oocslen,bcs,bcslen,cmgr) +# define moo_conv_oochars_to_bchars_with_cmgr(oocs,oocslen,bcs,bcslen,cmgr) moo_conv_uchars_to_bchars_with_cmgr(oocs,oocslen,bcs,bcslen,cmgr) #else # define moo_conv_oocs_to_ucs_with_cmgr(oocs,oocslen,ucs,ucslen,cmgr) moo_conv_bcs_to_ucs_with_cmgr(oocs,oocslen,ucs,ucslen,cmgr,0) -# define moo_conv_oocsn_to_ucsn_with_cmgr(oocs,oocslen,ucs,ucslen,cmgr) moo_conv_bcsn_to_ucsn_with_cmgr(oocs,oocslen,ucs,ucslen,cmgr,0) +# define moo_conv_oochars_to_uchars_with_cmgr(oocs,oocslen,ucs,ucslen,cmgr) moo_conv_bchars_to_uchars_with_cmgr(oocs,oocslen,ucs,ucslen,cmgr,0) #endif @@ -363,7 +363,7 @@ MOO_EXPORT int moo_conv_bcs_to_ucs_with_cmgr ( int all ); -MOO_EXPORT int moo_conv_bcsn_to_ucsn_with_cmgr ( +MOO_EXPORT int moo_conv_bchars_to_uchars_with_cmgr ( const moo_bch_t* bcs, moo_oow_t* bcslen, moo_uch_t* ucs, @@ -380,7 +380,7 @@ MOO_EXPORT int moo_conv_ucs_to_bcs_with_cmgr ( moo_cmgr_t* cmgr ); -MOO_EXPORT int moo_conv_ucsn_to_bcsn_with_cmgr ( +MOO_EXPORT int moo_conv_uchars_to_bchars_with_cmgr ( const moo_uch_t* ucs, moo_oow_t* ucslen, moo_bch_t* bcs, diff --git a/moo/lib/moo.c b/moo/lib/moo.c index 2f37221..fda753e 100644 --- a/moo/lib/moo.c +++ b/moo/lib/moo.c @@ -505,7 +505,7 @@ moo_mod_data_t* moo_openmod (moo_t* moo, const moo_ooch_t* name, moo_oow_t namel /* copy instead of encoding conversion. MOD_PREFIX must not * include a character that requires encoding conversion. * note the terminating null isn't needed in buf here. */ - moo_copybctooochars (buf, MOD_PREFIX, MOD_PREFIX_LEN); + moo_copy_bchars_to_oochars (buf, MOD_PREFIX, MOD_PREFIX_LEN); if (namelen > MOO_COUNTOF(buf) - (MOD_PREFIX_LEN + 1 + 1)) { @@ -514,7 +514,7 @@ moo_mod_data_t* moo_openmod (moo_t* moo, const moo_ooch_t* name, moo_oow_t namel return MOO_NULL; } - moo_copyoochars (&buf[MOD_PREFIX_LEN], name, namelen); + moo_copy_oochars (&buf[MOD_PREFIX_LEN], name, namelen); buf[MOD_PREFIX_LEN + namelen] = '\0'; #if defined(MOO_ENABLE_STATIC_MODULE) @@ -523,7 +523,7 @@ moo_mod_data_t* moo_openmod (moo_t* moo, const moo_ooch_t* name, moo_oow_t namel /* TODO: binary search ... */ for (n = 0; n < MOO_COUNTOF(static_modtab); n++) { - if (moo_compoocharsbcstr(name, namelen, static_modtab[n].modname) == 0) + if (moo_comp_oochars_bcstr(name, namelen, static_modtab[n].modname) == 0) { load = static_modtab[n].modload; break; @@ -535,7 +535,7 @@ moo_mod_data_t* moo_openmod (moo_t* moo, const moo_ooch_t* name, moo_oow_t namel /* found the module in the staic module table */ MOO_MEMSET (&md, 0, MOO_SIZEOF(md)); - moo_copyoochars ((moo_ooch_t*)md.mod.name, name, namelen); + moo_copy_oochars ((moo_ooch_t*)md.mod.name, name, namelen); /* Note md.handle is MOO_NULL for a static module */ /* i copy-insert 'md' into the table before calling 'load'. @@ -579,7 +579,7 @@ moo_mod_data_t* moo_openmod (moo_t* moo, const moo_ooch_t* name, moo_oow_t namel /* attempt to find a dynamic external module */ MOO_MEMSET (&md, 0, MOO_SIZEOF(md)); - moo_copyoochars ((moo_ooch_t*)md.mod.name, name, namelen); + moo_copy_oochars ((moo_ooch_t*)md.mod.name, name, namelen); if (moo->vmprim.dl_open && moo->vmprim.dl_getsym && moo->vmprim.dl_close) { md.handle = moo->vmprim.dl_open(moo, &buf[MOD_PREFIX_LEN], MOO_VMPRIM_OPENDL_PFMOD); @@ -654,7 +654,7 @@ void moo_closemod (moo_t* moo, moo_mod_data_t* mdp) if (mdp->pair) { /*mdp->pair = MOO_NULL;*/ /* this reset isn't needed as the area will get freed by moo_rbt_delete()) */ - moo_rbt_delete (&moo->modtab, mdp->mod.name, moo_countoocstr(mdp->mod.name)); + moo_rbt_delete (&moo->modtab, mdp->mod.name, moo_count_oocstr(mdp->mod.name)); } } @@ -724,7 +724,7 @@ moo_pfbase_t* moo_querymod (moo_t* moo, const moo_ooch_t* pfid, moo_oow_t pfidle moo_oow_t mod_name_len; moo_pfbase_t* pfbase; - sep = moo_rfindoochar (pfid, pfidlen, '.'); + sep = moo_rfind_oochar (pfid, pfidlen, '.'); if (!sep) { /* i'm writing a conservative code here. the compiler should @@ -918,7 +918,7 @@ moo_pfbase_t* moo_findpfbase (moo_t* moo, moo_pfinfo_t* pfinfo, moo_oow_t pfcoun /*mid = (left + right) / 2;*/ mid = left + ((right - left) / 2); - n = moo_compoocharsoocstr (name, namelen, pfinfo[mid].mthname); + n = moo_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 moo_oow_t for the variable */ else if (n > 0) left = mid + 1; else return &pfinfo[mid].base; @@ -930,7 +930,7 @@ moo_pfbase_t* moo_findpfbase (moo_t* moo, moo_pfinfo_t* pfinfo, moo_oow_t pfcoun for (base = 0, lim = pfcount; lim > 0; lim >>= 1) { mid = base + (lim >> 1); - n = moo_compoocharsoocstr (name, namelen, pfinfo[mid].mthname); + n = moo_comp_oochars_oocstr (name, namelen, pfinfo[mid].mthname); if (n == 0) return &pfinfo[mid].base; if (n > 0) { base = mid + 1; lim--; } } @@ -1010,7 +1010,7 @@ moo_oop_t moo_findclass (moo_t* moo, moo_oop_nsdic_t nsdic, const moo_ooch_t* na moo_oocs_t n; n.ptr = (moo_ooch_t*)name; - n.len = moo_countoocstr(name); + n.len = moo_count_oocstr(name); ass = moo_lookupdic (moo, (moo_oop_dic_t)nsdic, &n); if (!ass || MOO_CLASSOF(moo,ass->value) != moo->_class) diff --git a/moo/lib/opt.c b/moo/lib/opt.c index f8497f4..4f203f5 100644 --- a/moo/lib/opt.c +++ b/moo/lib/opt.c @@ -51,8 +51,8 @@ static moo_bch_t EMSG_BCH[] = { '\0' }; #define xopt_t moo_uopt_t #define xopt_lng_t moo_uopt_lng_t #define xgetopt moo_getuopt -#define xcompcharscstr moo_compucharsucstr -#define xfindcharincstr moo_finducharinucstr +#define xcompcharscstr moo_comp_uchars_ucstr +#define xfindcharincstr moo_find_uchar_in_ucstr #define XCI_EOF MOO_BCI_EOF #include "opt-impl.h" @@ -74,8 +74,8 @@ static moo_bch_t EMSG_BCH[] = { '\0' }; #define xopt_t moo_bopt_t #define xopt_lng_t moo_bopt_lng_t #define xgetopt moo_getbopt -#define xcompcharscstr moo_compbcharsbcstr -#define xfindcharincstr moo_findbcharinbcstr +#define xcompcharscstr moo_comp_bchars_bcstr +#define xfindcharincstr moo_find_bchar_in_bcstr #define XCI_EOF MOO_UCI_EOF #include "opt-impl.h" diff --git a/moo/lib/sym.c b/moo/lib/sym.c index 52245b7..d869c8b 100644 --- a/moo/lib/sym.c +++ b/moo/lib/sym.c @@ -98,7 +98,7 @@ static moo_oop_t find_or_make_symbol (moo_t* moo, const moo_ooch_t* ptr, moo_oow MOO_ASSERT (moo, MOO_CLASSOF(moo,symbol) == moo->_symbol); if (len == MOO_OBJ_GET_SIZE(symbol) && - moo_equaloochars (ptr, symbol->slot, len)) + moo_equal_oochars (ptr, symbol->slot, len)) { return (moo_oop_t)symbol; } diff --git a/moo/lib/utl.c b/moo/lib/utl.c index 4a11811..42e2fe1 100644 --- a/moo/lib/utl.c +++ b/moo/lib/utl.c @@ -35,7 +35,7 @@ * utobcstr -> ucstr to bcstr */ -moo_oow_t moo_hashbytes (const moo_oob_t* ptr, moo_oow_t len) +moo_oow_t moo_hash_bytes (const moo_oob_t* ptr, moo_oow_t len) { moo_oow_t h = 0; const moo_uint8_t* bp, * be; @@ -48,7 +48,7 @@ moo_oow_t moo_hashbytes (const moo_oob_t* ptr, moo_oow_t len) return h % ((moo_oow_t)MOO_SMOOI_MAX + 1); } -int moo_equaluchars (const moo_uch_t* str1, const moo_uch_t* str2, moo_oow_t len) +int moo_equal_uchars (const moo_uch_t* str1, const moo_uch_t* str2, moo_oow_t len) { moo_oow_t i; @@ -63,7 +63,7 @@ int moo_equaluchars (const moo_uch_t* str1, const moo_uch_t* str2, moo_oow_t len return 1; } -int moo_equalbchars (const moo_bch_t* str1, const moo_bch_t* str2, moo_oow_t len) +int moo_equal_bchars (const moo_bch_t* str1, const moo_bch_t* str2, moo_oow_t len) { moo_oow_t i; @@ -78,7 +78,7 @@ int moo_equalbchars (const moo_bch_t* str1, const moo_bch_t* str2, moo_oow_t len return 1; } -int moo_compuchars (const moo_uch_t* str1, moo_oow_t len1, const moo_uch_t* str2, moo_oow_t len2) +int moo_comp_uchars (const moo_uch_t* str1, moo_oow_t len1, const moo_uch_t* str2, moo_oow_t len2) { moo_uchu_t c1, c2; const moo_uch_t* end1 = str1 + len1; @@ -100,7 +100,7 @@ int moo_compuchars (const moo_uch_t* str1, moo_oow_t len1, const moo_uch_t* str2 return (str2 < end2)? -1: 0; } -int moo_compbchars (const moo_bch_t* str1, moo_oow_t len1, const moo_bch_t* str2, moo_oow_t len2) +int moo_comp_bchars (const moo_bch_t* str1, moo_oow_t len1, const moo_bch_t* str2, moo_oow_t len2) { moo_bchu_t c1, c2; const moo_bch_t* end1 = str1 + len1; @@ -122,7 +122,7 @@ int moo_compbchars (const moo_bch_t* str1, moo_oow_t len1, const moo_bch_t* str2 return (str2 < end2)? -1: 0; } -int moo_compucstr (const moo_uch_t* str1, const moo_uch_t* str2) +int moo_comp_ucstr (const moo_uch_t* str1, const moo_uch_t* str2) { while (*str1 == *str2) { @@ -133,7 +133,7 @@ int moo_compucstr (const moo_uch_t* str1, const moo_uch_t* str2) return ((moo_uchu_t)*str1 > (moo_uchu_t)*str2)? 1: -1; } -int moo_compbcstr (const moo_bch_t* str1, const moo_bch_t* str2) +int moo_comp_bcstr (const moo_bch_t* str1, const moo_bch_t* str2) { while (*str1 == *str2) { @@ -144,7 +144,7 @@ int moo_compbcstr (const moo_bch_t* str1, const moo_bch_t* str2) return ((moo_bchu_t)*str1 > (moo_bchu_t)*str2)? 1: -1; } -int moo_compucbcstr (const moo_uch_t* str1, const moo_bch_t* str2) +int moo_comp_ucstr_bcstr (const moo_uch_t* str1, const moo_bch_t* str2) { while (*str1 == *str2) { @@ -155,7 +155,7 @@ int moo_compucbcstr (const moo_uch_t* str1, const moo_bch_t* str2) return ((moo_uchu_t)*str1 > (moo_bchu_t)*str2)? 1: -1; } -int moo_compucharsucstr (const moo_uch_t* str1, moo_oow_t len, const moo_uch_t* str2) +int moo_comp_uchars_ucstr (const moo_uch_t* str1, moo_oow_t len, const moo_uch_t* str2) { /* for "abc\0" of length 4 vs "abc", the fourth character * of the first string is equal to the terminating null of @@ -170,7 +170,7 @@ int moo_compucharsucstr (const moo_uch_t* str1, moo_oow_t len, const moo_uch_t* return (str1 < end)? 1: (*str2 == '\0'? 0: -1); } -int moo_compucharsbcstr (const moo_uch_t* str1, moo_oow_t len, const moo_bch_t* str2) +int moo_comp_uchars_bcstr (const moo_uch_t* str1, moo_oow_t len, const moo_bch_t* str2) { const moo_uch_t* end = str1 + len; while (str1 < end && *str2 != '\0') @@ -181,7 +181,7 @@ int moo_compucharsbcstr (const moo_uch_t* str1, moo_oow_t len, const moo_bch_t* return (str1 < end)? 1: (*str2 == '\0'? 0: -1); } -int moo_compbcharsbcstr (const moo_bch_t* str1, moo_oow_t len, const moo_bch_t* str2) +int moo_comp_bchars_bcstr (const moo_bch_t* str1, moo_oow_t len, const moo_bch_t* str2) { const moo_bch_t* end = str1 + len; while (str1 < end && *str2 != '\0') @@ -192,7 +192,7 @@ int moo_compbcharsbcstr (const moo_bch_t* str1, moo_oow_t len, const moo_bch_t* return (str1 < end)? 1: (*str2 == '\0'? 0: -1); } -int moo_compbcharsucstr (const moo_bch_t* str1, moo_oow_t len, const moo_uch_t* str2) +int moo_comp_bchars_ucstr (const moo_bch_t* str1, moo_oow_t len, const moo_uch_t* str2) { const moo_bch_t* end = str1 + len; while (str1 < end && *str2 != '\0') @@ -203,21 +203,21 @@ int moo_compbcharsucstr (const moo_bch_t* str1, moo_oow_t len, const moo_uch_t* return (str1 < end)? 1: (*str2 == '\0'? 0: -1); } -void moo_copyuchars (moo_uch_t* dst, const moo_uch_t* src, moo_oow_t len) +void moo_copy_uchars (moo_uch_t* dst, const moo_uch_t* src, moo_oow_t len) { /* take note of no forced null termination */ moo_oow_t i; for (i = 0; i < len; i++) dst[i] = src[i]; } -void moo_copybchars (moo_bch_t* dst, const moo_bch_t* src, moo_oow_t len) +void moo_copy_bchars (moo_bch_t* dst, const moo_bch_t* src, moo_oow_t len) { /* take note of no forced null termination */ moo_oow_t i; for (i = 0; i < len; i++) dst[i] = src[i]; } -void moo_copybtouchars (moo_uch_t* dst, const moo_bch_t* src, moo_oow_t len) +void moo_copy_bchars_to_uchars (moo_uch_t* dst, const moo_bch_t* src, moo_oow_t len) { /* copy without conversions. * use moo_bctouchars() for conversion encoding */ @@ -225,7 +225,7 @@ void moo_copybtouchars (moo_uch_t* dst, const moo_bch_t* src, moo_oow_t len) for (i = 0; i < len; i++) dst[i] = src[i]; } -moo_oow_t moo_copyucstr (moo_uch_t* dst, moo_oow_t len, const moo_uch_t* src) +moo_oow_t moo_copy_ucstr (moo_uch_t* dst, moo_oow_t len, const moo_uch_t* src) { moo_uch_t* p, * p2; @@ -241,7 +241,7 @@ moo_oow_t moo_copyucstr (moo_uch_t* dst, moo_oow_t len, const moo_uch_t* src) return p - dst; } -moo_oow_t moo_copybcstr (moo_bch_t* dst, moo_oow_t len, const moo_bch_t* src) +moo_oow_t moo_copy_bcstr (moo_bch_t* dst, moo_oow_t len, const moo_bch_t* src) { moo_bch_t* p, * p2; @@ -257,21 +257,21 @@ moo_oow_t moo_copybcstr (moo_bch_t* dst, moo_oow_t len, const moo_bch_t* src) return p - dst; } -moo_oow_t moo_countucstr (const moo_uch_t* str) +moo_oow_t moo_count_ucstr (const moo_uch_t* str) { const moo_uch_t* ptr = str; while (*ptr != '\0') ptr++; return ptr - str; } -moo_oow_t moo_countbcstr (const moo_bch_t* str) +moo_oow_t moo_count_bcstr (const moo_bch_t* str) { const moo_bch_t* ptr = str; while (*ptr != '\0') ptr++; return ptr - str; } -moo_uch_t* moo_finduchar (const moo_uch_t* ptr, moo_oow_t len, moo_uch_t c) +moo_uch_t* moo_find_uchar (const moo_uch_t* ptr, moo_oow_t len, moo_uch_t c) { const moo_uch_t* end; @@ -285,7 +285,7 @@ moo_uch_t* moo_finduchar (const moo_uch_t* ptr, moo_oow_t len, moo_uch_t c) return MOO_NULL; } -moo_bch_t* moo_findbchar (const moo_bch_t* ptr, moo_oow_t len, moo_bch_t c) +moo_bch_t* moo_find_bchar (const moo_bch_t* ptr, moo_oow_t len, moo_bch_t c) { const moo_bch_t* end; @@ -299,7 +299,7 @@ moo_bch_t* moo_findbchar (const moo_bch_t* ptr, moo_oow_t len, moo_bch_t c) return MOO_NULL; } -moo_uch_t* moo_rfinduchar (const moo_uch_t* ptr, moo_oow_t len, moo_uch_t c) +moo_uch_t* moo_rfind_uchar (const moo_uch_t* ptr, moo_oow_t len, moo_uch_t c) { const moo_uch_t* cur; @@ -313,7 +313,7 @@ moo_uch_t* moo_rfinduchar (const moo_uch_t* ptr, moo_oow_t len, moo_uch_t c) return MOO_NULL; } -moo_bch_t* moo_rfindbchar (const moo_bch_t* ptr, moo_oow_t len, moo_bch_t c) +moo_bch_t* moo_rfind_bchar (const moo_bch_t* ptr, moo_oow_t len, moo_bch_t c) { const moo_bch_t* cur; @@ -327,7 +327,7 @@ moo_bch_t* moo_rfindbchar (const moo_bch_t* ptr, moo_oow_t len, moo_bch_t c) return MOO_NULL; } -moo_uch_t* moo_finducharinucstr (const moo_uch_t* ptr, moo_uch_t c) +moo_uch_t* moo_find_uchar_in_ucstr (const moo_uch_t* ptr, moo_uch_t c) { while (*ptr != '\0') { @@ -338,7 +338,7 @@ moo_uch_t* moo_finducharinucstr (const moo_uch_t* ptr, moo_uch_t c) return MOO_NULL; } -moo_bch_t* moo_findbcharinbcstr (const moo_bch_t* ptr, moo_bch_t c) +moo_bch_t* moo_find_bchar_in_bcstr (const moo_bch_t* ptr, moo_bch_t c) { while (*ptr != '\0') { @@ -357,7 +357,7 @@ int moo_concatoocstrtosbuf (moo_t* moo, const moo_ooch_t* str, int id) moo_oow_t len; p = &moo->sbuf[id]; - len = moo_countoocstr (str); + len = moo_count_oocstr (str); if (len > p->capa - p->len) { @@ -374,7 +374,7 @@ int moo_concatoocstrtosbuf (moo_t* moo, const moo_ooch_t* str, int id) p->capa = newcapa; } - moo_copyoochars (&p->ptr[p->len], str, len); + moo_copy_oochars (&p->ptr[p->len], str, len); p->len += len; p->ptr[p->len] = '\0'; @@ -389,7 +389,7 @@ int moo_copyoocstrtosbuf (moo_t* moo, const moo_ooch_t* str, int id) /* ----------------------------------------------------------------------- */ -MOO_INLINE int moo_conv_bcsn_to_ucsn_with_cmgr ( +MOO_INLINE int moo_conv_bchars_to_uchars_with_cmgr ( const moo_bch_t* bcs, moo_oow_t* bcslen, moo_uch_t* ucs, moo_oow_t* ucslen, moo_cmgr_t* cmgr, int all) { @@ -521,7 +521,7 @@ MOO_INLINE int moo_conv_bcs_to_ucs_with_cmgr ( for (bp = bcs; *bp != '\0'; bp++) /* nothing */ ; mlen = bp - bcs; wlen = *ucslen; - n = moo_conv_bcsn_to_ucsn_with_cmgr (bcs, &mlen, ucs, &wlen, cmgr, all); + n = moo_conv_bchars_to_uchars_with_cmgr (bcs, &mlen, ucs, &wlen, cmgr, all); if (ucs) { /* null-terminate the target buffer if it has room for it. */ @@ -533,7 +533,7 @@ MOO_INLINE int moo_conv_bcs_to_ucs_with_cmgr ( return n; } -MOO_INLINE int moo_conv_ucsn_to_bcsn_with_cmgr ( +MOO_INLINE int moo_conv_uchars_to_bchars_with_cmgr ( const moo_uch_t* ucs, moo_oow_t* ucslen, moo_bch_t* bcs, moo_oow_t* bcslen, moo_cmgr_t* cmgr) { @@ -699,13 +699,13 @@ moo_cmgr_t* moo_get_utf8_cmgr (void) int moo_conv_utf8_to_uchars (const moo_bch_t* bcs, moo_oow_t* bcslen, moo_uch_t* ucs, moo_oow_t* ucslen) { /* the source is length bound */ - return moo_conv_bcsn_to_ucsn_with_cmgr(bcs, bcslen, ucs, ucslen, &utf8_cmgr, 0); + return moo_conv_bchars_to_uchars_with_cmgr(bcs, bcslen, ucs, ucslen, &utf8_cmgr, 0); } int moo_conv_uchars_to_utf8 (const moo_uch_t* ucs, moo_oow_t* ucslen, moo_bch_t* bcs, moo_oow_t* bcslen) { /* length bound */ - return moo_conv_ucsn_to_bcsn_with_cmgr(ucs, ucslen, bcs, bcslen, &utf8_cmgr); + return moo_conv_uchars_to_bchars_with_cmgr(ucs, ucslen, bcs, bcslen, &utf8_cmgr); } int moo_conv_utf8_to_ucstr (const moo_bch_t* bcs, moo_oow_t* bcslen, moo_uch_t* ucs, moo_oow_t* ucslen) @@ -727,7 +727,7 @@ int moo_convbtouchars (moo_t* moo, const moo_bch_t* bcs, moo_oow_t* bcslen, moo_ /* length bound */ int n; - n = moo_conv_bcsn_to_ucsn_with_cmgr(bcs, bcslen, ucs, ucslen, moo->cmgr, 0); + n = moo_conv_bchars_to_uchars_with_cmgr(bcs, bcslen, ucs, ucslen, moo->cmgr, 0); if (n <= -1) { @@ -743,7 +743,7 @@ int moo_convutobchars (moo_t* moo, const moo_uch_t* ucs, moo_oow_t* ucslen, moo_ /* length bound */ int n; - n = moo_conv_ucsn_to_bcsn_with_cmgr(ucs, ucslen, bcs, bcslen, moo->cmgr); + n = moo_conv_uchars_to_bchars_with_cmgr(ucs, ucslen, bcs, bcslen, moo->cmgr); if (n <= -1) { @@ -910,7 +910,7 @@ moo_uch_t* moo_dupuchars (moo_t* moo, const moo_uch_t* ucs, moo_oow_t ucslen) ptr = (moo_uch_t*)moo_allocmem(moo, (ucslen + 1) * MOO_SIZEOF(moo_uch_t)); if (!ptr) return MOO_NULL; - moo_copyuchars (ptr, ucs, ucslen); + moo_copy_uchars (ptr, ucs, ucslen); ptr[ucslen] = '\0'; return ptr; } @@ -922,7 +922,7 @@ moo_bch_t* moo_dupbchars (moo_t* moo, const moo_bch_t* bcs, moo_oow_t bcslen) ptr = (moo_bch_t*)moo_allocmem(moo, (bcslen + 1) * MOO_SIZEOF(moo_bch_t)); if (!ptr) return MOO_NULL; - moo_copybchars (ptr, bcs, bcslen); + moo_copy_bchars (ptr, bcs, bcslen); ptr[bcslen] = '\0'; return ptr; }