aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2022-02-07 14:18:59 -0800
committerElliott Hughes <enh@google.com>2022-02-07 14:30:03 -0800
commit9defc2ecf491db1b1fd3589fcfb0d5d5b7235785 (patch)
tree7c445b534bec33bd34f8cf1b2ceaf0a4fe1e65bf
parente95470fb07c7cf56209ad3042485c324c91b0729 (diff)
parentcfa8d336db1b63a761be1d11251ad5d06b702d81 (diff)
downloadtoybox-android-t-preview-1.tar.gz
Test: make Change-Id: I0bdc2a7ccab6dd2759f837cc57553fbe8add29cb
-rw-r--r--Android.bp2
-rw-r--r--METADATA6
-rw-r--r--android/device/generated/globals.h2
-rw-r--r--android/device/generated/help.h2
-rw-r--r--android/linux/generated/globals.h2
-rw-r--r--android/linux/generated/help.h2
-rw-r--r--android/mac/generated/globals.h2
-rw-r--r--android/mac/generated/help.h2
-rw-r--r--lib/lib.h12
-rw-r--r--lib/tty.c5
-rw-r--r--lib/utf8.c (renamed from lib/linestack.c)85
-rwxr-xr-xscripts/install.sh5
-rwxr-xr-xscripts/mkroot.sh8
-rwxr-xr-xtests/find.test7
-rwxr-xr-xtests/sed.test3
-rw-r--r--toys/other/hexedit.c5
-rw-r--r--toys/posix/find.c2
-rw-r--r--toys/posix/ps.c51
-rw-r--r--toys/posix/sed.c2
19 files changed, 61 insertions, 144 deletions
diff --git a/Android.bp b/Android.bp
index 86102417..65820cb4 100644
--- a/Android.bp
+++ b/Android.bp
@@ -59,11 +59,11 @@ all_srcs = [
"lib/env.c",
"lib/help.c",
"lib/lib.c",
- "lib/linestack.c",
"lib/llist.c",
"lib/net.c",
"lib/portability.c",
"lib/tty.c",
+ "lib/utf8.c",
"lib/xwrap.c",
"main.c",
"toys/lsb/gzip.c",
diff --git a/METADATA b/METADATA
index ff87ac55..5fdff138 100644
--- a/METADATA
+++ b/METADATA
@@ -9,11 +9,11 @@ third_party {
type: GIT
value: "https://github.com/landley/toybox"
}
- version: "e7e4229c059f4a45eaf0ff0cb0f228275e3e7772"
+ version: "cfa8d336db1b63a761be1d11251ad5d06b702d81"
license_type: UNENCUMBERED
last_upgrade_date {
year: 2022
- month: 1
- day: 20
+ month: 2
+ day: 7
}
}
diff --git a/android/device/generated/globals.h b/android/device/generated/globals.h
index 55402400..2d5d1cf7 100644
--- a/android/device/generated/globals.h
+++ b/android/device/generated/globals.h
@@ -1465,7 +1465,7 @@ struct ps_data {
struct ptr_len gg, GG, pp, PP, ss, tt, uu, UU;
struct dirtree *threadparent;
- unsigned width, height;
+ unsigned width, height, scroll;
dev_t tty;
void *fields, *kfields;
long long ticks, bits, time;
diff --git a/android/device/generated/help.h b/android/device/generated/help.h
index bf561d09..02759fe3 100644
--- a/android/device/generated/help.h
+++ b/android/device/generated/help.h
@@ -550,7 +550,7 @@
#define HELP_iotop "usage: iotop [-AaKObq] [-n NUMBER] [-d SECONDS] [-p PID,] [-u USER,]\n\nRank processes by I/O.\n\n-A All I/O, not just disk\n-a Accumulated I/O (not percentage)\n-H Show threads\n-K Kilobytes\n-k Fallback sort FIELDS (default -[D]IO,-ETIME,-PID)\n-m Maximum number of tasks to show\n-O Only show processes doing I/O\n-o Show FIELDS (default PID,PR,USER,[D]READ,[D]WRITE,SWAP,[D]IO,COMM)\n-s Sort by field number (0-X, default 6)\n-b Batch mode (no tty)\n-d Delay SECONDS between each cycle (default 3)\n-n Exit after NUMBER iterations\n-p Show these PIDs\n-u Show these USERs\n-q Quiet (no header lines)\n\nCursor LEFT/RIGHT to change sort, UP/DOWN move list, space to force\nupdate, R to reverse sort, Q to exit."
-#define HELP_top "usage: top [-Hbq] [-k FIELD,] [-o FIELD,] [-s SORT] [-n NUMBER] [-m LINES] [-d SECONDS] [-p PID,] [-u USER,]\n\nShow process activity in real time.\n\n-H Show threads\n-k Fallback sort FIELDS (default -S,-%CPU,-ETIME,-PID)\n-o Show FIELDS (def PID,USER,PR,NI,VIRT,RES,SHR,S,%CPU,%MEM,TIME+,CMDLINE)\n-O Add FIELDS (replacing PR,NI,VIRT,RES,SHR,S from default)\n-s Sort by field number (1-X, default 9)\n-b Batch mode (no tty)\n-d Delay SECONDS between each cycle (default 3)\n-m Maximum number of tasks to show\n-n Exit after NUMBER iterations\n-p Show these PIDs\n-u Show these USERs\n-q Quiet (no header lines)\n\nCursor LEFT/RIGHT to change sort, UP/DOWN move list, space to force\nupdate, R to reverse sort, Q to exit."
+#define HELP_top "usage: top [-Hbq] [-k FIELD,] [-o FIELD,] [-s SORT] [-n NUMBER] [-m LINES] [-d SECONDS] [-p PID,] [-u USER,]\n\nShow process activity in real time.\n\n-H Show threads\n-k Fallback sort FIELDS (default -S,-%CPU,-ETIME,-PID)\n-o Show FIELDS (def PID,USER,PR,NI,VIRT,RES,SHR,S,%CPU,%MEM,TIME+,CMDLINE)\n-O Add FIELDS (replacing PR,NI,VIRT,RES,SHR,S from default)\n-s Sort by field number (1-X, default 9)\n-b Batch mode (no tty)\n-d Delay SECONDS between each cycle (default 3)\n-m Maximum number of tasks to show\n-n Exit after NUMBER iterations\n-p Show these PIDs\n-u Show these USERs\n-q Quiet (no header lines)\n\nCursor UP/DOWN or LEFT/RIGHT to move list, SHIFT LEFT/RIGHT to change sort,\nspace to force update, R to reverse sort, Q to exit."
#define HELP_ps "usage: ps [-AadefLlnwZ] [-gG GROUP,] [-k FIELD,] [-o FIELD,] [-p PID,] [-t TTY,] [-uU USER,]\n\nList processes.\n\nWhich processes to show (-gGuUpPt selections may be comma separated lists):\n\n-A All -a Has terminal not session leader\n-d All but session leaders -e Synonym for -A\n-g In GROUPs -G In real GROUPs (before sgid)\n-p PIDs (--pid) -P Parent PIDs (--ppid)\n-s In session IDs -t Attached to selected TTYs\n-T Show threads also -u Owned by selected USERs\n-U Real USERs (before suid)\n\nOutput modifiers:\n\n-k Sort FIELDs (-FIELD to reverse) -M Measure/pad future field widths\n-n Show numeric USER and GROUP -w Wide output (don't truncate fields)\n\nWhich FIELDs to show. (-o HELP for list, default = -o PID,TTY,TIME,CMD)\n\n-f Full listing (-o USER:12=UID,PID,PPID,C,STIME,TTY,TIME,ARGS=CMD)\n-l Long listing (-o F,S,UID,PID,PPID,C,PRI,NI,ADDR,SZ,WCHAN,TTY,TIME,CMD)\n-o Output FIELDs instead of defaults, each with optional :size and =title\n-O Add FIELDS to defaults\n-Z Include LABEL"
diff --git a/android/linux/generated/globals.h b/android/linux/generated/globals.h
index 55402400..2d5d1cf7 100644
--- a/android/linux/generated/globals.h
+++ b/android/linux/generated/globals.h
@@ -1465,7 +1465,7 @@ struct ps_data {
struct ptr_len gg, GG, pp, PP, ss, tt, uu, UU;
struct dirtree *threadparent;
- unsigned width, height;
+ unsigned width, height, scroll;
dev_t tty;
void *fields, *kfields;
long long ticks, bits, time;
diff --git a/android/linux/generated/help.h b/android/linux/generated/help.h
index 9ae1e48e..52a965a6 100644
--- a/android/linux/generated/help.h
+++ b/android/linux/generated/help.h
@@ -552,7 +552,7 @@
#define HELP_iotop "usage: iotop [-AaKObq] [-n NUMBER] [-d SECONDS] [-p PID,] [-u USER,]\n\nRank processes by I/O.\n\n-A All I/O, not just disk\n-a Accumulated I/O (not percentage)\n-H Show threads\n-K Kilobytes\n-k Fallback sort FIELDS (default -[D]IO,-ETIME,-PID)\n-m Maximum number of tasks to show\n-O Only show processes doing I/O\n-o Show FIELDS (default PID,PR,USER,[D]READ,[D]WRITE,SWAP,[D]IO,COMM)\n-s Sort by field number (0-X, default 6)\n-b Batch mode (no tty)\n-d Delay SECONDS between each cycle (default 3)\n-n Exit after NUMBER iterations\n-p Show these PIDs\n-u Show these USERs\n-q Quiet (no header lines)\n\nCursor LEFT/RIGHT to change sort, UP/DOWN move list, space to force\nupdate, R to reverse sort, Q to exit."
-#define HELP_top "usage: top [-Hbq] [-k FIELD,] [-o FIELD,] [-s SORT] [-n NUMBER] [-m LINES] [-d SECONDS] [-p PID,] [-u USER,]\n\nShow process activity in real time.\n\n-H Show threads\n-k Fallback sort FIELDS (default -S,-%CPU,-ETIME,-PID)\n-o Show FIELDS (def PID,USER,PR,NI,VIRT,RES,SHR,S,%CPU,%MEM,TIME+,CMDLINE)\n-O Add FIELDS (replacing PR,NI,VIRT,RES,SHR,S from default)\n-s Sort by field number (1-X, default 9)\n-b Batch mode (no tty)\n-d Delay SECONDS between each cycle (default 3)\n-m Maximum number of tasks to show\n-n Exit after NUMBER iterations\n-p Show these PIDs\n-u Show these USERs\n-q Quiet (no header lines)\n\nCursor LEFT/RIGHT to change sort, UP/DOWN move list, space to force\nupdate, R to reverse sort, Q to exit."
+#define HELP_top "usage: top [-Hbq] [-k FIELD,] [-o FIELD,] [-s SORT] [-n NUMBER] [-m LINES] [-d SECONDS] [-p PID,] [-u USER,]\n\nShow process activity in real time.\n\n-H Show threads\n-k Fallback sort FIELDS (default -S,-%CPU,-ETIME,-PID)\n-o Show FIELDS (def PID,USER,PR,NI,VIRT,RES,SHR,S,%CPU,%MEM,TIME+,CMDLINE)\n-O Add FIELDS (replacing PR,NI,VIRT,RES,SHR,S from default)\n-s Sort by field number (1-X, default 9)\n-b Batch mode (no tty)\n-d Delay SECONDS between each cycle (default 3)\n-m Maximum number of tasks to show\n-n Exit after NUMBER iterations\n-p Show these PIDs\n-u Show these USERs\n-q Quiet (no header lines)\n\nCursor UP/DOWN or LEFT/RIGHT to move list, SHIFT LEFT/RIGHT to change sort,\nspace to force update, R to reverse sort, Q to exit."
#define HELP_ps "usage: ps [-AadefLlnwZ] [-gG GROUP,] [-k FIELD,] [-o FIELD,] [-p PID,] [-t TTY,] [-uU USER,]\n\nList processes.\n\nWhich processes to show (-gGuUpPt selections may be comma separated lists):\n\n-A All -a Has terminal not session leader\n-d All but session leaders -e Synonym for -A\n-g In GROUPs -G In real GROUPs (before sgid)\n-p PIDs (--pid) -P Parent PIDs (--ppid)\n-s In session IDs -t Attached to selected TTYs\n-T Show threads also -u Owned by selected USERs\n-U Real USERs (before suid)\n\nOutput modifiers:\n\n-k Sort FIELDs (-FIELD to reverse) -M Measure/pad future field widths\n-n Show numeric USER and GROUP -w Wide output (don't truncate fields)\n\nWhich FIELDs to show. (-o HELP for list, default = -o PID,TTY,TIME,CMD)\n\n-f Full listing (-o USER:12=UID,PID,PPID,C,STIME,TTY,TIME,ARGS=CMD)\n-l Long listing (-o F,S,UID,PID,PPID,C,PRI,NI,ADDR,SZ,WCHAN,TTY,TIME,CMD)\n-o Output FIELDs instead of defaults, each with optional :size and =title\n-O Add FIELDS to defaults\n-Z Include LABEL"
diff --git a/android/mac/generated/globals.h b/android/mac/generated/globals.h
index 55402400..2d5d1cf7 100644
--- a/android/mac/generated/globals.h
+++ b/android/mac/generated/globals.h
@@ -1465,7 +1465,7 @@ struct ps_data {
struct ptr_len gg, GG, pp, PP, ss, tt, uu, UU;
struct dirtree *threadparent;
- unsigned width, height;
+ unsigned width, height, scroll;
dev_t tty;
void *fields, *kfields;
long long ticks, bits, time;
diff --git a/android/mac/generated/help.h b/android/mac/generated/help.h
index 9ae1e48e..52a965a6 100644
--- a/android/mac/generated/help.h
+++ b/android/mac/generated/help.h
@@ -552,7 +552,7 @@
#define HELP_iotop "usage: iotop [-AaKObq] [-n NUMBER] [-d SECONDS] [-p PID,] [-u USER,]\n\nRank processes by I/O.\n\n-A All I/O, not just disk\n-a Accumulated I/O (not percentage)\n-H Show threads\n-K Kilobytes\n-k Fallback sort FIELDS (default -[D]IO,-ETIME,-PID)\n-m Maximum number of tasks to show\n-O Only show processes doing I/O\n-o Show FIELDS (default PID,PR,USER,[D]READ,[D]WRITE,SWAP,[D]IO,COMM)\n-s Sort by field number (0-X, default 6)\n-b Batch mode (no tty)\n-d Delay SECONDS between each cycle (default 3)\n-n Exit after NUMBER iterations\n-p Show these PIDs\n-u Show these USERs\n-q Quiet (no header lines)\n\nCursor LEFT/RIGHT to change sort, UP/DOWN move list, space to force\nupdate, R to reverse sort, Q to exit."
-#define HELP_top "usage: top [-Hbq] [-k FIELD,] [-o FIELD,] [-s SORT] [-n NUMBER] [-m LINES] [-d SECONDS] [-p PID,] [-u USER,]\n\nShow process activity in real time.\n\n-H Show threads\n-k Fallback sort FIELDS (default -S,-%CPU,-ETIME,-PID)\n-o Show FIELDS (def PID,USER,PR,NI,VIRT,RES,SHR,S,%CPU,%MEM,TIME+,CMDLINE)\n-O Add FIELDS (replacing PR,NI,VIRT,RES,SHR,S from default)\n-s Sort by field number (1-X, default 9)\n-b Batch mode (no tty)\n-d Delay SECONDS between each cycle (default 3)\n-m Maximum number of tasks to show\n-n Exit after NUMBER iterations\n-p Show these PIDs\n-u Show these USERs\n-q Quiet (no header lines)\n\nCursor LEFT/RIGHT to change sort, UP/DOWN move list, space to force\nupdate, R to reverse sort, Q to exit."
+#define HELP_top "usage: top [-Hbq] [-k FIELD,] [-o FIELD,] [-s SORT] [-n NUMBER] [-m LINES] [-d SECONDS] [-p PID,] [-u USER,]\n\nShow process activity in real time.\n\n-H Show threads\n-k Fallback sort FIELDS (default -S,-%CPU,-ETIME,-PID)\n-o Show FIELDS (def PID,USER,PR,NI,VIRT,RES,SHR,S,%CPU,%MEM,TIME+,CMDLINE)\n-O Add FIELDS (replacing PR,NI,VIRT,RES,SHR,S from default)\n-s Sort by field number (1-X, default 9)\n-b Batch mode (no tty)\n-d Delay SECONDS between each cycle (default 3)\n-m Maximum number of tasks to show\n-n Exit after NUMBER iterations\n-p Show these PIDs\n-u Show these USERs\n-q Quiet (no header lines)\n\nCursor UP/DOWN or LEFT/RIGHT to move list, SHIFT LEFT/RIGHT to change sort,\nspace to force update, R to reverse sort, Q to exit."
#define HELP_ps "usage: ps [-AadefLlnwZ] [-gG GROUP,] [-k FIELD,] [-o FIELD,] [-p PID,] [-t TTY,] [-uU USER,]\n\nList processes.\n\nWhich processes to show (-gGuUpPt selections may be comma separated lists):\n\n-A All -a Has terminal not session leader\n-d All but session leaders -e Synonym for -A\n-g In GROUPs -G In real GROUPs (before sgid)\n-p PIDs (--pid) -P Parent PIDs (--ppid)\n-s In session IDs -t Attached to selected TTYs\n-T Show threads also -u Owned by selected USERs\n-U Real USERs (before suid)\n\nOutput modifiers:\n\n-k Sort FIELDs (-FIELD to reverse) -M Measure/pad future field widths\n-n Show numeric USER and GROUP -w Wide output (don't truncate fields)\n\nWhich FIELDs to show. (-o HELP for list, default = -o PID,TTY,TIME,CMD)\n\n-f Full listing (-o USER:12=UID,PID,PPID,C,STIME,TTY,TIME,ARGS=CMD)\n-l Long listing (-o F,S,UID,PID,PPID,C,PRI,NI,ADDR,SZ,WCHAN,TTY,TIME,CMD)\n-o Output FIELDs instead of defaults, each with optional :size and =title\n-O Add FIELDS to defaults\n-Z Include LABEL"
diff --git a/lib/lib.h b/lib/lib.h
index 16255da8..b825408a 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -302,18 +302,8 @@ char *xpop_env(char *name); // because xpopenv() looks like xpopen_v()
void xclearenv(void);
void reset_env(struct passwd *p, int clear);
-// linestack.c
+// utf8.c
-struct linestack {
- long len, max;
- struct ptr_len idx[];
-};
-
-void linestack_addstack(struct linestack **lls, struct linestack *throw,
- long pos);
-void linestack_insert(struct linestack **lls, long pos, char *line, long len);
-void linestack_append(struct linestack **lls, char *line);
-struct linestack *linestack_load(char *name);
int crunch_escape(FILE *out, int cols, int wc);
int crunch_rev_escape(FILE *out, int cols, int wc);
int crunch_str(char **str, int width, FILE *out, char *escmore,
diff --git a/lib/tty.c b/lib/tty.c
index b4aee45e..c09413b5 100644
--- a/lib/tty.c
+++ b/lib/tty.c
@@ -1,6 +1,11 @@
/* tty.c - cursor control
*
* Copyright 2015 Rob Landley <rob@landley.net>
+ *
+ * Common ANSI (See https://man7.org/linux/man-pages/man4/console_codes.4.html)
+ * \e[#m - color change \e[y;xH - jump to x/y pos (1;1 is top left)
+ * \e[K - delete to EOL \e[25l - disable cursor (h to enable)
+ * \e[1L - Insert 1 (blank) line \e[1M - Delete 1 line (scrolling rest up)
*/
#include "toys.h"
diff --git a/lib/linestack.c b/lib/utf8.c
index 47eb2af9..1608c2f8 100644
--- a/lib/linestack.c
+++ b/lib/utf8.c
@@ -1,90 +1,5 @@
#include "toys.h"
-// The design idea here is indexing a big blob of (potentially mmaped) data
-// instead of copying the data into a zillion seperate malloc()s.
-
-// A linestack is an array of struct ptr_len, with a currently used len
-// and max tracking the memory allocation. This indexes existing string data,
-// the lifetime of which is tracked externally.
-
-// Insert one stack into another before position in old stack.
-// (Does not copy contents of strings, just shuffles index array contents.)
-void linestack_addstack(struct linestack **lls, struct linestack *throw,
- long pos)
-{
- struct linestack *catch = *lls;
-
- if (CFG_TOYBOX_DEBUG)
- if (pos > catch->len) error_exit("linestack_addstack past end.");
-
- // Make a hole, allocating more space if necessary.
- if (catch->len+throw->len >= catch->max) {
- // New size rounded up to next multiple of 64, allocate and copy start.
- catch->max = ((catch->len+throw->len)|63)+1;
- *lls = xmalloc(sizeof(struct linestack)+catch->max*sizeof(struct ptr_len));
- memcpy(*lls, catch, sizeof(struct linestack)+pos*sizeof(struct ptr_len));
- }
-
- // Copy end (into new allocation if necessary)
- if (pos != catch->len)
- memmove((*lls)->idx+pos+throw->len, catch->idx+pos,
- (catch->len-pos)*sizeof(struct ptr_len));
-
- // Cleanup if we had to realloc.
- if (catch != *lls) {
- free(catch);
- catch = *lls;
- }
-
- // Copy new chunk we made space for
- memcpy(catch->idx+pos, throw->idx, throw->len*sizeof(struct ptr_len));
- catch->len += throw->len;
-}
-
-// Insert one line/len into a linestack at pos
-void linestack_insert(struct linestack **lls, long pos, char *line, long len)
-{
- // alloca() was in 32V and Turbo C for DOS, but isn't in posix or c99.
- // This allocates enough memory for the linestack to have one ptr_len.
- // (Even if a compiler adds gratuitous padidng that just makes it bigger.)
- struct {
- struct ptr_len pl;
- struct linestack ls;
- } ls;
-
- ls.ls.len = ls.ls.max = 1;
- ls.ls.idx[0].ptr = line;
- ls.ls.idx[0].len = len;
- linestack_addstack(lls, &ls.ls, pos);
-}
-
-void linestack_append(struct linestack **lls, char *line)
-{
- linestack_insert(lls, (*lls)->len, line, strlen(line));
-}
-
-struct linestack *linestack_load(char *name)
-{
- FILE *fp = fopen(name, "r");
- struct linestack *ls;
-
- if (!fp) return 0;
-
- ls = xzalloc(sizeof(struct linestack));
-
- for (;;) {
- char *line = 0;
- ssize_t len;
-
- if ((len = getline(&line, (void *)&len, fp))<1) break;
- if (line[len-1]=='\n') len--;
- linestack_insert(&ls, ls->len, line, len);
- }
- fclose(fp);
-
- return ls;
-}
-
// Show width many columns, negative means from right edge, out=0 just measure
// if escout, send it unprintable chars, otherwise pass through raw data.
// Returns width in columns, moves *str to end of data consumed.
diff --git a/scripts/install.sh b/scripts/install.sh
index adf36027..d58d075d 100755
--- a/scripts/install.sh
+++ b/scripts/install.sh
@@ -106,9 +106,10 @@ done
# The following are commands toybox should provide, but doesn't yet.
# For now symlink the host version. This list must go away by 1.0.
-PENDING="dd diff expr ftpd less tr vi wget awk sh unxz xzcat bc bison flex make nm ar gzip"
+PENDING="dd diff expr tr vi wget sh xzcat bc ar gzip ftpd less awk unxz bison flex make nm"
-# "gcc" should go away for llvm, but some things still hardwire it
+# "gcc" can go away if the kernel guys merge my patch:
+# http://lkml.iu.edu/hypermail/linux/kernel/2202.0/01505.html
TOOLCHAIN="as cc ld gcc objdump"
# Tools needed to build packages
diff --git a/scripts/mkroot.sh b/scripts/mkroot.sh
index 8a0582df..f1ddc505 100755
--- a/scripts/mkroot.sh
+++ b/scripts/mkroot.sh
@@ -105,10 +105,10 @@ if ! mountpoint -q dev; then
[ $$ -eq 1 ] && exec 0<>/dev/console 1>&0 2>&1
for i in ,fd /0,stdin /1,stdout /2,stderr
do ln -sf /proc/self/fd${i/,*/} dev/${i/*,/}; done
- mkdir -p dev/{shm,pts}
+ mkdir dev/shm
chmod +t /dev/shm
fi
-mountpoint -q dev/pts || mount -t devpts dev/pts dev/pts
+mountpoint -q dev/pts || { mkdir dev/pts && mount -t devpts dev/pts dev/pts; }
mountpoint -q proc || mount -t proc proc proc
mountpoint -q sys || mount -t sysfs sys sys
echo 0 99999 > /proc/sys/net/ipv4/ping_group_range
@@ -221,8 +221,8 @@ else
QEMU="s390x" KARCH=s390 VMLINUX=arch/s390/boot/bzImage
KCONF=MARCH_Z900,PACK_STACK,NET_CORE,VIRTIO_NET,VIRTIO_BLK,SCLP_TTY,SCLP_CONSOLE,SCLP_VT220_TTY,SCLP_VT220_CONSOLE,S390_GUEST
elif [ "$TARGET" == sh2eb ]; then
- KARCH=sh VMLINUX=vmlinux KERNEL_CONFIG='CONFIG_MEMORY_START=0x10000000
-CONFIG_CMDLINE="console=ttyUL0 earlycon"' BUILTIN=1
+ BUILTIN=1 KARCH=sh VMLINUX=vmlinux
+ KERNEL_CONFIG=$'CONFIG_MEMORY_START=0x10000000\nCONFIG_CMDLINE="console=ttyUL0 earlycon"'
KCONF=CPU_SUBTYPE_J2,CPU_BIG_ENDIAN,SH_JCORE_SOC,SMP,BINFMT_ELF_FDPIC,JCORE_EMAC,SERIAL_UARTLITE,SERIAL_UARTLITE_CONSOLE,HZ_100,CMDLINE_OVERWRITE,SPI,SPI_JCORE,MMC,PWRSEQ_SIMPLE,MMC_BLOCK,MMC_SPI
elif [ "$TARGET" == sh4 ]; then
QEMU="sh4 -M r2d -serial null -serial mon:stdio" KARCH=sh
diff --git a/tests/find.test b/tests/find.test
index 74a452aa..344489dc 100755
--- a/tests/find.test
+++ b/tests/find.test
@@ -149,5 +149,10 @@ testing 'quit' 'find dir perm -print -quit' 'dir\n' '' ''
ln dir/file perm/hardlink
testing 'samefile' 'find . -samefile dir/file | sort' \
'./dir/file\n./perm/hardlink\n' '' ''
-
rm -rf dir broken perm irrelevant
+
+mkdir dir
+touch -d @12345 dir/one
+touch -d @12346 dir/two
+testing 'newerat' 'find dir -type f -newerat @12345' 'dir/two\n' '' ''
+rm -rf dir
diff --git a/tests/sed.test b/tests/sed.test
index fd3b2057..5035478b 100755
--- a/tests/sed.test
+++ b/tests/sed.test
@@ -195,6 +195,9 @@ testing 'megabyte s/x/y/g (20 sec timeout)' \
'138c1fa7c3f64186203b0192fb4abdb33cb4e98a -\n' '' "$X\n"
unset X Y
+testing "w doesn't blank" "sed -e 'w one' -e 'w one' -e d; cat one" \
+ 'hello\nhello\n' '' 'hello\n'
+
testing 's i and I' 'sed s/o/0/ig' "f00l F00L" "" "fool FOOL"
# -i with $ last line test
diff --git a/toys/other/hexedit.c b/toys/other/hexedit.c
index bf1c7a6a..d3402056 100644
--- a/toys/other/hexedit.c
+++ b/toys/other/hexedit.c
@@ -3,11 +3,6 @@
* Copyright 2015 Rob Landley <rob@landley.net>
*
* No standard.
- *
- * See https://man7.org/linux/man-pages/man4/console_codes.4.html
- * \e[#m - color change \e[y,xH - jump to x/y pos (1-based)
- * \e[K - delete to EOL \e[25l - disable cursor (h to enable)
- * \e[1L - zap line after cursor \e[1M - zap line before cursor
USE_HEXEDIT(NEWTOY(hexedit, "<1>1r", TOYFLAG_USR|TOYFLAG_BIN|TOYFLAG_LOCALE))
diff --git a/toys/posix/find.c b/toys/posix/find.c
index 6a792544..bca7c67b 100644
--- a/toys/posix/find.c
+++ b/toys/posix/find.c
@@ -457,7 +457,7 @@ static int do_find(struct dirtree *new)
}
}
} else if (!strcmp(s, "user") || !strcmp(s, "group")
- || !strcmp(s, "newer") || !strcmp(s, "samefile"))
+ || !strncmp(s, "newer", 5) || !strcmp(s, "samefile"))
{
int macoff[] = {offsetof(struct stat, st_mtim),
offsetof(struct stat, st_atim), offsetof(struct stat, st_ctim)};
diff --git a/toys/posix/ps.c b/toys/posix/ps.c
index 35bfbf45..48a065a8 100644
--- a/toys/posix/ps.c
+++ b/toys/posix/ps.c
@@ -106,8 +106,8 @@ config TOP
-u Show these USERs
-q Quiet (no header lines)
- Cursor LEFT/RIGHT to change sort, UP/DOWN move list, space to force
- update, R to reverse sort, Q to exit.
+ Cursor UP/DOWN or LEFT/RIGHT to move list, SHIFT LEFT/RIGHT to change sort,
+ space to force update, R to reverse sort, Q to exit.
# Requires CONFIG_IRQ_TIME_ACCOUNTING in the kernel for /proc/$$/io
config IOTOP
@@ -210,7 +210,7 @@ GLOBALS(
struct ptr_len gg, GG, pp, PP, ss, tt, uu, UU;
struct dirtree *threadparent;
- unsigned width, height;
+ unsigned width, height, scroll;
dev_t tty;
void *fields, *kfields;
long long ticks, bits, time;
@@ -638,11 +638,14 @@ static char *string_field(struct procpid *tb, struct ofields *field)
static void show_ps(void *p)
{
struct procpid *tb = p;
- struct ofields *field;
- int pad, len, width = TT.width, abslen, sign, olen, extra = 0;
+ struct ofields *field = TT.fields;
+ int pad, len, width = TT.width, abslen, sign, olen, scroll, extra = 0;
+
+ // Skip TT.scroll many fields (but not last one)
+ for (scroll = TT.scroll; scroll && field->next; scroll--) field = field->next;
// Loop through fields to display
- for (field = TT.fields; field; field = field->next) {
+ for (; field; field = field->next) {
char *out = string_field(tb, field);
// Output the field, appropriately padded
@@ -1125,7 +1128,10 @@ static char *parse_ko(void *data, char *type, int length)
static long long get_headers(struct ofields *field, char *buf, int blen)
{
long long bits = 0;
- int len = 0;
+ int len = 0, scroll;
+
+ // Skip TT.scroll many fields (but not last one)
+ for (scroll = TT.scroll; scroll && field->next; scroll--) field = field->next;
for (; field; field = field->next) {
len += snprintf(buf+len, blen-len, " %*s"+!bits, field->len,
@@ -1636,6 +1642,7 @@ static void top_common(
pos += sprintf(pos, "% *lld%%%s", j, (ll+5)/10, cpufields[i]);
}
lines = header_line(lines, 0);
+ // Display "iotop" header.
} else {
struct ofields *field;
struct procpid tb;
@@ -1672,9 +1679,7 @@ static void top_common(
*pos = 0;
lines = header_line(lines, 1);
}
- if (!recalc && !FLAG(b))
- printf("\e[%dH\e[J", 1+TT.height-lines);
- recalc = 1;
+ if (!recalc && !FLAG(b)) printf("\e[%dH\e[J", 1+TT.height-lines);
for (i = 0; i<lines && i+topoff<mix.count; i++) {
// Running processes are shown in bold.
@@ -1703,6 +1708,7 @@ static void top_common(
break;
} else fflush(stdout);
+ recalc = 1;
i = scan_key_getsize(scratch, timeout-now, &TT.width, &TT.height);
if (i==-1 || i==3 || toupper(i)=='Q') {
done++;
@@ -1720,21 +1726,18 @@ static void top_common(
((struct ofields *)TT.kfields)->reverse *= -1;
else {
i -= 256;
- if (i == KEY_LEFT) setsort(TT.sortpos-1);
- else if (i == KEY_RIGHT) setsort(TT.sortpos+1);
- // KEY_UP is 0, so at end of strchr
- else if (strchr((char []){KEY_DOWN,KEY_PGUP,KEY_PGDN,KEY_UP}, i)) {
- recalc = 0;
-
- if (i == KEY_UP) topoff--;
- else if (i == KEY_DOWN) topoff++;
- else if (i == KEY_PGDN) topoff += lines;
- else if (i == KEY_PGUP) topoff -= lines;
- if (topoff<0) topoff = 0;
- if (topoff>mix.count) topoff = mix.count;
- }
+ if (i == (KEY_SHIFT|KEY_LEFT)) setsort(TT.sortpos-1);
+ else if (i == (KEY_SHIFT|KEY_RIGHT)) setsort(TT.sortpos+1);
+ else if (i == KEY_RIGHT) TT.scroll++;
+ else if (i == KEY_LEFT && TT.scroll) TT.scroll--;
+ else if (recalc-- && i == KEY_UP) topoff--;
+ else if (i == KEY_DOWN) topoff++;
+ else if (i == KEY_PGDN) topoff += lines;
+ else if (i == KEY_PGUP) topoff -= lines;
+ else continue;
+ if (topoff<0) topoff = 0;
+ if (topoff>mix.count) topoff = mix.count;
}
- continue;
}
free(mix.tb);
diff --git a/toys/posix/sed.c b/toys/posix/sed.c
index d5a4a833..cea12ea5 100644
--- a/toys/posix/sed.c
+++ b/toys/posix/sed.c
@@ -881,7 +881,7 @@ writenow:
for (cc = line; *cc; cc++) if (*cc == '\\' && cc[1] == ';') break;
delim = *cc;
*cc = 0;
- fd = xcreate(line, O_WRONLY|O_CREAT|O_TRUNC, 0644);
+ fd = xcreate(line, O_WRONLY|O_CREAT|O_TRUNC|O_APPEND, 0644);
*cc = delim;
command->w = reg - (char *)command;