libsmartcols: fix WRAPNL on strings without \n

Addresses: https://github.com/karelzak/util-linux/issues/343
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2016-09-12 16:12:22 +02:00
parent 975ed32fd9
commit ef4a34bbb8
1 changed files with 6 additions and 4 deletions

View File

@ -993,14 +993,16 @@ static size_t count_wrapnl_size(const char *data)
while (data && *data) {
const char *p = data;
size_t sz;
p = strchr(data, '\n');
if (p) {
size_t sz = mbs_safe_nwidth(data, p - data, NULL);
sum = max(sum, sz);
sz = mbs_safe_nwidth(data, p - data, NULL);
p++;
}
} else
sz = mbs_safe_width(data);
sum = max(sum, sz);
data = p;;
}