simple changes to fmtoutv.h

This commit is contained in:
hyunghwan.chung 2019-05-27 11:57:40 +00:00
parent 450f9a8b5c
commit ea9f9b81e1

View File

@ -165,19 +165,11 @@ static int fmtoutv (moo_t* moo, const fmtchar_t* fmt, moo_fmtout_data_t* data, v
bclen = fmt - checkpoint - 1; bclen = fmt - checkpoint - 1;
cmgr = moo->cmgr; cmgr = moo->cmgr;
cvlen = cmgr->bctouc(checkpoint, bclen, &ch); cvlen = cmgr->bctouc(checkpoint, bclen, &ch);
if (cvlen == 0 || cvlen > bclen) if (cvlen == 0 || cvlen > bclen)
{ {
/* conversion error. just emit the byte as it is. */ /* conversion error. just emit the byte as it is. */
#if defined(FMTOUT_STRICT) ch = *checkpoint;
goto oops; cvlen = 1;
#else
cmgr = moo_get_utf8_cmgr();
if (cmgr == moo->cmgr || (cvlen = cmgr->bctouc(checkpoint, bclen, &ch)) == 0 || cvlen > bclen)
{
cmgr = moo_get_mb8_cmgr();
if (cmgr == moo->cmgr || (cvlen = cmgr->bctouc(checkpoint, bclen, &ch)) == 0 || cvlen > bclen) goto oops;
}
#endif
} }
checkpoint += cvlen; checkpoint += cvlen;
PUT_OOCH (ch, 1); PUT_OOCH (ch, 1);
@ -506,21 +498,7 @@ static int fmtoutv (moo_t* moo, const fmtchar_t* fmt, moo_fmtout_data_t* data, v
/* get the required length for successful conversion in a fail-safe manner */ /* get the required length for successful conversion in a fail-safe manner */
cmgr = moo->cmgr; cmgr = moo->cmgr;
bslen = obslen; bslen = obslen;
if (moo_conv_bchars_to_uchars_with_cmgr(bsp, &bslen, MOO_NULL, &slen, cmgr, 0) <= -1) if (moo_conv_bchars_to_uchars_with_cmgr(bsp, &bslen, MOO_NULL, &slen, cmgr, 0) <= -1) goto oops;
{
#if defined(FMTOUT_STRICT)
goto oops;
#else
cmgr = moo_get_utf8_cmgr();
bslen = obslen;
if (cmgr == moo->cmgr || moo_conv_bchars_to_uchars_with_cmgr(bsp, &bslen, MOO_NULL, &slen, cmgr, 0) <= -1)
{
cmgr = moo_get_mb8_cmgr();
bslen = obslen;
if (cmgr == moo->cmgr || moo_conv_bchars_to_uchars_with_cmgr(bsp, &bslen, MOO_NULL, &slen, cmgr, 0) <= -1) goto oops;
}
#endif
}
/* slen holds the length after conversion */ /* slen holds the length after conversion */
n = slen; n = slen;
@ -1042,22 +1020,22 @@ static int fmtoutv (moo_t* moo, const fmtchar_t* fmt, moo_fmtout_data_t* data, v
} }
#if 0 #if 0
else if (lm_flag & LF_T) else if (lm_flag & LF_T)
num = va_arg (ap, moo_ptrdiff_t); num = va_arg(ap, moo_ptrdiff_t);
#endif #endif
else if (lm_flag & LF_Z) else if (lm_flag & LF_Z)
num = va_arg (ap, moo_oow_t); num = va_arg(ap, moo_oow_t);
#if (MOO_SIZEOF_LONG_LONG > 0) #if (MOO_SIZEOF_LONG_LONG > 0)
else if (lm_flag & LF_Q) else if (lm_flag & LF_Q)
num = va_arg (ap, unsigned long long int); num = va_arg(ap, unsigned long long int);
#endif #endif
else if (lm_flag & (LF_L | LF_LD)) else if (lm_flag & (LF_L | LF_LD))
num = va_arg (ap, unsigned long int); num = va_arg(ap, unsigned long int);
else if (lm_flag & LF_H) else if (lm_flag & LF_H)
num = (unsigned short int)va_arg (ap, int); num = (unsigned short int)va_arg(ap, int);
else if (lm_flag & LF_C) else if (lm_flag & LF_C)
num = (unsigned char)va_arg (ap, int); num = (unsigned char)va_arg(ap, int);
else else
num = va_arg (ap, unsigned int); num = va_arg(ap, unsigned int);
goto number; goto number;
handle_sign: handle_sign: