diff options
author | Stephen Hemminger <stephen@networkplumber.org> | 2020-01-29 05:44:53 -0800 |
---|---|---|
committer | Stephen Hemminger <stephen@networkplumber.org> | 2020-01-29 05:44:53 -0800 |
commit | d80d22d5fd63f82d056efafe1e42e6f5aef5223a (patch) | |
tree | 6cd5d2af04754dab185e67e0fd6aa98fa7e78f9f /misc/ss.c | |
parent | d4df55404aec707bd55c9264c666ddb1bb05d7f1 (diff) | |
parent | eae5f4b5c88eb60465d8b70c52efff57039d0024 (diff) | |
download | iproute2-d80d22d5fd63f82d056efafe1e42e6f5aef5223a.tar.gz |
Merge branch 'master' of git://git.kernel.org/pub/scm/network/iproute2/iproute2-next
Resolved conflict in tc/f_flower.c
Diffstat (limited to 'misc/ss.c')
-rw-r--r-- | misc/ss.c | 19 |
1 files changed, 15 insertions, 4 deletions
@@ -1135,10 +1135,10 @@ static void buf_free_all(void) buffer.chunks = 0; } -/* Get current screen width, default to 80 columns if TIOCGWINSZ fails */ +/* Get current screen width, returns -1 if TIOCGWINSZ fails */ static int render_screen_width(void) { - int width = 80; + int width = -1; if (isatty(STDOUT_FILENO)) { struct winsize w; @@ -1159,9 +1159,15 @@ static int render_screen_width(void) */ static void render_calc_width(void) { - int screen_width = render_screen_width(); + int screen_width, first, len = 0, linecols = 0; struct column *c, *eol = columns - 1; - int first, len = 0, linecols = 0; + bool compact_output = false; + + screen_width = render_screen_width(); + if (screen_width == -1) { + screen_width = INT_MAX; + compact_output = true; + } /* First pass: set width for each column to measured content length */ for (first = 1, c = columns; c - columns < COL_MAX; c++) { @@ -1183,6 +1189,11 @@ static void render_calc_width(void) first = 0; } + if (compact_output) { + /* Compact output, skip extending columns. */ + return; + } + /* Second pass: find out newlines and distribute available spacing */ for (c = columns; c - columns < COL_MAX; c++) { int pad, spacing, rem, last; |