summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2021-07-13 16:16:21 +0200
committerDenys Vlasenko2021-07-13 16:16:21 +0200
commit36feb2682481d55ae49df899c38e16130227ba4a (patch)
tree37f9376873ec433d596aa062bee90b5518c24033
parent2759201401cf87a9a8621edd9e5f44dfe838407c (diff)
downloadbusybox-36feb2682481d55ae49df899c38e16130227ba4a.zip
busybox-36feb2682481d55ae49df899c38e16130227ba4a.tar.gz
vi: somewhat more readable code, no logic changes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--editors/vi.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/editors/vi.c b/editors/vi.c
index c6bb74c..5c601c7 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -2683,12 +2683,13 @@ static char *expand_args(char *args)
// Like strchr() but skipping backslash-escaped characters
static char *strchr_backslash(const char *s, int c)
{
- for (; *s; ++s) {
+ while (*s) {
if (*s == c) {
return (char *)s;
- } else if (*s == '\\' && *++s == '\0') {
- break;
- }
+ if (*s == '\\')
+ if (*++s == '\0')
+ break;
+ s++;
}
return NULL;
}
@@ -3237,10 +3238,10 @@ static void colon(char *buf)
# endif
if (TEST_LEN_F) // match can be empty, no delete needed
text_hole_delete(found, found + len_F - 1,
- TEST_UNDO1 ? ALLOW_UNDO_CHAIN: ALLOW_UNDO);
- if (len_R) { // insert the "replace" pattern, if required
+ TEST_UNDO1 ? ALLOW_UNDO_CHAIN : ALLOW_UNDO);
+ if (len_R != 0) { // insert the "replace" pattern, if required
bias = string_insert(found, R,
- TEST_UNDO2 ? ALLOW_UNDO_CHAIN: ALLOW_UNDO);
+ TEST_UNDO2 ? ALLOW_UNDO_CHAIN : ALLOW_UNDO);
found += bias;
ls += bias;
dot = ls;
@@ -3249,7 +3250,7 @@ static void colon(char *buf)
# if ENABLE_FEATURE_VI_REGEX_SEARCH
free(R);
# endif
- if (TEST_LEN_F || len_R) {
+ if (TEST_LEN_F || len_R != 0) {
dot = ls;
subs++;
# if ENABLE_FEATURE_VI_VERBOSE_STATUS