diff options
author | 1996-02-17 18:49:22 +0000 | |
---|---|---|
committer | 1996-02-17 18:49:22 +0000 | |
commit | a570d4492d8820fc51262fd1e009dde3ea8319e9 (patch) | |
tree | 1ee3664ed460b5066d260eac443fdc868dc9afb2 | |
parent | From netbsd: (diff) | |
download | wireguard-openbsd-a570d4492d8820fc51262fd1e009dde3ea8319e9.tar.xz wireguard-openbsd-a570d4492d8820fc51262fd1e009dde3ea8319e9.zip |
From netbsd:
Changed so that COLUMNS environment variable will override the value
obtained via the TIOCGWINSIZ ioctl. This is required by POSIX.2, see
section 4.39.5.3.
-rw-r--r-- | bin/ls/ls.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/bin/ls/ls.c b/bin/ls/ls.c index c64d7c8e657..2fc2ef8d43b 100644 --- a/bin/ls/ls.c +++ b/bin/ls/ls.c @@ -1,4 +1,4 @@ -/* $NetBSD: ls.c,v 1.15 1995/09/07 06:42:58 jtc Exp $ */ +/* $NetBSD: ls.c,v 1.16 1996/02/14 05:58:53 jtc Exp $ */ /* * Copyright (c) 1989, 1993, 1994 @@ -46,7 +46,7 @@ static char copyright[] = #if 0 static char sccsid[] = "@(#)ls.c 8.7 (Berkeley) 8/5/94"; #else -static char rcsid[] = "$NetBSD: ls.c,v 1.15 1995/09/07 06:42:58 jtc Exp $"; +static char rcsid[] = "$NetBSD: ls.c,v 1.16 1996/02/14 05:58:53 jtc Exp $"; #endif #endif /* not lint */ @@ -118,12 +118,10 @@ main(argc, argv) /* Terminal defaults to -Cq, non-terminal defaults to -1. */ if (isatty(STDOUT_FILENO)) { - if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == -1 || - !win.ws_col) { - if ((p = getenv("COLUMNS")) != NULL) - termwidth = atoi(p); - } - else + if ((p = getenv("COLUMNS")) != NULL) + termwidth = atoi(p); + else if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == 0 && + win.ws_col > 0) termwidth = win.ws_col; f_column = f_nonprint = 1; } else |