Thu Sep 14 00:48:31 2023 UTC ()
misc/colorls: Fix mangled datetime in long format ('colorls -l')


(charlotte)
diff -r1.32 -r1.33 pkgsrc/misc/colorls/Makefile
diff -r1.14 -r1.15 pkgsrc/misc/colorls/distinfo
diff -r1.5 -r1.6 pkgsrc/misc/colorls/patches/patch-ae

cvs diff -r1.32 -r1.33 pkgsrc/misc/colorls/Makefile (expand / switch to unified diff)

--- pkgsrc/misc/colorls/Makefile 2018/12/29 08:54:01 1.32
+++ pkgsrc/misc/colorls/Makefile 2023/09/14 00:48:31 1.33
@@ -1,18 +1,18 @@ @@ -1,18 +1,18 @@
1# $NetBSD: Makefile,v 1.32 2018/12/29 08:54:01 triaxx Exp $ 1# $NetBSD: Makefile,v 1.33 2023/09/14 00:48:31 charlotte Exp $
2 2
3DISTNAME= ls 3DISTNAME= ls
4PKGNAME= colorls-2.2 4PKGNAME= colorls-2.2
5PKGREVISION= 1 5PKGREVISION= 2
6CATEGORIES= misc 6CATEGORIES= misc
7MASTER_SITES= ${MASTER_SITE_LOCAL} 7MASTER_SITES= ${MASTER_SITE_LOCAL}
8 8
9MAINTAINER= pkgsrc-users@NetBSD.org 9MAINTAINER= pkgsrc-users@NetBSD.org
10COMMENT= Uses color with ls(1) to display file attributes 10COMMENT= Uses color with ls(1) to display file attributes
11LICENSE= original-bsd 11LICENSE= original-bsd
12 12
13USE_FEATURES+= fts_open 13USE_FEATURES+= fts_open
14USE_TOOLS= nroff 14USE_TOOLS= nroff
15 15
16RESTRICTED= Already in MASTER_SITE_LOCAL 16RESTRICTED= Already in MASTER_SITE_LOCAL
17NO_SRC_ON_FTP= ${RESTRICTED} 17NO_SRC_ON_FTP= ${RESTRICTED}
18 18

cvs diff -r1.14 -r1.15 pkgsrc/misc/colorls/distinfo (expand / switch to unified diff)

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

cvs diff -r1.5 -r1.6 pkgsrc/misc/colorls/patches/patch-ae (expand / switch to unified diff)

