aboutsummaryrefslogtreecommitdiffstats
path: root/package/utils/busybox/patches/402-vi-avoid-touching-a-new-file-with-ZZ-when-no-editing.patch
diff options
context:
space:
mode:
authorYousong Zhou <yszhou4tech@gmail.com>2017-03-25 13:23:06 +0800
committerYousong Zhou <yszhou4tech@gmail.com>2017-03-25 13:23:58 +0800
commit0d304d4228332b2233d40207ca686083cb4a5ae1 (patch)
treef1b55345d6df1732dececef00b0d31dc6f7cb478 /package/utils/busybox/patches/402-vi-avoid-touching-a-new-file-with-ZZ-when-no-editing.patch
parent474c31a20d834d24646837738355d7ffc2483efa (diff)
downloadupstream-0d304d4228332b2233d40207ca686083cb4a5ae1.tar.gz
upstream-0d304d4228332b2233d40207ca686083cb4a5ae1.tar.bz2
upstream-0d304d4228332b2233d40207ca686083cb4a5ae1.zip
busybox: vi: backporting patches to fix ZZ and :x command
Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
Diffstat (limited to 'package/utils/busybox/patches/402-vi-avoid-touching-a-new-file-with-ZZ-when-no-editing.patch')
-rw-r--r--package/utils/busybox/patches/402-vi-avoid-touching-a-new-file-with-ZZ-when-no-editing.patch53
1 files changed, 53 insertions, 0 deletions
diff --git a/package/utils/busybox/patches/402-vi-avoid-touching-a-new-file-with-ZZ-when-no-editing.patch b/package/utils/busybox/patches/402-vi-avoid-touching-a-new-file-with-ZZ-when-no-editing.patch
new file mode 100644
index 0000000000..b56cf735c2
--- /dev/null
+++ b/package/utils/busybox/patches/402-vi-avoid-touching-a-new-file-with-ZZ-when-no-editing.patch
@@ -0,0 +1,53 @@
+From 8f3bf4f0d3605b50a8e4c48c89aeabc455f04884 Mon Sep 17 00:00:00 2001
+From: Yousong Zhou <yszhou4tech@gmail.com>
+Date: Fri, 24 Mar 2017 21:13:10 +0100
+Subject: [PATCH 2/2] vi: avoid touching a new file with ZZ when no editing has
+ been done
+
+This is the behaviour observed with standard vim and busybox vi of at
+least 1.22.1. It was changed with commit "32afd3a vi: some
+simplifications" which happened before 1.23.0.
+
+Mistyping filename on command line happens fairly often and it's better
+we restore the old behaviour to avoid a few unnecessary flash writes and
+sometimes efforts of debugging bugs caused by those unneeded stray
+files.
+
+Signed-off-by: Yousong Zhou <yszhou4tech@gmail.com>
+Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
+---
+ editors/vi.c | 16 ++++++++--------
+ 1 file changed, 8 insertions(+), 8 deletions(-)
+
+--- a/editors/vi.c
++++ b/editors/vi.c
+@@ -719,14 +719,6 @@ static int init_text_buffer(char *fn)
+ {
+ int rc;
+
+- flush_undo_data();
+- modified_count = 0;
+- last_modified_count = -1;
+-#if ENABLE_FEATURE_VI_YANKMARK
+- /* init the marks */
+- memset(mark, 0, sizeof(mark));
+-#endif
+-
+ /* allocate/reallocate text buffer */
+ free(text);
+ text_size = 10240;
+@@ -741,6 +733,14 @@ static int init_text_buffer(char *fn)
+ // file doesnt exist. Start empty buf with dummy line
+ char_insert(text, '\n', NO_UNDO);
+ }
++
++ flush_undo_data();
++ modified_count = 0;
++ last_modified_count = -1;
++#if ENABLE_FEATURE_VI_YANKMARK
++ /* init the marks */
++ memset(mark, 0, sizeof(mark));
++#endif
+ return rc;
+ }
+