]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libsmartcols: remove unnecessary code
authorKarel Zak <kzak@redhat.com>
Wed, 19 Mar 2014 16:25:31 +0000 (17:25 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 3 Apr 2014 10:29:17 +0000 (12:29 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
libsmartcols/src/smartcolsP.h
libsmartcols/src/table.c
libsmartcols/src/table_print.c

index d7211438e67036d4d13ae1d2ef7e8b5044bc1301..20c262951e37f53e6c7b58d9598527f323e8d6b9 100644 (file)
@@ -107,7 +107,6 @@ struct libscols_table {
        size_t  termreduce;     /* extra blank space */
        int     is_term;        /* is a tty? */
        int     flags;
-       int     first_run;
        FILE    *out;           /* output stream */
 
        struct list_head        tb_columns;
index 770aaccc2f77c21ff1525736865d0865d6323052..d99bc3335122d18c833d191fd6c0a207b0d95638 100644 (file)
@@ -46,7 +46,6 @@ struct libscols_table *scols_new_table(int flags, struct libscols_symbols *syms)
 
        tb->flags = flags;
        tb->refcount = 1;
-       tb->first_run = TRUE;
        tb->out = stdout;
 
        INIT_LIST_HEAD(&tb->tb_lines);
index 2edd185b456865da34da460460a934b9d6708257..7da79598a4d1dea77a0a92611a788cae1c9ae920 100644 (file)
@@ -231,8 +231,7 @@ static void print_header(struct libscols_table *tb, char *buf, size_t bufsz)
 
        assert(tb);
 
-       if (!tb->first_run ||
-           (tb->flags & SCOLS_FL_NOHEADINGS) ||
+       if ((tb->flags & SCOLS_FL_NOHEADINGS) ||
            (tb->flags & SCOLS_FL_EXPORT) ||
            list_empty(&tb->tb_lines))
                return;
@@ -551,15 +550,11 @@ int scols_print_table(struct libscols_table *tb)
        if (!tb)
                return -1;
 
-       if (tb->first_run) {
-               tb->is_term = isatty(STDOUT_FILENO);
-
-               if (tb->is_term && !tb->termwidth)
-                       tb->termwidth = get_terminal_width();
-               if (tb->termwidth <= 0)
-                       tb->termwidth = 80;
-               tb->termwidth -= tb->termreduce;
-       }
+       tb->is_term = isatty(STDOUT_FILENO);
+       tb->termwidth = tb->is_term ? get_terminal_width() : 0;
+       if (tb->termwidth <= 0)
+               tb->termwidth = 80;
+       tb->termwidth -= tb->termreduce;
 
        line_sz = tb->termwidth;
 
@@ -575,8 +570,7 @@ int scols_print_table(struct libscols_table *tb)
        if (!line)
                return -ENOMEM;
 
-       if (tb->first_run &&
-           !((tb->flags & SCOLS_FL_RAW) || (tb->flags & SCOLS_FL_EXPORT)))
+       if (!((tb->flags & SCOLS_FL_RAW) || (tb->flags & SCOLS_FL_EXPORT)))
                recount_widths(tb, line, line_sz);
 
        if (tb->flags & SCOLS_FL_TREE)
@@ -585,6 +579,5 @@ int scols_print_table(struct libscols_table *tb)
                print_table(tb, line, line_sz);
 
        free(line);
-       tb->first_run = FALSE;
        return 0;
 }