]> granicus.if.org Git - procps-ng/commitdiff
watch: remove arbitrary terminal size restriction
authorSami Kerola <kerolasa@iki.fi>
Thu, 8 Mar 2012 21:41:23 +0000 (22:41 +0100)
committerSami Kerola <kerolasa@iki.fi>
Fri, 16 Mar 2012 12:18:57 +0000 (13:18 +0100)
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
watch.c

diff --git a/watch.c b/watch.c
index d759c64b6259190aa9349f18c48a416f653f495f..3848ef28e982c3f8454199580c170c0278f9e55b 100644 (file)
--- a/watch.c
+++ b/watch.c
@@ -63,7 +63,7 @@
 #endif
 
 static int curses_started = 0;
-static int height = 24, width = 80;
+static long height = 24, width = 80;
 static int screen_size_changed = 0;
 static int first_screen = 1;
 static int show_title = 2;     /* number of lines used, 2 or 0 */
@@ -195,10 +195,10 @@ static void get_terminal_size(void)
                        long t;
                        char *endptr;
                        t = strtol(s, &endptr, 0);
-                       if (!*endptr && (t > 0) && (t < (long)666))
-                               incoming_cols = (int)t;
+                       if (!*endptr && 0 < t)
+                               incoming_cols = t;
                        width = incoming_cols;
-                       snprintf(env_col_buf, sizeof env_col_buf, "COLUMNS=%d",
+                       snprintf(env_col_buf, sizeof env_col_buf, "COLUMNS=%ld",
                                 width);
                        putenv(env_col_buf);
                }
@@ -211,26 +211,26 @@ static void get_terminal_size(void)
                        long t;
                        char *endptr;
                        t = strtol(s, &endptr, 0);
-                       if (!*endptr && (t > 0) && (t < (long)666))
-                               incoming_rows = (int)t;
+                       if (!*endptr && 0 < t)
+                               incoming_rows = t;
                        height = incoming_rows;
-                       snprintf(env_row_buf, sizeof env_row_buf, "LINES=%d",
+                       snprintf(env_row_buf, sizeof env_row_buf, "LINES=%ld",
                                 height);
                        putenv(env_row_buf);
                }
        }
-       if (incoming_cols < 0 || incoming_rows < 0) {
-               if (ioctl(STDERR_FILENO, TIOCGWINSZ, &w) == 0) {
+       if (ioctl(STDERR_FILENO, TIOCGWINSZ, &w) == 0) {
+               if (incoming_cols < 0 || incoming_rows < 0) {
                        if (incoming_rows < 0 && w.ws_row > 0) {
                                height = w.ws_row;
                                snprintf(env_row_buf, sizeof env_row_buf,
-                                        "LINES=%d", height);
+                                        "LINES=%ld", height);
                                putenv(env_row_buf);
                        }
                        if (incoming_cols < 0 && w.ws_col > 0) {
                                width = w.ws_col;
                                snprintf(env_col_buf, sizeof env_col_buf,
-                                        "COLUMNS=%d", width);
+                                        "COLUMNS=%ld", width);
                                putenv(env_col_buf);
                        }
                }