enabled the errenous/incomplete utf16 option in main.c

This commit is contained in:
hyunghwan.chung 2019-05-03 00:43:28 +00:00
parent 582c8203ff
commit 409aa7befe
5 changed files with 12 additions and 42 deletions

View File

@ -209,6 +209,7 @@ static int put_ooch (moo_t* moo, moo_bitmask_t mask, moo_ooch_t ch, moo_oow_t le
/* no line ending - append a line terminator */ /* no line ending - append a line terminator */
moo->log.ptr[moo->log.len++] = '\n'; moo->log.ptr[moo->log.len++] = '\n';
} }
vmprim_log_write (moo, moo->log.last_mask, moo->log.ptr, moo->log.len); vmprim_log_write (moo, moo->log.last_mask, moo->log.ptr, moo->log.len);
moo->log.len = 0; moo->log.len = 0;
} }
@ -253,6 +254,7 @@ redo:
/* no line ending - append a line terminator */ /* no line ending - append a line terminator */
moo->log.ptr[moo->log.len++] = '\n'; moo->log.ptr[moo->log.len++] = '\n';
} }
vmprim_log_write (moo, moo->log.last_mask, moo->log.ptr, moo->log.len); vmprim_log_write (moo, moo->log.last_mask, moo->log.ptr, moo->log.len);
moo->log.len = 0; moo->log.len = 0;
} }
@ -284,7 +286,6 @@ redo:
goto redo; goto redo;
} }
return 1; /* success */ return 1; /* success */
} }

View File

