aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSatoshi Asami <asami@FreeBSD.org>2000-06-16 19:16:36 +0000
committerSatoshi Asami <asami@FreeBSD.org>2000-06-16 19:16:36 +0000
commitad52f33b880f816076631935440794fe3117ac0b (patch)
treeb0ce25582f505fe26feef0bedef0307bf1d0d0eb
parentcab18ae662340a8c8489666ff3df202cbe17ac07 (diff)
downloadports-ad52f33b880f816076631935440794fe3117ac0b.tar.gz
ports-ad52f33b880f816076631935440794fe3117ac0b.zip
Update colorls to use a new tarball (now 3-stable based) and use ache's
improvements instead of my own hack. Note that you need a "color-capable" terminal to use it -- in particular, this means set your TERM to "xterm-color" or "kterm-color" when using normal xterm or kterm, not "xterm" or "kterm" (which termcap doesn't know that are color-capable).
Notes
Notes: svn path=/head/; revision=29646
-rw-r--r--misc/colorls/Makefile6
-rw-r--r--misc/colorls/distinfo2
-rw-r--r--misc/colorls/files/patch-aa410
3 files changed, 308 insertions, 110 deletions
diff --git a/misc/colorls/Makefile b/misc/colorls/Makefile
index 26e397904c25..ac438144b8fb 100644
--- a/misc/colorls/Makefile
+++ b/misc/colorls/Makefile
@@ -1,5 +1,5 @@
# New ports collection makefile for: colorls
-# Version required: FreeBSD-2.2-stable (around August '98)
+# Version required: FreeBSD-3-stable (around June 2000)
# Date created: 8 March 1995
# Whom: Satoshi Asami
#
@@ -7,10 +7,10 @@
#
PORTNAME= colorls
-PORTVERSION= 2.2.7
+PORTVERSION= 3.4
CATEGORIES= misc
MASTER_SITES= ${MASTER_SITE_LOCAL}
-MASTER_SITE_SUBDIR= asami
+MASTER_SITE_SUBDIR= asami/colorls
DISTFILES= ls-${PORTVERSION}.tar.gz
MAINTAINER= asami@FreeBSD.org
diff --git a/misc/colorls/distinfo b/misc/colorls/distinfo
index 63b049082694..14c3394ad2fd 100644
--- a/misc/colorls/distinfo
+++ b/misc/colorls/distinfo
@@ -1 +1 @@
-MD5 (ls-2.2.7.tar.gz) = 60b6a15d9f2470f66607d22e15746d60
+MD5 (ls-3.4.tar.gz) = fd98746a9541c72a5110da77650f2ab6
diff --git a/misc/colorls/files/patch-aa b/misc/colorls/files/patch-aa
index 64f89c92561c..909706da555e 100644
--- a/misc/colorls/files/patch-aa
+++ b/misc/colorls/files/patch-aa
@@ -1,14 +1,51 @@
---- ls.c.orig Sun Jul 19 23:29:17 1998
-+++ ls.c Sun Nov 21 11:51:18 1999
-@@ -94,6 +94,7 @@
- int f_statustime; /* use time of last mode change */
+Index: ls.c
+===================================================================
+RCS file: /usr/cvs/src/bin/ls/ls.c,v
+retrieving revision 1.32
+retrieving revision 1.40
+diff -u -r1.32 -r1.40
+--- ls.c 2000/02/05 18:42:27 1.32
++++ ls.c 2000/06/06 13:02:52 1.40
+@@ -63,7 +63,11 @@
+ #include <stdlib.h>
+ #include <string.h>
+ #include <unistd.h>
+ #include <locale.h>
++#ifdef COLORLS
++#include <termcap.h>
++#include <signal.h>
++#endif
+
+ #include "ls.h"
+ #include "extern.h"
+@@ -111,6 +115,13 @@
int f_timesort; /* sort by time vice name */
int f_type; /* add type character for non-regular files */
+ int f_whiteout; /* show whiteout entries */
++#ifdef COLORLS
+int f_color; /* add type in color for non-regular files */
++
++char *ansi_bgcol; /* ANSI sequence to set background colour */
++char *ansi_fgcol; /* ANSI sequence to set foreground colour */
++char *ansi_coloff; /* ANSI sequence to reset colours */
++#endif
int rval;
-@@ -131,7 +132,7 @@
+@@ -124,6 +135,12 @@
+ int ch, fts_options, notused;
+ char *p;
+
++#ifdef COLORLS
++ char termcapbuf[1024]; /* termcap definition buffer */
++ char tcapbuf[512]; /* capability buffer */
++ char *bp = tcapbuf;
++#endif
++
+ (void) setlocale(LC_ALL, "");
+
+ /* Terminal defaults to -Cq, non-terminal defaults to -1. */
+@@ -148,7 +165,7 @@
f_listdot = 1;
fts_options = FTS_PHYSICAL;
@@ -17,57 +54,149 @@
switch (ch) {
/*
* The -1, -C and -l options all override each other so shell
-@@ -169,6 +170,10 @@
+@@ -186,6 +203,26 @@
case 'H':
fts_options |= FTS_COMFOLLOW;
break;
+ case 'G':
+ if (isatty(STDOUT_FILENO))
-+ f_color = 1;
++#ifdef COLORLS
++ if (tgetent(termcapbuf, getenv("TERM")) == 1) {
++ ansi_fgcol = tgetstr("AF", &bp);
++ ansi_bgcol = tgetstr("AB", &bp);
++
++ /* To switch colours off use 'op' if
++ * available, otherwise use 'oc', or
++ * don't do colours at all. */
++ ansi_coloff = tgetstr("op", &bp);
++ if (!ansi_coloff)
++ ansi_coloff = tgetstr("oc", &bp);
++ if (ansi_fgcol && ansi_bgcol && ansi_coloff)
++ f_color = 1;
++ }
++#else
++ (void)fprintf(stderr, "Color support not compiled in.\n");
++#endif
+ break;
case 'L':
fts_options &= ~FTS_PHYSICAL;
fts_options |= FTS_LOGICAL;
-@@ -236,18 +241,21 @@
+@@ -259,11 +296,30 @@
argc -= optind;
argv += optind;
-+ parsecolors(getenv("LSCOLORS"));
++#ifdef COLORLS
++ if (f_color) {
++ /*
++ * We can't put tabs and color sequences together:
++ * column number will be incremented incorrectly
++ * for "stty oxtabs" mode.
++ */
++ f_notabs = 1;
++ (void) signal(SIGINT, colorquit);
++ (void) signal(SIGQUIT, colorquit);
++ parsecolors(getenv("LSCOLORS"));
++ }
++#endif
+
/*
* If not -F, -i, -l, -s or -t options, don't require stat
- * information.
+- * information.
++ * information, unless in color mode in which case we do
++ * need this to determine which colors to display.
*/
- if (!f_inode && !f_longform && !f_size && !f_timesort && !f_type)
+ if (!f_inode && !f_longform && !f_size && !f_timesort && !f_type
-+ && !f_color)
++#ifdef COLORLS
++ && !f_color
++#endif
++ )
fts_options |= FTS_NOSTAT;
/*
- * If not -F, -d or -l options, follow any symbolic links listed on
- * the command line.
- */
-- if (!f_longform && !f_listdir && !f_type)
-+ if (!f_longform && !f_listdir && !f_type && !f_color)
- fts_options |= FTS_COMFOLLOW;
-
- /* If -l or -s, figure out block size. */
---- ./ls.h.org Sun Jul 19 23:29:17 1998
-+++ ./ls.h Mon Aug 24 01:24:27 1998
-@@ -52,6 +52,7 @@
- extern int f_size; /* list size in short listing */
+@@ -471,7 +527,11 @@
+ case 4: maxgroup = 0;
+ case 5: maxflags = 0;
+ case 6: maxsize = 0;
+- case 7: maxlen = 0, f_notabs = 0;
++ case 7: maxlen = 0;
++#ifdef COLORLS
++ if (!f_color)
++#endif
++ f_notabs = 0;
+ }
+ maxinode = makenines(maxinode);
+ maxblock = makenines(maxblock);
+Index: ls.h
+===================================================================
+RCS file: /usr/cvs/src/bin/ls/ls.h,v
+retrieving revision 1.11
+retrieving revision 1.13
+diff -u -r1.11 -r1.13
+--- ls.h 1999/08/27 23:14:32 1.11
++++ ls.h 2000/06/05 02:14:01 1.13
+@@ -53,6 +53,9 @@
extern int f_statustime; /* use time of last mode change */
+ extern int f_notabs; /* don't use tab-separated multi-col output */
extern int f_type; /* add type character for non-regular files */
++#ifdef COLORLS
+extern int f_color; /* add type in color for non-regular files */
++#endif
typedef struct {
FTSENT *list;
---- ./print.c.org Sun Jul 19 23:29:17 1998
-+++ ./print.c Mon Aug 24 01:29:28 1998
-@@ -64,6 +64,26 @@
+Index: extern.h
+===================================================================
+RCS file: /usr/cvs/src/bin/ls/extern.h,v
+retrieving revision 1.7
+retrieving revision 1.12
+diff -u -r1.7 -r1.12
+--- extern.h 1999/08/27 23:14:31 1.7
++++ extern.h 2000/06/06 07:14:01 1.12
+@@ -51,3 +51,11 @@
+ void usage __P((void));
+ int len_octal __P((char *, int));
+ int prn_octal __P((char *));
++#ifdef COLORLS
++void parsecolors __P((char *cs));
++void colorquit __P((int));
++
++extern char *ansi_fgcol;
++extern char *ansi_bgcol;
++extern char *ansi_coloff;
++#endif
+Index: print.c
+===================================================================
+RCS file: /usr/cvs/src/bin/ls/print.c,v
+retrieving revision 1.19
+retrieving revision 1.33
+diff -u -r1.19 -r1.33
+--- print.c 2000/01/06 14:40:10 1.19
++++ print.c 2000/06/06 16:39:24 1.33
+@@ -56,6 +56,11 @@
+ #include <string.h>
+ #include <time.h>
+ #include <unistd.h>
++#ifdef COLORLS
++#include <ctype.h>
++#include <termcap.h>
++#include <signal.h>
++#endif
+
+ #include "ls.h"
+ #include "extern.h"
+@@ -64,9 +69,35 @@
+ static void printlink __P((FTSENT *));
+ static void printtime __P((time_t));
+ static int printtype __P((u_int));
++#ifdef COLORLS
++static void endcolor __P((int));
++static int colortype __P((mode_t));
++#endif
#define IS_NOPRINT(p) ((p)->fts_number == NO_PRINT)
++#ifdef COLORLS
+/* Most of these are taken from <sys/stat.h> */
+typedef enum Colors {
+ C_DIR, /* directory */
@@ -87,84 +216,115 @@
+char *defcolors = "4x5x2x3x1x464301060203";
+
+static int colors[C_NUMCOLORS][2];
++#endif
+
void
printscol(dp)
DISPLAY *dp;
-@@ -124,10 +144,14 @@
+@@ -89,6 +120,9 @@
+ FTSENT *p;
+ NAMES *np;
+ char buf[20];
++#ifdef COLORLS
++ int color_printed = 0;
++#endif
+
+ if (dp->list->fts_level != FTS_ROOTLEVEL && (f_longform || f_size))
+ (void)printf("total %lu\n", howmany(dp->btotal, blocksize));
+@@ -128,8 +162,16 @@
printtime(sp->st_ctime);
else
printtime(sp->st_mtime);
++#ifdef COLORLS
+ if (f_color)
-+ (void)colortype(sp->st_mode);
++ color_printed = colortype(sp->st_mode);
++#endif
if (f_octal || f_octal_escape) (void)prn_octal(p->fts_name);
else (void)printf("%s", p->fts_name);
++#ifdef COLORLS
++ if (f_color && color_printed)
++ endcolor(0);
++#endif
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');
-@@ -191,10 +215,22 @@
- 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
-+ * 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;
-+ }
- endcol += colwidth;
- }
- (void)putchar('\n');
-@@ -220,8 +256,12 @@
+@@ -221,6 +263,9 @@
+ {
+ struct stat *sp;
+ int chcnt;
++#ifdef COLORLS
++ int color_printed = 0;
++#endif
+
+ sp = p->fts_statp;
+ chcnt = 0;
+@@ -229,8 +274,16 @@
if (f_size)
chcnt += printf("%*qd ",
(int)sizefield, howmany(sp->st_blocks, blocksize));
++#ifdef COLORLS
+ if (f_color)
-+ (void)colortype(sp->st_mode);
++ color_printed = colortype(sp->st_mode);
++#endif
chcnt += (f_octal || f_octal_escape) ? prn_octal(p->fts_name)
: printf("%s", p->fts_name);
-+ if (f_color)
-+ printf("\033[m");
++#ifdef COLORLS
++ if (f_color && color_printed)
++ endcolor(0);
++#endif
if (f_type)
chcnt += printtype(sp->st_mode);
return (chcnt);
-@@ -282,6 +322,95 @@
+@@ -294,6 +347,138 @@
return (0);
}
-+void
++#ifdef COLORLS
++static int
++putch(c)
++ int c;
++{
++ (void) putchar(c);
++ return 0;
++}
++
++static int
++writech(c)
++ int c;
++{
++ char tmp = c;
++
++ (void) write(STDOUT_FILENO, &tmp, 1);
++ return 0;
++}
++
++static void
+printcolor(c)
+ Colors c;
+{
-+ printf("\033[");
++ char *ansiseq;
++
+ if (colors[c][0] != -1) {
-+ printf("3%d", colors[c][0]);
-+ if (colors[c][1] != -1)
-+ printf(";");
++ ansiseq = tgoto(ansi_fgcol, 0, colors[c][0]);
++ if (ansiseq)
++ tputs(ansiseq, 1, putch);
++ }
++
++ if (colors[c][1] != -1) {
++ ansiseq = tgoto(ansi_bgcol, 0, colors[c][1]);
++ if (ansiseq)
++ tputs(ansiseq, 1, putch);
+ }
-+ if (colors[c][1] != -1)
-+ printf("4%d", colors[c][1]);
-+ printf("m");
+}
+
++static void
++endcolor(sig)
++ int sig;
++{
++ tputs(ansi_coloff, 1, sig ? writech : putch);
++}
++
++static int
+colortype(mode)
+ mode_t mode;
+{
@@ -212,6 +372,7 @@
+{
+ int i, j, len;
+ char c[2];
++
+ if (cs == NULL) cs = ""; /* LSCOLORS not set */
+ len = strlen(cs);
+ for (i = 0 ; i < C_NUMCOLORS ; i++) {
@@ -225,53 +386,92 @@
+ }
+ for (j = 0 ; j < 2 ; j++) {
+ if ((c[j] < '0' || c[j] > '7') &&
-+ tolower(c[j]) != 'x') {
++ tolower((unsigned char)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')
++ if (tolower((unsigned char)c[j]) == 'x')
+ colors[i][j] = -1;
+ else
+ colors[i][j] = c[j]-'0';
+ }
+ }
+}
++
++void
++colorquit(sig)
++ int sig;
++{
++ endcolor(sig);
++
++ (void) signal(sig, SIG_DFL);
++ (void) kill(getpid(), sig);
++}
++#endif /*COLORLS*/
+
static void
printlink(p)
FTSENT *p;
---- ./Makefile.org Mon Jul 7 03:02:47 1997
-+++ ./Makefile Mon Aug 24 01:24:27 1998
-@@ -1,7 +1,9 @@
- # @(#)Makefile 8.1 (Berkeley) 6/2/93
- # $Id: Makefile,v 1.2 1994/09/24 02:55:51 davidg Exp $
-
+Index: util.c
+===================================================================
+RCS file: /usr/cvs/src/bin/ls/util.c,v
+retrieving revision 1.20
+retrieving revision 1.21
+diff -u -r1.20 -r1.21
+--- util.c 1999/08/27 23:14:33 1.20
++++ util.c 2000/06/06 07:29:43 1.21
+@@ -158,7 +158,12 @@
+ void
+ usage()
+ {
+- (void)fprintf(stderr, "usage: ls [-ACFHLPRTWacdfgikloqrstu1]"
++ (void)fprintf(stderr,
++#ifdef COLORLS
++ "usage: ls [-ACFGHLPRTWacdfgikloqrstu1]"
++#else
++ "usage: ls [-ACFHLPRTWacdfgikloqrstu1]"
++#endif
+ " [file ...]\n");
+ exit(1);
+ }
+Index: Makefile
+===================================================================
+RCS file: /usr/cvs/src/bin/ls/Makefile,v
+retrieving revision 1.9
+retrieving revision 1.12
+diff -u -r1.9 -r1.12
+--- Makefile 2000/02/05 18:42:27 1.9
++++ Makefile 2000/06/05 19:34:31 1.12
+@@ -4,5 +4,13 @@
+
-PROG= ls
+PROG= colorls
SRCS= cmp.c stat_flags.c ls.c print.c util.c
+BINDIR= ${PREFIX}/bin
+MANDIR= ${PREFIX}/man/man
++.if !defined(RELEASE_BUILD_FIXIT)
++CFLAGS+= -DCOLORLS
++LDADD+= -ltermcap
++DPADD+= ${LIBTERMCAP}
++.endif
++
.include <bsd.prog.mk>
---- ./colorls.1.org Mon Aug 24 01:24:27 1998
-+++ ./colorls.1 Mon Aug 24 01:27:33 1998
-@@ -36,16 +36,24 @@
- .\" $Id: ls.1,v 1.5.2.6 1998/07/15 02:01:34 jkh Exp $
- .\"
- .Dd April 18, 1994
--.Dt LS 1
-+.Dt COLORLS 1
- .Os
- .Sh NAME
- .Nm ls
--.Nd list directory contents
-+.Nd list directory contents in color
+Index: colorls.1
+===================================================================
+RCS file: /usr/cvs/src/bin/ls/ls.1,v
+retrieving revision 1.33
+retrieving revision 1.35
+diff -u -r1.33 -r1.35
+--- colorls.1 2000/03/02 14:53:20 1.33
++++ colorls.1 2000/06/06 00:42:24 1.35
+@@ -43,7 +43,15 @@
+ .Nd list directory contents
.Sh SYNOPSIS
--.Nm ls
+ .Nm ls
-.Op Fl ABCFHLPRTWabcdfgikloqrstu1
-+.Nm colorls
+.Op Fl ABCFGHLPRTWabcdfgikloqrstu1
.Op Ar file ...
.Sh DESCRIPTION
@@ -284,22 +484,20 @@
+is for color display.)
+.Pp
For each operand that names a
- .Ar file
- of a type other than
-@@ -90,6 +98,12 @@
+@@ -90,6 +90,12 @@
a percent sign (%) after each whiteout,
and a vertical bar (|) after each that is a
.Tn FIFO .
+.It Fl G
-+Use ANSI color sequences to distinguish file types. (See
++Use termcap color sequences to distinguish file types. (See
+.Ev LSCOLORS
-+below.) In addition to those mentioned above in
++below.) In addition to those mentioned above in
+.Fl F ,
+some extra attributes (setuid bit set, etc.) are also displayed.
.It Fl H
Symbolic links on the command line are followed. This option is assumed if
none of the
-@@ -373,6 +387,74 @@
+@@ -386,6 +392,74 @@
See
.Xr environ 7
for more information.
@@ -325,7 +523,7 @@
+.It Sy 2
+green
+.It Sy 3
-+yellow
++brown
+.It Sy 4
+blue
+.It Sy 5
@@ -333,7 +531,7 @@
+.It Sy 6
+cyan
+.It Sy 7
-+white
++light grey
+.It Sy x
+default foreground or background
+.El
@@ -371,6 +569,6 @@
+The default is "4x5x2x3x1x464301060203", i.e., blue foreground and
+default background for regular directories, black foreground and red
+background for setuid executables, etc.
- .El
- .Sh COMPATIBILITY
- The group field is now automatically included in the long listing for
+ .It Ev LS_COLWIDTHS
+ If this variable is set, it is considered to be a
+ colon-delimited list of minimum column widths. Unreasonable