From f021d0ca05e284cc047b8a1259d61ed3bec59b06 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 28 Nov 1994 04:32:07 +0000 Subject: [PATCH] (indent): Use TABs only when doing so replaces at least two spaces. --- src/ls.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/ls.c b/src/ls.c index 6c05c9d..4ea9de7 100644 --- a/src/ls.c +++ b/src/ls.c @@ -1599,7 +1599,7 @@ make_link_path (path, linkname) /* The link is to a relative path. Prepend any leading path in `path' to the link name. */ - linkbuf = rindex (path, '/'); + linkbuf = strrchr (path, '/'); if (linkbuf == 0) return xstrdup (linkname); @@ -1667,7 +1667,7 @@ is_not_dot_or_dotdot (name) { char *t; - t = rindex (name, '/'); + t = strrchr (name, '/'); if (t) name = t + 1; @@ -1804,8 +1804,8 @@ compare_extension (file1, file2) register char *base1, *base2; register int cmp; - base1 = rindex (file1->name, '.'); - base2 = rindex (file2->name, '.'); + base1 = strrchr (file1->name, '.'); + base2 = strrchr (file2->name, '.'); if (base1 == 0 && base2 == 0) return strcmp (file1->name, file2->name); if (base1 == 0) @@ -1825,8 +1825,8 @@ rev_cmp_extension (file2, file1) register char *base1, *base2; register int cmp; - base1 = rindex (file1->name, '.'); - base2 = rindex (file2->name, '.'); + base1 = strrchr (file1->name, '.'); + base2 = strrchr (file2->name, '.'); if (base1 == 0 && base2 == 0) return strcmp (file1->name, file2->name); if (base1 == 0) @@ -2494,7 +2494,8 @@ print_with_commas () putchar ('\n'); } -/* Assuming cursor is at position FROM, indent up to position TO. */ +/* Assuming cursor is at position FROM, indent up to position TO. + Use a TAB character instead of two or more spaces whenever possible. */ static void indent (from, to) @@ -2502,7 +2503,7 @@ indent (from, to) { while (from < to) { - if (to / tabsize > from / tabsize) + if (to / tabsize > (from + 1) / tabsize) { putchar ('\t'); from += tabsize - from % tabsize; -- 2.7.4