aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2017-09-27 10:08:12 +0100
committerRon Yorston <rmy@pobox.com>2017-09-27 10:11:19 +0100
commitd9383e984da8de72e61e5094a3cf6404c5707ddc (patch)
treedd42825854fc42aea40d4f7a95548d53721d1733 /editors
parent166b3e4e82799f87d3b002c7177891111eff079e (diff)
parent0c4dbd481aedb5d22c1048e7f7eb547a3b5e50a5 (diff)
downloadbusybox-w32-d9383e984da8de72e61e5094a3cf6404c5707ddc.tar.gz
busybox-w32-d9383e984da8de72e61e5094a3cf6404c5707ddc.tar.bz2
busybox-w32-d9383e984da8de72e61e5094a3cf6404c5707ddc.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'editors')
-rw-r--r--editors/awk.c1
-rw-r--r--editors/cmp.c11
-rw-r--r--editors/diff.c6
-rw-r--r--editors/patch.c1
-rw-r--r--editors/sed.c21
-rw-r--r--editors/vi.c23
6 files changed, 30 insertions, 33 deletions
diff --git a/editors/awk.c b/editors/awk.c
index 2fc7d6102..1a273ff2e 100644
--- a/editors/awk.c
+++ b/editors/awk.c
@@ -6,7 +6,6 @@
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9
10//config:config AWK 9//config:config AWK
11//config: bool "awk (22 kb)" 10//config: bool "awk (22 kb)"
12//config: default y 11//config: default y
diff --git a/editors/cmp.c b/editors/cmp.c
index ec86c0ce2..2a410fdec 100644
--- a/editors/cmp.c
+++ b/editors/cmp.c
@@ -6,10 +6,6 @@
6 * 6 *
7 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
8 */ 8 */
9
10/* BB_AUDIT SUSv3 (virtually) compliant -- uses nicer GNU format for -l. */
11/* http://www.opengroup.org/onlinepubs/007904975/utilities/cmp.html */
12
13//config:config CMP 9//config:config CMP
14//config: bool "cmp (5.4 kb)" 10//config: bool "cmp (5.4 kb)"
15//config: default y 11//config: default y
@@ -17,10 +13,10 @@
17//config: cmp is used to compare two files and returns the result 13//config: cmp is used to compare two files and returns the result
18//config: to standard output. 14//config: to standard output.
19 15
20//kbuild:lib-$(CONFIG_CMP) += cmp.o
21
22//applet:IF_CMP(APPLET(cmp, BB_DIR_USR_BIN, BB_SUID_DROP)) 16//applet:IF_CMP(APPLET(cmp, BB_DIR_USR_BIN, BB_SUID_DROP))
23 17
18//kbuild:lib-$(CONFIG_CMP) += cmp.o
19
24//usage:#define cmp_trivial_usage 20//usage:#define cmp_trivial_usage
25//usage: "[-l] [-s] FILE1 [FILE2" IF_DESKTOP(" [SKIP1 [SKIP2]]") "]" 21//usage: "[-l] [-s] FILE1 [FILE2" IF_DESKTOP(" [SKIP1 [SKIP2]]") "]"
26//usage:#define cmp_full_usage "\n\n" 22//usage:#define cmp_full_usage "\n\n"
@@ -29,6 +25,9 @@
29//usage: "\n for all differing bytes" 25//usage: "\n for all differing bytes"
30//usage: "\n -s Quiet" 26//usage: "\n -s Quiet"
31 27
28/* BB_AUDIT SUSv3 (virtually) compliant -- uses nicer GNU format for -l. */
29/* http://www.opengroup.org/onlinepubs/007904975/utilities/cmp.html */
30
32#include "libbb.h" 31#include "libbb.h"
33 32
34static const char fmt_eof[] ALIGN1 = "cmp: EOF on %s\n"; 33static const char fmt_eof[] ALIGN1 = "cmp: EOF on %s\n";
diff --git a/editors/diff.c b/editors/diff.c
index 1ff399ffb..beea3e618 100644
--- a/editors/diff.c
+++ b/editors/diff.c
@@ -12,7 +12,6 @@
12 * 12 *
13 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 13 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
14 */ 14 */
15
16/* 15/*
17 * The following code uses an algorithm due to Harold Stone, 16 * The following code uses an algorithm due to Harold Stone,
18 * which finds a pair of longest identical subsequences in 17 * which finds a pair of longest identical subsequences in
@@ -75,7 +74,6 @@
75 * 3*(number of k-candidates installed), typically about 74 * 3*(number of k-candidates installed), typically about
76 * 6n words for files of length n. 75 * 6n words for files of length n.
77 */ 76 */
78
79//config:config DIFF 77//config:config DIFF
80//config: bool "diff (13 kb)" 78//config: bool "diff (13 kb)"
81//config: default y 79//config: default y
@@ -97,10 +95,10 @@
97//config: This option enables support for directory and subdirectory 95//config: This option enables support for directory and subdirectory
98//config: comparison. 96//config: comparison.
99 97
100//kbuild:lib-$(CONFIG_DIFF) += diff.o
101
102//applet:IF_DIFF(APPLET(diff, BB_DIR_USR_BIN, BB_SUID_DROP)) 98//applet:IF_DIFF(APPLET(diff, BB_DIR_USR_BIN, BB_SUID_DROP))
103 99
100//kbuild:lib-$(CONFIG_DIFF) += diff.o
101
104//usage:#define diff_trivial_usage 102//usage:#define diff_trivial_usage
105//usage: "[-abBdiNqrTstw] [-L LABEL] [-S FILE] [-U LINES] FILE1 FILE2" 103//usage: "[-abBdiNqrTstw] [-L LABEL] [-S FILE] [-U LINES] FILE1 FILE2"
106//usage:#define diff_full_usage "\n\n" 104//usage:#define diff_full_usage "\n\n"
diff --git a/editors/patch.c b/editors/patch.c
index 81316fae3..a51b7a502 100644
--- a/editors/patch.c
+++ b/editors/patch.c
@@ -21,7 +21,6 @@
21 * -F fuzz (number, default 2) 21 * -F fuzz (number, default 2)
22 * [file] which file to patch 22 * [file] which file to patch
23 */ 23 */
24
25//config:config PATCH 24//config:config PATCH
26//config: bool "patch (9.1 kb)" 25//config: bool "patch (9.1 kb)"
27//config: default y 26//config: default y
diff --git a/editors/sed.c b/editors/sed.c
index e2c6690bb..bb2809d3c 100644
--- a/editors/sed.c
+++ b/editors/sed.c
@@ -12,7 +12,6 @@
12 * 12 *
13 * Licensed under GPLv2, see file LICENSE in this source tree. 13 * Licensed under GPLv2, see file LICENSE in this source tree.
14 */ 14 */
15
16/* Code overview. 15/* Code overview.
17 * 16 *
18 * Files are laid out to avoid unnecessary function declarations. So for 17 * Files are laid out to avoid unnecessary function declarations. So for
@@ -29,7 +28,6 @@
29 * 28 *
30 * sed_main() is where external code calls into this, with a command line. 29 * sed_main() is where external code calls into this, with a command line.
31 */ 30 */
32
33/* Supported features and commands in this version of sed: 31/* Supported features and commands in this version of sed:
34 * 32 *
35 * - comments ('#') 33 * - comments ('#')
@@ -55,7 +53,6 @@
55 * http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html 53 * http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html
56 * http://sed.sourceforge.net/sedfaq3.html 54 * http://sed.sourceforge.net/sedfaq3.html
57 */ 55 */
58
59//config:config SED 56//config:config SED
60//config: bool "sed (12 kb)" 57//config: bool "sed (12 kb)"
61//config: default y 58//config: default y
@@ -63,10 +60,10 @@
63//config: sed is used to perform text transformations on a file 60//config: sed is used to perform text transformations on a file
64//config: or input from a pipeline. 61//config: or input from a pipeline.
65 62
66//kbuild:lib-$(CONFIG_SED) += sed.o
67
68//applet:IF_SED(APPLET(sed, BB_DIR_BIN, BB_SUID_DROP)) 63//applet:IF_SED(APPLET(sed, BB_DIR_BIN, BB_SUID_DROP))
69 64
65//kbuild:lib-$(CONFIG_SED) += sed.o
66
70//usage:#define sed_trivial_usage 67//usage:#define sed_trivial_usage
71//usage: "[-i[SFX]] [-nrE] [-f FILE]... [-e CMD]... [FILE]...\n" 68//usage: "[-i[SFX]] [-nrE] [-f FILE]... [-e CMD]... [FILE]...\n"
72//usage: "or: sed [-i[SFX]] [-nrE] CMD [FILE]..." 69//usage: "or: sed [-i[SFX]] [-nrE] CMD [FILE]..."
@@ -356,10 +353,16 @@ static int get_address(const char *my_str, int *linenum, regex_t ** regex)
356 if (*my_str == '\\') 353 if (*my_str == '\\')
357 delimiter = *++pos; 354 delimiter = *++pos;
358 next = index_of_next_unescaped_regexp_delim(delimiter, ++pos); 355 next = index_of_next_unescaped_regexp_delim(delimiter, ++pos);
359 temp = copy_parsing_escapes(pos, next); 356 if (next != 0) {
360 *regex = xzalloc(sizeof(regex_t)); 357 temp = copy_parsing_escapes(pos, next);
361 xregcomp(*regex, temp, G.regex_type); 358 G.previous_regex_ptr = *regex = xzalloc(sizeof(regex_t));
362 free(temp); 359 xregcomp(*regex, temp, G.regex_type);
360 free(temp);
361 } else {
362 *regex = G.previous_regex_ptr;
363 if (!G.previous_regex_ptr)
364 bb_error_msg_and_die("no previous regexp");
365 }
363 /* Move position to next character after last delimiter */ 366 /* Move position to next character after last delimiter */
364 pos += (next+1); 367 pos += (next+1);
365 } 368 }
diff --git a/editors/vi.c b/editors/vi.c
index 91e954a87..8393eb825 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -5,7 +5,6 @@
5 * 5 *
6 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 6 * Licensed under GPLv2 or later, see file LICENSE in this source tree.
7 */ 7 */
8
9/* 8/*
10 * Things To Do: 9 * Things To Do:
11 * EXINIT 10 * EXINIT
@@ -19,7 +18,6 @@
19 * ":r !cmd" and "!cmd" to filter text through an external command 18 * ":r !cmd" and "!cmd" to filter text through an external command
20 * An "ex" line oriented mode- maybe using "cmdedit" 19 * An "ex" line oriented mode- maybe using "cmdedit"
21 */ 20 */
22
23//config:config VI 21//config:config VI
24//config: bool "vi (22 kb)" 22//config: bool "vi (22 kb)"
25//config: default y 23//config: default y
@@ -224,24 +222,25 @@ enum {
224 * See "Xterm Control Sequences" 222 * See "Xterm Control Sequences"
225 * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html 223 * http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
226 */ 224 */
225#define ESC "\033"
227/* Inverse/Normal text */ 226/* Inverse/Normal text */
228#define ESC_BOLD_TEXT "\033[7m" 227#define ESC_BOLD_TEXT ESC"[7m"
229#define ESC_NORM_TEXT "\033[0m" 228#define ESC_NORM_TEXT ESC"[m"
230/* Bell */ 229/* Bell */
231#define ESC_BELL "\007" 230#define ESC_BELL "\007"
232/* Clear-to-end-of-line */ 231/* Clear-to-end-of-line */
233#define ESC_CLEAR2EOL "\033[K" 232#define ESC_CLEAR2EOL ESC"[K"
234/* Clear-to-end-of-screen. 233/* Clear-to-end-of-screen.
235 * (We use default param here. 234 * (We use default param here.
236 * Full sequence is "ESC [ <num> J", 235 * Full sequence is "ESC [ <num> J",
237 * <num> is 0/1/2 = "erase below/above/all".) 236 * <num> is 0/1/2 = "erase below/above/all".)
238 */ 237 */
239#define ESC_CLEAR2EOS "\033[J" 238#define ESC_CLEAR2EOS ESC"[J"
240/* Cursor to given coordinate (1,1: top left) */ 239/* Cursor to given coordinate (1,1: top left) */
241#define ESC_SET_CURSOR_POS "\033[%u;%uH" 240#define ESC_SET_CURSOR_POS ESC"[%u;%uH"
242//UNUSED 241//UNUSED
243///* Cursor up and down */ 242///* Cursor up and down */
244//#define ESC_CURSOR_UP "\033[A" 243//#define ESC_CURSOR_UP ESC"[A"
245//#define ESC_CURSOR_DOWN "\n" 244//#define ESC_CURSOR_DOWN "\n"
246 245
247#if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK 246#if ENABLE_FEATURE_VI_DOT_CMD || ENABLE_FEATURE_VI_YANKMARK
@@ -696,14 +695,14 @@ int vi_main(int argc, char **argv)
696 save_argc = argc; 695 save_argc = argc;
697 optind = 0; 696 optind = 0;
698 // "Save cursor, use alternate screen buffer, clear screen" 697 // "Save cursor, use alternate screen buffer, clear screen"
699 write1("\033[?1049h"); 698 write1(ESC"[?1049h");
700 while (1) { 699 while (1) {
701 edit_file(argv[optind]); /* param might be NULL */ 700 edit_file(argv[optind]); /* param might be NULL */
702 if (++optind >= argc) 701 if (++optind >= argc)
703 break; 702 break;
704 } 703 }
705 // "Use normal screen buffer, restore cursor" 704 // "Use normal screen buffer, restore cursor"
706 write1("\033[?1049l"); 705 write1(ESC"[?1049l");
707 //----------------------------------------------------------- 706 //-----------------------------------------------------------
708 707
709 return 0; 708 return 0;
@@ -772,7 +771,7 @@ static void edit_file(char *fn)
772#if ENABLE_FEATURE_VI_ASK_TERMINAL 771#if ENABLE_FEATURE_VI_ASK_TERMINAL
773 if (G.get_rowcol_error /* TODO? && no input on stdin */) { 772 if (G.get_rowcol_error /* TODO? && no input on stdin */) {
774 uint64_t k; 773 uint64_t k;
775 write1("\033[999;999H" "\033[6n"); 774 write1(ESC"[999;999H" ESC"[6n");
776 fflush_all(); 775 fflush_all();
777 k = read_key(STDIN_FILENO, readbuffer, /*timeout_ms:*/ 100); 776 k = read_key(STDIN_FILENO, readbuffer, /*timeout_ms:*/ 100);
778 if ((int32_t)k == KEYCODE_CURSOR_POS) { 777 if ((int32_t)k == KEYCODE_CURSOR_POS) {
@@ -4501,7 +4500,7 @@ static void crash_dummy()
4501 sleeptime = 0; // how fast to type 4500 sleeptime = 0; // how fast to type
4502 } 4501 }
4503 } 4502 }
4504 strcat(readbuffer, "\033"); 4503 strcat(readbuffer, ESC);
4505 } 4504 }
4506 readbuffer[0] = strlen(readbuffer + 1); 4505 readbuffer[0] = strlen(readbuffer + 1);
4507 cd1: 4506 cd1: