From 409aa7befe3abfc8697bb5f1bb87aa03fd38257a Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Fri, 3 May 2019 00:43:28 +0000 Subject: [PATCH] enabled the errenous/incomplete utf16 option in main.c --- moo/lib/fmtout.c | 3 ++- moo/lib/main.c | 6 ------ moo/lib/std.c | 7 +++---- moo/lib/utl.c | 34 +++++----------------------------- moo/mod/stdio.c | 4 ++-- 5 files changed, 12 insertions(+), 42 deletions(-) diff --git a/moo/lib/fmtout.c b/moo/lib/fmtout.c index 554d16d..2d40390 100644 --- a/moo/lib/fmtout.c +++ b/moo/lib/fmtout.c @@ -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 */ } diff --git a/moo/lib/main.c b/moo/lib/main.c index ae8a126..ee78f8e 100644 --- a/moo/lib/main.c +++ b/moo/lib/main.c @@ -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) { diff --git a/moo/lib/std.c b/moo/lib/std.c index 22e67fa..013fdcc 100644 --- a/moo/lib/std.c +++ b/moo/lib/std.c @@ -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); diff --git a/moo/lib/utl.c b/moo/lib/utl.c index 67470aa..e434605 100644 --- a/moo/lib/utl.c +++ b/moo/lib/utl.c @@ -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); - } - + /* -1: illegal character, -2: buffer too small, -3: incomplete sequence */ + 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; } diff --git a/moo/mod/stdio.c b/moo/mod/stdio.c index 257c7d3..6953aa1 100644 --- a/moo/mod/stdio.c +++ b/moo/mod/stdio.c @@ -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) {