summaryrefslogtreecommitdiff
path: root/src/ls.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1996-06-25 04:56:22 +0000
committerJim Meyering <jim@meyering.net>1996-06-25 04:56:22 +0000
commitf58702e8f97ca1fde5abc475987c9da2585583df (patch)
treecc9142a4ebe0f9116f6bf56ee6d2a1ac9375428e /src/ls.c
parent80c03e37baf70f58fb318ef10db0851eeff5cded (diff)
downloadcoreutils-f58702e8f97ca1fde5abc475987c9da2585583df.tar.xz
(decode_switches): Allow 0 as argument to --tabsize (-T) option.
Interpret as a directive to use no TAB characters to separate columns. (indent): Handle TABSIZE == 0.
Diffstat (limited to 'src/ls.c')
-rw-r--r--src/ls.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/ls.c b/src/ls.c
index f97fddd8a..be268241c 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -456,7 +456,8 @@ static int qmark_funny_chars;
static int quote_as_string;
-/* The number of chars per hardware tab stop. -T */
+/* The number of chars per hardware tab stop. Setting this to zero
+ inhibits the use of TAB characters for separating columns. -T */
static int tabsize;
/* Nonzero means we are listing the working directory because no
@@ -834,14 +835,14 @@ decode_switches (int argc, char **argv)
if (!getenv ("POSIXLY_CORRECT") && (p = getenv ("TABSIZE")))
{
if (xstrtol (p, NULL, 0, &tmp_long, NULL) == LONGINT_OK
- && 0 < tmp_long && tmp_long <= INT_MAX)
+ && 0 <= tmp_long && tmp_long <= INT_MAX)
{
tabsize = (int) tmp_long;
}
else
{
error (0, 0,
- _("ignoring invalid tab size in environment variable TABSIZE: %s"),
+ _("ignoring invalid tab size in environment variable TABSIZE: %s"),
p);
}
}
@@ -1005,7 +1006,7 @@ decode_switches (int argc, char **argv)
case 'T':
if (xstrtol (optarg, NULL, 0, &tmp_long, NULL) != LONGINT_OK
- || tmp_long <= 0 || tmp_long > INT_MAX)
+ || tmp_long < 0 || tmp_long > INT_MAX)
error (1, 0, _("invalid tab size: %s"), optarg);
tabsize = (int) tmp_long;
break;
@@ -1079,7 +1080,7 @@ decode_switches (int argc, char **argv)
/* Don't use TAB characters in output. Some terminal
emulators can't handle the combination of tabs and
color codes on the same line. */
- tabsize = line_length;
+ tabsize = 0;
}
break;
@@ -1380,8 +1381,7 @@ parse_ls_color (void)
{
color_indicator[ind_no].string = buf;
state = ((color_indicator[ind_no].len =
- get_funky_string (&buf, &p, 0)) < 0 ?
- -1 : 1);
+ get_funky_string (&buf, &p, 0)) < 0 ? -1 : 1);
break;
}
}
@@ -2638,7 +2638,7 @@ indent (int from, int to)
{
while (from < to)
{
- if (to / tabsize > (from + 1) / tabsize)
+ if (tabsize > 0 && to / tabsize > (from + 1) / tabsize)
{
putchar ('\t');
from += tabsize - from % tabsize;