--- pkgsrc/misc/colorls/patches/patch-ae 2015/07/09 11:44:09 1.5
+++ pkgsrc/misc/colorls/patches/patch-ae 2023/09/14 00:48:31 1.6
@@ -1,19 +1,19 @@ @@ -1,19 +1,19 @@
1$NetBSD: patch-ae,v 1.5 2015/07/09 11:44:09 jperkin Exp $ 1$NetBSD: patch-ae,v 1.6 2023/09/14 00:48:31 charlotte Exp $
2 2
3Use nbcompat. 3Use nbcompat, and fix mangled datetime formatting.
4 4
5--- print.c.orig 1996-12-21 23:40:58.000000000 +0000 5--- print.c.orig 1996-12-21 15:40:58.000000000 -0800
6+++ print.c 6+++ print.c 2023-09-13 17:30:15.209912546 -0700
7@@ -43,9 +43,15 @@ static char const sccsid[] = "@(#)print. 7@@ -43,9 +43,15 @@ static char const sccsid[] = "@(#)print.
8 #include <sys/param.h> 8 #include <sys/param.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10  10
11+#include <ctype.h> 11+#include <ctype.h>
12 #include <err.h> 12 #include <err.h>
13 #include <errno.h> 13 #include <errno.h>
14+#if defined(HAVE_NBCOMPAT_H) 14+#if defined(HAVE_NBCOMPAT_H)
15+#include <nbcompat.h> 15+#include <nbcompat.h>
16+#include <nbcompat/fts.h> 16+#include <nbcompat/fts.h>
17+#else 17+#else
18 #include <fts.h> 18 #include <fts.h>
19+#endif 19+#endif
@@ -57,100 +57,101 @@ Use nbcompat. @@ -57,100 +57,101 @@ Use nbcompat.
57+ dp->s_block, (long long)howmany(sp->st_blocks, blocksize)); 57+ dp->s_block, (long long)howmany(sp->st_blocks, blocksize));
58 (void)strmode(sp->st_mode, buf); 58 (void)strmode(sp->st_mode, buf);
59 np = p->fts_pointer; 59 np = p->fts_pointer;
60 (void)printf("%s %*u %-*s %-*s ", buf, dp->s_nlink, 60 (void)printf("%s %*u %-*s %-*s ", buf, dp->s_nlink,
61 sp->st_nlink, dp->s_user, np->user, dp->s_group, 61 sp->st_nlink, dp->s_user, np->user, dp->s_group,
62 np->group); 62 np->group);
63+#ifndef __sun 63+#ifndef __sun
64 if (f_flags) 64 if (f_flags)
65 (void)printf("%-*s ", dp->s_flags, np->flags); 65 (void)printf("%-*s ", dp->s_flags, np->flags);
66+#endif 66+#endif
67 if (S_ISCHR(sp->st_mode) || S_ISBLK(sp->st_mode)) 67 if (S_ISCHR(sp->st_mode) || S_ISBLK(sp->st_mode))
68 if (minor(sp->st_rdev) > 255) 68 if (minor(sp->st_rdev) > 255)
69 (void)printf("%3d, 0x%08x ", 69 (void)printf("%3d, 0x%08x ",
70@@ -114,20 +142,24 @@ printlong(dp) 70@@ -114,19 +142,23 @@ printlong(dp)
71 (void)printf("%3d, %3d ", 71 (void)printf("%3d, %3d ",
72 major(sp->st_rdev), minor(sp->st_rdev)); 72 major(sp->st_rdev), minor(sp->st_rdev));
73 else if (dp->bcfile) 73 else if (dp->bcfile)
74- (void)printf("%*s%*qd ", 74- (void)printf("%*s%*qd ",
75- 8 - dp->s_size, "", dp->s_size, sp->st_size); 75- 8 - dp->s_size, "", dp->s_size, sp->st_size);
76+ (void)printf("%*s%*lld ", 76+ (void)printf("%*s%*lld ",
77+ 8 - dp->s_size, "", dp->s_size, (long long)sp->st_size); 77+ 8 - dp->s_size, "", dp->s_size, (long long)sp->st_size);
78 else 78 else
79- (void)printf("%*qd ", dp->s_size, sp->st_size); 79- (void)printf("%*qd ", dp->s_size, sp->st_size);
80+ (void)printf("%*lld ", dp->s_size, (long long)sp->st_size); 80+ (void)printf("%*lld ", dp->s_size, (long long)sp->st_size);
81 if (f_accesstime) 81 if (f_accesstime)
82 printtime(sp->st_atime); 82 printtime(sp->st_atime);
83 else if (f_statustime) 83 else if (f_statustime)
84 printtime(sp->st_ctime); 84 printtime(sp->st_ctime);
85 else 85 else
86 printtime(sp->st_mtime); 86 printtime(sp->st_mtime);
87+ if (f_color) 87+ if (f_color)
88+ (void)colortype(sp->st_mode); 88+ (void)colortype(sp->st_mode);
89 (void)printf("%s", p->fts_name); 89 (void)printf("%s", p->fts_name);
90 if (f_type) 90 if (f_type)
91 (void)printtype(sp->st_mode); 91 (void)printtype(sp->st_mode);
92- if (S_ISLNK(sp->st_mode)) 
93+ if (f_color) 92+ if (f_color)
94+ (void)printf("\033[m"); 93+ (void)printf("\033[m");
95+ if (S_ISLNK(sp->st_mode)) 94 if (S_ISLNK(sp->st_mode))
96 printlink(p); 95 printlink(p);
97 (void)putchar('\n'); 96 (void)putchar('\n');
98 } 97@@ -190,7 +222,19 @@ printcol(dp)
99@@ -190,10 +222,22 @@ printcol(dp) 
100 dp->s_block); 98 dp->s_block);
101 if ((base += numrows) >= num) 99 if ((base += numrows) >= num)
102 break; 100 break;
103- while ((cnt = ((chcnt + TAB) & ~(TAB - 1))) <= endcol){ 101- while ((cnt = ((chcnt + TAB) & ~(TAB - 1))) <= endcol){
104- (void)putchar('\t'); 
105- chcnt = cnt; 
106- } 
107+ 102+
108+ /* 103+ /*
109+ * some terminals get confused if we mix tabs 104+ * some terminals get confused if we mix tabs
110+ * with color sequences 105+ * with color sequences
111+ */ 106+ */
112+ if (f_color) 107+ if (f_color)
113+ while ((cnt = (chcnt + 1)) <= endcol) { 108+ while ((cnt = (chcnt + 1)) <= endcol) {
114+ (void)putchar(' '); 109+ (void)putchar(' ');
115+ chcnt = cnt; 110+ chcnt = cnt;
116+ } 111+ }
117+ else 112+ else
118+ while ((cnt = ((chcnt + TAB) & ~(TAB - 1))) 113+ while ((cnt = ((chcnt + TAB) & ~(TAB - 1)))
119+ <= endcol) { 114+ <= endcol) {
120+ (void)putchar('\t'); 115 (void)putchar('\t');
121+ chcnt = cnt; 116 chcnt = cnt;
122+ } 117 }
123 endcol += colwidth; 
124 } 
125 (void)putchar('\n'); 
126@@ -217,11 +261,15 @@ printaname(p, inodefield, sizefield) 118@@ -217,11 +261,15 @@ printaname(p, inodefield, sizefield)
127 if (f_inode) 119 if (f_inode)
128 chcnt += printf("%*lu ", (int)inodefield, (u_long)sp->st_ino); 120 chcnt += printf("%*lu ", (int)inodefield, (u_long)sp->st_ino);
129 if (f_size) 121 if (f_size)
130- chcnt += printf("%*qd ", 122- chcnt += printf("%*qd ",
131- (int)sizefield, howmany(sp->st_blocks, blocksize)); 123- (int)sizefield, howmany(sp->st_blocks, blocksize));
132+ chcnt += printf("%*lld ", 124+ chcnt += printf("%*lld ",
133+ (int)sizefield, (long long)howmany(sp->st_blocks, blocksize)); 125+ (int)sizefield, (long long)howmany(sp->st_blocks, blocksize));
134+ if (f_color) 126+ if (f_color)
135+ (void)colortype(sp->st_mode); 127+ (void)colortype(sp->st_mode);
136 chcnt += printf("%s", p->fts_name); 128 chcnt += printf("%s", p->fts_name);
137 if (f_type) 129 if (f_type)
138 chcnt += printtype(sp->st_mode); 130 chcnt += printtype(sp->st_mode);
139+ if (f_color) 131+ if (f_color)
140+ printf("\033[m"); 132+ printf("\033[m");
141 return (chcnt); 133 return (chcnt);
142 } 134 }
143  135
 136@@ -232,7 +280,7 @@ printtime(ftime)
 137 int i;
 138 char longstring[80];
 139
 140- strftime(longstring, sizeof(longstring), "%c", localtime(&ftime));
 141+ snprintf(longstring, sizeof(longstring), "%s", ctime(&ftime));
 142 for (i = 4; i < 11; ++i)
 143 (void)putchar(longstring[i]);
 144
144@@ -281,6 +329,96 @@ printtype(mode) 145@@ -281,6 +329,96 @@ printtype(mode)
145 return (0); 146 return (0);
146 } 147 }
147  148
148+void 149+void
149+printcolor(c) 150+printcolor(c)
150+ Colors c; 151+ Colors c;
151+{ 152+{
152+ printf("\033["); 153+ printf("\033[");
153+ if (colors[c][0] != -1) { 154+ if (colors[c][0] != -1) {
154+ printf("3%d", colors[c][0]); 155+ printf("3%d", colors[c][0]);
155+ if (colors[c][1] != -1) 156+ if (colors[c][1] != -1)
156+ printf(";"); 157+ printf(";");