UTF8: Moved variable into lower scope

This commit is contained in:
Paul Beckingham 2015-04-04 09:55:54 -04:00
parent 5b01abc27f
commit 21dc2ec100

View file

@ -188,21 +188,18 @@ unsigned int utf8_length (const std::string& str)
unsigned int utf8_width (const std::string& str)
{
unsigned int length = 0;
int l;
std::string::size_type i = 0;
unsigned int c;
while ((c = utf8_next_char (str, i)))
{
l = mk_wcwidth (c);
// Control characters, and more especially newline characters, make
// mk_wcwidth() return -1. Ignore that, thereby "adding zero" to length.
// Since control characters are not displayed in reports, this is a valid
// choice.
int l = mk_wcwidth (c);
if (l != -1)
{
length += l;
}
}
return length;
}