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 */
moo->log.ptr[moo->log.len++] = '\n';
}
vmprim_log_write (moo, moo->log.last_mask, moo->log.ptr, moo->log.len);
moo->log.len = 0;
}
@ -253,6 +254,7 @@ redo:
/* no line ending - append a line terminator */
moo->log.ptr[moo->log.len++] = '\n';
}
vmprim_log_write (moo, moo->log.last_mask, moo->log.ptr, moo->log.len);
moo->log.len = 0;
}
@ -284,7 +286,6 @@ redo:
goto redo;
}
return 1; /* success */
}

View File

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

View File

@ -555,7 +555,7 @@ static MOO_INLINE moo_ooi_t read_input (moo_t* moo, moo_ioarg_t* arg)
MOO_ASSERT (moo, bb != MOO_NULL && bb->fp != MOO_NULL);
do
{
x = fgetc (bb->fp);
x = fgetc(bb->fp);
if (x == EOF)
{
if (ferror((FILE*)bb->fp))
@ -573,7 +573,7 @@ static MOO_INLINE moo_ooi_t read_input (moo_t* moo, moo_ioarg_t* arg)
#if defined(MOO_OOCH_IS_UCH)
bcslen = bb->len;
ucslen = MOO_COUNTOF(arg->buf);
x = moo_convbtooochars (moo, bb->buf, &bcslen, arg->buf, &ucslen);
x = moo_convbtooochars(moo, bb->buf, &bcslen, arg->buf, &ucslen);
if (x <= -1 && ucslen <= 0) return -1;
/* if ucslen is greater than 0, i see that some characters have been
* converted properly */
@ -3593,8 +3593,7 @@ static void fini_moo (moo_t* moo)
vmprim.vm_muxwait = vm_muxwait;
vmprim.vm_sleep = vm_sleep;
moo = moo_open(&sys_mmgr, MOO_SIZEOF(xtn_t) + xtnsize,
(cfg->cmgr? cfg->cmgr: moo_get_utf8_cmgr()), &vmprim, errinfo);
moo = moo_open(&sys_mmgr, MOO_SIZEOF(xtn_t) + xtnsize, (cfg->cmgr? cfg->cmgr: moo_get_utf8_cmgr()), &vmprim, errinfo);
if (!moo) return MOO_NULL;
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 */
int n;
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 */
moo_seterrnum (moo, (n == -2)? MOO_EBUFFULL: MOO_EECERR);
}
if (n <= -1) moo_seterrnum (moo, (n == -2)? MOO_EBUFFULL: MOO_EECERR);
return n;
}
@ -828,14 +822,8 @@ int moo_convutobchars (moo_t* moo, const moo_uch_t* ucs, moo_oow_t* ucslen, moo_
{
/* length bound */
int n;
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;
}
@ -843,14 +831,8 @@ int moo_convbtoucstr (moo_t* moo, const moo_bch_t* bcs, moo_oow_t* bcslen, moo_u
{
/* null-terminated. */
int n;
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;
}
@ -858,14 +840,8 @@ int moo_convutobcstr (moo_t* moo, const moo_uch_t* ucs, moo_oow_t* ucslen, moo_b
{
/* null-terminated */
int n;
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;
}

View File

@ -69,9 +69,9 @@ static moo_pfrc_t pf_open (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
if (moo_convootobchars(moo, MOO_OBJ_GET_CHAR_SLOT(mode), &ucslen, modebuf, &bcslen) <= -1) goto softfail;
modebuf[bcslen] = '\0';
stdio->fp = fopen (namebuf, modebuf);
stdio->fp = fopen(namebuf, modebuf);
#else
stdio->fp = fopen (MOO_OBJ_GET_CHAR_SLOT(name), MOO_OBJ_GET_CHAR_SLOT(mode));
stdio->fp = fopen(MOO_OBJ_GET_CHAR_SLOT(name), MOO_OBJ_GET_CHAR_SLOT(mode));
#endif
if (!stdio->fp)
{