]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(indent): Use TABs only when doing so replaces at least two spaces.
authorJim Meyering <jim@meyering.net>
Mon, 28 Nov 1994 04:32:07 +0000 (04:32 +0000)
committerJim Meyering <jim@meyering.net>
Mon, 28 Nov 1994 04:32:07 +0000 (04:32 +0000)
src/ls.c

index 6c05c9d7ba775c173b50d2418761dd6c41eaf64d..4ea9de7b23f57cbf053f929d1cd1fa085503dab6 100644 (file)
--- 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');
 }
 \f
-/* 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;