From ee708ff4aaf7ecf857431955a10600cd5be7774f Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sun, 21 Apr 1996 04:07:41 +0000 Subject: (decode_switches): Clean up last change. [posix_pedantic]: Don't consider TABSIZE environment variable. --- src/ls.c | 48 +++++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/ls.c b/src/ls.c index 1a1ebbc06..8b524d954 100644 --- a/src/ls.c +++ b/src/ls.c @@ -702,18 +702,20 @@ decode_switches (int argc, char **argv) ignore_patterns = 0; quote_as_string = 0; - p = getenv ("COLUMNS"); - if (xstrtol (p, NULL, 0, &tmp_long, NULL) == LONGINT_OK - && 0 < tmp_long && tmp_long <= INT_MAX) + line_length = 80; + if ((p = getenv ("COLUMNS"))) { - line_length = (int) tmp_long; - } - else - { - error (0, 0, - _("ignoring invalid width in enironment variable COLUMNS: %s"), - p); - line_length = 80; + if (xstrtol (p, NULL, 0, &tmp_long, NULL) == LONGINT_OK + && 0 < tmp_long && tmp_long <= INT_MAX) + { + line_length = (int) tmp_long; + } + else + { + error (0, 0, + _("ignoring invalid width in enironment variable COLUMNS: %s"), + p); + } } #ifdef TIOCGWINSZ @@ -725,20 +727,20 @@ decode_switches (int argc, char **argv) } #endif - /* FIXME: reference TABSIZE iff !posix_pedantic. */ - p = getenv ("TABSIZE"); - - if (xstrtol (p, NULL, 0, &tmp_long, NULL) == LONGINT_OK - && 0 < tmp_long && tmp_long <= INT_MAX) + tabsize = 8; + if (!posix_pedantic && (p = getenv ("TABSIZE"))) { - tabsize = (int) tmp_long; - } - else - { - error (0, 0, + if (xstrtol (p, NULL, 0, &tmp_long, NULL) == LONGINT_OK + && 0 < tmp_long && tmp_long <= INT_MAX) + { + tabsize = (int) tmp_long; + } + else + { + error (0, 0, _("ignoring invalid tab size in enironment variable TABSIZE: %s"), - p); - tabsize = 8; + p); + } } while ((c = getopt_long (argc, argv, -- cgit v1.2.3-70-g09d2