encoding experiment with cmgr

This commit is contained in:
hyunghwan.chung 2019-05-14 15:54:16 +00:00
parent 2b2ffb5521
commit 8e4b175579
2 changed files with 18 additions and 7 deletions

View File

@ -101,7 +101,13 @@ enum moo_option_t
MOO_OPTION_SYMTAB_SIZE, /* default system table size */ MOO_OPTION_SYMTAB_SIZE, /* default system table size */
MOO_OPTION_SYSDIC_SIZE, /* default system dictionary size */ MOO_OPTION_SYSDIC_SIZE, /* default system dictionary size */
MOO_OPTION_PROCSTK_SIZE, /* default process stack size */ MOO_OPTION_PROCSTK_SIZE, /* default process stack size */
MOO_OPTION_MOD_INCTX MOO_OPTION_MOD_INCTX,
/*
MOO_OPTION_CMGR_FS,
MOO_OPTION_CMGR_FILE_SYS
MOO_OPTION_CMGR_
*/
}; };
typedef enum moo_option_t moo_option_t; typedef enum moo_option_t moo_option_t;

View File

@ -442,7 +442,8 @@ static MOO_INLINE moo_ooi_t open_input (moo_t* moo, moo_ioarg_t* arg)
const moo_bch_t* fn, * fb; const moo_bch_t* fn, * fb;
#if defined(MOO_OOCH_IS_UCH) #if defined(MOO_OOCH_IS_UCH)
if (moo_convootobcstr(moo, arg->name, &ucslen, MOO_NULL, &bcslen) <= -1) goto oops; /*if (moo_convootobcstr(moo, arg->name, &ucslen, MOO_NULL, &bcslen) <= -1) goto oops;*/
if (moo_conv_uchars_to_bchars_with_cmgr(arg->name, &ucslen, MOO_NULL, &bcslen, moo_get_cmgr_by_id(MOO_CMGR_UTF8)) <= -1) goto oops;
#else #else
bcslen = moo_count_bcstr(arg->name); bcslen = moo_count_bcstr(arg->name);
#endif #endif
@ -458,7 +459,11 @@ static MOO_INLINE moo_ooi_t open_input (moo_t* moo, moo_ioarg_t* arg)
bb->fn = (moo_bch_t*)(bb + 1); bb->fn = (moo_bch_t*)(bb + 1);
moo_copy_bchars (bb->fn, fn, parlen); moo_copy_bchars (bb->fn, fn, parlen);
#if defined(MOO_OOCH_IS_UCH) #if defined(MOO_OOCH_IS_UCH)
moo_convootobcstr (moo, arg->name, &ucslen, &bb->fn[parlen], &bcslen); /* [NOTE] as i convert a unicode string for fopen() below, the conversion
* should use the system locale instead of moo's cmgr configuration.
* but let's not use the system locale for now. */
/*moo_convootobcstr (moo, arg->name, &ucslen, &bb->fn[parlen], &bcslen);*/
moo_conv_uchars_to_bchars_with_cmgr (arg->name, &ucslen, &bb->fn[parlen], &bcslen, moo_get_cmgr_by_id(MOO_CMGR_UTF8));
#else #else
moo_copy_bcstr (&bb->fn[parlen], bcslen + 1, arg->name); moo_copy_bcstr (&bb->fn[parlen], bcslen + 1, arg->name);
#endif #endif
@ -482,7 +487,7 @@ static MOO_INLINE moo_ooi_t open_input (moo_t* moo, moo_ioarg_t* arg)
bb->fn = (moo_bch_t*)(bb + 1); bb->fn = (moo_bch_t*)(bb + 1);
moo_copy_bcstr (bb->fn, bcslen + 1, xtn->in->u.fileb.path); moo_copy_bcstr (bb->fn, bcslen + 1, xtn->in->u.fileb.path);
break; break;
#if defined(MOO_OOCH_IS_UCH) #if defined(MOO_OOCH_IS_UCH)
@ -1467,7 +1472,7 @@ static void* dl_open (moo_t* moo, const moo_ooch_t* name, int flags)
bcslen = bufcapa - len; bcslen = bufcapa - len;
#if defined(MOO_OOCH_IS_UCH) #if defined(MOO_OOCH_IS_UCH)
moo_convootobcstr(moo, name, &ucslen, &bufptr[len], &bcslen); moo_convootobcstr (moo, name, &ucslen, &bufptr[len], &bcslen);
#else #else
bcslen = moo_copy_bcstr(&bufptr[len], bcslen, name); bcslen = moo_copy_bcstr(&bufptr[len], bcslen, name);
#endif #endif
@ -1534,12 +1539,12 @@ static void* dl_open (moo_t* moo, const moo_ooch_t* name, int flags)
/* opening a raw shared object without a prefix and/or a postfix */ /* opening a raw shared object without a prefix and/or a postfix */
#if defined(MOO_OOCH_IS_UCH) #if defined(MOO_OOCH_IS_UCH)
bcslen = bufcapa; bcslen = bufcapa;
moo_convootobcstr(moo, name, &ucslen, bufptr, &bcslen); moo_convootobcstr (moo, name, &ucslen, bufptr, &bcslen);
#else #else
bcslen = moo_copy_bcstr(bufptr, bufcapa, name); bcslen = moo_copy_bcstr(bufptr, bufcapa, name);
#endif #endif
if (moo_find_bchar (bufptr, bcslen, '.')) if (moo_find_bchar(bufptr, bcslen, '.'))
{ {
handle = sys_dl_open(bufptr); handle = sys_dl_open(bufptr);
if (!handle) if (!handle)