@ -90,10 +90,8 @@ int main (int argc, char* argv[])
{ ":log", 'l' }, { ":log", 'l' },
{ ":memsize", 'm' }, { ":memsize", 'm' },
{ "large-pages", '\0' }, { "large-pages", '\0' },
#if defined(_WIN32)
{ "utf8", '\0' }, { "utf8", '\0' },
{ "utf16", '\0' }, { "utf16", '\0' },
#endif
#if defined(MOO_BUILD_DEBUG) #if defined(MOO_BUILD_DEBUG)
{ ":debug", '\0' }, /* NOTE: there is no short option for --debug */ { ":debug", '\0' }, /* NOTE: there is no short option for --debug */
#endif #endif
@ -115,10 +113,8 @@ int main (int argc, char* argv[])
fprintf (stderr, " --log filename[,logopts]\n"); fprintf (stderr, " --log filename[,logopts]\n");
fprintf (stderr, " --memsize number\n"); fprintf (stderr, " --memsize number\n");
fprintf (stderr, " --large-pages\n"); fprintf (stderr, " --large-pages\n");
#if defined(_WIN32)
fprintf (stderr, " --utf16\n"); fprintf (stderr, " --utf16\n");
fprintf (stderr, " --utf8\n"); fprintf (stderr, " --utf8\n");
#endif
#if defined(MOO_BUILD_DEBUG) #if defined(MOO_BUILD_DEBUG)
fprintf (stderr, " --debug dbgopts\n"); fprintf (stderr, " --debug dbgopts\n");
#endif #endif
@ -150,7 +146,6 @@ int main (int argc, char* argv[])
cfg.large_pages = 1; cfg.large_pages = 1;
break; break;
} }
#if defined(_WIN32)
else if (moo_comp_bcstr(opt.lngopt, "utf8") == 0) else if (moo_comp_bcstr(opt.lngopt, "utf8") == 0)
{ {
cfg.cmgr = moo_get_utf8_cmgr(); cfg.cmgr = moo_get_utf8_cmgr();
@ -161,7 +156,6 @@ int main (int argc, char* argv[])
cfg.cmgr = moo_get_utf16_cmgr(); cfg.cmgr = moo_get_utf16_cmgr();
break; break;
} }
#endif
#if defined(MOO_BUILD_DEBUG) #if defined(MOO_BUILD_DEBUG)
else if (moo_comp_bcstr(opt.lngopt, "debug") == 0) else if (moo_comp_bcstr(opt.lngopt, "debug") == 0)
{ {

View File

@ -3593,8 +3593,7 @@ static void fini_moo (moo_t* moo)
vmprim.vm_muxwait = vm_muxwait; vmprim.vm_muxwait = vm_muxwait;
vmprim.vm_sleep = vm_sleep; vmprim.vm_sleep = vm_sleep;
moo = moo_open(&sys_mmgr, MOO_SIZEOF(xtn_t) + xtnsize, moo = moo_open(&sys_mmgr, MOO_SIZEOF(xtn_t) + xtnsize, (cfg->cmgr? cfg->cmgr: moo_get_utf8_cmgr()), &vmprim, errinfo);
(cfg->cmgr? cfg->cmgr: moo_get_utf8_cmgr()), &vmprim, errinfo);
if (!moo) return MOO_NULL; if (!moo) return MOO_NULL;
xtn = GET_XTN(moo); xtn = GET_XTN(moo);

View File

@ -812,15 +812,9 @@ int moo_convbtouchars (moo_t* moo, const moo_bch_t* bcs, moo_oow_t* bcslen, moo_
{ {
/* length bound */ /* length bound */
int n; int n;
n = moo_conv_bchars_to_uchars_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)
{
/* -1: illegal character, -2: buffer too small, -3: incomplete sequence */ /* -1: illegal character, -2: buffer too small, -3: incomplete sequence */
moo_seterrnum (moo, (n == -2)? MOO_EBUFFULL: MOO_EECERR); if (n <= -1) moo_seterrnum (moo, (n == -2)? MOO_EBUFFULL: MOO_EECERR);
}
return n; return n;
} }
@ -828,14 +822,8 @@ int moo_convutobchars (moo_t* moo, const moo_uch_t* ucs, moo_oow_t* ucslen, moo_
{ {
/* length bound */ /* length bound */
int n; int n;
n = moo_conv_uchars_to_bchars_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) moo_seterrnum (moo, (n == -2)? MOO_EBUFFULL: MOO_EECERR);
if (n <= -1)
{
moo_seterrnum (moo, (n == -2)? MOO_EBUFFULL: MOO_EECERR);
}
return n; return n;
} }
@ -843,14 +831,8 @@ int moo_convbtoucstr (moo_t* moo, const moo_bch_t* bcs, moo_oow_t* bcslen, moo_u
{ {
/* null-terminated. */ /* null-terminated. */
int n; int n;
n = moo_conv_bcstr_to_ucstr_with_cmgr(bcs, bcslen, ucs, ucslen, moo->cmgr, 0); n = moo_conv_bcstr_to_ucstr_with_cmgr(bcs, bcslen, ucs, ucslen, moo->cmgr, 0);
if (n <= -1) moo_seterrnum (moo, (n == -2)? MOO_EBUFFULL: MOO_EECERR);
if (n <= -1)
{
moo_seterrnum (moo, (n == -2)? MOO_EBUFFULL: MOO_EECERR);
}
return n; return n;
} }
@ -858,14 +840,8 @@ int moo_convutobcstr (moo_t* moo, const moo_uch_t* ucs, moo_oow_t* ucslen, moo_b
{ {
/* null-terminated */ /* null-terminated */
int n; int n;
n = moo_conv_ucstr_to_bcstr_with_cmgr(ucs, ucslen, bcs, bcslen, moo->cmgr); n = moo_conv_ucstr_to_bcstr_with_cmgr(ucs, ucslen, bcs, bcslen, moo->cmgr);
if (n <= -1) moo_seterrnum (moo, (n == -2)? MOO_EBUFFULL: MOO_EECERR);
if (n <= -1)
{
moo_seterrnum (moo, (n == -2)? MOO_EBUFFULL: MOO_EECERR);
}
return n; return n;
} }