]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: keep scols_table_get_termwidth() read-only
authorKarel Zak <kzak@redhat.com>
Thu, 22 Sep 2016 11:47:23 +0000 (13:47 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 22 Sep 2016 11:47:23 +0000 (13:47 +0200)
Addresses: https://github.com/karelzak/util-linux/issues/356
Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/src/table.c

index 9aae75c9588fd6d28be4dba98e54545472f2d082..4040b43654dabb227298f6a7dfc1e6a59681f015 100644 (file)
@@ -68,6 +68,7 @@ struct libscols_table *scols_new_table(void)
 
        tb->refcount = 1;
        tb->out = stdout;
+       tb->termwidth = get_terminal_width(80);
 
        INIT_LIST_HEAD(&tb->tb_lines);
        INIT_LIST_HEAD(&tb->tb_columns);
@@ -1154,7 +1155,5 @@ int scols_table_set_termwidth(struct libscols_table *tb, size_t width)
  */
 size_t scols_table_get_termwidth(struct libscols_table *tb)
 {
-       if (tb->termwidth == 0)
-               tb->termwidth = get_terminal_width(80);
        return tb->termwidth;
 }