diff options
Diffstat (limited to 'src/nvim/ex_getln.c')
-rw-r--r-- | src/nvim/ex_getln.c | 53 |
1 files changed, 22 insertions, 31 deletions
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c index fd11acff84..1810056a4a 100644 --- a/src/nvim/ex_getln.c +++ b/src/nvim/ex_getln.c @@ -201,7 +201,10 @@ static Array cmdline_block = ARRAY_DICT_INIT; /* * Type used by call_user_expand_func */ -typedef void *(*user_expand_func_T)(char_u *, int, char_u **, int); +typedef void *(*user_expand_func_T)(const char_u *, + int, + const char_u * const *, + bool); static histentry_T *(history[HIST_COUNT]) = {NULL, NULL, NULL, NULL, NULL}; static int hisidx[HIST_COUNT] = {-1, -1, -1, -1, -1}; /* lastused entry */ @@ -3324,16 +3327,11 @@ static bool cmdline_paste(int regname, bool literally, bool remcr) /* Locate start of last word in the cmd buffer. */ for (w = ccline.cmdbuff + ccline.cmdpos; w > ccline.cmdbuff; ) { - if (has_mbyte) { - len = (*mb_head_off)(ccline.cmdbuff, w - 1) + 1; - if (!vim_iswordc(mb_ptr2char(w - len))) - break; - w -= len; - } else { - if (!vim_iswordc(w[-1])) - break; - --w; + len = utf_head_off(ccline.cmdbuff, w - 1) + 1; + if (!vim_iswordc(utf_ptr2char(w - len))) { + break; } + w -= len; } len = (int)((ccline.cmdbuff + ccline.cmdpos) - w); if (p_ic ? STRNICMP(w, arg, len) == 0 : STRNCMP(w, arg, len) == 0) @@ -3834,24 +3832,13 @@ ExpandOne ( // Find longest common part if (mode == WILD_LONGEST && xp->xp_numfiles > 0) { - size_t len; - size_t mb_len = 1; - int c0; - int ci; + size_t len = 0; - for (len = 0; xp->xp_files[0][len]; len += mb_len) { - if (has_mbyte) { - mb_len = (* mb_ptr2len)(&xp->xp_files[0][len]); - c0 = (* mb_ptr2char)(&xp->xp_files[0][len]); - } else { - c0 = xp->xp_files[0][len]; - } - for (i = 1; i < xp->xp_numfiles; ++i) { - if (has_mbyte) { - ci =(* mb_ptr2char)(&xp->xp_files[i][len]); - } else { - ci = xp->xp_files[i][len]; - } + for (size_t mb_len; xp->xp_files[0][len]; len += mb_len) { + mb_len = utfc_ptr2len(&xp->xp_files[0][len]); + int c0 = utf_ptr2char(&xp->xp_files[0][len]); + for (i = 1; i < xp->xp_numfiles; i++) { + int ci = utf_ptr2char(&xp->xp_files[i][len]); if (p_fic && (xp->xp_context == EXPAND_DIRECTORIES || xp->xp_context == EXPAND_FILES @@ -5046,7 +5033,10 @@ static void * call_user_expand_func(user_expand_func_T user_expand_func, ccline.cmdprompt = NULL; current_SID = xp->xp_scriptID; - ret = user_expand_func(xp->xp_arg, 3, args, FALSE); + ret = user_expand_func(xp->xp_arg, + 3, + (const char_u * const *)args, + false); ccline = save_ccline; current_SID = save_current_SID; @@ -5062,11 +5052,12 @@ static void * call_user_expand_func(user_expand_func_T user_expand_func, */ static int ExpandUserDefined(expand_T *xp, regmatch_T *regmatch, int *num_file, char_u ***file) { - char_u *e; - garray_T ga; + char_u *e; + garray_T ga; char_u *const retstr = call_user_expand_func( (user_expand_func_T)call_func_retstr, xp, num_file, file); + if (retstr == NULL) { return FAIL; } @@ -6093,7 +6084,7 @@ static int open_cmdwin(void) /* Replace the empty last line with the current command-line and put the * cursor there. */ - ml_replace(curbuf->b_ml.ml_line_count, ccline.cmdbuff, TRUE); + ml_replace(curbuf->b_ml.ml_line_count, ccline.cmdbuff, true); curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count; curwin->w_cursor.col = ccline.cmdpos; changed_line_abv_curs(); |