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;
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;
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;
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)
print_table(tb, line, line_sz);
free(line);
- tb->first_run = FALSE;
return 0;
}