fixed a bug of not honoring precision specified with %.* in computing string length given for 's' and 'S'

This commit is contained in:
hyunghwan.chung 2019-01-31 09:16:52 +00:00
parent 20eb34302a
commit 1ff172097c
2 changed files with 18 additions and 4 deletions

View File

@ -465,7 +465,14 @@ static int fmtoutv (moo_t* moo, const fmtchar_t* fmt, moo_fmtout_data_t* data, v
#if defined(MOO_OOCH_IS_UCH)
/* get the length */
for (bslen = 0; bsp[bslen]; bslen++);
if (flagc & FLAGC_DOT)
{
for (bslen = 0; bslen < precision && bsp[bslen]; bslen++);
}
else
{
for (bslen = 0; bsp[bslen]; bslen++);
}
if (moo_conv_bchars_to_uchars_with_cmgr(bsp, &bslen, MOO_NULL, &slen, moo->cmgr, 0) <= -1) goto oops;
@ -534,7 +541,14 @@ static int fmtoutv (moo_t* moo, const fmtchar_t* fmt, moo_fmtout_data_t* data, v
#if defined(MOO_OOCH_IS_BCH)
/* get the length */
for (uslen = 0; usp[uslen]; uslen++);
if (flagc & FLAGC_DOT)
{
for (uslen = 0; uslen < precision && usp[uslen]; uslen++);
}
else
{
for (uslen = 0; usp[uslen]; uslen++);
}
if (moo_conv_uchars_to_bchars_with_cmgr(usp, &uslen, MOO_NULL, &slen, moo->cmgr) <= -1) goto oops;

View File

@ -429,7 +429,7 @@ MOO_INLINE int moo_conv_bchars_to_uchars_with_cmgr (
break;
}
n = cmgr->bctouc (p, mlen, q);
n = cmgr->bctouc(p, mlen, q);
if (n == 0)
{
/* invalid sequence */
@ -485,7 +485,7 @@ MOO_INLINE int moo_conv_bchars_to_uchars_with_cmgr (
{
moo_oow_t n;
n = cmgr->bctouc (p, mlen, &w);
n = cmgr->bctouc(p, mlen, &w);
if (n == 0)
{
/* invalid sequence */