]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: fix WRAPNL on strings without \n
authorKarel Zak <kzak@redhat.com>
Mon, 12 Sep 2016 14:12:22 +0000 (16:12 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 12 Sep 2016 14:12:22 +0000 (16:12 +0200)
Addresses: https://github.com/karelzak/util-linux/issues/343
Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/src/table_print.c

index 7355fe8e1fa06f84d469140d43c1299fc8ab2850..7d5fe0ffa730a49d81e06cfee11d90db2d4cef17 100644 (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;;
        }