aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2025-11-01 17:39:07 -0600
committerPaul Eggert <eggert@cs.ucla.edu>2025-11-01 18:00:32 -0600
commitb427c185f266f5ab549e311a3c26a179d51f7d35 (patch)
treedd5df129739d7501722fbae56f3e8c2ee0846c49
parentbuild: update gnulib submodule to latest (diff)
downloadcoreutils-b427c185f266f5ab549e311a3c26a179d51f7d35.tar.gz
coreutils-b427c185f266f5ab549e311a3c26a179d51f7d35.zip
ls: better nstrftime failure check
* src/ls.c (print_long_format): Streamline the checking for failure of nstrftime.
-rw-r--r--src/ls.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/ls.c b/src/ls.c
index 5183a414e..7144d0d9a 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -4422,8 +4422,7 @@ print_long_format (const struct fileinfo *f)
p[-1] = ' ';
}
- s = 0;
- *p = '\1';
+ s = -1;
if (f->stat_ok && btime_ok
&& localtime_rz (localtz, &when_timespec.tv_sec, &when_local))
@@ -4451,11 +4450,9 @@ print_long_format (const struct fileinfo *f)
whole number of seconds. */
s = align_nstrftime (p, TIME_STAMP_LEN_MAXIMUM + 1, recent,
&when_local, localtz, when_timespec.tv_nsec);
- if (s < 0)
- s = 0;
}
- if (s || !*p)
+ if (0 <= s)
{
p += s;
*p++ = ' ';