diff options
author | Jim Meyering <jim@meyering.net> | 1994-10-20 04:42:43 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1994-10-20 04:42:43 +0000 |
commit | 9f167c85b07d7cc84bb7608bdbcafd19e4a4fe09 (patch) | |
tree | 380b1d88ecf7ec2439cea85141e0152d77c56d3d /src | |
parent | 544baf5482a56229515f24806f35ab1a847f3504 (diff) | |
download | coreutils-9f167c85b07d7cc84bb7608bdbcafd19e4a4fe09.tar.xz |
.
Diffstat (limited to 'src')
-rw-r--r-- | src/ls.c | 62 |
1 files changed, 30 insertions, 32 deletions
@@ -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); |