summaryrefslogtreecommitdiff
path: root/src/ls.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2006-07-25 15:30:27 +0000
committerJim Meyering <jim@meyering.net>2006-07-25 15:30:27 +0000
commitc04a374bb026e19b2a993681cadae617b918d692 (patch)
tree2ea91d3ef63c72a242e2e704a037aa2d50fa522c /src/ls.c
parent5a06d062c78b2f0b755eef9c4ec2faaf385fa6ac (diff)
downloadcoreutils-c04a374bb026e19b2a993681cadae617b918d692.tar.xz
Get --dired offsets right when handling stat-failed entries.
* src/ls.c (print_long_format): Be careful to increment P by the appropriate amount, even when inode_number_width and nlink_width are zero. * tests/ls/stat-failed: Test for the above.
Diffstat (limited to 'src/ls.c')
-rw-r--r--src/ls.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ls.c b/src/ls.c
index 67f16bd6b..37e206cb6 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -3395,7 +3395,9 @@ print_long_format (const struct fileinfo *f)
char hbuf[INT_BUFSIZE_BOUND (uintmax_t)];
sprintf (p, "%*s ", inode_number_width,
f->stat_failed ? "?" : umaxtostr (f->stat.st_ino, hbuf));
- p += inode_number_width + 1;
+ /* Increment by strlen (p) here, rather than by inode_number_width + 1.
+ The latter is wrong when inode_number_width is zero. */
+ p += strlen (p);
}
if (print_block_size)
@@ -3421,7 +3423,10 @@ print_long_format (const struct fileinfo *f)
sprintf (p, "%s %*s ", modebuf, nlink_width,
f->stat_failed ? "?" : umaxtostr (f->stat.st_nlink, hbuf));
}
- p += sizeof modebuf - 2 + any_has_acl + 1 + nlink_width + 1;
+ /* Increment by strlen (p) here, rather than by, e.g.,
+ sizeof modebuf - 2 + any_has_acl + 1 + nlink_width + 1.
+ The latter is wrong when nlink_width is zero. */
+ p += strlen (p);
DIRED_INDENT ();