fish: Prepare for the 2.4 update
This commit is contained in:
parent
0c3f26971d
commit
ebfe961e75
|
@ -0,0 +1,28 @@
|
|||
TERMUX_PKG_HOMEPAGE=http://fishshell.com/
|
||||
TERMUX_PKG_DESCRIPTION="Shell geared towards interactive use"
|
||||
TERMUX_PKG_VERSION=2.4~b1
|
||||
# TERMUX_PKG_SRCURL=https://github.com/fish-shell/fish-shell/releases/download/$TERMUX_PKG_VERSION/fish-${TERMUX_PKG_VERSION}.tar.gz
|
||||
TERMUX_PKG_SRCURL=https://github.com/fish-shell/fish-shell/releases/download/2.4b1/fish-2.4b1.tar.gz
|
||||
# fish calls 'tput' from ncurses-utils, at least when cancelling (Ctrl+C) a command line.
|
||||
# man is needed since fish calls apropos during command completion.
|
||||
TERMUX_PKG_DEPENDS="ncurses, libandroid-support, ncurses-utils, man"
|
||||
TERMUX_PKG_BUILD_IN_SRC=yes
|
||||
# TERMUX_PKG_FOLDERNAME=fish-$TERMUX_PKG_VERSION
|
||||
TERMUX_PKG_FOLDERNAME=fish-2.4b1
|
||||
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_file__proc_self_stat=yes"
|
||||
|
||||
termux_step_pre_configure() {
|
||||
CXXFLAGS+=" $CPPFLAGS"
|
||||
|
||||
# The column(1) utility is used by oh-my-fish, so we bundle column.c from bsdmainutils with it:
|
||||
$CC $CFLAGS $LDFLAGS -DLINE_MAX=_POSIX2_LINE_MAX $TERMUX_PKG_BUILDER_DIR/column.c -o $TERMUX_PREFIX/bin/column
|
||||
}
|
||||
|
||||
termux_step_post_make_install () {
|
||||
cat >> $TERMUX_PREFIX/etc/fish/config.fish <<HERE
|
||||
|
||||
function __fish_command_not_found_handler --on-event fish_command_not_found
|
||||
$TERMUX_PREFIX/libexec/termux/command-not-found \$argv[1]
|
||||
end
|
||||
HERE
|
||||
}
|
|
@ -0,0 +1,338 @@
|
|||
/*
|
||||
* Copyright (c) 1989, 1993, 1994
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
static const char copyright[] =
|
||||
"@(#) Copyright (c) 1989, 1993, 1994\n\
|
||||
The Regents of the University of California. All rights reserved.\n";
|
||||
#endif
|
||||
|
||||
#if 0
|
||||
#ifndef lint
|
||||
static char sccsid[] = "@(#)column.c 8.4 (Berkeley) 5/4/95";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#include <err.h>
|
||||
#include <limits.h>
|
||||
#include <locale.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
|
||||
#define TAB 8
|
||||
|
||||
void c_columnate(void);
|
||||
void input(FILE *);
|
||||
void maketbl(void);
|
||||
void print(void);
|
||||
void r_columnate(void);
|
||||
void usage(void);
|
||||
int width(const wchar_t *);
|
||||
|
||||
int termwidth = 80; /* default terminal width */
|
||||
|
||||
int entries; /* number of records */
|
||||
int eval; /* exit value */
|
||||
int maxlength; /* longest record */
|
||||
wchar_t **list; /* array of pointers to records */
|
||||
const wchar_t *separator = L"\t "; /* field separator for table option */
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
struct winsize win;
|
||||
FILE *fp;
|
||||
int ch, tflag, xflag;
|
||||
char *p;
|
||||
const char *src;
|
||||
wchar_t *newsep;
|
||||
size_t seplen;
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
if (ioctl(1, TIOCGWINSZ, &win) == -1 || !win.ws_col) {
|
||||
if ((p = getenv("COLUMNS")))
|
||||
termwidth = atoi(p);
|
||||
} else
|
||||
termwidth = win.ws_col;
|
||||
|
||||
tflag = xflag = 0;
|
||||
while ((ch = getopt(argc, argv, "c:s:tx")) != -1)
|
||||
switch(ch) {
|
||||
case 'c':
|
||||
termwidth = atoi(optarg);
|
||||
break;
|
||||
case 's':
|
||||
src = optarg;
|
||||
seplen = mbsrtowcs(NULL, &src, 0, NULL);
|
||||
if (seplen == (size_t)-1)
|
||||
err(1, "bad separator");
|
||||
newsep = malloc((seplen + 1) * sizeof(wchar_t));
|
||||
if (newsep == NULL)
|
||||
err(1, NULL);
|
||||
mbsrtowcs(newsep, &src, seplen + 1, NULL);
|
||||
separator = newsep;
|
||||
break;
|
||||
case 't':
|
||||
tflag = 1;
|
||||
break;
|
||||
case 'x':
|
||||
xflag = 1;
|
||||
break;
|
||||
case '?':
|
||||
default:
|
||||
usage();
|
||||
}
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (!*argv)
|
||||
input(stdin);
|
||||
else for (; *argv; ++argv)
|
||||
if ((fp = fopen(*argv, "r"))) {
|
||||
input(fp);
|
||||
(void)fclose(fp);
|
||||
} else {
|
||||
warn("%s", *argv);
|
||||
eval = 1;
|
||||
}
|
||||
|
||||
if (!entries)
|
||||
exit(eval);
|
||||
|
||||
maxlength = roundup(maxlength + 1, TAB);
|
||||
if (tflag)
|
||||
maketbl();
|
||||
else if (maxlength >= termwidth)
|
||||
print();
|
||||
else if (xflag)
|
||||
c_columnate();
|
||||
else
|
||||
r_columnate();
|
||||
exit(eval);
|
||||
}
|
||||
|
||||
void
|
||||
c_columnate(void)
|
||||
{
|
||||
int chcnt, col, cnt, endcol, numcols;
|
||||
wchar_t **lp;
|
||||
|
||||
numcols = termwidth / maxlength;
|
||||
endcol = maxlength;
|
||||
for (chcnt = col = 0, lp = list;; ++lp) {
|
||||
wprintf(L"%ls", *lp);
|
||||
chcnt += width(*lp);
|
||||
if (!--entries)
|
||||
break;
|
||||
if (++col == numcols) {
|
||||
chcnt = col = 0;
|
||||
endcol = maxlength;
|
||||
putwchar('\n');
|
||||
} else {
|
||||
while ((cnt = roundup(chcnt + 1, TAB)) <= endcol) {
|
||||
(void)putwchar('\t');
|
||||
chcnt = cnt;
|
||||
}
|
||||
endcol += maxlength;
|
||||
}
|
||||
}
|
||||
if (chcnt)
|
||||
putwchar('\n');
|
||||
}
|
||||
|
||||
void
|
||||
r_columnate(void)
|
||||
{
|
||||
int base, chcnt, cnt, col, endcol, numcols, numrows, row;
|
||||
|
||||
numcols = termwidth / maxlength;
|
||||
numrows = entries / numcols;
|
||||
if (entries % numcols)
|
||||
++numrows;
|
||||
|
||||
for (row = 0; row < numrows; ++row) {
|
||||
endcol = maxlength;
|
||||
for (base = row, chcnt = col = 0; col < numcols; ++col) {
|
||||
wprintf(L"%ls", list[base]);
|
||||
chcnt += width(list[base]);
|
||||
if ((base += numrows) >= entries)
|
||||
break;
|
||||
while ((cnt = roundup(chcnt + 1, TAB)) <= endcol) {
|
||||
(void)putwchar('\t');
|
||||
chcnt = cnt;
|
||||
}
|
||||
endcol += maxlength;
|
||||
}
|
||||
putwchar('\n');
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
print(void)
|
||||
{
|
||||
int cnt;
|
||||
wchar_t **lp;
|
||||
|
||||
for (cnt = entries, lp = list; cnt--; ++lp)
|
||||
(void)wprintf(L"%ls\n", *lp);
|
||||
}
|
||||
|
||||
typedef struct _tbl {
|
||||
wchar_t **list;
|
||||
int cols, *len;
|
||||
} TBL;
|
||||
#define DEFCOLS 25
|
||||
|
||||
void
|
||||
maketbl(void)
|
||||
{
|
||||
TBL *t;
|
||||
int coloff, cnt;
|
||||
wchar_t *p, **lp;
|
||||
int *lens, maxcols;
|
||||
TBL *tbl;
|
||||
wchar_t **cols;
|
||||
wchar_t *last;
|
||||
|
||||
if ((t = tbl = calloc(entries, sizeof(TBL))) == NULL)
|
||||
err(1, (char *)NULL);
|
||||
if ((cols = calloc((maxcols = DEFCOLS), sizeof(*cols))) == NULL)
|
||||
err(1, (char *)NULL);
|
||||
if ((lens = calloc(maxcols, sizeof(int))) == NULL)
|
||||
err(1, (char *)NULL);
|
||||
for (cnt = 0, lp = list; cnt < entries; ++cnt, ++lp, ++t) {
|
||||
for (coloff = 0, p = *lp;
|
||||
(cols[coloff] = wcstok(p, separator, &last));
|
||||
p = NULL)
|
||||
if (++coloff == maxcols) {
|
||||
if (!(cols = realloc(cols, ((u_int)maxcols +
|
||||
DEFCOLS) * sizeof(char *))) ||
|
||||
!(lens = realloc(lens,
|
||||
((u_int)maxcols + DEFCOLS) * sizeof(int))))
|
||||
err(1, NULL);
|
||||
memset((char *)lens + maxcols * sizeof(int),
|
||||
0, DEFCOLS * sizeof(int));
|
||||
maxcols += DEFCOLS;
|
||||
}
|
||||
if ((t->list = calloc(coloff, sizeof(*t->list))) == NULL)
|
||||
err(1, (char *)NULL);
|
||||
if ((t->len = calloc(coloff, sizeof(int))) == NULL)
|
||||
err(1, (char *)NULL);
|
||||
for (t->cols = coloff; --coloff >= 0;) {
|
||||
t->list[coloff] = cols[coloff];
|
||||
t->len[coloff] = width(cols[coloff]);
|
||||
if (t->len[coloff] > lens[coloff])
|
||||
lens[coloff] = t->len[coloff];
|
||||
}
|
||||
}
|
||||
for (cnt = 0, t = tbl; cnt < entries; ++cnt, ++t) {
|
||||
for (coloff = 0; coloff < t->cols - 1; ++coloff)
|
||||
(void)wprintf(L"%ls%*ls", t->list[coloff],
|
||||
lens[coloff] - t->len[coloff] + 2, L" ");
|
||||
(void)wprintf(L"%ls\n", t->list[coloff]);
|
||||
}
|
||||
}
|
||||
|
||||
#define DEFNUM 1000
|
||||
#define MAXLINELEN (LINE_MAX + 1)
|
||||
|
||||
void
|
||||
input(FILE *fp)
|
||||
{
|
||||
static int maxentry;
|
||||
int len;
|
||||
wchar_t *p, buf[MAXLINELEN];
|
||||
|
||||
if (!list)
|
||||
if ((list = calloc((maxentry = DEFNUM), sizeof(*list))) ==
|
||||
NULL)
|
||||
err(1, (char *)NULL);
|
||||
while (fgetws(buf, MAXLINELEN, fp)) {
|
||||
for (p = buf; *p && iswspace(*p); ++p);
|
||||
if (!*p)
|
||||
continue;
|
||||
if (!(p = wcschr(p, L'\n'))) {
|
||||
warnx("line too long");
|
||||
eval = 1;
|
||||
continue;
|
||||
}
|
||||
*p = L'\0';
|
||||
len = width(buf);
|
||||
if (maxlength < len)
|
||||
maxlength = len;
|
||||
if (entries == maxentry) {
|
||||
maxentry += DEFNUM;
|
||||
if (!(list = realloc(list,
|
||||
(u_int)maxentry * sizeof(*list))))
|
||||
err(1, NULL);
|
||||
}
|
||||
list[entries] = malloc((wcslen(buf) + 1) * sizeof(wchar_t));
|
||||
if (list[entries] == NULL)
|
||||
err(1, NULL);
|
||||
wcscpy(list[entries], buf);
|
||||
entries++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Like wcswidth(), but ignores non-printing characters. */
|
||||
int
|
||||
width(const wchar_t *wcs)
|
||||
{
|
||||
int w, cw;
|
||||
|
||||
for (w = 0; *wcs != L'\0'; wcs++)
|
||||
if ((cw = wcwidth(*wcs)) > 0)
|
||||
w += cw;
|
||||
return (w);
|
||||
}
|
||||
|
||||
void
|
||||
usage(void)
|
||||
{
|
||||
|
||||
(void)fprintf(stderr,
|
||||
"usage: column [-tx] [-c columns] [-s sep] [file ...]\n");
|
||||
exit(1);
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
diff -u -r ../fish-2.4b1/configure.ac ./configure.ac
|
||||
--- ../fish-2.4b1/configure.ac 2016-10-18 10:17:06.000000000 -0400
|
||||
+++ ./configure.ac 2016-10-19 17:39:47.630582854 -0400
|
||||
@@ -251,8 +251,6 @@
|
||||
|
||||
# Check for os dependant libraries for all binaries.
|
||||
AC_SEARCH_LIBS( connect, socket, , [AC_MSG_ERROR([Cannot find the socket library, needed to build this package.] )] )
|
||||
-AC_SEARCH_LIBS( nanosleep, rt, , [AC_MSG_ERROR([Cannot find the rt library, needed to build this package.] )] )
|
||||
-AC_SEARCH_LIBS( shm_open, rt, , [AC_MSG_ERROR([Cannot find the rt library, needed to build this package.] )] )
|
||||
AC_SEARCH_LIBS( pthread_create, pthread, , [AC_MSG_ERROR([Cannot find the pthread library, needed to build this package.] )] )
|
||||
AC_SEARCH_LIBS( setupterm, [ncurses tinfo curses], , [AC_MSG_ERROR([Could not find a curses implementation, needed to build fish. If this is Linux, try running 'sudo apt-get install libncurses5-dev' or 'sudo yum install ncurses-devel'])] )
|
||||
AC_SEARCH_LIBS( [dladdr], [dl] )
|
|
@ -0,0 +1,20 @@
|
|||
diff -u -r ../fish-2.4b1/share/functions/__fish_print_help.fish ./share/functions/__fish_print_help.fish
|
||||
--- ../fish-2.4b1/share/functions/__fish_print_help.fish 2016-10-18 10:17:06.000000000 -0400
|
||||
+++ ./share/functions/__fish_print_help.fish 2016-10-19 17:37:08.948931562 -0400
|
||||
@@ -40,7 +40,7 @@
|
||||
set rLL -rLL=$cols[1]n
|
||||
end
|
||||
if test -e "$__fish_datadir/man/man1/$item.1"
|
||||
- set help (nroff -man -c -t $rLL "$__fish_datadir/man/man1/$item.1" ^/dev/null)
|
||||
+ set help (mandoc "$__fish_datadir/man/man1/$item.1" ^/dev/null)
|
||||
else if test -e "$__fish_datadir/man/man1/$item.1.gz"
|
||||
set help (gunzip -c "$__fish_datadir/man/man1/$item.1.gz" ^/dev/null | nroff -man -c -t $rLL ^/dev/null)
|
||||
end
|
||||
@@ -98,6 +98,6 @@
|
||||
# skip it
|
||||
end
|
||||
end
|
||||
- end | ul # post-process with `ul`, to interpret the old-style grotty escapes
|
||||
+ end # post-process with `ul`, to interpret the old-style grotty escapes
|
||||
echo # print a trailing blank line
|
||||
end
|
|
@ -0,0 +1,50 @@
|
|||
diff -u -r ../fish-2.4b1/src/env_universal_common.cpp ./src/env_universal_common.cpp
|
||||
--- ../fish-2.4b1/src/env_universal_common.cpp 2016-10-18 10:17:06.000000000 -0400
|
||||
+++ ./src/env_universal_common.cpp 2016-10-19 17:42:06.900520935 -0400
|
||||
@@ -137,7 +137,7 @@
|
||||
}
|
||||
|
||||
// /tmp/fish.user
|
||||
- std::string tmpdir = "/tmp/fish.";
|
||||
+ std::string tmpdir = "@TERMUX_PREFIX@/tmp/fish.";
|
||||
tmpdir.append(uname);
|
||||
if (check_runtime_path(tmpdir.c_str()) != 0) {
|
||||
debug(0,
|
||||
@@ -987,6 +987,7 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
+#ifndef __ANDROID__
|
||||
class universal_notifier_shmem_poller_t : public universal_notifier_t {
|
||||
// This is what our shared memory looks like. Everything here is stored in network byte order
|
||||
// (big-endian).
|
||||
@@ -1127,6 +1128,7 @@
|
||||
return usec_per_sec / 3; // 3 times a second
|
||||
}
|
||||
};
|
||||
+#endif
|
||||
|
||||
/// A notifyd-based notifier. Very straightforward.
|
||||
class universal_notifier_notifyd_t : public universal_notifier_t {
|
||||
@@ -1410,7 +1412,9 @@
|
||||
const char *name;
|
||||
universal_notifier_t::notifier_strategy_t strat;
|
||||
} options[] = {{"default", universal_notifier_t::strategy_default},
|
||||
+#ifndef __ANDROID__
|
||||
{"shmem", universal_notifier_t::strategy_shmem_polling},
|
||||
+#endif
|
||||
{"pipe", universal_notifier_t::strategy_named_pipe},
|
||||
{"notifyd", universal_notifier_t::strategy_notifyd}};
|
||||
const size_t opt_count = sizeof options / sizeof *options;
|
||||
@@ -1463,9 +1467,11 @@
|
||||
strat = resolve_default_strategy();
|
||||
}
|
||||
switch (strat) {
|
||||
+#ifndef __ANDROID__
|
||||
case strategy_shmem_polling: {
|
||||
return new universal_notifier_shmem_poller_t();
|
||||
}
|
||||
+#endif
|
||||
case strategy_notifyd: {
|
||||
return new universal_notifier_notifyd_t();
|
||||
}
|
Loading…
Reference in New Issue