diff options
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r-- | src/nvim/ex_docmd.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index b8b98c4f0d..ead0922c5a 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -4538,6 +4538,19 @@ skip_cmd_arg ( return p; } +int get_bad_opt(const char_u *p, exarg_T *eap) + FUNC_ATTR_NONNULL_ALL +{ + if (STRICMP(p, "keep") == 0) { + eap->bad_char = BAD_KEEP; + } else if (STRICMP(p, "drop") == 0) { + eap->bad_char = BAD_DROP; + } else if (MB_BYTE2LEN(*p) == 1 && p[1] == NUL) { + eap->bad_char = *p; + } + return FAIL; +} + /* * Get "++opt=arg" argument. * Return FAIL or OK. @@ -4596,8 +4609,10 @@ static int getargopt(exarg_T *eap) *arg = NUL; if (pp == &eap->force_ff) { - if (check_ff_value(eap->cmd + eap->force_ff) == FAIL) + if (check_ff_value(eap->cmd + eap->force_ff) == FAIL) { return FAIL; + } + eap->force_ff = eap->cmd[eap->force_ff]; } else if (pp == &eap->force_enc) { /* Make 'fileencoding' lower case. */ for (p = eap->cmd + eap->force_enc; *p != NUL; ++p) @@ -4605,15 +4620,9 @@ static int getargopt(exarg_T *eap) } else { /* Check ++bad= argument. Must be a single-byte character, "keep" or * "drop". */ - p = eap->cmd + bad_char_idx; - if (STRICMP(p, "keep") == 0) - eap->bad_char = BAD_KEEP; - else if (STRICMP(p, "drop") == 0) - eap->bad_char = BAD_DROP; - else if (MB_BYTE2LEN(*p) == 1 && p[1] == NUL) - eap->bad_char = *p; - else + if (get_bad_opt(eap->cmd + bad_char_idx, eap) == FAIL) { return FAIL; + } } return OK; |