=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/column/column.c,v retrieving revision 1.22 retrieving revision 1.23 diff -c -r1.22 -r1.23 *** src/usr.bin/column/column.c 2015/11/03 04:55:44 1.22 --- src/usr.bin/column/column.c 2016/03/17 05:27:10 1.23 *************** *** 1,4 **** ! /* $OpenBSD: column.c,v 1.22 2015/11/03 04:55:44 mmcc Exp $ */ /* $NetBSD: column.c,v 1.4 1995/09/02 05:53:03 jtc Exp $ */ /* --- 1,4 ---- ! /* $OpenBSD: column.c,v 1.23 2016/03/17 05:27:10 bentley Exp $ */ /* $NetBSD: column.c,v 1.4 1995/09/02 05:53:03 jtc Exp $ */ /* *************** *** 50,56 **** void r_columnate(void); void usage(void); ! int termwidth = 80; /* default terminal width */ int entries; /* number of records */ int eval; /* exit value */ --- 50,56 ---- void r_columnate(void); void usage(void); ! int termwidth; /* default terminal width */ int entries; /* number of records */ int eval; /* exit value */ *************** *** 67,80 **** char *p; const char *errstr; ! if (ioctl(1, TIOCGWINSZ, &win) == -1 || !win.ws_col) { ! if ((p = getenv("COLUMNS")) && *p != '\0') { ! termwidth = strtonum(p, 1, INT_MAX, &errstr); ! if (errstr != NULL) ! errx(1, "%s: %s", errstr, p); ! } ! } else termwidth = win.ws_col; if (pledge("stdio rpath", NULL) == -1) err(1, "pledge"); --- 67,80 ---- char *p; const char *errstr; ! termwidth = 0; ! if ((p = getenv("COLUMNS")) != NULL) ! termwidth = strtonum(p, 1, INT_MAX, NULL); ! if (termwidth == 0 && ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == 0 && ! win.ws_col > 0) termwidth = win.ws_col; + if (termwidth == 0) + termwidth = 80; if (pledge("stdio rpath", NULL) == -1) err(1, "pledge");