Note on glibc-2.7 at least, this speeds up the whole 'ls -lU'
process by around 17%, compared to letting strftime() handle the %b. */
-static size_t
+static ptrdiff_t
align_nstrftime (char *buf, size_t size, bool recent, struct tm const *tm,
timezone_t tz, int ns)
{
their implementations limit the offset to 167:59 and 24:00, resp. */
if (localtime_rz (localtz, &epoch, &tm))
{
- size_t len = align_nstrftime (buf, sizeof buf, false,
- &tm, localtz, 0);
- if (len != 0)
+ ptrdiff_t len = align_nstrftime (buf, sizeof buf, false,
+ &tm, localtz, 0);
+ if (len > 0)
width = mbsnwidth (buf, len, MBSWIDTH_FLAGS);
}
+ LONGEST_HUMAN_READABLE + 1 /* minor device number */
+ TIME_STAMP_LEN_MAXIMUM + 1 /* max length of time/date */
];
- size_t s;
+ ptrdiff_t s;
char *p;
struct timespec when_timespec;
struct tm when_local;
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)