[git commit] vi: fix '' command (goto to prev context)
Denys Vlasenko
vda.linux at googlemail.com
Wed Sep 28 14:23:05 UTC 2016
commit: https://git.busybox.net/busybox/commit/?id=61fcc8c78174f92fbdad0a7f86b5086619b05ed9
branch: https://git.busybox.net/busybox/commit/?id=refs/heads/master
The '' command in vi doesn't currently work because after the first
apostrophe is read, the next character is converted to an integer
between 0 and 25 inclusive (for indexing the array of marks). The
comparison of the converted character with an apostrophe therefore never
succeeds, meaning that '' doesn't do anything.
Based on the patch by Francis Rounds <francis.rounds at 4bridgeworks.com>
Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
editors/vi.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/editors/vi.c b/editors/vi.c
index c142dac..38a4692 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -2722,9 +2722,8 @@ static char *swap_context(char *p) // goto new context for '' command make this
// only swap context if other context is valid
if (text <= mark[27] && mark[27] <= end - 1) {
tmp = mark[27];
- mark[27] = mark[26];
- mark[26] = tmp;
- p = mark[26]; // where we are going- previous context
+ mark[27] = p;
+ mark[26] = p = tmp;
context_start = prev_line(prev_line(prev_line(p)));
context_end = next_line(next_line(next_line(p)));
}
@@ -3618,8 +3617,9 @@ static void do_cmd(int c)
}
break;
case '\'': // '- goto a specific mark
- c1 = (get_one_char() | 0x20) - 'a';
- if ((unsigned)c1 <= 25) { // a-z?
+ c1 = (get_one_char() | 0x20);
+ if ((unsigned)(c1 - 'a') <= 25) { // a-z?
+ c1 = (c1 - 'a');
// get the b-o-l
q = mark[c1];
if (text <= q && q < end) {
More information about the busybox-cvs
mailing list