Update to 5.9, which has pledge(2) and UTF-8 improvements.
From Lauri Tirkkonen <lotheac@iki.fi>.
This commit is contained in:
parent
ed24c125fe
commit
fc9dfe4a28
@ -1,11 +1,10 @@
|
||||
# $OpenBSD: Makefile,v 1.32 2015/10/30 14:12:42 bentley Exp $
|
||||
# $OpenBSD: Makefile,v 1.33 2016/04/06 18:53:16 naddy Exp $
|
||||
|
||||
COMMENT= ls(1) that can use color to display file attributes
|
||||
|
||||
VERSION= 5.7
|
||||
VERSION= 5.9
|
||||
DISTNAME= ls-${VERSION}
|
||||
PKGNAME= colorls-${VERSION}
|
||||
REVISION= 1
|
||||
CATEGORIES= sysutils
|
||||
|
||||
MAINTAINER= Christian Weisgerber <naddy@openbsd.org>
|
||||
|
@ -1,2 +1,2 @@
|
||||
SHA256 (ls-5.7.tar.gz) = QcaZe1qiopv2HUm4eDlXjKxgWPVOOXUm3EyrCUJU5YI=
|
||||
SIZE (ls-5.7.tar.gz) = 12759
|
||||
SHA256 (ls-5.9.tar.gz) = w48YNQ+FbJ6bC6LPGUb3JK1Qf5KFdcMyNmBzOq1tZlU=
|
||||
SIZE (ls-5.9.tar.gz) = 13500
|
||||
|
@ -1,12 +1,12 @@
|
||||
$OpenBSD: patch-Makefile,v 1.12 2015/10/30 14:12:42 bentley Exp $
|
||||
--- Makefile.orig Wed Aug 6 13:09:09 2003
|
||||
+++ Makefile Thu Oct 29 00:55:06 2015
|
||||
$OpenBSD: patch-Makefile,v 1.13 2016/04/06 18:53:16 naddy Exp $
|
||||
--- Makefile.orig Tue Dec 1 19:36:13 2015
|
||||
+++ Makefile Wed Apr 6 19:05:04 2016
|
||||
@@ -1,8 +1,12 @@
|
||||
# $OpenBSD: patch-Makefile,v 1.12 2015/10/30 14:12:42 bentley Exp $
|
||||
# $OpenBSD: patch-Makefile,v 1.13 2016/04/06 18:53:16 naddy Exp $
|
||||
|
||||
-PROG= ls
|
||||
+PROG= colorls
|
||||
SRCS= cmp.c ls.c main.c print.c util.c
|
||||
SRCS= cmp.c ls.c main.c print.c util.c utf8.c
|
||||
-DPADD= ${LIBUTIL}
|
||||
-LDADD= -lutil
|
||||
+BINDIR= ${TRUEPREFIX}/bin
|
||||
|
@ -1,6 +1,6 @@
|
||||
$OpenBSD: patch-colorls_1,v 1.15 2014/11/29 19:16:48 naddy Exp $
|
||||
--- colorls.1.orig Sat Nov 29 19:57:03 2014
|
||||
+++ colorls.1 Sat Nov 29 20:02:08 2014
|
||||
$OpenBSD: patch-colorls_1,v 1.16 2016/04/06 18:53:16 naddy Exp $
|
||||
--- colorls.1.orig Wed Apr 6 19:24:58 2016
|
||||
+++ colorls.1 Wed Apr 6 19:26:02 2016
|
||||
@@ -37,11 +37,11 @@
|
||||
.Dt COLORLS 1
|
||||
.Os
|
||||
@ -38,7 +38,7 @@ $OpenBSD: patch-colorls_1,v 1.15 2014/11/29 19:16:48 naddy Exp $
|
||||
.It Ev BLOCKSIZE
|
||||
If the environment variable
|
||||
.Ev BLOCKSIZE
|
||||
@@ -435,11 +441,138 @@ option is not specified, the block counts
|
||||
@@ -435,6 +441,40 @@ option is not specified, the block counts
|
||||
(see
|
||||
.Fl s )
|
||||
will be displayed in units of that size block.
|
||||
@ -79,8 +79,10 @@ $OpenBSD: patch-colorls_1,v 1.15 2014/11/29 19:16:48 naddy Exp $
|
||||
.It COLUMNS
|
||||
If this variable contains a string representing a
|
||||
decimal integer, it is used as the
|
||||
column position width for displaying
|
||||
multiple-text-column output.
|
||||
@@ -446,6 +486,99 @@ If set to a string ending in
|
||||
.Nm
|
||||
respects character display widths when columnating output.
|
||||
Otherwise, non-ASCII bytes are replaced by question marks.
|
||||
+.It Ev LSCOLORS
|
||||
+The value of this variable describes what color to use for which
|
||||
+attribute when colors are enabled with
|
||||
@ -177,7 +179,7 @@ $OpenBSD: patch-colorls_1,v 1.15 2014/11/29 19:16:48 naddy Exp $
|
||||
.It Ev TZ
|
||||
The time zone to use when displaying dates.
|
||||
See
|
||||
@@ -447,33 +580,34 @@ See
|
||||
@@ -453,33 +586,34 @@ See
|
||||
for more information.
|
||||
.El
|
||||
.Sh EXIT STATUS
|
||||
@ -199,7 +201,7 @@ $OpenBSD: patch-colorls_1,v 1.15 2014/11/29 19:16:48 naddy Exp $
|
||||
.Pp
|
||||
List the files in
|
||||
.Pa /var/log ,
|
||||
sorting the output such that the mostly recently modified entries are
|
||||
sorting the output such that the most recently modified entries are
|
||||
printed first:
|
||||
.Pp
|
||||
-.Dl $ ls -lt /var/log
|
||||
@ -217,7 +219,7 @@ $OpenBSD: patch-colorls_1,v 1.15 2014/11/29 19:16:48 naddy Exp $
|
||||
utility is compliant with the
|
||||
.St -p1003.1-2008
|
||||
specification,
|
||||
@@ -482,10 +616,10 @@ except behaviour for the
|
||||
@@ -488,10 +622,10 @@ except behaviour for the
|
||||
flag differs.
|
||||
.Pp
|
||||
The flags
|
||||
@ -230,7 +232,7 @@ $OpenBSD: patch-colorls_1,v 1.15 2014/11/29 19:16:48 naddy Exp $
|
||||
are extensions to that specification.
|
||||
.Pp
|
||||
The flags
|
||||
@@ -505,6 +639,6 @@ flag has been changed in order to be compatible with t
|
||||
@@ -511,6 +645,6 @@ flag has been changed in order to be compatible with t
|
||||
specification.
|
||||
.Sh HISTORY
|
||||
An
|
||||
|
@ -1,11 +1,10 @@
|
||||
$OpenBSD: patch-extern_h,v 1.5 2015/10/30 14:12:42 bentley Exp $
|
||||
--- extern.h.orig Mon Jun 2 17:32:08 2003
|
||||
+++ extern.h Thu Oct 29 01:01:28 2015
|
||||
@@ -52,3 +52,14 @@ void printlong(DISPLAY *);
|
||||
$OpenBSD: patch-extern_h,v 1.6 2016/04/06 18:53:16 naddy Exp $
|
||||
--- extern.h.orig Tue Dec 1 19:36:13 2015
|
||||
+++ extern.h Wed Apr 6 19:12:57 2016
|
||||
@@ -52,3 +52,13 @@ void printlong(DISPLAY *);
|
||||
void printscol(DISPLAY *);
|
||||
void printstream(DISPLAY *);
|
||||
void usage(void);
|
||||
+size_t strwidth(char *);
|
||||
+#ifdef COLORLS
|
||||
+void parsecolors(const char *cs);
|
||||
+void colorquit(int);
|
||||
|
@ -1,16 +1,9 @@
|
||||
$OpenBSD: patch-ls_c,v 1.15 2015/10/30 14:12:42 bentley Exp $
|
||||
--- ls.c.orig Mon Mar 31 14:54:37 2014
|
||||
+++ ls.c Thu Oct 29 01:00:04 2015
|
||||
@@ -42,12 +42,17 @@
|
||||
#include <errno.h>
|
||||
#include <fts.h>
|
||||
#include <grp.h>
|
||||
+#include <locale.h>
|
||||
#include <pwd.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
$OpenBSD: patch-ls_c,v 1.16 2016/04/06 18:53:16 naddy Exp $
|
||||
--- ls.c.orig Tue Dec 1 19:36:13 2015
|
||||
+++ ls.c Wed Apr 6 20:33:39 2016
|
||||
@@ -50,6 +50,10 @@
|
||||
#include <limits.h>
|
||||
#include <locale.h>
|
||||
#include <util.h>
|
||||
+#ifdef COLORLS
|
||||
+#include <termcap.h>
|
||||
@ -19,7 +12,7 @@ $OpenBSD: patch-ls_c,v 1.15 2015/10/30 14:12:42 bentley Exp $
|
||||
|
||||
#include "ls.h"
|
||||
#include "extern.h"
|
||||
@@ -90,6 +95,15 @@ int f_statustime; /* use time of last mode change */
|
||||
@@ -92,6 +96,15 @@ int f_statustime; /* use time of last mode change */
|
||||
int f_stream; /* stream format */
|
||||
int f_type; /* add type character for non-regular files */
|
||||
int f_typedir; /* add type character for directories */
|
||||
@ -35,9 +28,9 @@ $OpenBSD: patch-ls_c,v 1.15 2015/10/30 14:12:42 bentley Exp $
|
||||
|
||||
int rval;
|
||||
|
||||
@@ -101,7 +115,14 @@ ls_main(int argc, char *argv[])
|
||||
@@ -103,6 +116,11 @@ ls_main(int argc, char *argv[])
|
||||
int ch, fts_options, notused;
|
||||
int kflag = 0;
|
||||
int kflag = 0, width = 0;
|
||||
char *p;
|
||||
+#ifdef COLORLS
|
||||
+ char termcapbuf[1024]; /* termcap definition buffer */
|
||||
@ -45,12 +38,21 @@ $OpenBSD: patch-ls_c,v 1.15 2015/10/30 14:12:42 bentley Exp $
|
||||
+ char *bp = tcapbuf;
|
||||
+#endif
|
||||
|
||||
+ setlocale(LC_CTYPE, "");
|
||||
+
|
||||
/* Terminal defaults to -Cq, non-terminal defaults to -1. */
|
||||
if (isatty(STDOUT_FILENO)) {
|
||||
if ((p = getenv("COLUMNS")) != NULL)
|
||||
@@ -122,7 +143,7 @@ ls_main(int argc, char *argv[])
|
||||
#ifndef SMALL
|
||||
setlocale(LC_CTYPE, "");
|
||||
@@ -128,7 +146,11 @@ ls_main(int argc, char *argv[])
|
||||
termwidth = width;
|
||||
}
|
||||
|
||||
+#ifdef COLORLS
|
||||
+ if (pledge("stdio rpath getpw tty", NULL) == -1)
|
||||
+#else
|
||||
if (pledge("stdio rpath getpw", NULL) == -1)
|
||||
+#endif
|
||||
err(1, "pledge");
|
||||
|
||||
/* Root is -A automatically. */
|
||||
@@ -136,7 +158,7 @@ ls_main(int argc, char *argv[])
|
||||
f_listdot = 1;
|
||||
|
||||
fts_options = FTS_PHYSICAL;
|
||||
@ -59,7 +61,7 @@ $OpenBSD: patch-ls_c,v 1.15 2015/10/30 14:12:42 bentley Exp $
|
||||
switch (ch) {
|
||||
/*
|
||||
* The -1, -C and -l, -m, -n and -x options all override each
|
||||
@@ -176,6 +197,9 @@ ls_main(int argc, char *argv[])
|
||||
@@ -190,6 +212,9 @@ ls_main(int argc, char *argv[])
|
||||
case 'F':
|
||||
f_type = 1;
|
||||
break;
|
||||
@ -69,7 +71,7 @@ $OpenBSD: patch-ls_c,v 1.15 2015/10/30 14:12:42 bentley Exp $
|
||||
case 'H':
|
||||
fts_options |= FTS_COMFOLLOW;
|
||||
break;
|
||||
@@ -248,19 +272,59 @@ ls_main(int argc, char *argv[])
|
||||
@@ -262,19 +287,59 @@ ls_main(int argc, char *argv[])
|
||||
if (f_grouponly == -1)
|
||||
f_grouponly = 0;
|
||||
|
||||
@ -132,14 +134,3 @@ $OpenBSD: patch-ls_c,v 1.15 2015/10/30 14:12:42 bentley Exp $
|
||||
fts_options |= FTS_COMFOLLOW;
|
||||
|
||||
/* If -l or -s, figure out block size. */
|
||||
@@ -463,8 +527,8 @@ display(FTSENT *p, FTSENT *list)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
- if (cur->fts_namelen > maxlen)
|
||||
- maxlen = cur->fts_namelen;
|
||||
+ if (strwidth(cur->fts_name) > maxlen)
|
||||
+ maxlen = strwidth(cur->fts_name);
|
||||
if (needstats) {
|
||||
sp = cur->fts_statp;
|
||||
if (sp->st_blocks > maxblock)
|
||||
|
@ -1,29 +1,24 @@
|
||||
$OpenBSD: patch-print_c,v 1.13 2015/10/30 14:12:42 bentley Exp $
|
||||
--- print.c.orig Thu Jan 15 23:39:32 2015
|
||||
+++ print.c Thu Oct 29 01:01:20 2015
|
||||
$OpenBSD: patch-print_c,v 1.14 2016/04/06 18:53:16 naddy Exp $
|
||||
--- print.c.orig Tue Dec 1 19:36:13 2015
|
||||
+++ print.c Wed Apr 6 20:47:37 2016
|
||||
@@ -1,4 +1,4 @@
|
||||
-/* $OpenBSD: patch-print_c,v 1.13 2015/10/30 14:12:42 bentley Exp $ */
|
||||
+/* $OpenBSD: patch-print_c,v 1.13 2015/10/30 14:12:42 bentley Exp $ */
|
||||
-/* $OpenBSD: patch-print_c,v 1.14 2016/04/06 18:53:16 naddy Exp $ */
|
||||
+/* $OpenBSD: patch-print_c,v 1.14 2016/04/06 18:53:16 naddy Exp $ */
|
||||
/* $NetBSD: print.c,v 1.15 1996/12/11 03:25:39 thorpej Exp $ */
|
||||
|
||||
/*
|
||||
@@ -45,10 +45,14 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
-#include <tzfile.h>
|
||||
@@ -48,6 +48,10 @@
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <util.h>
|
||||
+#ifdef COLORLS
|
||||
+#include <ctype.h>
|
||||
+#include <termcap.h>
|
||||
+#include <signal.h>
|
||||
+#endif
|
||||
|
||||
#include "ls.h"
|
||||
#include "extern.h"
|
||||
@@ -59,12 +63,44 @@ static void printsize(size_t, off_t);
|
||||
@@ -58,6 +62,10 @@ static void printsize(size_t, off_t);
|
||||
static void printtime(time_t);
|
||||
static int printtype(u_int);
|
||||
static int compute_columns(DISPLAY *, int *);
|
||||
@ -34,12 +29,10 @@ $OpenBSD: patch-print_c,v 1.13 2015/10/30 14:12:42 bentley Exp $
|
||||
|
||||
#define IS_NOPRINT(p) ((p)->fts_number == NO_PRINT)
|
||||
|
||||
#define DATELEN 64
|
||||
-#define SIXMONTHS ((DAYSPERNYEAR / 2) * SECSPERDAY)
|
||||
@@ -66,6 +74,32 @@ static int compute_columns(DISPLAY *, int *);
|
||||
#define SECSPERDAY (24 * 60 * 60)
|
||||
#define SIXMONTHS (SECSPERDAY * 365 / 2)
|
||||
|
||||
+#define SECSPERDAY (24 * 60 * 60)
|
||||
+#define SIXMONTHS (SECSPERDAY * 365 / 2)
|
||||
+
|
||||
+#ifdef COLORLS
|
||||
+/* Most of these are taken from <sys/stat.h> */
|
||||
+typedef enum Colors {
|
||||
@ -69,7 +62,7 @@ $OpenBSD: patch-print_c,v 1.13 2015/10/30 14:12:42 bentley Exp $
|
||||
void
|
||||
printscol(DISPLAY *dp)
|
||||
{
|
||||
@@ -85,6 +121,9 @@ printlong(DISPLAY *dp)
|
||||
@@ -86,6 +120,9 @@ printlong(DISPLAY *dp)
|
||||
FTSENT *p;
|
||||
NAMES *np;
|
||||
char buf[20];
|
||||
@ -79,7 +72,7 @@ $OpenBSD: patch-print_c,v 1.13 2015/10/30 14:12:42 bentley Exp $
|
||||
|
||||
if (dp->list->fts_level != FTS_ROOTLEVEL && (f_longform || f_size))
|
||||
(void)printf("total %llu\n", howmany(dp->btotal, blocksize));
|
||||
@@ -121,7 +160,15 @@ printlong(DISPLAY *dp)
|
||||
@@ -122,7 +159,15 @@ printlong(DISPLAY *dp)
|
||||
printtime(sp->st_ctime);
|
||||
else
|
||||
printtime(sp->st_mtime);
|
||||
@ -87,7 +80,7 @@ $OpenBSD: patch-print_c,v 1.13 2015/10/30 14:12:42 bentley Exp $
|
||||
+ if (f_color)
|
||||
+ color_printed = colortype(sp->st_mode);
|
||||
+#endif
|
||||
(void)putname(p->fts_name);
|
||||
(void)mbsprint(p->fts_name, 1);
|
||||
+#ifdef COLORLS
|
||||
+ if (f_color && color_printed)
|
||||
+ endcolor(0);
|
||||
@ -95,7 +88,7 @@ $OpenBSD: patch-print_c,v 1.13 2015/10/30 14:12:42 bentley Exp $
|
||||
if (f_type || (f_typedir && S_ISDIR(sp->st_mode)))
|
||||
(void)printtype(sp->st_mode);
|
||||
if (S_ISLNK(sp->st_mode))
|
||||
@@ -221,6 +268,9 @@ printaname(FTSENT *p, u_long inodefield, u_long sizefi
|
||||
@@ -222,6 +267,9 @@ printaname(FTSENT *p, u_long inodefield, u_long sizefi
|
||||
{
|
||||
struct stat *sp;
|
||||
int chcnt;
|
||||
@ -105,33 +98,23 @@ $OpenBSD: patch-print_c,v 1.13 2015/10/30 14:12:42 bentley Exp $
|
||||
|
||||
sp = p->fts_statp;
|
||||
chcnt = 0;
|
||||
@@ -230,7 +280,15 @@ printaname(FTSENT *p, u_long inodefield, u_long sizefi
|
||||
@@ -231,7 +279,15 @@ printaname(FTSENT *p, u_long inodefield, u_long sizefi
|
||||
if (f_size)
|
||||
chcnt += printf("%*qd ",
|
||||
(int)sizefield, howmany(sp->st_blocks, blocksize));
|
||||
+#ifdef COLORLS
|
||||
+ if (f_color)
|
||||
+ color_printed = colortype(sp->st_mode);
|
||||
+#endif
|
||||
chcnt += putname(p->fts_name);
|
||||
+#endif
|
||||
chcnt += mbsprint(p->fts_name, 1);
|
||||
+#ifdef COLORLS
|
||||
+ if (f_color && color_printed)
|
||||
+ endcolor(0);
|
||||
+#endif
|
||||
+#endif
|
||||
if (f_type || (f_typedir && S_ISDIR(sp->st_mode)))
|
||||
chcnt += printtype(sp->st_mode);
|
||||
return (chcnt);
|
||||
@@ -309,7 +367,8 @@ printstream(DISPLAY *dp)
|
||||
continue;
|
||||
if (col > 0) {
|
||||
(void)putchar(','), col++;
|
||||
- if (col + 1 + extwidth + p->fts_namelen >= termwidth)
|
||||
+ if (col + 1 + extwidth + strwidth(p->fts_name) >=
|
||||
+ termwidth)
|
||||
(void)putchar('\n'), col = 0;
|
||||
else
|
||||
(void)putchar(' '), col++;
|
||||
@@ -342,6 +401,151 @@ printtype(u_int mode)
|
||||
@@ -344,6 +400,151 @@ printtype(u_int mode)
|
||||
}
|
||||
return (0);
|
||||
}
|
||||
|
@ -1,98 +1,7 @@
|
||||
$OpenBSD: patch-util_c,v 1.10 2015/10/30 14:12:42 bentley Exp $
|
||||
--- util.c.orig Thu Nov 21 08:54:45 2013
|
||||
+++ util.c Thu Oct 29 01:08:52 2015
|
||||
@@ -38,13 +38,16 @@
|
||||
|
||||
#include <ctype.h>
|
||||
#include <fts.h>
|
||||
+#include <limits.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
+#include <wchar.h>
|
||||
|
||||
#include "ls.h"
|
||||
#include "extern.h"
|
||||
|
||||
+#ifdef SMALL
|
||||
int
|
||||
putname(char *name)
|
||||
{
|
||||
@@ -55,11 +58,85 @@ putname(char *name)
|
||||
return len;
|
||||
}
|
||||
|
||||
+size_t
|
||||
+strwidth(char *s)
|
||||
+{
|
||||
+ return strlen(s);
|
||||
+}
|
||||
+#else
|
||||
+int
|
||||
+putname(char *name)
|
||||
+{
|
||||
+ int len;
|
||||
+ wchar_t wc;
|
||||
+ size_t n;
|
||||
+ mbstate_t mbs;
|
||||
+ int w;
|
||||
+
|
||||
+ len = 0;
|
||||
+ bzero(&mbs, sizeof(mbs));
|
||||
+ while (*name) {
|
||||
+ n = mbrtowc(&wc, name, MB_CUR_MAX, &mbs);
|
||||
+ if (n == 0)
|
||||
+ break;
|
||||
+ if (n == (size_t)-1 || n == (size_t)-2) {
|
||||
+ /* Filename encoding doesn't match locale encoding.
|
||||
+ * Fall back to printing single bytes. */
|
||||
+ while (*name) {
|
||||
+ putchar((!isprint(*name) && f_nonprint)
|
||||
+ ? '?' : *name);
|
||||
+ len++;
|
||||
+ name++;
|
||||
+ }
|
||||
+ return len;
|
||||
+ }
|
||||
+ name += n;
|
||||
+ if (!iswprint(wc) && f_nonprint) {
|
||||
+ putchar('?');
|
||||
+ len++;
|
||||
+ } else {
|
||||
+ putwchar(wc);
|
||||
+ w = wcwidth(wc);
|
||||
+ if (w > 0)
|
||||
+ len += w;
|
||||
+ }
|
||||
+ }
|
||||
+ return len;
|
||||
+}
|
||||
+
|
||||
+size_t
|
||||
+strwidth(char *s)
|
||||
+{
|
||||
+ int width, n;
|
||||
+ wchar_t wc;
|
||||
+
|
||||
+ width = 0;
|
||||
+ while ((n = mbtowc(&wc, s, MB_LEN_MAX)) != 0) {
|
||||
+ if (n == -1) {
|
||||
+ width++;
|
||||
+ s++;
|
||||
+ } else if (iswprint(wc)) {
|
||||
+ width += wcwidth(wc);
|
||||
+ s += n;
|
||||
+ } else {
|
||||
+ width++;
|
||||
+ s += n;
|
||||
+ }
|
||||
+ }
|
||||
+
|
||||
+ return width;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
void
|
||||
$OpenBSD: patch-util_c,v 1.11 2016/04/06 18:53:16 naddy Exp $
|
||||
--- util.c.orig Tue Dec 1 19:36:13 2015
|
||||
+++ util.c Wed Apr 6 20:28:44 2016
|
||||
@@ -64,7 +64,11 @@ void
|
||||
usage(void)
|
||||
{
|
||||
(void)fprintf(stderr,
|
||||
|
Loading…
Reference in New Issue
Block a user