aboutsummaryrefslogtreecommitdiff
path: root/src/listalf.c
diff options
context:
space:
mode:
authorB. Watson <urchlay@slackware.uk>2025-12-02 14:58:10 -0500
committerB. Watson <urchlay@slackware.uk>2025-12-02 14:58:10 -0500
commit8998af28a197babbeaa5ae828f1229e499b193c1 (patch)
treec74b0625595b34c2637bee9babf290f444766c86 /src/listalf.c
parentee459dea483ae556ca16a2a5dc9cbb26e26bb425 (diff)
downloadalftools-8998af28a197babbeaa5ae828f1229e499b193c1.tar.gz
alf: Use 0 datestamp if year out of range; unalf: Display 0 datestamps as <none>.
Diffstat (limited to 'src/listalf.c')
-rw-r--r--src/listalf.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/listalf.c b/src/listalf.c
index 34078e5..33b2bfe 100644
--- a/src/listalf.c
+++ b/src/listalf.c
@@ -50,14 +50,16 @@ void format_msdos_date(char *buf) {
/* year actually ranges 1980 to 2107... */
year = (d >> 9) + 1980;
- /* valid months range 1 to 12. values 0, 13, 14, 15 are possible
- but invalid (print as ???) */
+ /* valid months range 1 to 12 */
month = (d >> 5) & 0x0f;
- /* valid day range is 1 to 31. 0 is invalid, print as-is. */
+ /* valid day range is 1 to 31. 0 is invalid. */
day = d & 0x1f;
- snprintf(buf, 12, "%2d %3s %04d", day, monthnames[month], year);
+ if(day == 0 || month == 0 || month > 12)
+ strncpy(buf, "<none>", 12);
+ else
+ snprintf(buf, 12, "%2d %3s %04d", day, monthnames[month], year);
}
/* small files may be "compressed" larger than the original, so this