@@ -971,7 +971,7 @@ void formatargument(char type, void *rawarg, FormatterParams formatter, char *&o
971
971
// format width is longer than the string) or where to clip off a substring
972
972
// (if the precision is shorter than the string)
973
973
const char *si = s;
974
- while (*si)
974
+ while (*si && (formatter. Precision == FormatterParams::NoPrecision || precision > 0 ) )
975
975
{
976
976
if ((*si & 0x80 ) == 0 ) // ascii character
977
977
{
@@ -994,22 +994,18 @@ void formatargument(char type, void *rawarg, FormatterParams formatter, char *&o
994
994
}
995
995
996
996
len++; // one more codepoint
997
+ clipoffs = (si - s);
998
+
999
+ // if we've reached the desired precision we can stop counting
997
1000
if (len == precision && formatter.Precision != FormatterParams::NoPrecision)
998
- {
999
- // if we've reached the desired precision we can stop counting
1000
- clipoffs = (si - s);
1001
1001
break ;
1002
- }
1003
1002
}
1004
1003
1005
1004
if (formatter.Width != FormatterParams::NoWidth && len < width &&
1006
1005
!(formatter.Flags & LeftJustify))
1007
1006
addchars (output, actualsize, end, width - len, ' ' );
1008
1007
1009
- if (clipoffs > 0 )
1010
- appendstring (output, actualsize, end, s, clipoffs);
1011
- else
1012
- appendstring (output, actualsize, end, s);
1008
+ appendstring (output, actualsize, end, s, clipoffs);
1013
1009
1014
1010
if (formatter.Width != FormatterParams::NoWidth && len < width && (formatter.Flags & LeftJustify))
1015
1011
addchars (output, actualsize, end, width - len, ' ' );
0 commit comments