misc/colorls: Fix mangled datetime in long format ('colorls -l')

This commit is contained in:
charlotte 2023-09-14 00:48:31 +00:00
parent bb7bdb92c9
commit 50838b55f5
3 changed files with 23 additions and 22 deletions

View File

@ -1,8 +1,8 @@
# $NetBSD: Makefile,v 1.32 2018/12/29 08:54:01 triaxx Exp $
# $NetBSD: Makefile,v 1.33 2023/09/14 00:48:31 charlotte Exp $
DISTNAME= ls
PKGNAME= colorls-2.2
PKGREVISION= 1
PKGREVISION= 2
CATEGORIES= misc
MASTER_SITES= ${MASTER_SITE_LOCAL}

View File

@ -1,4 +1,4 @@
$NetBSD: distinfo,v 1.14 2021/10/26 10:59:00 nia Exp $
$NetBSD: distinfo,v 1.15 2023/09/14 00:48:31 charlotte Exp $
BLAKE2s (ls.tar.gz) = 58f01d54574006bd1e6084314810007513c2ef487e1b70189f06fc389704afed
SHA512 (ls.tar.gz) = cdd7e68b1122831a5393c328df02e41c2505d0c0684b0fac4ec111b95646e221cc5540056fc22b3da5b51eb679faf0283e5801ccefa45378e0033fea71f4d6c0
@ -7,7 +7,7 @@ SHA1 (patch-aa) = 5c43a6d6fcbf44606a68f81be14f81a92c7dd3e7
SHA1 (patch-ab) = 9e54a34c85ec0e4011aa6e5a4776b29e8cb0be54
SHA1 (patch-ac) = ca39144a044969fe5aa17960c898c7e1b8bba86f
SHA1 (patch-ad) = fb1d96b03fa028d45ddd4fe46ca520036f26be25
SHA1 (patch-ae) = 70cfb2b8942e0130406e0c483b8e01de8c02a8d4
SHA1 (patch-ae) = 6c4f078ecab7a0ae940bead07b1d68d1d41f9f15
SHA1 (patch-cmp.c) = 0f2675956bbf010055e39cd868337f1e452cf297
SHA1 (patch-extern.h) = da879e819ce201ca434bb4bd6d15b92413877361
SHA1 (patch-stat__flags.c) = 08f16c05d9383dc75c8954022fd491aa466312fa

View File

@ -1,9 +1,9 @@
$NetBSD: patch-ae,v 1.5 2015/07/09 11:44:09 jperkin Exp $
$NetBSD: patch-ae,v 1.6 2023/09/14 00:48:31 charlotte Exp $
Use nbcompat.
Use nbcompat, and fix mangled datetime formatting.
--- print.c.orig 1996-12-21 23:40:58.000000000 +0000
+++ print.c
--- print.c.orig 1996-12-21 15:40:58.000000000 -0800
+++ print.c 2023-09-13 17:30:15.209912546 -0700
@@ -43,9 +43,15 @@ static char const sccsid[] = "@(#)print.
#include <sys/param.h>
#include <sys/stat.h>
@ -67,7 +67,7 @@ Use nbcompat.
if (S_ISCHR(sp->st_mode) || S_ISBLK(sp->st_mode))
if (minor(sp->st_rdev) > 255)
(void)printf("%3d, 0x%08x ",
@@ -114,20 +142,24 @@ printlong(dp)
@@ -114,19 +142,23 @@ printlong(dp)
(void)printf("%3d, %3d ",
major(sp->st_rdev), minor(sp->st_rdev));
else if (dp->bcfile)
@ -89,21 +89,16 @@ Use nbcompat.
(void)printf("%s", p->fts_name);
if (f_type)
(void)printtype(sp->st_mode);
- if (S_ISLNK(sp->st_mode))
+ if (f_color)
+ (void)printf("\033[m");
+ if (S_ISLNK(sp->st_mode))
if (S_ISLNK(sp->st_mode))
printlink(p);
(void)putchar('\n');
}
@@ -190,10 +222,22 @@ printcol(dp)
@@ -190,7 +222,19 @@ printcol(dp)
dp->s_block);
if ((base += numrows) >= num)
break;
- while ((cnt = ((chcnt + TAB) & ~(TAB - 1))) <= endcol){
- (void)putchar('\t');
- chcnt = cnt;
- }
+
+ /*
+ * some terminals get confused if we mix tabs
@ -117,12 +112,9 @@ Use nbcompat.
+ else
+ while ((cnt = ((chcnt + TAB) & ~(TAB - 1)))
+ <= endcol) {
+ (void)putchar('\t');
+ chcnt = cnt;
+ }
endcol += colwidth;
}
(void)putchar('\n');
(void)putchar('\t');
chcnt = cnt;
}
@@ -217,11 +261,15 @@ printaname(p, inodefield, sizefield)
if (f_inode)
chcnt += printf("%*lu ", (int)inodefield, (u_long)sp->st_ino);
@ -141,6 +133,15 @@ Use nbcompat.
return (chcnt);
}
@@ -232,7 +280,7 @@ printtime(ftime)
int i;
char longstring[80];
- strftime(longstring, sizeof(longstring), "%c", localtime(&ftime));
+ snprintf(longstring, sizeof(longstring), "%s", ctime(&ftime));
for (i = 4; i < 11; ++i)
(void)putchar(longstring[i]);
@@ -281,6 +329,96 @@ printtype(mode)
return (0);
}