From d7246b729ea786107b7d845cdb18d10ad00a16e2 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Sun, 2 Jun 2019 15:58:31 +0000 Subject: [PATCH] diverted w/W to k/K in format_stack_args() in the non-unicode mode --- moo/lib/fmt.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/moo/lib/fmt.c b/moo/lib/fmt.c index d641237..c5651ff 100644 --- a/moo/lib/fmt.c +++ b/moo/lib/fmt.c @@ -2345,6 +2345,10 @@ static MOO_INLINE int format_stack_args (moo_fmtout_t* fmtout, moo_ooi_t nargs, break; } + #if !defined(MOO_OOCH_IS_UCH) + case 'w': /* the string object is not in the unicode encoding */ + case 'W': /* treat w/W like k/K */ + #endif case 'k': case 'K': { @@ -2397,7 +2401,13 @@ static MOO_INLINE int format_stack_args (moo_fmtout_t* fmtout, moo_ooi_t nargs, else { moo_bch_t xbuf[3]; - moo_byte_to_bcstr (*bsp, xbuf, MOO_COUNTOF(xbuf), (16 | (ch == 'k'? MOO_BYTE_TO_BCSTR_LOWERCASE: 0)), '0'); + int flagged_radix = 16; + #if defined(HCL_OOCH_IS_UCH) + if (ch == 'k') flagged_radix |= MOO_BYTE_TO_BCSTR_LOWERCASE; + #else + if (ch == 'k' || ch == 'w') flagged_radix |= MOO_BYTE_TO_BCSTR_LOWERCASE; + #endif + moo_byte_to_bcstr (*bsp, xbuf, MOO_COUNTOF(xbuf), flagged_radix, '0'); if (lm_flag & (LF_H | LF_L)) PUT_BCS (fmtout, "\\x", 2); PUT_BCS (fmtout, xbuf, 2); } @@ -2413,6 +2423,7 @@ static MOO_INLINE int format_stack_args (moo_fmtout_t* fmtout, moo_ooi_t nargs, break; } + #if defined(MOO_OOCH_IS_UCH) case 'w': case 'W': { @@ -2479,6 +2490,7 @@ static MOO_INLINE int format_stack_args (moo_fmtout_t* fmtout, moo_ooi_t nargs, if ((flagc & FLAGC_LEFTADJ) && width > 0) PUT_OOCH (fmtout, padc, width); break; } + #endif case 'O': /* object - ignore precision, width, adjustment */ GET_NEXT_ARG_TO (moo, nargs, &arg_state, arg);