aboutsummaryrefslogtreecommitdiff
path: root/miscutils
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2018-02-13 09:44:44 +0000
committerRon Yorston <rmy@pobox.com>2018-02-13 09:44:44 +0000
commitdc19a361bd6c6df30338371532691bbc7f7126bb (patch)
tree1fb2cd646d54b5f8e425c4f11f3e09fc21d1966b /miscutils
parent096aee2bb468d1ab044de36e176ed1f6c7e3674d (diff)
parent3459024bf404af814cacfe90a0deb719e282ae62 (diff)
downloadbusybox-w32-dc19a361bd6c6df30338371532691bbc7f7126bb.tar.gz
busybox-w32-dc19a361bd6c6df30338371532691bbc7f7126bb.tar.bz2
busybox-w32-dc19a361bd6c6df30338371532691bbc7f7126bb.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'miscutils')
-rw-r--r--miscutils/flash_eraseall.c2
-rw-r--r--miscutils/hexedit.c2
-rw-r--r--miscutils/less.c68
-rw-r--r--miscutils/nandwrite.c9
-rw-r--r--miscutils/setfattr.c2
5 files changed, 76 insertions, 7 deletions
diff --git a/miscutils/flash_eraseall.c b/miscutils/flash_eraseall.c
index fab21291c..8e93060ca 100644
--- a/miscutils/flash_eraseall.c
+++ b/miscutils/flash_eraseall.c
@@ -101,7 +101,7 @@ int flash_eraseall_main(int argc UNUSED_PARAM, char **argv)
101 if (flags & OPTION_J) { 101 if (flags & OPTION_J) {
102 uint32_t *crc32_table; 102 uint32_t *crc32_table;
103 103
104 crc32_table = crc32_filltable(NULL, 0); 104 crc32_table = crc32_new_table_le();
105 105
106 cleanmarker.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK); 106 cleanmarker.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
107 cleanmarker.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER); 107 cleanmarker.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER);
diff --git a/miscutils/hexedit.c b/miscutils/hexedit.c
index bafb834b5..95c930d12 100644
--- a/miscutils/hexedit.c
+++ b/miscutils/hexedit.c
@@ -4,7 +4,7 @@
4 * Licensed under GPLv2, see file LICENSE in this source tree. 4 * Licensed under GPLv2, see file LICENSE in this source tree.
5 */ 5 */
6//config:config HEXEDIT 6//config:config HEXEDIT
7//config: bool "hexedit" 7//config: bool "hexedit (20 kb)"
8//config: default y 8//config: default y
9//config: help 9//config: help
10//config: Edit file in hexadecimal. 10//config: Edit file in hexadecimal.
diff --git a/miscutils/less.c b/miscutils/less.c
index 4ab0e17da..41e4989ad 100644
--- a/miscutils/less.c
+++ b/miscutils/less.c
@@ -99,6 +99,22 @@
99//config: bool "Enable -N (dynamic switching of line numbers)" 99//config: bool "Enable -N (dynamic switching of line numbers)"
100//config: default y 100//config: default y
101//config: depends on FEATURE_LESS_DASHCMD 101//config: depends on FEATURE_LESS_DASHCMD
102//config:
103//config:config FEATURE_LESS_RAW
104//config: bool "Enable -R ('raw control characters')"
105//config: default y
106//config: depends on FEATURE_LESS_DASHCMD
107//config: help
108//config: This is essential for less applet to work with tools that use colors
109//config: and paging, such as git, systemd tools or nmcli.
110//config:
111//config:config FEATURE_LESS_ENV
112//config: bool "Take options from $LESS environment variable"
113//config: default y
114//config: depends on FEATURE_LESS_DASHCMD
115//config: help
116//config: This is essential for less applet to work with tools that use colors
117//config: and paging, such as git, systemd tools or nmcli.
102 118
103//applet:IF_LESS(APPLET(less, BB_DIR_USR_BIN, BB_SUID_DROP)) 119//applet:IF_LESS(APPLET(less, BB_DIR_USR_BIN, BB_SUID_DROP))
104 120
@@ -106,7 +122,7 @@
106 122
107//usage:#define less_trivial_usage 123//usage:#define less_trivial_usage
108//usage: "[-E" IF_FEATURE_LESS_REGEXP("I")IF_FEATURE_LESS_FLAGS("Mm") 124//usage: "[-E" IF_FEATURE_LESS_REGEXP("I")IF_FEATURE_LESS_FLAGS("Mm")
109//usage: "N" IF_FEATURE_LESS_TRUNCATE("S") "h~] [FILE]..." 125//usage: "N" IF_FEATURE_LESS_TRUNCATE("S") IF_FEATURE_LESS_RAW("R") "h~] [FILE]..."
110//usage:#define less_full_usage "\n\n" 126//usage:#define less_full_usage "\n\n"
111//usage: "View FILE (or stdin) one screenful at a time\n" 127//usage: "View FILE (or stdin) one screenful at a time\n"
112//usage: "\n -E Quit once the end of a file is reached" 128//usage: "\n -E Quit once the end of a file is reached"
@@ -121,6 +137,9 @@
121//usage: IF_FEATURE_LESS_TRUNCATE( 137//usage: IF_FEATURE_LESS_TRUNCATE(
122//usage: "\n -S Truncate long lines" 138//usage: "\n -S Truncate long lines"
123//usage: ) 139//usage: )
140//usage: IF_FEATURE_LESS_RAW(
141//usage: "\n -R Remove color escape codes in input"
142//usage: )
124//usage: "\n -~ Suppress ~s displayed past EOF" 143//usage: "\n -~ Suppress ~s displayed past EOF"
125 144
126#include <sched.h> /* sched_yield() */ 145#include <sched.h> /* sched_yield() */
@@ -161,6 +180,7 @@ enum {
161 FLAG_TILDE = 1 << 4, 180 FLAG_TILDE = 1 << 4,
162 FLAG_I = 1 << 5, 181 FLAG_I = 1 << 5,
163 FLAG_S = (1 << 6) * ENABLE_FEATURE_LESS_TRUNCATE, 182 FLAG_S = (1 << 6) * ENABLE_FEATURE_LESS_TRUNCATE,
183 FLAG_R = (1 << 7) * ENABLE_FEATURE_LESS_RAW,
164/* hijack command line options variable for internal state vars */ 184/* hijack command line options variable for internal state vars */
165 LESS_STATE_MATCH_BACKWARDS = 1 << 15, 185 LESS_STATE_MATCH_BACKWARDS = 1 << 15,
166}; 186};
@@ -211,6 +231,9 @@ struct globals {
211 regex_t pattern; 231 regex_t pattern;
212 smallint pattern_valid; 232 smallint pattern_valid;
213#endif 233#endif
234#if ENABLE_FEATURE_LESS_RAW
235 smallint in_escape;
236#endif
214#if ENABLE_FEATURE_LESS_ASK_TERMINAL 237#if ENABLE_FEATURE_LESS_ASK_TERMINAL
215 smallint winsize_err; 238 smallint winsize_err;
216#endif 239#endif
@@ -259,7 +282,6 @@ struct globals {
259 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ 282 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \
260 less_gets_pos = -1; \ 283 less_gets_pos = -1; \
261 empty_line_marker = "~"; \ 284 empty_line_marker = "~"; \
262 num_files = 1; \
263 current_file = 1; \ 285 current_file = 1; \
264 eof_error = 1; \ 286 eof_error = 1; \
265 terminated = 1; \ 287 terminated = 1; \
@@ -518,6 +540,26 @@ static void read_lines(void)
518 *--p = '\0'; 540 *--p = '\0';
519 continue; 541 continue;
520 } 542 }
543#if ENABLE_FEATURE_LESS_RAW
544 if (option_mask32 & FLAG_R) {
545 if (c == '\033')
546 goto discard;
547 if (G.in_escape) {
548 if (isdigit(c)
549 || c == '['
550 || c == ';'
551 || c == 'm'
552 ) {
553 discard:
554 G.in_escape = (c != 'm');
555 readpos++;
556 continue;
557 }
558 /* Hmm, unexpected end of "ESC [ N ; N m" sequence */
559 G.in_escape = 0;
560 }
561 }
562#endif
521 { 563 {
522 size_t new_last_line_pos = last_line_pos + 1; 564 size_t new_last_line_pos = last_line_pos + 1;
523 if (c == '\t') { 565 if (c == '\t') {
@@ -1849,11 +1891,29 @@ int less_main(int argc, char **argv)
1849 * (used by some setups for manpage display) 1891 * (used by some setups for manpage display)
1850 */ 1892 */
1851 getopt32(argv, "EMmN~I" IF_FEATURE_LESS_TRUNCATE("S") /*ignored:*/"s"); 1893 getopt32(argv, "EMmN~I" IF_FEATURE_LESS_TRUNCATE("S") /*ignored:*/"s");
1852 argc -= optind;
1853 argv += optind; 1894 argv += optind;
1854 num_files = argc; 1895 num_files = argc - optind;
1855 files = argv; 1896 files = argv;
1856 1897
1898 /* Tools typically pass LESS="FRSXMK".
1899 * The options we don't understand are ignored. */
1900 if (ENABLE_FEATURE_LESS_ENV) {
1901 char *c = getenv("LESS");
1902 if (c) while (*c) switch (*c++) {
1903 case 'M':
1904 option_mask32 |= FLAG_M;
1905 break;
1906 case 'R':
1907 option_mask32 |= FLAG_R;
1908 break;
1909 case 'S':
1910 option_mask32 |= FLAG_S;
1911 break;
1912 default:
1913 break;
1914 }
1915 }
1916
1857 /* Another popular pager, most, detects when stdout 1917 /* Another popular pager, most, detects when stdout
1858 * is not a tty and turns into cat. This makes sense. */ 1918 * is not a tty and turns into cat. This makes sense. */
1859 if (!isatty(STDOUT_FILENO)) 1919 if (!isatty(STDOUT_FILENO))
diff --git a/miscutils/nandwrite.c b/miscutils/nandwrite.c
index 72f028ed3..29c800612 100644
--- a/miscutils/nandwrite.c
+++ b/miscutils/nandwrite.c
@@ -53,6 +53,15 @@
53#include "libbb.h" 53#include "libbb.h"
54#include <mtd/mtd-user.h> 54#include <mtd/mtd-user.h>
55 55
56/* Old headers call it MTD_MODE_RAW.
57 * FIXME: In kernel headers, MTD_FILE_MODE_RAW is not a define,
58 * it's an enum. How I can test for existence of an enum?
59 */
60#if !defined(MTD_FILE_MODE_RAW)
61# define MTD_FILE_MODE_RAW 3
62#endif
63
64
56#define IS_NANDDUMP (ENABLE_NANDDUMP && (!ENABLE_NANDWRITE || (applet_name[4] == 'd'))) 65#define IS_NANDDUMP (ENABLE_NANDDUMP && (!ENABLE_NANDWRITE || (applet_name[4] == 'd')))
57#define IS_NANDWRITE (ENABLE_NANDWRITE && (!ENABLE_NANDDUMP || (applet_name[4] != 'd'))) 66#define IS_NANDWRITE (ENABLE_NANDWRITE && (!ENABLE_NANDDUMP || (applet_name[4] != 'd')))
58 67
diff --git a/miscutils/setfattr.c b/miscutils/setfattr.c
index f0ef227cb..12eebc56e 100644
--- a/miscutils/setfattr.c
+++ b/miscutils/setfattr.c
@@ -6,7 +6,7 @@
6 * Licensed under GPLv2, see file LICENSE in this source tree. 6 * Licensed under GPLv2, see file LICENSE in this source tree.
7 */ 7 */
8//config:config SETFATTR 8//config:config SETFATTR
9//config: bool "setfattr" 9//config: bool "setfattr (3.6 kb)"
10//config: default y 10//config: default y
11//config: help 11//config: help
12//config: Set/delete extended attributes on files 12//config: Set/delete extended attributes on files