head 1.6; access; symbols pkgsrc-2026Q1:1.6.0.22 pkgsrc-2026Q1-base:1.6 pkgsrc-2025Q4:1.6.0.20 pkgsrc-2025Q4-base:1.6 pkgsrc-2025Q3:1.6.0.18 pkgsrc-2025Q3-base:1.6 pkgsrc-2025Q2:1.6.0.16 pkgsrc-2025Q2-base:1.6 pkgsrc-2025Q1:1.6.0.14 pkgsrc-2025Q1-base:1.6 pkgsrc-2024Q4:1.6.0.12 pkgsrc-2024Q4-base:1.6 pkgsrc-2024Q3:1.6.0.10 pkgsrc-2024Q3-base:1.6 pkgsrc-2024Q2:1.6.0.8 pkgsrc-2024Q2-base:1.6 pkgsrc-2024Q1:1.6.0.6 pkgsrc-2024Q1-base:1.6 pkgsrc-2023Q4:1.6.0.4 pkgsrc-2023Q4-base:1.6 pkgsrc-2023Q3:1.6.0.2 pkgsrc-2023Q3-base:1.6 pkgsrc-2023Q2:1.5.0.64 pkgsrc-2023Q2-base:1.5 pkgsrc-2023Q1:1.5.0.62 pkgsrc-2023Q1-base:1.5 pkgsrc-2022Q4:1.5.0.60 pkgsrc-2022Q4-base:1.5 pkgsrc-2022Q3:1.5.0.58 pkgsrc-2022Q3-base:1.5 pkgsrc-2022Q2:1.5.0.56 pkgsrc-2022Q2-base:1.5 pkgsrc-2022Q1:1.5.0.54 pkgsrc-2022Q1-base:1.5 pkgsrc-2021Q4:1.5.0.52 pkgsrc-2021Q4-base:1.5 pkgsrc-2021Q3:1.5.0.50 pkgsrc-2021Q3-base:1.5 pkgsrc-2021Q2:1.5.0.48 pkgsrc-2021Q2-base:1.5 pkgsrc-2021Q1:1.5.0.46 pkgsrc-2021Q1-base:1.5 pkgsrc-2020Q4:1.5.0.44 pkgsrc-2020Q4-base:1.5 pkgsrc-2020Q3:1.5.0.42 pkgsrc-2020Q3-base:1.5 pkgsrc-2020Q2:1.5.0.38 pkgsrc-2020Q2-base:1.5 pkgsrc-2020Q1:1.5.0.18 pkgsrc-2020Q1-base:1.5 pkgsrc-2019Q4:1.5.0.40 pkgsrc-2019Q4-base:1.5 pkgsrc-2019Q3:1.5.0.36 pkgsrc-2019Q3-base:1.5 pkgsrc-2019Q2:1.5.0.34 pkgsrc-2019Q2-base:1.5 pkgsrc-2019Q1:1.5.0.32 pkgsrc-2019Q1-base:1.5 pkgsrc-2018Q4:1.5.0.30 pkgsrc-2018Q4-base:1.5 pkgsrc-2018Q3:1.5.0.28 pkgsrc-2018Q3-base:1.5 pkgsrc-2018Q2:1.5.0.26 pkgsrc-2018Q2-base:1.5 pkgsrc-2018Q1:1.5.0.24 pkgsrc-2018Q1-base:1.5 pkgsrc-2017Q4:1.5.0.22 pkgsrc-2017Q4-base:1.5 pkgsrc-2017Q3:1.5.0.20 pkgsrc-2017Q3-base:1.5 pkgsrc-2017Q2:1.5.0.16 pkgsrc-2017Q2-base:1.5 pkgsrc-2017Q1:1.5.0.14 pkgsrc-2017Q1-base:1.5 pkgsrc-2016Q4:1.5.0.12 pkgsrc-2016Q4-base:1.5 pkgsrc-2016Q3:1.5.0.10 pkgsrc-2016Q3-base:1.5 pkgsrc-2016Q2:1.5.0.8 pkgsrc-2016Q2-base:1.5 pkgsrc-2016Q1:1.5.0.6 pkgsrc-2016Q1-base:1.5 pkgsrc-2015Q4:1.5.0.4 pkgsrc-2015Q4-base:1.5 pkgsrc-2015Q3:1.5.0.2 pkgsrc-2015Q3-base:1.5 pkgsrc-2015Q2:1.4.0.16 pkgsrc-2015Q2-base:1.4 pkgsrc-2015Q1:1.4.0.14 pkgsrc-2015Q1-base:1.4 pkgsrc-2014Q4:1.4.0.12 pkgsrc-2014Q4-base:1.4 pkgsrc-2014Q3:1.4.0.10 pkgsrc-2014Q3-base:1.4 pkgsrc-2014Q2:1.4.0.8 pkgsrc-2014Q2-base:1.4 pkgsrc-2014Q1:1.4.0.6 pkgsrc-2014Q1-base:1.4 pkgsrc-2013Q4:1.4.0.4 pkgsrc-2013Q4-base:1.4 pkgsrc-2013Q3:1.4.0.2 pkgsrc-2013Q3-base:1.4 pkgsrc-2013Q2:1.3.0.18 pkgsrc-2013Q2-base:1.3 pkgsrc-2013Q1:1.3.0.16 pkgsrc-2013Q1-base:1.3 pkgsrc-2012Q4:1.3.0.14 pkgsrc-2012Q4-base:1.3 pkgsrc-2012Q3:1.3.0.12 pkgsrc-2012Q3-base:1.3 pkgsrc-2012Q2:1.3.0.10 pkgsrc-2012Q2-base:1.3 pkgsrc-2012Q1:1.3.0.8 pkgsrc-2012Q1-base:1.3 pkgsrc-2011Q4:1.3.0.6 pkgsrc-2011Q4-base:1.3 pkgsrc-2011Q3:1.3.0.4 pkgsrc-2011Q3-base:1.3 pkgsrc-2011Q2:1.3.0.2 pkgsrc-2011Q2-base:1.3 pkgsrc-2011Q1:1.2.0.72 pkgsrc-2011Q1-base:1.2 pkgsrc-2010Q4:1.2.0.70 pkgsrc-2010Q4-base:1.2 pkgsrc-2010Q3:1.2.0.68 pkgsrc-2010Q3-base:1.2 pkgsrc-2010Q2:1.2.0.66 pkgsrc-2010Q2-base:1.2 pkgsrc-2010Q1:1.2.0.64 pkgsrc-2010Q1-base:1.2 pkgsrc-2009Q4:1.2.0.62 pkgsrc-2009Q4-base:1.2 pkgsrc-2009Q3:1.2.0.60 pkgsrc-2009Q3-base:1.2 pkgsrc-2009Q2:1.2.0.58 pkgsrc-2009Q2-base:1.2 pkgsrc-2009Q1:1.2.0.56 pkgsrc-2009Q1-base:1.2 pkgsrc-2008Q4:1.2.0.54 pkgsrc-2008Q4-base:1.2 pkgsrc-2008Q3:1.2.0.52 pkgsrc-2008Q3-base:1.2 cube-native-xorg:1.2.0.50 cube-native-xorg-base:1.2 pkgsrc-2008Q2:1.2.0.48 pkgsrc-2008Q2-base:1.2 cwrapper:1.2.0.46 pkgsrc-2008Q1:1.2.0.44 pkgsrc-2008Q1-base:1.2 pkgsrc-2007Q4:1.2.0.42 pkgsrc-2007Q4-base:1.2 pkgsrc-2007Q3:1.2.0.40 pkgsrc-2007Q3-base:1.2 pkgsrc-2007Q2:1.2.0.38 pkgsrc-2007Q2-base:1.2 pkgsrc-2007Q1:1.2.0.36 pkgsrc-2007Q1-base:1.2 pkgsrc-2006Q4:1.2.0.34 pkgsrc-2006Q4-base:1.2 pkgsrc-2006Q3:1.2.0.32 pkgsrc-2006Q3-base:1.2 pkgsrc-2006Q2:1.2.0.30 pkgsrc-2006Q2-base:1.2 pkgsrc-2006Q1:1.2.0.28 pkgsrc-2006Q1-base:1.2 pkgsrc-2005Q4:1.2.0.26 pkgsrc-2005Q4-base:1.2 pkgsrc-2005Q3:1.2.0.24 pkgsrc-2005Q3-base:1.2 pkgsrc-2005Q2:1.2.0.22 pkgsrc-2005Q2-base:1.2 pkgsrc-2005Q1:1.2.0.20 pkgsrc-2005Q1-base:1.2 pkgsrc-2004Q4:1.2.0.18 pkgsrc-2004Q4-base:1.2 pkgsrc-2004Q3:1.2.0.16 pkgsrc-2004Q3-base:1.2 pkgsrc-2004Q2:1.2.0.14 pkgsrc-2004Q2-base:1.2 pkgsrc-2004Q1:1.2.0.12 pkgsrc-2004Q1-base:1.2 pkgsrc-2003Q4:1.2.0.10 pkgsrc-2003Q4-base:1.2 netbsd-1-6-1:1.2.0.6 netbsd-1-6-1-base:1.2 netbsd-1-6:1.2.0.8 netbsd-1-6-RELEASE-base:1.2 pkgviews:1.2.0.4 pkgviews-base:1.2 buildlink2:1.2.0.2 buildlink2-base:1.2 netbsd-1-5-PATCH003:1.2 netbsd-1-5-PATCH001:1.2 netbsd-1-5-RELEASE:1.2 netbsd-1-4-PATCH003:1.2 netbsd-1-4-PATCH002:1.2 comdex-fall-1999:1.2 netbsd-1-4-PATCH001:1.2 netbsd-1-4-RELEASE:1.2 netbsd-1-3-PATCH003:1.2; locks; strict; comment @# @; 1.6 date 2023.09.14.00.48.31; author charlotte; state Exp; branches; next 1.5; commitid 46JOc5JvW8QuNFEE; 1.5 date 2015.07.09.11.44.09; author jperkin; state Exp; branches; next 1.4; commitid 8PWUs1MPC6CvvBsy; 1.4 date 2013.09.10.14.24.20; author joerg; state Exp; branches; next 1.3; commitid xMPb0meEmU7MPT4x; 1.3 date 2011.06.14.13.25.57; author wiz; state Exp; branches; next 1.2; 1.2 date 98.08.07.11.10.13; author agc; state Exp; branches; next 1.1; 1.1 date 98.05.21.14.06.37; author frueauf; state Exp; branches; next ; desc @@ 1.6 log @misc/colorls: Fix mangled datetime in long format ('colorls -l') @ text @$NetBSD: patch-ae,v 1.5 2015/07/09 11:44:09 jperkin Exp $ Use nbcompat, and fix mangled datetime formatting. --- 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 #include +#include #include #include +#if defined(HAVE_NBCOMPAT_H) +#include +#include +#else #include +#endif #include #include #include @@@@ -64,6 +70,26 @@@@ static int printtype __P((u_int)); #define IS_NOPRINT(p) ((p)->fts_number == NO_PRINT) +/* Most of these are taken from */ +typedef enum Colors { + C_DIR, /* directory */ + C_LNK, /* symbolic link */ + C_SOCK, /* socket */ + C_FIFO, /* pipe */ + C_EXEC, /* executable */ + C_BLK, /* block special */ + C_CHR, /* character special */ + C_SUID, /* setuid executable */ + C_SGID, /* setgid executable */ + C_WSDIR, /* directory writeble to others, with sticky bit */ + C_WDIR, /* directory writeble to others, without sticky bit */ + C_NUMCOLORS /* just a place-holder */ +} Colors ; + +char *defcolors = "4x5x2x3x1x464301060203"; + +static int colors[C_NUMCOLORS][2]; + void printscol(dp) DISPLAY *dp; @@@@ -97,15 +123,17 @@@@ printlong(dp) if (f_inode) (void)printf("%*lu ", dp->s_inode, (u_long)sp->st_ino); if (f_size) - (void)printf("%*qd ", - dp->s_block, howmany(sp->st_blocks, blocksize)); + (void)printf("%*lld ", + dp->s_block, (long long)howmany(sp->st_blocks, blocksize)); (void)strmode(sp->st_mode, buf); np = p->fts_pointer; (void)printf("%s %*u %-*s %-*s ", buf, dp->s_nlink, sp->st_nlink, dp->s_user, np->user, dp->s_group, np->group); +#ifndef __sun if (f_flags) (void)printf("%-*s ", dp->s_flags, np->flags); +#endif if (S_ISCHR(sp->st_mode) || S_ISBLK(sp->st_mode)) if (minor(sp->st_rdev) > 255) (void)printf("%3d, 0x%08x ", @@@@ -114,19 +142,23 @@@@ printlong(dp) (void)printf("%3d, %3d ", major(sp->st_rdev), minor(sp->st_rdev)); else if (dp->bcfile) - (void)printf("%*s%*qd ", - 8 - dp->s_size, "", dp->s_size, sp->st_size); + (void)printf("%*s%*lld ", + 8 - dp->s_size, "", dp->s_size, (long long)sp->st_size); else - (void)printf("%*qd ", dp->s_size, sp->st_size); + (void)printf("%*lld ", dp->s_size, (long long)sp->st_size); if (f_accesstime) printtime(sp->st_atime); else if (f_statustime) printtime(sp->st_ctime); else printtime(sp->st_mtime); + if (f_color) + (void)colortype(sp->st_mode); (void)printf("%s", p->fts_name); if (f_type) (void)printtype(sp->st_mode); + if (f_color) + (void)printf("\033[m"); if (S_ISLNK(sp->st_mode)) printlink(p); (void)putchar('\n'); @@@@ -190,7 +222,19 @@@@ printcol(dp) dp->s_block); if ((base += numrows) >= num) break; - while ((cnt = ((chcnt + TAB) & ~(TAB - 1))) <= endcol){ + + /* + * some terminals get confused if we mix tabs + * with color sequences + */ + if (f_color) + while ((cnt = (chcnt + 1)) <= endcol) { + (void)putchar(' '); + chcnt = cnt; + } + else + while ((cnt = ((chcnt + TAB) & ~(TAB - 1))) + <= endcol) { (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); if (f_size) - chcnt += printf("%*qd ", - (int)sizefield, howmany(sp->st_blocks, blocksize)); + chcnt += printf("%*lld ", + (int)sizefield, (long long)howmany(sp->st_blocks, blocksize)); + if (f_color) + (void)colortype(sp->st_mode); chcnt += printf("%s", p->fts_name); if (f_type) chcnt += printtype(sp->st_mode); + if (f_color) + printf("\033[m"); 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); } +void +printcolor(c) + Colors c; +{ + printf("\033["); + if (colors[c][0] != -1) { + printf("3%d", colors[c][0]); + if (colors[c][1] != -1) + printf(";"); + } + if (colors[c][1] != -1) + printf("4%d", colors[c][1]); + printf("m"); +} + +int +colortype(mode) + mode_t mode; +{ + switch(mode & S_IFMT) { + case S_IFDIR: + if (mode & S_IWOTH) + if (mode & S_ISTXT) + printcolor(C_WSDIR); + else + printcolor(C_WDIR); + else + printcolor(C_DIR); + return(1); + case S_IFLNK: + printcolor(C_LNK); + return(1); + case S_IFSOCK: + printcolor(C_SOCK); + return(1); + case S_IFIFO: + printcolor(C_FIFO); + return(1); + case S_IFBLK: + printcolor(C_BLK); + return(1); + case S_IFCHR: + printcolor(C_CHR); + return(1); + } + if (mode & (S_IXUSR | S_IXGRP | S_IXOTH)) { + if (mode & S_ISUID) + printcolor(C_SUID); + else if (mode & S_ISGID) + printcolor(C_SGID); + else + printcolor(C_EXEC); + return(1); + } + return(0); +} + +void +parsecolors(cs) +char *cs; +{ + int i, j, len; + char c[2]; + if (cs == NULL) cs = ""; /* LSCOLORS not set */ + len = strlen(cs); + for (i = 0 ; i < C_NUMCOLORS ; i++) { + if (len <= 2*i) { + c[0] = defcolors[2*i]; + c[1] = defcolors[2*i+1]; + } + else { + c[0] = cs[2*i]; + c[1] = cs[2*i+1]; + } + for (j = 0 ; j < 2 ; j++) { + if ((c[j] < '0' || c[j] > '7') && + tolower(c[j]) != 'x') { + fprintf(stderr, + "error: invalid character '%c' in LSCOLORS env var\n", + c[j]); + c[j] = defcolors[2*i+j]; + } + if (c[j] == 'x') + colors[i][j] = -1; + else + colors[i][j] = c[j]-'0'; + } + } +} + static void printlink(p) FTSENT *p; @ 1.5 log @Use nbcompat correctly, add patch comments. Fixes build on SunOS. @ text @d1 1 a1 1 $NetBSD: patch-ae,v 1.4 2013/09/10 14:24:20 joerg Exp $ d3 1 a3 1 Use nbcompat. d5 2 a6 2 --- print.c.orig 1996-12-21 23:40:58.000000000 +0000 +++ print.c d70 1 a70 1 @@@@ -114,20 +142,24 @@@@ printlong(dp) a91 1 - if (S_ISLNK(sp->st_mode)) d94 1 a94 1 + if (S_ISLNK(sp->st_mode)) d97 1 a97 2 } @@@@ -190,10 +222,22 @@@@ printcol(dp) a101 3 - (void)putchar('\t'); - chcnt = cnt; - } d115 3 a117 6 + (void)putchar('\t'); + chcnt = cnt; + } endcol += colwidth; } (void)putchar('\n'); d136 9 @ 1.4 log @Don't use non-standard %qd. @ text @d1 3 a3 1 $NetBSD: patch-ae,v 1.3 2011/06/14 13:25:57 wiz Exp $ d7 1 a7 1 @@@@ -43,6 +43,7 @@@@ static char const sccsid[] = "@@(#)print. d14 4 d19 5 a23 1 @@@@ -64,6 +65,26 @@@@ static int printtype __P((u_int)); d50 1 a50 1 @@@@ -97,8 +118,8 @@@@ printlong(dp) d61 10 a70 1 @@@@ -114,20 +135,24 @@@@ printlong(dp) d99 1 a99 1 @@@@ -190,10 +215,22 @@@@ printcol(dp) d126 1 a126 1 @@@@ -217,11 +254,15 @@@@ printaname(p, inodefield, sizefield) d144 1 a144 1 @@@@ -281,6 +322,96 @@@@ printtype(mode) @ 1.3 log @Fix build on NetBSD-current. From Daniel Loffgren in PR 45019. @ text @d1 1 a1 1 $NetBSD: patch-ae,v 1.2 1998/08/07 11:10:13 agc Exp $ d40 25 a64 1 @@@@ -124,10 +145,14 @@@@ printlong(dp) d107 3 a109 1 @@@@ -219,9 +256,13 @@@@ printaname(p, inodefield, sizefield) d111 4 a114 2 chcnt += printf("%*qd ", (int)sizefield, howmany(sp->st_blocks, blocksize)); @ 1.2 log @Add NetBSD RCS Ids. @ text @d1 1 a1 1 $NetBSD$ d3 11 a13 3 --- print.c.orig Sun Dec 22 00:40:58 1996 +++ print.c Thu May 21 15:42:08 1998 @@@@ -64,6 +64,26 @@@@ d40 1 a40 1 @@@@ -124,10 +144,14 @@@@ d56 1 a56 1 @@@@ -190,10 +214,22 @@@@ d83 1 a83 1 @@@@ -219,9 +255,13 @@@@ d97 1 a97 1 @@@@ -281,6 +321,95 @@@@ d116 1 @ 1.1 log @Handle MANZ case better and split the big patch file into one patch per file for better maintainance. @ text @d1 2 @