Skip to content

Commit c8a1608

Browse files
committed
If the precision is 0 for strings, don't print anything
1 parent 56e1d6a commit c8a1608

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

renderdoc/serialise/utf8printf.cpp

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ void formatargument(char type, void *rawarg, FormatterParams formatter, char *&o
971971
// format width is longer than the string) or where to clip off a substring
972972
// (if the precision is shorter than the string)
973973
const char *si = s;
974-
while(*si)
974+
while(*si && (formatter.Precision == FormatterParams::NoPrecision || precision > 0))
975975
{
976976
if((*si & 0x80) == 0) // ascii character
977977
{
@@ -994,22 +994,18 @@ void formatargument(char type, void *rawarg, FormatterParams formatter, char *&o
994994
}
995995

996996
len++; // one more codepoint
997+
clipoffs = (si - s);
998+
999+
// if we've reached the desired precision we can stop counting
9971000
if(len == precision && formatter.Precision != FormatterParams::NoPrecision)
998-
{
999-
// if we've reached the desired precision we can stop counting
1000-
clipoffs = (si - s);
10011001
break;
1002-
}
10031002
}
10041003

10051004
if(formatter.Width != FormatterParams::NoWidth && len < width &&
10061005
!(formatter.Flags & LeftJustify))
10071006
addchars(output, actualsize, end, width - len, ' ');
10081007

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);
10131009

10141010
if(formatter.Width != FormatterParams::NoWidth && len < width && (formatter.Flags & LeftJustify))
10151011
addchars(output, actualsize, end, width - len, ' ');

0 commit comments

Comments
 (0)