diff --git a/hawk/lib/mod-hawk.c b/hawk/lib/mod-hawk.c index 4d9a7179..e7e0da84 100644 --- a/hawk/lib/mod-hawk.c +++ b/hawk/lib/mod-hawk.c @@ -214,7 +214,7 @@ static int fnc_function_exists (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi) /* hawk_query_module_with_name() may update some shared data under * the hawk object. use a mutex for shared data safety */ hawk_mtx_lock (&md->mq_mtx, HAWK_NULL); - rx = (hawk_querymodulewithname(hawk_rtx_gethawk(rtx), &name, &sym) != HAWK_NULL); + rx = (hawk_querymodulewithname(hawk_rtx_gethawk(rtx), name.ptr, &sym) != HAWK_NULL); hawk_mtx_unlock (&md->mq_mtx); } } diff --git a/hawk/lib/parse-prv.h b/hawk/lib/parse-prv.h index 8a69c868..44e27c18 100644 --- a/hawk/lib/parse-prv.h +++ b/hawk/lib/parse-prv.h @@ -118,9 +118,9 @@ void hawk_clearsionames ( hawk_mod_t* hawk_querymodulewithname ( - hawk_t* hawk, - const hawk_oocs_t* name, - hawk_mod_sym_t* sym + hawk_t* hawk, + hawk_ooch_t* name, /* this must be a mutable null-terminated string */ + hawk_mod_sym_t* sym ); #if defined(__cplusplus) diff --git a/hawk/lib/parse.c b/hawk/lib/parse.c index b29ab07c..2da06811 100644 --- a/hawk/lib/parse.c +++ b/hawk/lib/parse.c @@ -7555,43 +7555,34 @@ done: } -hawk_mod_t* hawk_querymodulewithname (hawk_t* hawk, const hawk_oocs_t* name, hawk_mod_sym_t* sym) +hawk_mod_t* hawk_querymodulewithname (hawk_t* hawk, hawk_ooch_t* name, hawk_mod_sym_t* sym) { const hawk_ooch_t* dc; hawk_oocs_t segs[2]; hawk_mod_t* mod; + hawk_oow_t name_len; hawk_ooch_t tmp; /*TOOD: non-module builtin function? fnc? */ - dc = hawk_find_oochars_in_oochars(name->ptr, name->len, HAWK_T("::"), 2, 0); + name_len = hawk_count_oocstr(name); + dc = hawk_find_oochars_in_oochars(name, name_len, HAWK_T("::"), 2, 0); if (!dc) { hawk_seterrfmt (hawk, HAWK_NULL, HAWK_EINVAL, HAWK_T("invalid module name - %js"), name); return HAWK_NULL; } -#if 1 - segs[0].len = dc - name->ptr; - segs[0].ptr = hawk_dupoochars(hawk, name->ptr, segs[0].len); - if (!segs[0].ptr) return HAWK_NULL; -#else - segs[0].len = dc - name->ptr; - segs[0].ptr = name->ptr; - tmp = name->ptr[segs[0].len]; - name->ptr[segs[0].len] = '\0'; -#endif + segs[0].len = dc - name; + segs[0].ptr = name; + tmp = name[segs[0].len]; + name[segs[0].len] = '\0'; - segs[1].len = name->len - segs[0].len - 2; - segs[1].ptr = name->ptr + segs[0].len + 2; + segs[1].len = name_len - segs[0].len - 2; + segs[1].ptr = (hawk_ooch_t*)name + segs[0].len + 2; mod = query_module(hawk, segs, 2, sym); -#if 1 - hawk_freemem (hawk, segs[0].ptr); -#else - name->ptr[segs[0].len] = tmp; -#endif - + name[segs[0].len] = tmp; return mod; } diff --git a/hawk/lib/val.c b/hawk/lib/val.c index 917be65e..dd467115 100644 --- a/hawk/lib/val.c +++ b/hawk/lib/val.c @@ -2863,7 +2863,7 @@ hawk_fnc_t* hawk_rtx_valtofnc (hawk_rtx_t* rtx, hawk_val_t* v, hawk_fnc_t* rfnc) hawk_mod_t* mod; hawk_mod_sym_t sym; - mod = hawk_querymodulewithname(hawk, &x, &sym); + mod = hawk_querymodulewithname(hawk, x.ptr, &sym); hawk_rtx_freevaloocstr (rtx, v, x.ptr); if (!mod) return HAWK_NULL;