diff options
author | Ron Yorston <rmy@pobox.com> | 2012-03-22 15:41:00 +0000 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2012-03-22 15:41:00 +0000 |
commit | 1118c95535ea51961437089fc3dece5ab4ea7e1b (patch) | |
tree | 1515bd2376a6d6c5123791662307ce2ed90cdf36 /editors | |
parent | 0d8b2c4a929ea9d3ac37499319fe0d8e7941a0c2 (diff) | |
parent | 066f39956641300c1e5c6bfe6c11a115cea3e2cf (diff) | |
download | busybox-w32-1118c95535ea51961437089fc3dece5ab4ea7e1b.tar.gz busybox-w32-1118c95535ea51961437089fc3dece5ab4ea7e1b.tar.bz2 busybox-w32-1118c95535ea51961437089fc3dece5ab4ea7e1b.zip |
Merge commit '066f39956641300c1e5c6bfe6c11a115cea3e2cf' into merge
Conflicts:
procps/ps.c
Diffstat (limited to 'editors')
-rw-r--r-- | editors/Config.src | 117 | ||||
-rw-r--r-- | editors/Kbuild.src | 1 | ||||
-rw-r--r-- | editors/awk.c | 3 | ||||
-rw-r--r-- | editors/cmp.c | 1 | ||||
-rw-r--r-- | editors/diff.c | 1 | ||||
-rw-r--r-- | editors/patch.c | 17 | ||||
-rw-r--r-- | editors/sed.c | 3 | ||||
-rw-r--r-- | editors/vi.c | 229 |
8 files changed, 198 insertions, 174 deletions
diff --git a/editors/Config.src b/editors/Config.src index 201ee6eb9..af1e1de5e 100644 --- a/editors/Config.src +++ b/editors/Config.src | |||
@@ -67,123 +67,6 @@ config SED | |||
67 | sed is used to perform text transformations on a file | 67 | sed is used to perform text transformations on a file |
68 | or input from a pipeline. | 68 | or input from a pipeline. |
69 | 69 | ||
70 | config VI | ||
71 | bool "vi" | ||
72 | default y | ||
73 | help | ||
74 | 'vi' is a text editor. More specifically, it is the One True | ||
75 | text editor <grin>. It does, however, have a rather steep | ||
76 | learning curve. If you are not already comfortable with 'vi' | ||
77 | you may wish to use something else. | ||
78 | |||
79 | config FEATURE_VI_MAX_LEN | ||
80 | int "Maximum screen width in vi" | ||
81 | range 256 16384 | ||
82 | default 4096 | ||
83 | depends on VI | ||
84 | help | ||
85 | Contrary to what you may think, this is not eating much. | ||
86 | Make it smaller than 4k only if you are very limited on memory. | ||
87 | |||
88 | config FEATURE_VI_8BIT | ||
89 | bool "Allow vi to display 8-bit chars (otherwise shows dots)" | ||
90 | default n | ||
91 | depends on VI | ||
92 | help | ||
93 | If your terminal can display characters with high bit set, | ||
94 | you may want to enable this. Note: vi is not Unicode-capable. | ||
95 | If your terminal combines several 8-bit bytes into one character | ||
96 | (as in Unicode mode), this will not work properly. | ||
97 | |||
98 | config FEATURE_VI_COLON | ||
99 | bool "Enable \":\" colon commands (no \"ex\" mode)" | ||
100 | default y | ||
101 | depends on VI | ||
102 | help | ||
103 | Enable a limited set of colon commands for vi. This does not | ||
104 | provide an "ex" mode. | ||
105 | |||
106 | config FEATURE_VI_YANKMARK | ||
107 | bool "Enable yank/put commands and mark cmds" | ||
108 | default y | ||
109 | depends on VI | ||
110 | help | ||
111 | This will enable you to use yank and put, as well as mark in | ||
112 | busybox vi. | ||
113 | |||
114 | config FEATURE_VI_SEARCH | ||
115 | bool "Enable search and replace cmds" | ||
116 | default y | ||
117 | depends on VI | ||
118 | help | ||
119 | Select this if you wish to be able to do search and replace in | ||
120 | busybox vi. | ||
121 | |||
122 | config FEATURE_VI_USE_SIGNALS | ||
123 | bool "Catch signals" | ||
124 | default y | ||
125 | depends on VI | ||
126 | help | ||
127 | Selecting this option will make busybox vi signal aware. This will | ||
128 | make busybox vi support SIGWINCH to deal with Window Changes, catch | ||
129 | Ctrl-Z and Ctrl-C and alarms. | ||
130 | |||
131 | config FEATURE_VI_DOT_CMD | ||
132 | bool "Remember previous cmd and \".\" cmd" | ||
133 | default y | ||
134 | depends on VI | ||
135 | help | ||
136 | Make busybox vi remember the last command and be able to repeat it. | ||
137 | |||
138 | config FEATURE_VI_READONLY | ||
139 | bool "Enable -R option and \"view\" mode" | ||
140 | default y | ||
141 | depends on VI | ||
142 | help | ||
143 | Enable the read-only command line option, which allows the user to | ||
144 | open a file in read-only mode. | ||
145 | |||
146 | config FEATURE_VI_SETOPTS | ||
147 | bool "Enable set-able options, ai ic showmatch" | ||
148 | default y | ||
149 | depends on VI | ||
150 | help | ||
151 | Enable the editor to set some (ai, ic, showmatch) options. | ||
152 | |||
153 | config FEATURE_VI_SET | ||
154 | bool "Support for :set" | ||
155 | default y | ||
156 | depends on VI | ||
157 | help | ||
158 | Support for ":set". | ||
159 | |||
160 | config FEATURE_VI_WIN_RESIZE | ||
161 | bool "Handle window resize" | ||
162 | default y | ||
163 | depends on VI | ||
164 | help | ||
165 | Make busybox vi behave nicely with terminals that get resized. | ||
166 | |||
167 | config FEATURE_VI_ASK_TERMINAL | ||
168 | bool "Use 'tell me cursor position' ESC sequence to measure window" | ||
169 | default y | ||
170 | depends on VI | ||
171 | help | ||
172 | If terminal size can't be retrieved and $LINES/$COLUMNS are not set, | ||
173 | this option makes vi perform a last-ditch effort to find it: | ||
174 | vi positions cursor to 999,999 and asks terminal to report real | ||
175 | cursor position using "ESC [ 6 n" escape sequence, then reads stdin. | ||
176 | |||
177 | This is not clean but helps a lot on serial lines and such. | ||
178 | |||
179 | config FEATURE_VI_OPTIMIZE_CURSOR | ||
180 | bool "Optimize cursor movement" | ||
181 | default y | ||
182 | depends on VI | ||
183 | help | ||
184 | This will make the cursor movement faster, but requires more memory | ||
185 | and it makes the applet a tiny bit larger. | ||
186 | |||
187 | config FEATURE_ALLOW_EXEC | 70 | config FEATURE_ALLOW_EXEC |
188 | bool "Allow vi and awk to execute shell commands" | 71 | bool "Allow vi and awk to execute shell commands" |
189 | default y | 72 | default y |
diff --git a/editors/Kbuild.src b/editors/Kbuild.src index 2f23ae12f..8888cba12 100644 --- a/editors/Kbuild.src +++ b/editors/Kbuild.src | |||
@@ -12,4 +12,3 @@ lib-$(CONFIG_CMP) += cmp.o | |||
12 | lib-$(CONFIG_DIFF) += diff.o | 12 | lib-$(CONFIG_DIFF) += diff.o |
13 | lib-$(CONFIG_ED) += ed.o | 13 | lib-$(CONFIG_ED) += ed.o |
14 | lib-$(CONFIG_SED) += sed.o | 14 | lib-$(CONFIG_SED) += sed.o |
15 | lib-$(CONFIG_VI) += vi.o | ||
diff --git a/editors/awk.c b/editors/awk.c index 9d38b1f88..7685546e5 100644 --- a/editors/awk.c +++ b/editors/awk.c | |||
@@ -10,8 +10,7 @@ | |||
10 | //usage:#define awk_trivial_usage | 10 | //usage:#define awk_trivial_usage |
11 | //usage: "[OPTIONS] [AWK_PROGRAM] [FILE]..." | 11 | //usage: "[OPTIONS] [AWK_PROGRAM] [FILE]..." |
12 | //usage:#define awk_full_usage "\n\n" | 12 | //usage:#define awk_full_usage "\n\n" |
13 | //usage: "Options:" | 13 | //usage: " -v VAR=VAL Set variable" |
14 | //usage: "\n -v VAR=VAL Set variable" | ||
15 | //usage: "\n -F SEP Use SEP as field separator" | 14 | //usage: "\n -F SEP Use SEP as field separator" |
16 | //usage: "\n -f FILE Read program from FILE" | 15 | //usage: "\n -f FILE Read program from FILE" |
17 | 16 | ||
diff --git a/editors/cmp.c b/editors/cmp.c index 3a0f5aa4f..fbe6b9753 100644 --- a/editors/cmp.c +++ b/editors/cmp.c | |||
@@ -14,7 +14,6 @@ | |||
14 | //usage: "[-l] [-s] FILE1 [FILE2" IF_DESKTOP(" [SKIP1 [SKIP2]]") "]" | 14 | //usage: "[-l] [-s] FILE1 [FILE2" IF_DESKTOP(" [SKIP1 [SKIP2]]") "]" |
15 | //usage:#define cmp_full_usage "\n\n" | 15 | //usage:#define cmp_full_usage "\n\n" |
16 | //usage: "Compare FILE1 with FILE2 (or stdin)\n" | 16 | //usage: "Compare FILE1 with FILE2 (or stdin)\n" |
17 | //usage: "\nOptions:" | ||
18 | //usage: "\n -l Write the byte numbers (decimal) and values (octal)" | 17 | //usage: "\n -l Write the byte numbers (decimal) and values (octal)" |
19 | //usage: "\n for all differing bytes" | 18 | //usage: "\n for all differing bytes" |
20 | //usage: "\n -s Quiet" | 19 | //usage: "\n -s Quiet" |
diff --git a/editors/diff.c b/editors/diff.c index 8b1e92783..8c0a31f47 100644 --- a/editors/diff.c +++ b/editors/diff.c | |||
@@ -81,7 +81,6 @@ | |||
81 | //usage:#define diff_full_usage "\n\n" | 81 | //usage:#define diff_full_usage "\n\n" |
82 | //usage: "Compare files line by line and output the differences between them.\n" | 82 | //usage: "Compare files line by line and output the differences between them.\n" |
83 | //usage: "This implementation supports unified diffs only.\n" | 83 | //usage: "This implementation supports unified diffs only.\n" |
84 | //usage: "\nOptions:" | ||
85 | //usage: "\n -a Treat all files as text" | 84 | //usage: "\n -a Treat all files as text" |
86 | //usage: "\n -b Ignore changes in the amount of whitespace" | 85 | //usage: "\n -b Ignore changes in the amount of whitespace" |
87 | //usage: "\n -B Ignore changes whose lines are all blank" | 86 | //usage: "\n -B Ignore changes whose lines are all blank" |
diff --git a/editors/patch.c b/editors/patch.c index 6d3f319b0..ec5b8e7ad 100644 --- a/editors/patch.c +++ b/editors/patch.c | |||
@@ -15,22 +15,23 @@ | |||
15 | * -D define wrap #ifdef and #ifndef around changes | 15 | * -D define wrap #ifdef and #ifndef around changes |
16 | * -o outfile output here instead of in place | 16 | * -o outfile output here instead of in place |
17 | * -r rejectfile write rejected hunks to this file | 17 | * -r rejectfile write rejected hunks to this file |
18 | * --dry-run (regression!) | ||
18 | * | 19 | * |
19 | * -f force (no questions asked) | 20 | * -f force (no questions asked) |
20 | * -F fuzz (number, default 2) | 21 | * -F fuzz (number, default 2) |
21 | * [file] which file to patch | 22 | * [file] which file to patch |
22 | */ | 23 | */ |
23 | 24 | ||
24 | //applet:IF_PATCH(APPLET(patch, BB_DIR_USR_BIN, BB_SUID_DROP)) | ||
25 | |||
26 | //kbuild:lib-$(CONFIG_PATCH) += patch.o | ||
27 | |||
28 | //config:config PATCH | 25 | //config:config PATCH |
29 | //config: bool "patch" | 26 | //config: bool "patch" |
30 | //config: default y | 27 | //config: default y |
31 | //config: help | 28 | //config: help |
32 | //config: Apply a unified diff formatted patch. | 29 | //config: Apply a unified diff formatted patch. |
33 | 30 | ||
31 | //applet:IF_PATCH(APPLET(patch, BB_DIR_USR_BIN, BB_SUID_DROP)) | ||
32 | |||
33 | //kbuild:lib-$(CONFIG_PATCH) += patch.o | ||
34 | |||
34 | //usage:#define patch_trivial_usage | 35 | //usage:#define patch_trivial_usage |
35 | //usage: "[OPTIONS] [ORIGFILE [PATCHFILE]]" | 36 | //usage: "[OPTIONS] [ORIGFILE [PATCHFILE]]" |
36 | //usage:#define patch_full_usage "\n\n" | 37 | //usage:#define patch_full_usage "\n\n" |
@@ -39,7 +40,7 @@ | |||
39 | //usage: "\n -i,--input DIFF Read DIFF instead of stdin" | 40 | //usage: "\n -i,--input DIFF Read DIFF instead of stdin" |
40 | //usage: "\n -R,--reverse Reverse patch" | 41 | //usage: "\n -R,--reverse Reverse patch" |
41 | //usage: "\n -N,--forward Ignore already applied patches" | 42 | //usage: "\n -N,--forward Ignore already applied patches" |
42 | //usage: "\n --dry-run Don't actually change files" | 43 | /*usage: "\n --dry-run Don't actually change files" - TODO */ |
43 | //usage: "\n -E,--remove-empty-files Remove output files if they become empty" | 44 | //usage: "\n -E,--remove-empty-files Remove output files if they become empty" |
44 | //usage: ) | 45 | //usage: ) |
45 | //usage: IF_NOT_LONG_OPTS( | 46 | //usage: IF_NOT_LONG_OPTS( |
@@ -49,6 +50,8 @@ | |||
49 | //usage: "\n -N Ignore already applied patches" | 50 | //usage: "\n -N Ignore already applied patches" |
50 | //usage: "\n -E Remove output files if they become empty" | 51 | //usage: "\n -E Remove output files if they become empty" |
51 | //usage: ) | 52 | //usage: ) |
53 | /* -u "interpret as unified diff" is supported but not documented: this info is not useful for --help */ | ||
54 | /* -x "debug" is supported but does nothing */ | ||
52 | //usage: | 55 | //usage: |
53 | //usage:#define patch_example_usage | 56 | //usage:#define patch_example_usage |
54 | //usage: "$ patch -p1 < example.diff\n" | 57 | //usage: "$ patch -p1 < example.diff\n" |
@@ -130,8 +133,8 @@ struct globals { | |||
130 | #define FLAG_INPUT (1 << 3) | 133 | #define FLAG_INPUT (1 << 3) |
131 | #define FLAG_IGNORE (1 << 4) | 134 | #define FLAG_IGNORE (1 << 4) |
132 | #define FLAG_RMEMPTY (1 << 5) | 135 | #define FLAG_RMEMPTY (1 << 5) |
133 | //non-standard: | 136 | /* Enable this bit and use -x for debug output: */ |
134 | #define FLAG_DEBUG (1 << 6) | 137 | #define FLAG_DEBUG (0 << 6) |
135 | 138 | ||
136 | // Dispose of a line of input, either by writing it out or discarding it. | 139 | // Dispose of a line of input, either by writing it out or discarding it. |
137 | 140 | ||
diff --git a/editors/sed.c b/editors/sed.c index 99e56ff52..5c4e9cc3b 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -59,8 +59,7 @@ | |||
59 | //usage:#define sed_trivial_usage | 59 | //usage:#define sed_trivial_usage |
60 | //usage: "[-efinr] SED_CMD [FILE]..." | 60 | //usage: "[-efinr] SED_CMD [FILE]..." |
61 | //usage:#define sed_full_usage "\n\n" | 61 | //usage:#define sed_full_usage "\n\n" |
62 | //usage: "Options:" | 62 | //usage: " -e CMD Add CMD to sed commands to be executed" |
63 | //usage: "\n -e CMD Add CMD to sed commands to be executed" | ||
64 | //usage: "\n -f FILE Add FILE contents to sed commands to be executed" | 63 | //usage: "\n -f FILE Add FILE contents to sed commands to be executed" |
65 | //usage: "\n -i Edit files in-place (else sends result to stdout)" | 64 | //usage: "\n -i Edit files in-place (else sends result to stdout)" |
66 | //usage: "\n -n Suppress automatic printing of pattern space" | 65 | //usage: "\n -n Suppress automatic printing of pattern space" |
diff --git a/editors/vi.c b/editors/vi.c index 9d74acc91..deb471d04 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -21,11 +21,138 @@ | |||
21 | * An "ex" line oriented mode- maybe using "cmdedit" | 21 | * An "ex" line oriented mode- maybe using "cmdedit" |
22 | */ | 22 | */ |
23 | 23 | ||
24 | //config:config VI | ||
25 | //config: bool "vi" | ||
26 | //config: default y | ||
27 | //config: help | ||
28 | //config: 'vi' is a text editor. More specifically, it is the One True | ||
29 | //config: text editor <grin>. It does, however, have a rather steep | ||
30 | //config: learning curve. If you are not already comfortable with 'vi' | ||
31 | //config: you may wish to use something else. | ||
32 | //config: | ||
33 | //config:config FEATURE_VI_MAX_LEN | ||
34 | //config: int "Maximum screen width in vi" | ||
35 | //config: range 256 16384 | ||
36 | //config: default 4096 | ||
37 | //config: depends on VI | ||
38 | //config: help | ||
39 | //config: Contrary to what you may think, this is not eating much. | ||
40 | //config: Make it smaller than 4k only if you are very limited on memory. | ||
41 | //config: | ||
42 | //config:config FEATURE_VI_8BIT | ||
43 | //config: bool "Allow vi to display 8-bit chars (otherwise shows dots)" | ||
44 | //config: default n | ||
45 | //config: depends on VI | ||
46 | //config: help | ||
47 | //config: If your terminal can display characters with high bit set, | ||
48 | //config: you may want to enable this. Note: vi is not Unicode-capable. | ||
49 | //config: If your terminal combines several 8-bit bytes into one character | ||
50 | //config: (as in Unicode mode), this will not work properly. | ||
51 | //config: | ||
52 | //config:config FEATURE_VI_COLON | ||
53 | //config: bool "Enable \":\" colon commands (no \"ex\" mode)" | ||
54 | //config: default y | ||
55 | //config: depends on VI | ||
56 | //config: help | ||
57 | //config: Enable a limited set of colon commands for vi. This does not | ||
58 | //config: provide an "ex" mode. | ||
59 | //config: | ||
60 | //config:config FEATURE_VI_YANKMARK | ||
61 | //config: bool "Enable yank/put commands and mark cmds" | ||
62 | //config: default y | ||
63 | //config: depends on VI | ||
64 | //config: help | ||
65 | //config: This will enable you to use yank and put, as well as mark in | ||
66 | //config: busybox vi. | ||
67 | //config: | ||
68 | //config:config FEATURE_VI_SEARCH | ||
69 | //config: bool "Enable search and replace cmds" | ||
70 | //config: default y | ||
71 | //config: depends on VI | ||
72 | //config: help | ||
73 | //config: Select this if you wish to be able to do search and replace in | ||
74 | //config: busybox vi. | ||
75 | //config: | ||
76 | //config:config FEATURE_VI_REGEX_SEARCH | ||
77 | //config: bool "Enable regex in search and replace" | ||
78 | //config: default n # Uses GNU regex, which may be unavailable. FIXME | ||
79 | //config: depends on FEATURE_VI_SEARCH | ||
80 | //config: help | ||
81 | //config: Use extended regex search. | ||
82 | //config: | ||
83 | //config:config FEATURE_VI_USE_SIGNALS | ||
84 | //config: bool "Catch signals" | ||
85 | //config: default y | ||
86 | //config: depends on VI | ||
87 | //config: help | ||
88 | //config: Selecting this option will make busybox vi signal aware. This will | ||
89 | //config: make busybox vi support SIGWINCH to deal with Window Changes, catch | ||
90 | //config: Ctrl-Z and Ctrl-C and alarms. | ||
91 | //config: | ||
92 | //config:config FEATURE_VI_DOT_CMD | ||
93 | //config: bool "Remember previous cmd and \".\" cmd" | ||
94 | //config: default y | ||
95 | //config: depends on VI | ||
96 | //config: help | ||
97 | //config: Make busybox vi remember the last command and be able to repeat it. | ||
98 | //config: | ||
99 | //config:config FEATURE_VI_READONLY | ||
100 | //config: bool "Enable -R option and \"view\" mode" | ||
101 | //config: default y | ||
102 | //config: depends on VI | ||
103 | //config: help | ||
104 | //config: Enable the read-only command line option, which allows the user to | ||
105 | //config: open a file in read-only mode. | ||
106 | //config: | ||
107 | //config:config FEATURE_VI_SETOPTS | ||
108 | //config: bool "Enable set-able options, ai ic showmatch" | ||
109 | //config: default y | ||
110 | //config: depends on VI | ||
111 | //config: help | ||
112 | //config: Enable the editor to set some (ai, ic, showmatch) options. | ||
113 | //config: | ||
114 | //config:config FEATURE_VI_SET | ||
115 | //config: bool "Support for :set" | ||
116 | //config: default y | ||
117 | //config: depends on VI | ||
118 | //config: help | ||
119 | //config: Support for ":set". | ||
120 | //config: | ||
121 | //config:config FEATURE_VI_WIN_RESIZE | ||
122 | //config: bool "Handle window resize" | ||
123 | //config: default y | ||
124 | //config: depends on VI | ||
125 | //config: help | ||
126 | //config: Make busybox vi behave nicely with terminals that get resized. | ||
127 | //config: | ||
128 | //config:config FEATURE_VI_ASK_TERMINAL | ||
129 | //config: bool "Use 'tell me cursor position' ESC sequence to measure window" | ||
130 | //config: default y | ||
131 | //config: depends on VI | ||
132 | //config: help | ||
133 | //config: If terminal size can't be retrieved and $LINES/$COLUMNS are not set, | ||
134 | //config: this option makes vi perform a last-ditch effort to find it: | ||
135 | //config: vi positions cursor to 999,999 and asks terminal to report real | ||
136 | //config: cursor position using "ESC [ 6 n" escape sequence, then reads stdin. | ||
137 | //config: | ||
138 | //config: This is not clean but helps a lot on serial lines and such. | ||
139 | //config: | ||
140 | //config:config FEATURE_VI_OPTIMIZE_CURSOR | ||
141 | //config: bool "Optimize cursor movement" | ||
142 | //config: default y | ||
143 | //config: depends on VI | ||
144 | //config: help | ||
145 | //config: This will make the cursor movement faster, but requires more memory | ||
146 | //config: and it makes the applet a tiny bit larger. | ||
147 | |||
148 | //applet:IF_VI(APPLET(vi, BB_DIR_BIN, BB_SUID_DROP)) | ||
149 | |||
150 | //kbuild:lib-$(CONFIG_VI) += vi.o | ||
151 | |||
24 | //usage:#define vi_trivial_usage | 152 | //usage:#define vi_trivial_usage |
25 | //usage: "[OPTIONS] [FILE]..." | 153 | //usage: "[OPTIONS] [FILE]..." |
26 | //usage:#define vi_full_usage "\n\n" | 154 | //usage:#define vi_full_usage "\n\n" |
27 | //usage: "Edit FILE\n" | 155 | //usage: "Edit FILE\n" |
28 | //usage: "\nOptions:" | ||
29 | //usage: IF_FEATURE_VI_COLON( | 156 | //usage: IF_FEATURE_VI_COLON( |
30 | //usage: "\n -c Initial command to run ($EXINIT also available)" | 157 | //usage: "\n -c Initial command to run ($EXINIT also available)" |
31 | //usage: ) | 158 | //usage: ) |
@@ -35,6 +162,10 @@ | |||
35 | //usage: "\n -H Short help regarding available features" | 162 | //usage: "\n -H Short help regarding available features" |
36 | 163 | ||
37 | #include "libbb.h" | 164 | #include "libbb.h" |
165 | /* Should be after libbb.h: on some systems regex.h needs sys/types.h: */ | ||
166 | #if ENABLE_FEATURE_VI_REGEX_SEARCH | ||
167 | # include <regex.h> | ||
168 | #endif | ||
38 | 169 | ||
39 | /* the CRASHME code is unmaintained, and doesn't currently build */ | 170 | /* the CRASHME code is unmaintained, and doesn't currently build */ |
40 | #define ENABLE_FEATURE_VI_CRASHME 0 | 171 | #define ENABLE_FEATURE_VI_CRASHME 0 |
@@ -53,9 +184,9 @@ | |||
53 | 184 | ||
54 | /* 0x9b is Meta-ESC */ | 185 | /* 0x9b is Meta-ESC */ |
55 | #if ENABLE_FEATURE_VI_8BIT | 186 | #if ENABLE_FEATURE_VI_8BIT |
56 | #define Isprint(c) ((unsigned char)(c) >= ' ' && (c) != 0x7f && (unsigned char)(c) != 0x9b) | 187 | # define Isprint(c) ((unsigned char)(c) >= ' ' && (c) != 0x7f && (unsigned char)(c) != 0x9b) |
57 | #else | 188 | #else |
58 | #define Isprint(c) ((unsigned char)(c) >= ' ' && (unsigned char)(c) < 0x7f) | 189 | # define Isprint(c) ((unsigned char)(c) >= ' ' && (unsigned char)(c) < 0x7f) |
59 | #endif | 190 | #endif |
60 | 191 | ||
61 | #endif | 192 | #endif |
@@ -367,7 +498,6 @@ static void Hit_Return(void); | |||
367 | 498 | ||
368 | #if ENABLE_FEATURE_VI_SEARCH | 499 | #if ENABLE_FEATURE_VI_SEARCH |
369 | static char *char_search(char *, const char *, int, int); // search for pattern starting at p | 500 | static char *char_search(char *, const char *, int, int); // search for pattern starting at p |
370 | static int mycmp(const char *, const char *, int); // string cmp based in "ignorecase" | ||
371 | #endif | 501 | #endif |
372 | #if ENABLE_FEATURE_VI_COLON | 502 | #if ENABLE_FEATURE_VI_COLON |
373 | static char *get_one_address(char *, int *); // get colon addr, if present | 503 | static char *get_one_address(char *, int *); // get colon addr, if present |
@@ -1562,48 +1692,16 @@ static char *new_screen(int ro, int co) | |||
1562 | } | 1692 | } |
1563 | 1693 | ||
1564 | #if ENABLE_FEATURE_VI_SEARCH | 1694 | #if ENABLE_FEATURE_VI_SEARCH |
1565 | static int mycmp(const char *s1, const char *s2, int len) | 1695 | |
1566 | { | 1696 | # if ENABLE_FEATURE_VI_REGEX_SEARCH |
1567 | if (ENABLE_FEATURE_VI_SETOPTS && ignorecase) { | ||
1568 | return strncasecmp(s1, s2, len); | ||
1569 | } | ||
1570 | return strncmp(s1, s2, len); | ||
1571 | } | ||
1572 | 1697 | ||
1573 | // search for pattern starting at p | 1698 | // search for pattern starting at p |
1574 | static char *char_search(char *p, const char *pat, int dir, int range) | 1699 | static char *char_search(char *p, const char *pat, int dir, int range) |
1575 | { | 1700 | { |
1576 | #ifndef REGEX_SEARCH | ||
1577 | char *start, *stop; | ||
1578 | int len; | ||
1579 | |||
1580 | len = strlen(pat); | ||
1581 | if (dir == FORWARD) { | ||
1582 | stop = end - 1; // assume range is p - end-1 | ||
1583 | if (range == LIMITED) | ||
1584 | stop = next_line(p); // range is to next line | ||
1585 | for (start = p; start < stop; start++) { | ||
1586 | if (mycmp(start, pat, len) == 0) { | ||
1587 | return start; | ||
1588 | } | ||
1589 | } | ||
1590 | } else if (dir == BACK) { | ||
1591 | stop = text; // assume range is text - p | ||
1592 | if (range == LIMITED) | ||
1593 | stop = prev_line(p); // range is to prev line | ||
1594 | for (start = p - len; start >= stop; start--) { | ||
1595 | if (mycmp(start, pat, len) == 0) { | ||
1596 | return start; | ||
1597 | } | ||
1598 | } | ||
1599 | } | ||
1600 | // pattern not found | ||
1601 | return NULL; | ||
1602 | #else /* REGEX_SEARCH */ | ||
1603 | char *q; | 1701 | char *q; |
1604 | struct re_pattern_buffer preg; | 1702 | struct re_pattern_buffer preg; |
1605 | int i; | 1703 | int i; |
1606 | int size, range; | 1704 | int size; |
1607 | 1705 | ||
1608 | re_syntax_options = RE_SYNTAX_POSIX_EXTENDED; | 1706 | re_syntax_options = RE_SYNTAX_POSIX_EXTENDED; |
1609 | preg.translate = 0; | 1707 | preg.translate = 0; |
@@ -1626,7 +1724,7 @@ static char *char_search(char *p, const char *pat, int dir, int range) | |||
1626 | // RANGE could be negative if we are searching backwards | 1724 | // RANGE could be negative if we are searching backwards |
1627 | range = q - p; | 1725 | range = q - p; |
1628 | 1726 | ||
1629 | q = re_compile_pattern(pat, strlen(pat), &preg); | 1727 | q = (char *)re_compile_pattern(pat, strlen(pat), (struct re_pattern_buffer *)&preg); |
1630 | if (q != 0) { | 1728 | if (q != 0) { |
1631 | // The pattern was not compiled | 1729 | // The pattern was not compiled |
1632 | status_line_bold("bad search pattern: \"%s\": %s", pat, q); | 1730 | status_line_bold("bad search pattern: \"%s\": %s", pat, q); |
@@ -1660,8 +1758,53 @@ static char *char_search(char *p, const char *pat, int dir, int range) | |||
1660 | p = p - i; | 1758 | p = p - i; |
1661 | } | 1759 | } |
1662 | return p; | 1760 | return p; |
1663 | #endif /* REGEX_SEARCH */ | ||
1664 | } | 1761 | } |
1762 | |||
1763 | # else | ||
1764 | |||
1765 | # if ENABLE_FEATURE_VI_SETOPTS | ||
1766 | static int mycmp(const char *s1, const char *s2, int len) | ||
1767 | { | ||
1768 | if (ignorecase) { | ||
1769 | return strncasecmp(s1, s2, len); | ||
1770 | } | ||
1771 | return strncmp(s1, s2, len); | ||
1772 | } | ||
1773 | # else | ||
1774 | # define mycmp strncmp | ||
1775 | # endif | ||
1776 | |||
1777 | static char *char_search(char *p, const char *pat, int dir, int range) | ||
1778 | { | ||
1779 | char *start, *stop; | ||
1780 | int len; | ||
1781 | |||
1782 | len = strlen(pat); | ||
1783 | if (dir == FORWARD) { | ||
1784 | stop = end - 1; // assume range is p - end-1 | ||
1785 | if (range == LIMITED) | ||
1786 | stop = next_line(p); // range is to next line | ||
1787 | for (start = p; start < stop; start++) { | ||
1788 | if (mycmp(start, pat, len) == 0) { | ||
1789 | return start; | ||
1790 | } | ||
1791 | } | ||
1792 | } else if (dir == BACK) { | ||
1793 | stop = text; // assume range is text - p | ||
1794 | if (range == LIMITED) | ||
1795 | stop = prev_line(p); // range is to prev line | ||
1796 | for (start = p - len; start >= stop; start--) { | ||
1797 | if (mycmp(start, pat, len) == 0) { | ||
1798 | return start; | ||
1799 | } | ||
1800 | } | ||
1801 | } | ||
1802 | // pattern not found | ||
1803 | return NULL; | ||
1804 | } | ||
1805 | |||
1806 | # endif | ||
1807 | |||
1665 | #endif /* FEATURE_VI_SEARCH */ | 1808 | #endif /* FEATURE_VI_SEARCH */ |
1666 | 1809 | ||
1667 | static char *char_insert(char *p, char c) // insert the char c at 'p' | 1810 | static char *char_insert(char *p, char c) // insert the char c at 'p' |
@@ -2023,8 +2166,8 @@ static void show_help(void) | |||
2023 | "\n\tNamed buffers with \"x" | 2166 | "\n\tNamed buffers with \"x" |
2024 | #endif | 2167 | #endif |
2025 | #if ENABLE_FEATURE_VI_READONLY | 2168 | #if ENABLE_FEATURE_VI_READONLY |
2026 | "\n\tReadonly if vi is called as \"view\"" | 2169 | //not implemented: "\n\tReadonly if vi is called as \"view\"" |
2027 | "\n\tReadonly with -R command line arg" | 2170 | //redundant: usage text says this too: "\n\tReadonly with -R command line arg" |
2028 | #endif | 2171 | #endif |
2029 | #if ENABLE_FEATURE_VI_SET | 2172 | #if ENABLE_FEATURE_VI_SET |
2030 | "\n\tSome colon mode commands with \':\'" | 2173 | "\n\tSome colon mode commands with \':\'" |