]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
.
authorJim Meyering <jim@meyering.net>
Thu, 20 Oct 1994 04:42:43 +0000 (04:42 +0000)
committerJim Meyering <jim@meyering.net>
Thu, 20 Oct 1994 04:42:43 +0000 (04:42 +0000)
src/ls.c

index 4fc77a69227e30423a4daba2fea94f3540636ae0..2f906d4c0bdc2f7d5631f39929e1ff6933aa6bfa 100644 (file)
--- a/src/ls.c
+++ b/src/ls.c
@@ -281,10 +281,8 @@ static int kilobyte_blocks;
 /* Precede each line of long output (per file) with a string like `m,n:'
    where M is the number of characters after the `:' and before the
    filename and N is the length of the filename.  Using this format,
-   Emacs' dired mode starts up twice as fast using this option, and
-   can handle all strange characters in file names.
-   FIXME: what about symlinks -- they have two names...
-   */
+   Emacs' dired mode starts up twice as fast, and can handle all
+   strange characters in file names.  */
 static int dired;
 
 /* none means don't mention the type of files.
@@ -452,42 +450,40 @@ static char const* const time_args[] =
   "atime", "access", "use", "ctime", "status", 0
 };
 
-/* FIXME comment  */
+/* This zero-based index is used solely with the --dired option.
+   When that option is in effect, this counter is incremented for each
+   character of output generated by this program so that the beginning
+   and ending indices (in that output) of every file name can be recorded
+   and later output themselves.  */
 static size_t dired_pos;
 
-/* FIXME comment  */
 #define PUTCHAR(c) do {putchar ((c)); ++dired_pos;} while (0)
 
-/* FIXME comment  */
+/* Write S to STREAM and increment DIRED_POS by S_LEN.  */
 #define FPUTS(s, stream, s_len) \
     do {fputs ((s), (stream)); dired_pos += s_len;} while (0)
 
-/* FIXME comment  */
+/* Like FPUTS, but for use when S is a literal string.  */
+#define FPUTS_LITERAL(s, stream) \
+    do {fputs ((s), (stream)); dired_pos += sizeof((s)) - 1;} while (0)
+
+/* With --dired, store pairs of beginning and ending indices of filenames.  */
 static struct obstack dired_obstack;
 
-/* FIXME comment  */
-#define PUSH_CURRENT_DIRED_POS()                                       \
-  do                                                                   \
-    {                                                                  \
-      /* FIXME: remove the `&& format == long_format' clause.  */      \
-      if (dired && format == long_format)                              \
-       obstack_grow (&dired_obstack, &dired_pos, sizeof (dired_pos));  \
-    }                                                                  \
-  while (0)
+/* With --dired and --recursive, store pairs of beginning and ending
+   indices of directory names.  */
+static struct obstack subdired_obstack;
 
-/* FIXME comment  */
-#define PUSH_CURRENT_SUBDIRED_POS()                                    \
+/* Save the current index on the specified obstack, OBS.  */
+#define PUSH_CURRENT_DIRED_POS(obs)                                    \
   do                                                                   \
     {                                                                  \
       /* FIXME: remove the `&& format == long_format' clause.  */      \
-      if (dired && format == long_format && trace_dirs)                        \
-       obstack_grow (&subdired_obstack, &dired_pos, sizeof (dired_pos));\
+      if (dired && format == long_format)                              \
+       obstack_grow ((obs), &dired_pos, sizeof (dired_pos));           \
     }                                                                  \
   while (0)
 
-/* FIXME comment  */
-static struct obstack subdired_obstack;
-
 static enum time_type const time_types[] =
 {
   time_atime, time_atime, time_atime, time_ctime, time_ctime
@@ -965,11 +961,14 @@ print_dir (name, realname)
     {
       const char *dir;
 
+      /* FIXME: remove the `&& format == long_format' clause.  */
+      if (dired && format == long_format)
+       FPUTS_LITERAL ("  ", stdout);
       dir = (realname ? realname : name);
-      PUSH_CURRENT_SUBDIRED_POS ();
+      PUSH_CURRENT_DIRED_POS (&subdired_obstack);
       FPUTS (dir, stdout, strlen (dir));
-      PUSH_CURRENT_SUBDIRED_POS ();
-      FPUTS (":\n", stdout, 2);
+      PUSH_CURRENT_DIRED_POS (&subdired_obstack);
+      FPUTS_LITERAL (":\n", stdout);
     }
 
   if (format == long_format || print_block_size)
@@ -1508,7 +1507,6 @@ print_long_format (f)
 {
   char modebuf[20];
   char timebuf[40];
-  int quoted_length;
 
   /* 7 fields that may (worst case be 64-bit integral values) require 20 bytes,
      10 character mode field,
@@ -1602,18 +1600,18 @@ print_long_format (f)
   p += strlen (p);
 
   if (dired)
-    FPUTS ("  ", stdout, 2);
+    FPUTS_LITERAL ("  ", stdout);
 
   FPUTS (bigbuf, stdout, p - bigbuf);
-  PUSH_CURRENT_DIRED_POS ();
+  PUSH_CURRENT_DIRED_POS (&dired_obstack);
   print_name_with_quoting (f->name);
-  PUSH_CURRENT_DIRED_POS ();
+  PUSH_CURRENT_DIRED_POS (&dired_obstack);
 
   if (f->filetype == symbolic_link)
     {
       if (f->linkname)
        {
-         FPUTS (" -> ", stdout, 4);
+         FPUTS_LITERAL (" -> ", stdout);
          print_name_with_quoting (f->linkname);
          if (indicator_style != none)
            print_type_indicator (f->linkmode);