summaryrefslogtreecommitdiff
path: root/editors/vi.c
diff options
context:
space:
mode:
authorDenys Vlasenko2021-04-15 23:17:01 +0200
committerDenys Vlasenko2021-04-15 23:18:40 +0200
commitb65e7f629ef3cd655eb9a2a6f47530e5fd098ae3 (patch)
treecc13932bf37240ae3c28859b01e46163cc50c2ae /editors/vi.c
parentf2277268384d47fbcaba081f19cebc68de819836 (diff)
downloadbusybox-b65e7f629ef3cd655eb9a2a6f47530e5fd098ae3.zip
busybox-b65e7f629ef3cd655eb9a2a6f47530e5fd098ae3.tar.gz
vi: move undo_queue_state in globals to other byte-sized members
function old new delta vi_main 278 275 -3 undo_queue_commit 62 56 -6 undo_push 374 362 -12 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/3 up/down: 0/-21) Total: -21 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'editors/vi.c')
-rw-r--r--editors/vi.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/editors/vi.c b/editors/vi.c
index 6dd9514..09f6eca 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -352,6 +352,9 @@ struct globals {
#if ENABLE_FEATURE_VI_CRASHME
char last_input_char; // last char read from user
#endif
+#if ENABLE_FEATURE_VI_UNDO_QUEUE
+ char undo_queue_state; // One of UNDO_INS, UNDO_DEL, UNDO_EMPTY
+#endif
#if ENABLE_FEATURE_VI_DOT_CMD
smallint adding2q; // are we currently adding user input to q
@@ -425,15 +428,6 @@ struct globals {
#define ALLOW_UNDO_QUEUED ALLOW_UNDO
# endif
-# if ENABLE_FEATURE_VI_UNDO_QUEUE
-#define UNDO_USE_SPOS 32
-#define UNDO_EMPTY 64
- char undo_queue_state; // One of UNDO_INS, UNDO_DEL, UNDO_EMPTY
- int undo_q;
- char *undo_queue_spos; // Start position of queued operation
- char undo_queue[CONFIG_FEATURE_VI_UNDO_QUEUE_MAX];
-# endif
-
struct undo_object {
struct undo_object *prev; // Linking back avoids list traversal (LIFO)
int start; // Offset where the data should be restored/deleted
@@ -441,6 +435,13 @@ struct globals {
uint8_t u_type; // 0=deleted, 1=inserted, 2=swapped
char undo_text[1]; // text that was deleted (if deletion)
} *undo_stack_tail;
+# if ENABLE_FEATURE_VI_UNDO_QUEUE
+#define UNDO_USE_SPOS 32
+#define UNDO_EMPTY 64
+ char *undo_queue_spos; // Start position of queued operation
+ int undo_q;
+ char undo_queue[CONFIG_FEATURE_VI_UNDO_QUEUE_MAX];
+# endif
#endif /* ENABLE_FEATURE_VI_UNDO */
};
#define G (*ptr_to_globals)
@@ -2071,8 +2072,8 @@ static uintptr_t stupid_insert(char *p, char c) // stupidly insert the char c at
static char *char_insert(char *p, char c, int undo) // insert the char c at 'p'
{
#if ENABLE_FEATURE_VI_SETOPTS
- char *q;
- size_t len;
+ char *q;
+ size_t len;
#endif
if (c == 22) { // Is this an ctrl-V?
@@ -2140,9 +2141,9 @@ static char *char_insert(char *p, char c, int undo) // insert the char c at 'p'
bias = text_hole_make(p, len);
p += bias;
q += bias;
-#if ENABLE_FEATURE_VI_UNDO
+# if ENABLE_FEATURE_VI_UNDO
undo_push_insert(p, len, undo);
-#endif
+# endif
memcpy(p, q, len);
p += len;
}