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 (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,30 +1,30 @@ @@ -1,30 +1,30 @@
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
19MANCOMPRESSED_IF_MANZ= yes 19MANCOMPRESSED_IF_MANZ= yes
20MAKE_ENV+= BINOWN=${BINOWN:Q} BINGRP=${BINGRP:Q} \ 20MAKE_ENV+= BINOWN=${BINOWN:Q} BINGRP=${BINGRP:Q} \
21 MANOWN=${MANOWN:Q} MANGRP=${MANGRP:Q} 21 MANOWN=${MANOWN:Q} MANGRP=${MANGRP:Q}
22MAKE_ENV+= LDADD=${LIBS:Q} 22MAKE_ENV+= LDADD=${LIBS:Q}
23INSTALLATION_DIRS= bin ${PKGMANDIR}/man1 ${PKGMANDIR}/cat1 23INSTALLATION_DIRS= bin ${PKGMANDIR}/man1 ${PKGMANDIR}/cat1
24 24
25CFLAGS.SunOS+= -Du_quad_t=uint64_t -DS_ISTXT=S_ISVTX 25CFLAGS.SunOS+= -Du_quad_t=uint64_t -DS_ISTXT=S_ISVTX
26 26
27pre-patch: 27pre-patch:
28 ${CP} ${WRKSRC}/ls.1 ${WRKSRC}/colorls.1 28 ${CP} ${WRKSRC}/ls.1 ${WRKSRC}/colorls.1
29 29
30.include "../../mk/bsd.pkg.mk" 30.include "../../mk/bsd.pkg.mk"

cvs diff -r1.14 -r1.15 pkgsrc/misc/colorls/distinfo (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 (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,240 +1,241 @@ @@ -1,240 +1,241 @@
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
20 #include <grp.h> 20 #include <grp.h>
21 #include <pwd.h> 21 #include <pwd.h>
22 #include <stdio.h> 22 #include <stdio.h>
23@@ -64,6 +70,26 @@ static int printtype __P((u_int)); 23@@ -64,6 +70,26 @@ static int printtype __P((u_int));
24  24
25 #define IS_NOPRINT(p) ((p)->fts_number == NO_PRINT) 25 #define IS_NOPRINT(p) ((p)->fts_number == NO_PRINT)
26  26
27+/* Most of these are taken from <sys/stat.h> */ 27+/* Most of these are taken from <sys/stat.h> */
28+typedef enum Colors { 28+typedef enum Colors {
29+ C_DIR, /* directory */ 29+ C_DIR, /* directory */
30+ C_LNK, /* symbolic link */ 30+ C_LNK, /* symbolic link */
31+ C_SOCK, /* socket */ 31+ C_SOCK, /* socket */
32+ C_FIFO, /* pipe */ 32+ C_FIFO, /* pipe */
33+ C_EXEC, /* executable */ 33+ C_EXEC, /* executable */
34+ C_BLK, /* block special */ 34+ C_BLK, /* block special */
35+ C_CHR, /* character special */ 35+ C_CHR, /* character special */
36+ C_SUID, /* setuid executable */ 36+ C_SUID, /* setuid executable */
37+ C_SGID, /* setgid executable */ 37+ C_SGID, /* setgid executable */
38+ C_WSDIR, /* directory writeble to others, with sticky bit */ 38+ C_WSDIR, /* directory writeble to others, with sticky bit */
39+ C_WDIR, /* directory writeble to others, without sticky bit */ 39+ C_WDIR, /* directory writeble to others, without sticky bit */
40+ C_NUMCOLORS /* just a place-holder */ 40+ C_NUMCOLORS /* just a place-holder */
41+} Colors ; 41+} Colors ;
42+ 42+
43+char *defcolors = "4x5x2x3x1x464301060203"; 43+char *defcolors = "4x5x2x3x1x464301060203";
44+ 44+
45+static int colors[C_NUMCOLORS][2]; 45+static int colors[C_NUMCOLORS][2];
46+ 46+
47 void 47 void
48 printscol(dp) 48 printscol(dp)
49 DISPLAY *dp; 49 DISPLAY *dp;
50@@ -97,15 +123,17 @@ printlong(dp) 50@@ -97,15 +123,17 @@ printlong(dp)
51 if (f_inode) 51 if (f_inode)
52 (void)printf("%*lu ", dp->s_inode, (u_long)sp->st_ino); 52 (void)printf("%*lu ", dp->s_inode, (u_long)sp->st_ino);
53 if (f_size) 53 if (f_size)
54- (void)printf("%*qd ", 54- (void)printf("%*qd ",
55- dp->s_block, howmany(sp->st_blocks, blocksize)); 55- dp->s_block, howmany(sp->st_blocks, blocksize));
56+ (void)printf("%*lld ", 56+ (void)printf("%*lld ",
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(";");
157+ } 158+ }
158+ if (colors[c][1] != -1) 159+ if (colors[c][1] != -1)
159+ printf("4%d", colors[c][1]); 160+ printf("4%d", colors[c][1]);
160+ printf("m"); 161+ printf("m");
161+} 162+}
162+ 163+
163+int 164+int
164+colortype(mode) 165+colortype(mode)
165+ mode_t mode; 166+ mode_t mode;
166+{ 167+{
167+ switch(mode & S_IFMT) { 168+ switch(mode & S_IFMT) {
168+ case S_IFDIR: 169+ case S_IFDIR:
169+ if (mode & S_IWOTH) 170+ if (mode & S_IWOTH)
170+ if (mode & S_ISTXT) 171+ if (mode & S_ISTXT)
171+ printcolor(C_WSDIR); 172+ printcolor(C_WSDIR);
172+ else 173+ else
173+ printcolor(C_WDIR); 174+ printcolor(C_WDIR);
174+ else 175+ else
175+ printcolor(C_DIR); 176+ printcolor(C_DIR);
176+ return(1); 177+ return(1);
177+ case S_IFLNK: 178+ case S_IFLNK:
178+ printcolor(C_LNK); 179+ printcolor(C_LNK);
179+ return(1); 180+ return(1);
180+ case S_IFSOCK: 181+ case S_IFSOCK:
181+ printcolor(C_SOCK); 182+ printcolor(C_SOCK);
182+ return(1); 183+ return(1);
183+ case S_IFIFO: 184+ case S_IFIFO:
184+ printcolor(C_FIFO); 185+ printcolor(C_FIFO);
185+ return(1); 186+ return(1);
186+ case S_IFBLK: 187+ case S_IFBLK:
187+ printcolor(C_BLK); 188+ printcolor(C_BLK);
188+ return(1); 189+ return(1);
189+ case S_IFCHR: 190+ case S_IFCHR:
190+ printcolor(C_CHR); 191+ printcolor(C_CHR);
191+ return(1); 192+ return(1);
192+ } 193+ }
193+ if (mode & (S_IXUSR | S_IXGRP | S_IXOTH)) { 194+ if (mode & (S_IXUSR | S_IXGRP | S_IXOTH)) {
194+ if (mode & S_ISUID) 195+ if (mode & S_ISUID)
195+ printcolor(C_SUID); 196+ printcolor(C_SUID);
196+ else if (mode & S_ISGID) 197+ else if (mode & S_ISGID)
197+ printcolor(C_SGID); 198+ printcolor(C_SGID);
198+ else 199+ else
199+ printcolor(C_EXEC); 200+ printcolor(C_EXEC);
200+ return(1); 201+ return(1);
201+ } 202+ }
202+ return(0); 203+ return(0);
203+} 204+}
204+ 205+
205+void 206+void
206+parsecolors(cs) 207+parsecolors(cs)
207+char *cs; 208+char *cs;
208+{ 209+{
209+ int i, j, len; 210+ int i, j, len;
210+ char c[2]; 211+ char c[2];
211+ if (cs == NULL) cs = ""; /* LSCOLORS not set */ 212+ if (cs == NULL) cs = ""; /* LSCOLORS not set */
212+ len = strlen(cs); 213+ len = strlen(cs);
213+ for (i = 0 ; i < C_NUMCOLORS ; i++) { 214+ for (i = 0 ; i < C_NUMCOLORS ; i++) {
214+ if (len <= 2*i) { 215+ if (len <= 2*i) {
215+ c[0] = defcolors[2*i]; 216+ c[0] = defcolors[2*i];
216+ c[1] = defcolors[2*i+1]; 217+ c[1] = defcolors[2*i+1];
217+ } 218+ }
218+ else { 219+ else {
219+ c[0] = cs[2*i]; 220+ c[0] = cs[2*i];
220+ c[1] = cs[2*i+1]; 221+ c[1] = cs[2*i+1];
221+ } 222+ }
222+ for (j = 0 ; j < 2 ; j++) { 223+ for (j = 0 ; j < 2 ; j++) {
223+ if ((c[j] < '0' || c[j] > '7') && 224+ if ((c[j] < '0' || c[j] > '7') &&
224+ tolower(c[j]) != 'x') { 225+ tolower(c[j]) != 'x') {
225+ fprintf(stderr, 226+ fprintf(stderr,
226+ "error: invalid character '%c' in LSCOLORS env var\n", 227+ "error: invalid character '%c' in LSCOLORS env var\n",
227+ c[j]); 228+ c[j]);
228+ c[j] = defcolors[2*i+j]; 229+ c[j] = defcolors[2*i+j];
229+ } 230+ }
230+ if (c[j] == 'x') 231+ if (c[j] == 'x')
231+ colors[i][j] = -1; 232+ colors[i][j] = -1;
232+ else 233+ else
233+ colors[i][j] = c[j]-'0'; 234+ colors[i][j] = c[j]-'0';
234+ } 235+ }
235+ } 236+ }
236+} 237+}
237+  238+
238 static void 239 static void
239 printlink(p) 240 printlink(p)
240 FTSENT *p; 241 FTSENT *p;