mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #8526 from janlazo/vim-8.0.0451
This commit is contained in:
commit
4c3c04d03c
@ -804,7 +804,7 @@ unsigned int win_linetabsize(win_T *wp, char_u *line, colnr_T len)
|
|||||||
|
|
||||||
for (char_u *s = line;
|
for (char_u *s = line;
|
||||||
*s != NUL && (len == MAXCOL || s < line + len);
|
*s != NUL && (len == MAXCOL || s < line + len);
|
||||||
mb_ptr_adv(s)) {
|
MB_PTR_ADV(s)) {
|
||||||
col += win_lbr_chartabsize(wp, line, s, col, NULL);
|
col += win_lbr_chartabsize(wp, line, s, col, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -971,7 +971,7 @@ int lbr_chartabsize_adv(char_u *line, char_u **s, colnr_T col)
|
|||||||
int retval;
|
int retval;
|
||||||
|
|
||||||
retval = lbr_chartabsize(line, *s, col);
|
retval = lbr_chartabsize(line, *s, col);
|
||||||
mb_ptr_adv(*s);
|
MB_PTR_ADV(*s);
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1038,7 +1038,7 @@ int win_lbr_chartabsize(win_T *wp, char_u *line, char_u *s, colnr_T col, int *he
|
|||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ps = s;
|
ps = s;
|
||||||
mb_ptr_adv(s);
|
MB_PTR_ADV(s);
|
||||||
c = *s;
|
c = *s;
|
||||||
|
|
||||||
if (!(c != NUL
|
if (!(c != NUL
|
||||||
@ -1283,7 +1283,7 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
vcol += incr;
|
vcol += incr;
|
||||||
mb_ptr_adv(ptr);
|
MB_PTR_ADV(ptr);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
@ -1304,7 +1304,7 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor,
|
|||||||
}
|
}
|
||||||
|
|
||||||
vcol += incr;
|
vcol += incr;
|
||||||
mb_ptr_adv(ptr);
|
MB_PTR_ADV(ptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
#include "nvim/pos.h"
|
#include "nvim/pos.h"
|
||||||
#include "nvim/buffer_defs.h"
|
#include "nvim/buffer_defs.h"
|
||||||
#include "nvim/eval/typval.h"
|
#include "nvim/eval/typval.h"
|
||||||
|
#include "nvim/option_defs.h"
|
||||||
|
|
||||||
/// Return the folded-case equivalent of the given character
|
/// Return the folded-case equivalent of the given character
|
||||||
///
|
///
|
||||||
@ -34,4 +35,15 @@ typedef enum {
|
|||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
# include "charset.h.generated.h"
|
# include "charset.h.generated.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static inline bool vim_isbreak(int c)
|
||||||
|
REAL_FATTR_CONST
|
||||||
|
REAL_FATTR_ALWAYS_INLINE;
|
||||||
|
|
||||||
|
/// Check if `c` is one of the characters in 'breakat'.
|
||||||
|
/// Used very often if 'linebreak' is set
|
||||||
|
static inline bool vim_isbreak(int c)
|
||||||
|
{
|
||||||
|
return breakat_flags[(char_u)c];
|
||||||
|
}
|
||||||
#endif // NVIM_CHARSET_H
|
#endif // NVIM_CHARSET_H
|
||||||
|
@ -144,7 +144,7 @@ static int coladvance2(
|
|||||||
while (col <= wcol && *ptr != NUL) {
|
while (col <= wcol && *ptr != NUL) {
|
||||||
/* Count a tab for what it's worth (if list mode not on) */
|
/* Count a tab for what it's worth (if list mode not on) */
|
||||||
csize = win_lbr_chartabsize(curwin, line, ptr, col, &head);
|
csize = win_lbr_chartabsize(curwin, line, ptr, col, &head);
|
||||||
mb_ptr_adv(ptr);
|
MB_PTR_ADV(ptr);
|
||||||
col += csize;
|
col += csize;
|
||||||
}
|
}
|
||||||
idx = (int)(ptr - line);
|
idx = (int)(ptr - line);
|
||||||
|
@ -658,7 +658,7 @@ static int insert_execute(VimState *state, int key)
|
|||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
if (str != NULL) {
|
if (str != NULL) {
|
||||||
for (p = str; *p != NUL; mb_ptr_adv(p)) {
|
for (p = str; *p != NUL; MB_PTR_ADV(p)) {
|
||||||
ins_compl_addleader(PTR2CHAR(p));
|
ins_compl_addleader(PTR2CHAR(p));
|
||||||
}
|
}
|
||||||
xfree(str);
|
xfree(str);
|
||||||
@ -1196,7 +1196,7 @@ normalchar:
|
|||||||
if (str != NULL) {
|
if (str != NULL) {
|
||||||
if (*str != NUL && stop_arrow() != FAIL) {
|
if (*str != NUL && stop_arrow() != FAIL) {
|
||||||
// Insert the new value of v:char literally.
|
// Insert the new value of v:char literally.
|
||||||
for (p = str; *p != NUL; mb_ptr_adv(p)) {
|
for (p = str; *p != NUL; MB_PTR_ADV(p)) {
|
||||||
s->c = PTR2CHAR(p);
|
s->c = PTR2CHAR(p);
|
||||||
if (s->c == CAR || s->c == K_KENTER || s->c == NL) {
|
if (s->c == CAR || s->c == K_KENTER || s->c == NL) {
|
||||||
ins_eol(s->c);
|
ins_eol(s->c);
|
||||||
@ -2008,8 +2008,8 @@ int ins_compl_add_infercase(char_u *str, int len, int icase, char_u *fname, int
|
|||||||
const char_u *p = str;
|
const char_u *p = str;
|
||||||
actual_len = 0;
|
actual_len = 0;
|
||||||
while (*p != NUL) {
|
while (*p != NUL) {
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
++actual_len;
|
actual_len++;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
actual_len = len;
|
actual_len = len;
|
||||||
@ -2019,8 +2019,8 @@ int ins_compl_add_infercase(char_u *str, int len, int icase, char_u *fname, int
|
|||||||
const char_u *p = compl_orig_text;
|
const char_u *p = compl_orig_text;
|
||||||
actual_compl_length = 0;
|
actual_compl_length = 0;
|
||||||
while (*p != NUL) {
|
while (*p != NUL) {
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
++actual_compl_length;
|
actual_compl_length++;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
actual_compl_length = compl_length;
|
actual_compl_length = compl_length;
|
||||||
@ -2322,8 +2322,8 @@ static void ins_compl_longest_match(compl_T *match)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (has_mbyte) {
|
if (has_mbyte) {
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
mb_ptr_adv(s);
|
MB_PTR_ADV(s);
|
||||||
} else {
|
} else {
|
||||||
++p;
|
++p;
|
||||||
++s;
|
++s;
|
||||||
@ -2974,7 +2974,7 @@ static int ins_compl_bs(void)
|
|||||||
|
|
||||||
line = get_cursor_line_ptr();
|
line = get_cursor_line_ptr();
|
||||||
p = line + curwin->w_cursor.col;
|
p = line + curwin->w_cursor.col;
|
||||||
mb_ptr_back(line, p);
|
MB_PTR_BACK(line, p);
|
||||||
|
|
||||||
// Stop completion when the whole word was deleted. For Omni completion
|
// Stop completion when the whole word was deleted. For Omni completion
|
||||||
// allow the word to be deleted, we won't match everything.
|
// allow the word to be deleted, we won't match everything.
|
||||||
@ -3440,8 +3440,9 @@ static void ins_compl_fixRedoBufForLeader(char_u *ptr_arg)
|
|||||||
;
|
;
|
||||||
if (len > 0)
|
if (len > 0)
|
||||||
len -= (*mb_head_off)(p, p + len);
|
len -= (*mb_head_off)(p, p + len);
|
||||||
for (p += len; *p != NUL; mb_ptr_adv(p))
|
for (p += len; *p != NUL; MB_PTR_ADV(p)) {
|
||||||
AppendCharToRedobuff(K_BS);
|
AppendCharToRedobuff(K_BS);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
len = 0;
|
len = 0;
|
||||||
}
|
}
|
||||||
@ -4597,13 +4598,15 @@ static int ins_complete(int c, bool enable_pum)
|
|||||||
if (startcol > 0) {
|
if (startcol > 0) {
|
||||||
char_u *p = line + startcol;
|
char_u *p = line + startcol;
|
||||||
|
|
||||||
mb_ptr_back(line, p);
|
MB_PTR_BACK(line, p);
|
||||||
while (p > line && vim_isfilec(PTR2CHAR(p)))
|
while (p > line && vim_isfilec(PTR2CHAR(p))) {
|
||||||
mb_ptr_back(line, p);
|
MB_PTR_BACK(line, p);
|
||||||
if (p == line && vim_isfilec(PTR2CHAR(p)))
|
}
|
||||||
|
if (p == line && vim_isfilec(PTR2CHAR(p))) {
|
||||||
startcol = 0;
|
startcol = 0;
|
||||||
else
|
} else {
|
||||||
startcol = (int)(p - line) + 1;
|
startcol = (int)(p - line) + 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
compl_col += startcol;
|
compl_col += startcol;
|
||||||
|
127
src/nvim/eval.c
127
src/nvim/eval.c
@ -110,8 +110,8 @@
|
|||||||
|
|
||||||
#define DICT_MAXNEST 100 /* maximum nesting of lists and dicts */
|
#define DICT_MAXNEST 100 /* maximum nesting of lists and dicts */
|
||||||
|
|
||||||
#define AUTOLOAD_CHAR '#' /* Character used as separator in autoload
|
// Character used as separator in autoload function/variable names.
|
||||||
function/variable names. */
|
#define AUTOLOAD_CHAR '#'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Structure returned by get_lval() and used by set_var_lval().
|
* Structure returned by get_lval() and used by set_var_lval().
|
||||||
@ -728,8 +728,8 @@ static char_u *redir_varname = NULL;
|
|||||||
* Start recording command output to a variable
|
* Start recording command output to a variable
|
||||||
* Returns OK if successfully completed the setup. FAIL otherwise.
|
* Returns OK if successfully completed the setup. FAIL otherwise.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
var_redir_start (
|
var_redir_start(
|
||||||
char_u *name,
|
char_u *name,
|
||||||
int append /* append to an existing variable */
|
int append /* append to an existing variable */
|
||||||
)
|
)
|
||||||
@ -926,8 +926,8 @@ void eval_patch(const char *const origfile, const char *const difffile,
|
|||||||
* Sets "error" to TRUE if there was an error.
|
* Sets "error" to TRUE if there was an error.
|
||||||
* Return TRUE or FALSE.
|
* Return TRUE or FALSE.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
eval_to_bool (
|
eval_to_bool(
|
||||||
char_u *arg,
|
char_u *arg,
|
||||||
bool *error,
|
bool *error,
|
||||||
char_u **nextcmd,
|
char_u **nextcmd,
|
||||||
@ -1503,8 +1503,8 @@ void ex_let(exarg_T *eap)
|
|||||||
* or concatenate.
|
* or concatenate.
|
||||||
* Returns OK or FAIL;
|
* Returns OK or FAIL;
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
ex_let_vars (
|
ex_let_vars(
|
||||||
char_u *arg_start,
|
char_u *arg_start,
|
||||||
typval_T *tv,
|
typval_T *tv,
|
||||||
int copy, /* copy values from "tv", don't move */
|
int copy, /* copy values from "tv", don't move */
|
||||||
@ -2581,9 +2581,10 @@ void set_context_for_expression(expand_T *xp, char_u *arg, cmdidx_T cmdidx)
|
|||||||
/* ":let var1 var2 ...": find last space. */
|
/* ":let var1 var2 ...": find last space. */
|
||||||
for (p = arg + STRLEN(arg); p >= arg; ) {
|
for (p = arg + STRLEN(arg); p >= arg; ) {
|
||||||
xp->xp_pattern = p;
|
xp->xp_pattern = p;
|
||||||
mb_ptr_back(arg, p);
|
MB_PTR_BACK(arg, p);
|
||||||
if (ascii_iswhite(*p))
|
if (ascii_iswhite(*p)) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -4307,8 +4308,8 @@ static int eval7(
|
|||||||
* "*arg" points to the '[' or '.'.
|
* "*arg" points to the '[' or '.'.
|
||||||
* Returns FAIL or OK. "*arg" is advanced to after the ']'.
|
* Returns FAIL or OK. "*arg" is advanced to after the ']'.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
eval_index (
|
eval_index(
|
||||||
char_u **arg,
|
char_u **arg,
|
||||||
typval_T *rettv,
|
typval_T *rettv,
|
||||||
int evaluate,
|
int evaluate,
|
||||||
@ -4653,7 +4654,7 @@ static int get_string_tv(char_u **arg, typval_T *rettv, int evaluate)
|
|||||||
/*
|
/*
|
||||||
* Find the end of the string, skipping backslashed characters.
|
* Find the end of the string, skipping backslashed characters.
|
||||||
*/
|
*/
|
||||||
for (p = *arg + 1; *p != NUL && *p != '"'; mb_ptr_adv(p)) {
|
for (p = *arg + 1; *p != NUL && *p != '"'; MB_PTR_ADV(p)) {
|
||||||
if (*p == '\\' && p[1] != NUL) {
|
if (*p == '\\' && p[1] != NUL) {
|
||||||
++p;
|
++p;
|
||||||
/* A "\<x>" form occupies at least 4 characters, and produces up
|
/* A "\<x>" form occupies at least 4 characters, and produces up
|
||||||
@ -4777,7 +4778,7 @@ static int get_lit_string_tv(char_u **arg, typval_T *rettv, int evaluate)
|
|||||||
/*
|
/*
|
||||||
* Find the end of the string, skipping ''.
|
* Find the end of the string, skipping ''.
|
||||||
*/
|
*/
|
||||||
for (p = *arg + 1; *p != NUL; mb_ptr_adv(p)) {
|
for (p = *arg + 1; *p != NUL; MB_PTR_ADV(p)) {
|
||||||
if (*p == '\'') {
|
if (*p == '\'') {
|
||||||
if (p[1] != '\'')
|
if (p[1] != '\'')
|
||||||
break;
|
break;
|
||||||
@ -6061,15 +6062,15 @@ static char_u *deref_func_name(const char *name, int *lenp,
|
|||||||
* Allocate a variable for the result of a function.
|
* Allocate a variable for the result of a function.
|
||||||
* Return OK or FAIL.
|
* Return OK or FAIL.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
get_func_tv (
|
get_func_tv(
|
||||||
char_u *name, /* name of the function */
|
char_u *name, // name of the function
|
||||||
int len, /* length of "name" */
|
int len, // length of "name"
|
||||||
typval_T *rettv,
|
typval_T *rettv,
|
||||||
char_u **arg, /* argument, pointing to the '(' */
|
char_u **arg, // argument, pointing to the '('
|
||||||
linenr_T firstline, /* first line of range */
|
linenr_T firstline, // first line of range
|
||||||
linenr_T lastline, /* last line of range */
|
linenr_T lastline, // last line of range
|
||||||
int *doesrange, /* return: function handled range */
|
int *doesrange, // return: function handled range
|
||||||
int evaluate,
|
int evaluate,
|
||||||
partial_T *partial, // for extra arguments
|
partial_T *partial, // for extra arguments
|
||||||
dict_T *selfdict // Dictionary for "self"
|
dict_T *selfdict // Dictionary for "self"
|
||||||
@ -9961,8 +9962,8 @@ static void f_getmatches(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
while (cur != NULL) {
|
while (cur != NULL) {
|
||||||
dict_T *dict = tv_dict_alloc();
|
dict_T *dict = tv_dict_alloc();
|
||||||
if (cur->match.regprog == NULL) {
|
if (cur->match.regprog == NULL) {
|
||||||
// match added with matchaddpos()
|
// match added with matchaddpos()
|
||||||
for (i = 0; i < MAXPOSMATCH; ++i) {
|
for (i = 0; i < MAXPOSMATCH; i++) {
|
||||||
llpos_T *llpos;
|
llpos_T *llpos;
|
||||||
char buf[6];
|
char buf[6];
|
||||||
|
|
||||||
@ -10380,8 +10381,8 @@ static void f_getwinvar(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
/*
|
/*
|
||||||
* getwinvar() and gettabwinvar()
|
* getwinvar() and gettabwinvar()
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
getwinvar (
|
getwinvar(
|
||||||
typval_T *argvars,
|
typval_T *argvars,
|
||||||
typval_T *rettv,
|
typval_T *rettv,
|
||||||
int off /* 1 for gettabwinvar() */
|
int off /* 1 for gettabwinvar() */
|
||||||
@ -14160,17 +14161,17 @@ static void f_searchpairpos(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
* Used by searchpair(), see its documentation for the details.
|
* Used by searchpair(), see its documentation for the details.
|
||||||
* Returns 0 or -1 for no match,
|
* Returns 0 or -1 for no match,
|
||||||
*/
|
*/
|
||||||
long
|
long
|
||||||
do_searchpair (
|
do_searchpair(
|
||||||
char_u *spat, /* start pattern */
|
char_u *spat, // start pattern
|
||||||
char_u *mpat, /* middle pattern */
|
char_u *mpat, // middle pattern
|
||||||
char_u *epat, /* end pattern */
|
char_u *epat, // end pattern
|
||||||
int dir, /* BACKWARD or FORWARD */
|
int dir, // BACKWARD or FORWARD
|
||||||
char_u *skip, /* skip expression */
|
char_u *skip, // skip expression
|
||||||
int flags, /* SP_SETPCMARK and other SP_ values */
|
int flags, // SP_SETPCMARK and other SP_ values
|
||||||
pos_T *match_pos,
|
pos_T *match_pos,
|
||||||
linenr_T lnum_stop, /* stop at this line if not zero */
|
linenr_T lnum_stop, // stop at this line if not zero
|
||||||
long time_limit /* stop after this many msec */
|
long time_limit // stop after this many msec
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
char_u *save_cpo;
|
char_u *save_cpo;
|
||||||
@ -16398,7 +16399,7 @@ static list_T *string_to_list(const char *str, size_t len, const bool keepempty)
|
|||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv,
|
static void get_system_output_as_rettv(typval_T *argvars, typval_T *rettv,
|
||||||
bool retlist)
|
bool retlist)
|
||||||
{
|
{
|
||||||
rettv->v_type = VAR_STRING;
|
rettv->v_type = VAR_STRING;
|
||||||
@ -18061,16 +18062,17 @@ static const char_u *find_name_end(const char_u *arg, const char_u **expr_start,
|
|||||||
|| *p == '{'
|
|| *p == '{'
|
||||||
|| ((flags & FNE_INCL_BR) && (*p == '[' || *p == '.'))
|
|| ((flags & FNE_INCL_BR) && (*p == '[' || *p == '.'))
|
||||||
|| mb_nest != 0
|
|| mb_nest != 0
|
||||||
|| br_nest != 0); mb_ptr_adv(p)) {
|
|| br_nest != 0); MB_PTR_ADV(p)) {
|
||||||
if (*p == '\'') {
|
if (*p == '\'') {
|
||||||
/* skip over 'string' to avoid counting [ and ] inside it. */
|
// skip over 'string' to avoid counting [ and ] inside it.
|
||||||
for (p = p + 1; *p != NUL && *p != '\''; mb_ptr_adv(p))
|
for (p = p + 1; *p != NUL && *p != '\''; MB_PTR_ADV(p)) {
|
||||||
;
|
}
|
||||||
if (*p == NUL)
|
if (*p == NUL) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
} else if (*p == '"') {
|
} else if (*p == '"') {
|
||||||
// skip over "str\"ing" to avoid counting [ and ] inside it.
|
// skip over "str\"ing" to avoid counting [ and ] inside it.
|
||||||
for (p = p + 1; *p != NUL && *p != '"'; mb_ptr_adv(p)) {
|
for (p = p + 1; *p != NUL && *p != '"'; MB_PTR_ADV(p)) {
|
||||||
if (*p == '\\' && p[1] != NUL) {
|
if (*p == '\\' && p[1] != NUL) {
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
@ -20693,8 +20695,8 @@ void func_dump_profile(FILE *fd)
|
|||||||
xfree(sorttab);
|
xfree(sorttab);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
prof_sort_list (
|
prof_sort_list(
|
||||||
FILE *fd,
|
FILE *fd,
|
||||||
ufunc_T **sorttab,
|
ufunc_T **sorttab,
|
||||||
int st_len,
|
int st_len,
|
||||||
@ -21551,8 +21553,8 @@ static int can_free_funccal(funccall_T *fc, int copyID)
|
|||||||
/*
|
/*
|
||||||
* Free "fc" and what it contains.
|
* Free "fc" and what it contains.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
free_funccal (
|
free_funccal(
|
||||||
funccall_T *fc,
|
funccall_T *fc,
|
||||||
int free_val /* a: vars were allocated */
|
int free_val /* a: vars were allocated */
|
||||||
)
|
)
|
||||||
@ -22106,13 +22108,13 @@ void reset_v_option_vars(void)
|
|||||||
* Returns VALID_ flags or -1 for failure.
|
* Returns VALID_ flags or -1 for failure.
|
||||||
* When there is an error, *fnamep is set to NULL.
|
* When there is an error, *fnamep is set to NULL.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
modify_fname (
|
modify_fname(
|
||||||
char_u *src, /* string with modifiers */
|
char_u *src, // string with modifiers
|
||||||
size_t *usedlen, /* characters after src that are used */
|
size_t *usedlen, // characters after src that are used
|
||||||
char_u **fnamep, /* file name so far */
|
char_u **fnamep, // file name so far
|
||||||
char_u **bufp, /* buffer for allocated file name or NULL */
|
char_u **bufp, // buffer for allocated file name or NULL
|
||||||
size_t *fnamelen /* length of fnamep */
|
size_t *fnamelen // length of fnamep
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int valid = 0;
|
int valid = 0;
|
||||||
@ -22148,15 +22150,16 @@ repeat:
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* When "/." or "/.." is used: force expansion to get rid of it. */
|
// When "/." or "/.." is used: force expansion to get rid of it.
|
||||||
for (p = *fnamep; *p != NUL; mb_ptr_adv(p)) {
|
for (p = *fnamep; *p != NUL; MB_PTR_ADV(p)) {
|
||||||
if (vim_ispathsep(*p)
|
if (vim_ispathsep(*p)
|
||||||
&& p[1] == '.'
|
&& p[1] == '.'
|
||||||
&& (p[2] == NUL
|
&& (p[2] == NUL
|
||||||
|| vim_ispathsep(p[2])
|
|| vim_ispathsep(p[2])
|
||||||
|| (p[2] == '.'
|
|| (p[2] == '.'
|
||||||
&& (p[3] == NUL || vim_ispathsep(p[3])))))
|
&& (p[3] == NUL || vim_ispathsep(p[3]))))) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FullName_save() is slow, don't use it when not needed. */
|
/* FullName_save() is slow, don't use it when not needed. */
|
||||||
@ -22236,8 +22239,9 @@ repeat:
|
|||||||
valid |= VALID_HEAD;
|
valid |= VALID_HEAD;
|
||||||
*usedlen += 2;
|
*usedlen += 2;
|
||||||
s = get_past_head(*fnamep);
|
s = get_past_head(*fnamep);
|
||||||
while (tail > s && after_pathsep((char *)s, (char *)tail))
|
while (tail > s && after_pathsep((char *)s, (char *)tail)) {
|
||||||
mb_ptr_back(*fnamep, tail);
|
MB_PTR_BACK(*fnamep, tail);
|
||||||
|
}
|
||||||
*fnamelen = (size_t)(tail - *fnamep);
|
*fnamelen = (size_t)(tail - *fnamep);
|
||||||
if (*fnamelen == 0) {
|
if (*fnamelen == 0) {
|
||||||
/* Result is empty. Turn it into "." to make ":cd %:h" work. */
|
/* Result is empty. Turn it into "." to make ":cd %:h" work. */
|
||||||
@ -22245,8 +22249,9 @@ repeat:
|
|||||||
*bufp = *fnamep = tail = vim_strsave((char_u *)".");
|
*bufp = *fnamep = tail = vim_strsave((char_u *)".");
|
||||||
*fnamelen = 1;
|
*fnamelen = 1;
|
||||||
} else {
|
} else {
|
||||||
while (tail > s && !after_pathsep((char *)s, (char *)tail))
|
while (tail > s && !after_pathsep((char *)s, (char *)tail)) {
|
||||||
mb_ptr_back(*fnamep, tail);
|
MB_PTR_BACK(*fnamep, tail);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3269,9 +3269,10 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
|
|||||||
*cmd++ = NUL; /* replace it with a NUL */
|
*cmd++ = NUL; /* replace it with a NUL */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (cmd[0] == '\\' && cmd[1] != 0) /* skip escaped characters */
|
if (cmd[0] == '\\' && cmd[1] != 0) { // skip escaped characters
|
||||||
++cmd;
|
cmd++;
|
||||||
mb_ptr_adv(cmd);
|
}
|
||||||
|
MB_PTR_ADV(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!eap->skip && !preview) {
|
if (!eap->skip && !preview) {
|
||||||
|
@ -2532,7 +2532,7 @@ static void add_pack_plugin(char_u *fname, void *cookie)
|
|||||||
if (cookie != &APP_LOAD && strstr((char *)p_rtp, ffname) == NULL) {
|
if (cookie != &APP_LOAD && strstr((char *)p_rtp, ffname) == NULL) {
|
||||||
// directory is not yet in 'runtimepath', add it
|
// directory is not yet in 'runtimepath', add it
|
||||||
p4 = p3 = p2 = p1 = get_past_head((char_u *)ffname);
|
p4 = p3 = p2 = p1 = get_past_head((char_u *)ffname);
|
||||||
for (p = p1; *p; mb_ptr_adv(p)) {
|
for (p = p1; *p; MB_PTR_ADV(p)) {
|
||||||
if (vim_ispathsep_nocolon(*p)) {
|
if (vim_ispathsep_nocolon(*p)) {
|
||||||
p4 = p3; p3 = p2; p2 = p1; p1 = p;
|
p4 = p3; p3 = p2; p2 = p1; p1 = p;
|
||||||
}
|
}
|
||||||
|
@ -2872,7 +2872,7 @@ const char * set_one_cmd_context(
|
|||||||
return NULL; /* It's a comment */
|
return NULL; /* It's a comment */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2890,9 +2890,10 @@ const char * set_one_cmd_context(
|
|||||||
// Argument starts after a space.
|
// Argument starts after a space.
|
||||||
xp->xp_pattern = (char_u *)++p;
|
xp->xp_pattern = (char_u *)++p;
|
||||||
} else {
|
} else {
|
||||||
if (*p == '\\' && *(p + 1) != NUL)
|
if (*p == '\\' && *(p + 1) != NUL) {
|
||||||
++p; /* skip over escaped character */
|
p++; // skip over escaped character
|
||||||
mb_ptr_adv(p);
|
}
|
||||||
|
MB_PTR_ADV(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2943,7 +2944,7 @@ const char * set_one_cmd_context(
|
|||||||
} else {
|
} else {
|
||||||
len = 1;
|
len = 1;
|
||||||
}
|
}
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
}
|
}
|
||||||
if (in_quote) {
|
if (in_quote) {
|
||||||
bow = p;
|
bow = p;
|
||||||
@ -2952,7 +2953,7 @@ const char * set_one_cmd_context(
|
|||||||
}
|
}
|
||||||
p -= len;
|
p -= len;
|
||||||
}
|
}
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3336,12 +3337,13 @@ const char * set_one_cmd_context(
|
|||||||
// Find start of last argument.
|
// Find start of last argument.
|
||||||
p = arg;
|
p = arg;
|
||||||
while (*p) {
|
while (*p) {
|
||||||
if (*p == ' ')
|
if (*p == ' ') {
|
||||||
/* argument starts after a space */
|
// argument starts after a space
|
||||||
arg = p + 1;
|
arg = p + 1;
|
||||||
else if (*p == '\\' && *(p + 1) != NUL)
|
} else if (*p == '\\' && *(p + 1) != NUL) {
|
||||||
++p; /* skip over escaped character */
|
p++; // skip over escaped character
|
||||||
mb_ptr_adv(p);
|
}
|
||||||
|
MB_PTR_ADV(p);
|
||||||
}
|
}
|
||||||
xp->xp_pattern = (char_u *)arg;
|
xp->xp_pattern = (char_u *)arg;
|
||||||
}
|
}
|
||||||
@ -4238,7 +4240,7 @@ void separate_nextcmd(exarg_T *eap)
|
|||||||
|
|
||||||
p = skip_grep_pat(eap);
|
p = skip_grep_pat(eap);
|
||||||
|
|
||||||
for (; *p; mb_ptr_adv(p)) {
|
for (; *p; MB_PTR_ADV(p)) {
|
||||||
if (*p == Ctrl_V) {
|
if (*p == Ctrl_V) {
|
||||||
if (eap->argt & (USECTRLV | XFILE))
|
if (eap->argt & (USECTRLV | XFILE))
|
||||||
++p; /* skip CTRL-V and next char */
|
++p; /* skip CTRL-V and next char */
|
||||||
@ -4322,7 +4324,7 @@ skip_cmd_arg (
|
|||||||
else
|
else
|
||||||
++p;
|
++p;
|
||||||
}
|
}
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
}
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@ -9486,10 +9488,12 @@ static int ses_put_fname(FILE *fd, char_u *name, unsigned *flagp)
|
|||||||
char_u *sname = home_replace_save(NULL, name);
|
char_u *sname = home_replace_save(NULL, name);
|
||||||
|
|
||||||
if (*flagp & SSOP_SLASH) {
|
if (*flagp & SSOP_SLASH) {
|
||||||
/* change all backslashes to forward slashes */
|
// change all backslashes to forward slashes
|
||||||
for (p = sname; *p != NUL; mb_ptr_adv(p))
|
for (p = sname; *p != NUL; MB_PTR_ADV(p)) {
|
||||||
if (*p == '\\')
|
if (*p == '\\') {
|
||||||
*p = '/';
|
*p = '/';
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Escape special characters.
|
// Escape special characters.
|
||||||
|
@ -2934,7 +2934,7 @@ static void ui_ext_cmdline_show(CmdlineInfo *line)
|
|||||||
Array content = ARRAY_DICT_INIT;
|
Array content = ARRAY_DICT_INIT;
|
||||||
if (cmdline_star) {
|
if (cmdline_star) {
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
for (char_u *p = ccline.cmdbuff; *p; mb_ptr_adv(p)) {
|
for (char_u *p = ccline.cmdbuff; *p; MB_PTR_ADV(p)) {
|
||||||
len++;
|
len++;
|
||||||
}
|
}
|
||||||
char *buf = xmallocz(len);
|
char *buf = xmallocz(len);
|
||||||
@ -4254,7 +4254,7 @@ char_u *sm_gettail(char_u *s)
|
|||||||
t = p;
|
t = p;
|
||||||
had_sep = FALSE;
|
had_sep = FALSE;
|
||||||
}
|
}
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
@ -5179,7 +5179,7 @@ static int ExpandRTDir(char_u *pat, int flags, int *num_file, char_u ***file,
|
|||||||
char_u *e = s + STRLEN(s);
|
char_u *e = s + STRLEN(s);
|
||||||
if (e - s > 4 && STRNICMP(e - 4, ".vim", 4) == 0) {
|
if (e - s > 4 && STRNICMP(e - 4, ".vim", 4) == 0) {
|
||||||
e -= 4;
|
e -= 4;
|
||||||
for (s = e; s > match; mb_ptr_back(match, s)) {
|
for (s = e; s > match; MB_PTR_BACK(match, s)) {
|
||||||
if (vim_ispathsep(*s)) {
|
if (vim_ispathsep(*s)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -4404,7 +4404,7 @@ char *modname(const char *fname, const char *ext, bool prepend_dot)
|
|||||||
// Search backwards until we hit a '/', '\' or ':'.
|
// Search backwards until we hit a '/', '\' or ':'.
|
||||||
// Then truncate what is after the '/', '\' or ':' to BASENAMELEN characters.
|
// Then truncate what is after the '/', '\' or ':' to BASENAMELEN characters.
|
||||||
char *ptr = NULL;
|
char *ptr = NULL;
|
||||||
for (ptr = retval + fnamelen; ptr > retval; mb_ptr_back(retval, ptr)) {
|
for (ptr = retval + fnamelen; ptr > retval; MB_PTR_BACK(retval, ptr)) {
|
||||||
if (vim_ispathsep(*ptr)) {
|
if (vim_ispathsep(*ptr)) {
|
||||||
ptr++;
|
ptr++;
|
||||||
break;
|
break;
|
||||||
|
@ -1883,7 +1883,7 @@ void foldtext_cleanup(char_u *str)
|
|||||||
++len;
|
++len;
|
||||||
STRMOVE(s, s + len);
|
STRMOVE(s, s + len);
|
||||||
} else {
|
} else {
|
||||||
mb_ptr_adv(s);
|
MB_PTR_ADV(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3054,10 +3054,12 @@ static void foldlevelMarker(fline_T *flp)
|
|||||||
if (flp->lvl_next > start_lvl)
|
if (flp->lvl_next > start_lvl)
|
||||||
flp->lvl_next = start_lvl;
|
flp->lvl_next = start_lvl;
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
--flp->lvl_next;
|
flp->lvl_next--;
|
||||||
} else
|
}
|
||||||
mb_ptr_adv(s);
|
} else {
|
||||||
|
MB_PTR_ADV(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The level can't go negative, must be missing a start marker. */
|
/* The level can't go negative, must be missing a start marker. */
|
||||||
|
@ -872,8 +872,6 @@ enum {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
EXTERN char breakat_flags[256]; /* which characters are in 'breakat' */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Some file names are stored in pathdef.c, which is generated from the
|
* Some file names are stored in pathdef.c, which is generated from the
|
||||||
* Makefile to make their value depend on the Makefile.
|
* Makefile to make their value depend on the Makefile.
|
||||||
|
@ -82,12 +82,6 @@
|
|||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
/*
|
|
||||||
* vim_isbreak() is used very often if 'linebreak' is set, use a macro to make
|
|
||||||
* it work fast.
|
|
||||||
*/
|
|
||||||
#define vim_isbreak(c) (breakat_flags[(char_u)(c)])
|
|
||||||
|
|
||||||
#define WRITEBIN "wb" /* no CR-LF translation */
|
#define WRITEBIN "wb" /* no CR-LF translation */
|
||||||
#define READBIN "rb"
|
#define READBIN "rb"
|
||||||
#define APPENDBIN "ab"
|
#define APPENDBIN "ab"
|
||||||
@ -110,9 +104,9 @@
|
|||||||
/* Whether to draw the vertical bar on the right side of the cell. */
|
/* Whether to draw the vertical bar on the right side of the cell. */
|
||||||
# define CURSOR_BAR_RIGHT (curwin->w_p_rl && (!(State & CMDLINE) || cmdmsg_rl))
|
# define CURSOR_BAR_RIGHT (curwin->w_p_rl && (!(State & CMDLINE) || cmdmsg_rl))
|
||||||
|
|
||||||
// mb_ptr_adv(): advance a pointer to the next character, taking care of
|
// MB_PTR_ADV(): advance a pointer to the next character, taking care of
|
||||||
// multi-byte characters if needed.
|
// multi-byte characters if needed.
|
||||||
// mb_ptr_back(): backup a pointer to the previous character, taking care of
|
// MB_PTR_BACK(): backup a pointer to the previous character, taking care of
|
||||||
// multi-byte characters if needed.
|
// multi-byte characters if needed.
|
||||||
// MB_COPY_CHAR(f, t): copy one char from "f" to "t" and advance the pointers.
|
// MB_COPY_CHAR(f, t): copy one char from "f" to "t" and advance the pointers.
|
||||||
// PTR2CHAR(): get character from pointer.
|
// PTR2CHAR(): get character from pointer.
|
||||||
@ -120,11 +114,11 @@
|
|||||||
// Get the length of the character p points to
|
// Get the length of the character p points to
|
||||||
# define MB_PTR2LEN(p) mb_ptr2len(p)
|
# define MB_PTR2LEN(p) mb_ptr2len(p)
|
||||||
// Advance multi-byte pointer, skip over composing chars.
|
// Advance multi-byte pointer, skip over composing chars.
|
||||||
# define mb_ptr_adv(p) (p += mb_ptr2len((char_u *)p))
|
# define MB_PTR_ADV(p) (p += mb_ptr2len((char_u *)p))
|
||||||
// Advance multi-byte pointer, do not skip over composing chars.
|
// Advance multi-byte pointer, do not skip over composing chars.
|
||||||
# define mb_cptr_adv(p) (p += utf_ptr2len(p))
|
# define MB_CPTR_ADV(p) (p += utf_ptr2len(p))
|
||||||
// Backup multi-byte pointer. Only use with "p" > "s" !
|
// Backup multi-byte pointer. Only use with "p" > "s" !
|
||||||
# define mb_ptr_back(s, p) (p -= mb_head_off((char_u *)s, (char_u *)p - 1) + 1)
|
# define MB_PTR_BACK(s, p) (p -= mb_head_off((char_u *)s, (char_u *)p - 1) + 1)
|
||||||
// get length of multi-byte char, not including composing chars
|
// get length of multi-byte char, not including composing chars
|
||||||
# define MB_CPTR2LEN(p) utf_ptr2len(p)
|
# define MB_CPTR2LEN(p) utf_ptr2len(p)
|
||||||
|
|
||||||
|
@ -603,7 +603,7 @@ static char_u *mark_line(pos_T *mp, int lead_len)
|
|||||||
|
|
||||||
/* Truncate the line to fit it in the window */
|
/* Truncate the line to fit it in the window */
|
||||||
len = 0;
|
len = 0;
|
||||||
for (p = s; *p != NUL; mb_ptr_adv(p)) {
|
for (p = s; *p != NUL; MB_PTR_ADV(p)) {
|
||||||
len += ptr2cells(p);
|
len += ptr2cells(p);
|
||||||
if (len >= Columns - lead_len)
|
if (len >= Columns - lead_len)
|
||||||
break;
|
break;
|
||||||
|
@ -1722,8 +1722,9 @@ char_u * mb_prevptr(
|
|||||||
char_u *p
|
char_u *p
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
if (p > line)
|
if (p > line) {
|
||||||
mb_ptr_back(line, p);
|
MB_PTR_BACK(line, p);
|
||||||
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1432,7 +1432,7 @@ static char *make_percent_swname(const char *dir, char *name)
|
|||||||
char *f = fix_fname(name != NULL ? name : "");
|
char *f = fix_fname(name != NULL ? name : "");
|
||||||
if (f != NULL) {
|
if (f != NULL) {
|
||||||
char *s = xstrdup(f);
|
char *s = xstrdup(f);
|
||||||
for (d = s; *d != NUL; mb_ptr_adv(d)) {
|
for (d = s; *d != NUL; MB_PTR_ADV(d)) {
|
||||||
if (vim_ispathsep(*d)) {
|
if (vim_ispathsep(*d)) {
|
||||||
*d = '%';
|
*d = '%';
|
||||||
}
|
}
|
||||||
|
@ -97,7 +97,7 @@ ex_menu(exarg_T *eap)
|
|||||||
while (*arg != NUL && *arg != ' ') {
|
while (*arg != NUL && *arg != ' ') {
|
||||||
if (*arg == '\\')
|
if (*arg == '\\')
|
||||||
STRMOVE(arg, arg + 1);
|
STRMOVE(arg, arg + 1);
|
||||||
mb_ptr_adv(arg);
|
MB_PTR_ADV(arg);
|
||||||
}
|
}
|
||||||
if (*arg != NUL) {
|
if (*arg != NUL) {
|
||||||
*arg++ = NUL;
|
*arg++ = NUL;
|
||||||
@ -1099,7 +1099,7 @@ char_u *menu_name_skip(char_u *const name)
|
|||||||
{
|
{
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
for (p = name; *p && *p != '.'; mb_ptr_adv(p)) {
|
for (p = name; *p && *p != '.'; MB_PTR_ADV(p)) {
|
||||||
if (*p == '\\' || *p == Ctrl_V) {
|
if (*p == '\\' || *p == Ctrl_V) {
|
||||||
STRMOVE(p, p + 1);
|
STRMOVE(p, p + 1);
|
||||||
if (*p == NUL)
|
if (*p == NUL)
|
||||||
@ -1549,9 +1549,11 @@ static void menu_unescape_name(char_u *name)
|
|||||||
{
|
{
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
for (p = name; *p && *p != '.'; mb_ptr_adv(p))
|
for (p = name; *p && *p != '.'; MB_PTR_ADV(p)) {
|
||||||
if (*p == '\\')
|
if (*p == '\\') {
|
||||||
STRMOVE(p, p + 1);
|
STRMOVE(p, p + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2935,7 +2935,7 @@ static char_u * console_dialog_alloc(const char_u *message,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Advance to the next character
|
// Advance to the next character
|
||||||
mb_ptr_adv(r);
|
MB_PTR_ADV(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
len += (int)(STRLEN(message)
|
len += (int)(STRLEN(message)
|
||||||
@ -3053,7 +3053,7 @@ static void copy_hotkeys_and_msg(const char_u *message, char_u *buttons,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// advance to the next character
|
// advance to the next character
|
||||||
mb_ptr_adv(r);
|
MB_PTR_ADV(r);
|
||||||
}
|
}
|
||||||
|
|
||||||
*msgp++ = ':';
|
*msgp++ = ':';
|
||||||
|
@ -531,7 +531,7 @@ open_line (
|
|||||||
int l;
|
int l;
|
||||||
|
|
||||||
while (old_size < repl_size && p > leader) {
|
while (old_size < repl_size && p > leader) {
|
||||||
mb_ptr_back(leader, p);
|
MB_PTR_BACK(leader, p);
|
||||||
old_size += ptr2cells(p);
|
old_size += ptr2cells(p);
|
||||||
}
|
}
|
||||||
l = lead_repl_len - (int)(endp - p);
|
l = lead_repl_len - (int)(endp - p);
|
||||||
@ -1311,7 +1311,7 @@ int plines_win_col(win_T *wp, linenr_T lnum, long column)
|
|||||||
colnr_T col = 0;
|
colnr_T col = 0;
|
||||||
while (*s != NUL && --column >= 0) {
|
while (*s != NUL && --column >= 0) {
|
||||||
col += win_lbr_chartabsize(wp, line, s, col, NULL);
|
col += win_lbr_chartabsize(wp, line, s, col, NULL);
|
||||||
mb_ptr_adv(s);
|
MB_PTR_ADV(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If *s is a TAB, and the TAB is not displayed as ^I, and we're not in
|
// If *s is a TAB, and the TAB is not displayed as ^I, and we're not in
|
||||||
|
@ -526,7 +526,7 @@ static colnr_T scroll_line_len(linenr_T lnum)
|
|||||||
if (*line != NUL) {
|
if (*line != NUL) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int numchar = chartabsize(line, col);
|
int numchar = chartabsize(line, col);
|
||||||
mb_ptr_adv(line);
|
MB_PTR_ADV(line);
|
||||||
if (*line == NUL) { // don't count the last character
|
if (*line == NUL) { // don't count the last character
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -406,8 +406,9 @@ static void shift_block(oparg_T *oap, int amount)
|
|||||||
/* If "bd.startspaces" is set, "bd.textstart" points to the character,
|
/* If "bd.startspaces" is set, "bd.textstart" points to the character,
|
||||||
* the part of which is displayed at the block's beginning. Let's start
|
* the part of which is displayed at the block's beginning. Let's start
|
||||||
* searching from the next character. */
|
* searching from the next character. */
|
||||||
if (bd.startspaces)
|
if (bd.startspaces) {
|
||||||
mb_ptr_adv(non_white);
|
MB_PTR_ADV(non_white);
|
||||||
|
}
|
||||||
|
|
||||||
/* The character's column is in "bd.start_vcol". */
|
/* The character's column is in "bd.start_vcol". */
|
||||||
non_white_col = bd.start_vcol;
|
non_white_col = bd.start_vcol;
|
||||||
@ -443,7 +444,7 @@ static void shift_block(oparg_T *oap, int amount)
|
|||||||
if (verbatim_copy_width + incr > destination_col)
|
if (verbatim_copy_width + incr > destination_col)
|
||||||
break;
|
break;
|
||||||
verbatim_copy_width += incr;
|
verbatim_copy_width += incr;
|
||||||
mb_ptr_adv(verbatim_copy_end);
|
MB_PTR_ADV(verbatim_copy_end);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If "destination_col" is different from the width of the initial
|
/* If "destination_col" is different from the width of the initial
|
||||||
@ -2820,7 +2821,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
}
|
}
|
||||||
char_u *p = get_cursor_pos_ptr();
|
char_u *p = get_cursor_pos_ptr();
|
||||||
if (dir == FORWARD && *p != NUL) {
|
if (dir == FORWARD && *p != NUL) {
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
}
|
}
|
||||||
ptr = vim_strsave(p);
|
ptr = vim_strsave(p);
|
||||||
ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, false);
|
ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, false);
|
||||||
@ -2829,7 +2830,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
oldp = get_cursor_line_ptr();
|
oldp = get_cursor_line_ptr();
|
||||||
p = oldp + curwin->w_cursor.col;
|
p = oldp + curwin->w_cursor.col;
|
||||||
if (dir == FORWARD && *p != NUL) {
|
if (dir == FORWARD && *p != NUL) {
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
}
|
}
|
||||||
ptr = vim_strnsave(oldp, (size_t)(p - oldp));
|
ptr = vim_strnsave(oldp, (size_t)(p - oldp));
|
||||||
ml_replace(curwin->w_cursor.lnum, ptr, false);
|
ml_replace(curwin->w_cursor.lnum, ptr, false);
|
||||||
@ -3632,10 +3633,10 @@ int do_join(size_t count,
|
|||||||
if (insert_space && currsize > 0) {
|
if (insert_space && currsize > 0) {
|
||||||
if (has_mbyte) {
|
if (has_mbyte) {
|
||||||
cend = curr + currsize;
|
cend = curr + currsize;
|
||||||
mb_ptr_back(curr, cend);
|
MB_PTR_BACK(curr, cend);
|
||||||
endcurr1 = (*mb_ptr2char)(cend);
|
endcurr1 = (*mb_ptr2char)(cend);
|
||||||
if (cend > curr) {
|
if (cend > curr) {
|
||||||
mb_ptr_back(curr, cend);
|
MB_PTR_BACK(curr, cend);
|
||||||
endcurr2 = (*mb_ptr2char)(cend);
|
endcurr2 = (*mb_ptr2char)(cend);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -4272,7 +4273,7 @@ static void block_prep(oparg_T *oap, struct block_def *bdp, linenr_T lnum, int i
|
|||||||
bdp->pre_whitesp_c = 0;
|
bdp->pre_whitesp_c = 0;
|
||||||
}
|
}
|
||||||
prev_pstart = pstart;
|
prev_pstart = pstart;
|
||||||
mb_ptr_adv(pstart);
|
MB_PTR_ADV(pstart);
|
||||||
}
|
}
|
||||||
bdp->start_char_vcols = incr;
|
bdp->start_char_vcols = incr;
|
||||||
if (bdp->start_vcol < oap->start_vcol) { /* line too short */
|
if (bdp->start_vcol < oap->start_vcol) { /* line too short */
|
||||||
|
@ -2830,7 +2830,7 @@ did_set_string_option (
|
|||||||
for (s = p_sbr; *s; ) {
|
for (s = p_sbr; *s; ) {
|
||||||
if (ptr2cells(s) != 1)
|
if (ptr2cells(s) != 1)
|
||||||
errmsg = (char_u *)N_("E595: contains unprintable or wide character");
|
errmsg = (char_u *)N_("E595: contains unprintable or wide character");
|
||||||
mb_ptr_adv(s);
|
MB_PTR_ADV(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -6209,13 +6209,15 @@ void ExpandOldSetting(int *num_file, char_u ***file)
|
|||||||
#ifdef BACKSLASH_IN_FILENAME
|
#ifdef BACKSLASH_IN_FILENAME
|
||||||
/* For MS-Windows et al. we don't double backslashes at the start and
|
/* For MS-Windows et al. we don't double backslashes at the start and
|
||||||
* before a file name character. */
|
* before a file name character. */
|
||||||
for (var = buf; *var != NUL; mb_ptr_adv(var))
|
for (var = buf; *var != NUL; MB_PTR_ADV(var)) {
|
||||||
if (var[0] == '\\' && var[1] == '\\'
|
if (var[0] == '\\' && var[1] == '\\'
|
||||||
&& expand_option_idx >= 0
|
&& expand_option_idx >= 0
|
||||||
&& (options[expand_option_idx].flags & P_EXPAND)
|
&& (options[expand_option_idx].flags & P_EXPAND)
|
||||||
&& vim_isfilec(var[2])
|
&& vim_isfilec(var[2])
|
||||||
&& (var[2] != '\\' || (var == buf && var[4] != '\\')))
|
&& (var[2] != '\\' || (var == buf && var[4] != '\\'))) {
|
||||||
STRMOVE(var, var + 1);
|
STRMOVE(var, var + 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
*file[0] = buf;
|
*file[0] = buf;
|
||||||
@ -6383,9 +6385,10 @@ static void langmap_set(void)
|
|||||||
|
|
||||||
for (p = p_langmap; p[0] != NUL; ) {
|
for (p = p_langmap; p[0] != NUL; ) {
|
||||||
for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
|
for (p2 = p; p2[0] != NUL && p2[0] != ',' && p2[0] != ';';
|
||||||
mb_ptr_adv(p2)) {
|
MB_PTR_ADV(p2)) {
|
||||||
if (p2[0] == '\\' && p2[1] != NUL)
|
if (p2[0] == '\\' && p2[1] != NUL) {
|
||||||
++p2;
|
p2++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (p2[0] == ';')
|
if (p2[0] == ';')
|
||||||
++p2; /* abcd;ABCD form, p2 points to A */
|
++p2; /* abcd;ABCD form, p2 points to A */
|
||||||
@ -6401,7 +6404,7 @@ static void langmap_set(void)
|
|||||||
from = (*mb_ptr2char)(p);
|
from = (*mb_ptr2char)(p);
|
||||||
to = NUL;
|
to = NUL;
|
||||||
if (p2 == NULL) {
|
if (p2 == NULL) {
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
if (p[0] != ',') {
|
if (p[0] != ',') {
|
||||||
if (p[0] == '\\')
|
if (p[0] == '\\')
|
||||||
++p;
|
++p;
|
||||||
@ -6427,10 +6430,10 @@ static void langmap_set(void)
|
|||||||
langmap_mapchar[from & 255] = (char_u)to;
|
langmap_mapchar[from & 255] = (char_u)to;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Advance to next pair */
|
// Advance to next pair
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
if (p2 != NULL) {
|
if (p2 != NULL) {
|
||||||
mb_ptr_adv(p2);
|
MB_PTR_ADV(p2);
|
||||||
if (*p == ';') {
|
if (*p == ';') {
|
||||||
p = p2;
|
p = p2;
|
||||||
if (p[0] != NUL) {
|
if (p[0] != NUL) {
|
||||||
|
@ -314,9 +314,10 @@ static char *(p_bkc_values[]) =
|
|||||||
# define BKC_NO 0x004
|
# define BKC_NO 0x004
|
||||||
# define BKC_BREAKSYMLINK 0x008
|
# define BKC_BREAKSYMLINK 0x008
|
||||||
# define BKC_BREAKHARDLINK 0x010
|
# define BKC_BREAKHARDLINK 0x010
|
||||||
EXTERN char_u *p_bdir; /* 'backupdir' */
|
EXTERN char_u *p_bdir; // 'backupdir'
|
||||||
EXTERN char_u *p_bex; /* 'backupext' */
|
EXTERN char_u *p_bex; // 'backupext'
|
||||||
EXTERN char_u *p_bo; // 'belloff'
|
EXTERN char_u *p_bo; // 'belloff'
|
||||||
|
EXTERN char breakat_flags[256]; // which characters are in 'breakat'
|
||||||
EXTERN unsigned bo_flags;
|
EXTERN unsigned bo_flags;
|
||||||
# ifdef IN_OPTION_C
|
# ifdef IN_OPTION_C
|
||||||
static char *(p_bo_values[]) = {"all", "backspace", "cursor", "complete",
|
static char *(p_bo_values[]) = {"all", "backspace", "cursor", "complete",
|
||||||
|
@ -101,7 +101,7 @@ char_u *path_tail(const char_u *fname)
|
|||||||
if (vim_ispathsep_nocolon(*p)) {
|
if (vim_ispathsep_nocolon(*p)) {
|
||||||
tail = p + 1;
|
tail = p + 1;
|
||||||
}
|
}
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
}
|
}
|
||||||
return (char_u *)tail;
|
return (char_u *)tail;
|
||||||
}
|
}
|
||||||
@ -144,7 +144,7 @@ const char_u *invocation_path_tail(const char_u *invocation, size_t *len)
|
|||||||
const char_u *p = tail;
|
const char_u *p = tail;
|
||||||
while (*p != NUL && *p != ' ') {
|
while (*p != NUL && *p != ' ') {
|
||||||
bool was_sep = vim_ispathsep_nocolon(*p);
|
bool was_sep = vim_ispathsep_nocolon(*p);
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
if (was_sep) {
|
if (was_sep) {
|
||||||
tail = p; // Now tail points one past the separator.
|
tail = p; // Now tail points one past the separator.
|
||||||
}
|
}
|
||||||
@ -166,7 +166,7 @@ const char *path_next_component(const char *fname)
|
|||||||
{
|
{
|
||||||
assert(fname != NULL);
|
assert(fname != NULL);
|
||||||
while (*fname != NUL && !vim_ispathsep(*fname)) {
|
while (*fname != NUL && !vim_ispathsep(*fname)) {
|
||||||
mb_ptr_adv(fname);
|
MB_PTR_ADV(fname);
|
||||||
}
|
}
|
||||||
if (*fname != NUL) {
|
if (*fname != NUL) {
|
||||||
fname++;
|
fname++;
|
||||||
@ -468,7 +468,7 @@ char_u *save_abs_path(const char_u *name)
|
|||||||
bool path_has_wildcard(const char_u *p)
|
bool path_has_wildcard(const char_u *p)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
for (; *p; mb_ptr_adv(p)) {
|
for (; *p; MB_PTR_ADV(p)) {
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
if (p[0] == '\\' && p[1] != NUL) {
|
if (p[0] == '\\' && p[1] != NUL) {
|
||||||
p++;
|
p++;
|
||||||
@ -503,7 +503,7 @@ static int pstrcmp(const void *a, const void *b)
|
|||||||
bool path_has_exp_wildcard(const char_u *p)
|
bool path_has_exp_wildcard(const char_u *p)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
for (; *p != NUL; mb_ptr_adv(p)) {
|
for (; *p != NUL; MB_PTR_ADV(p)) {
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
if (p[0] == '\\' && p[1] != NUL) {
|
if (p[0] == '\\' && p[1] != NUL) {
|
||||||
p++;
|
p++;
|
||||||
@ -744,7 +744,7 @@ static int find_previous_pathsep(char_u *path, char_u **psep)
|
|||||||
while (*psep > path) {
|
while (*psep > path) {
|
||||||
if (vim_ispathsep(**psep))
|
if (vim_ispathsep(**psep))
|
||||||
return OK;
|
return OK;
|
||||||
mb_ptr_back(path, *psep);
|
MB_PTR_BACK(path, *psep);
|
||||||
}
|
}
|
||||||
|
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -859,10 +859,12 @@ static char_u *get_path_cutoff(char_u *fname, garray_T *gap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip to the file or directory name */
|
// skip to the file or directory name
|
||||||
if (cutoff != NULL)
|
if (cutoff != NULL) {
|
||||||
while (vim_ispathsep(*cutoff))
|
while (vim_ispathsep(*cutoff)) {
|
||||||
mb_ptr_adv(cutoff);
|
MB_PTR_ADV(cutoff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return cutoff;
|
return cutoff;
|
||||||
}
|
}
|
||||||
@ -1038,7 +1040,7 @@ const char *gettail_dir(const char *const fname)
|
|||||||
dir_end = next_dir_end;
|
dir_end = next_dir_end;
|
||||||
look_for_sep = true;
|
look_for_sep = true;
|
||||||
}
|
}
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
}
|
}
|
||||||
return dir_end;
|
return dir_end;
|
||||||
}
|
}
|
||||||
@ -1085,13 +1087,12 @@ expand_in_path (
|
|||||||
*/
|
*/
|
||||||
static bool has_env_var(char_u *p)
|
static bool has_env_var(char_u *p)
|
||||||
{
|
{
|
||||||
for (; *p; mb_ptr_adv(p)) {
|
for (; *p; MB_PTR_ADV(p)) {
|
||||||
if (*p == '\\' && p[1] != NUL)
|
if (*p == '\\' && p[1] != NUL) {
|
||||||
++p;
|
p++;
|
||||||
else if (vim_strchr((char_u *)
|
} else if (vim_strchr((char_u *) "$" , *p) != NULL) {
|
||||||
"$"
|
|
||||||
, *p) != NULL)
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -1102,7 +1103,7 @@ static bool has_env_var(char_u *p)
|
|||||||
// cannot expand, requires using a shell.
|
// cannot expand, requires using a shell.
|
||||||
static bool has_special_wildchar(char_u *p)
|
static bool has_special_wildchar(char_u *p)
|
||||||
{
|
{
|
||||||
for (; *p; mb_ptr_adv(p)) {
|
for (; *p; MB_PTR_ADV(p)) {
|
||||||
// Allow for escaping
|
// Allow for escaping
|
||||||
if (*p == '\\' && p[1] != NUL) {
|
if (*p == '\\' && p[1] != NUL) {
|
||||||
p++;
|
p++;
|
||||||
@ -1343,7 +1344,7 @@ void slash_adjust(char_u *p)
|
|||||||
if (*p == (char_u)psepcN) {
|
if (*p == (char_u)psepcN) {
|
||||||
*p = (char_u)psepc;
|
*p = (char_u)psepc;
|
||||||
}
|
}
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -1444,19 +1445,22 @@ void simplify_filename(char_u *filename)
|
|||||||
* we are after "start", or strip "." if we are at the beginning
|
* we are after "start", or strip "." if we are at the beginning
|
||||||
* of an absolute path name . */
|
* of an absolute path name . */
|
||||||
tail = p + 1;
|
tail = p + 1;
|
||||||
if (p[1] != NUL)
|
if (p[1] != NUL) {
|
||||||
while (vim_ispathsep(*tail))
|
while (vim_ispathsep(*tail)) {
|
||||||
mb_ptr_adv(tail);
|
MB_PTR_ADV(tail);
|
||||||
else if (p > start)
|
}
|
||||||
--p; /* strip preceding path separator */
|
} else if (p > start) {
|
||||||
|
p--; // strip preceding path separator
|
||||||
|
}
|
||||||
STRMOVE(p, tail);
|
STRMOVE(p, tail);
|
||||||
}
|
}
|
||||||
} else if (p[0] == '.' && p[1] == '.'
|
} else if (p[0] == '.' && p[1] == '.'
|
||||||
&& (vim_ispathsep(p[2]) || p[2] == NUL)) {
|
&& (vim_ispathsep(p[2]) || p[2] == NUL)) {
|
||||||
// Skip to after ".." or "../" or "..///".
|
// Skip to after ".." or "../" or "..///".
|
||||||
tail = p + 2;
|
tail = p + 2;
|
||||||
while (vim_ispathsep(*tail))
|
while (vim_ispathsep(*tail)) {
|
||||||
mb_ptr_adv(tail);
|
MB_PTR_ADV(tail);
|
||||||
|
}
|
||||||
|
|
||||||
if (components > 0) { /* strip one preceding component */
|
if (components > 0) { /* strip one preceding component */
|
||||||
bool do_strip = false;
|
bool do_strip = false;
|
||||||
@ -1475,10 +1479,11 @@ void simplify_filename(char_u *filename)
|
|||||||
}
|
}
|
||||||
p[-1] = saved_char;
|
p[-1] = saved_char;
|
||||||
|
|
||||||
--p;
|
p--;
|
||||||
/* Skip back to after previous '/'. */
|
// Skip back to after previous '/'.
|
||||||
while (p > start && !after_pathsep((char *)start, (char *)p))
|
while (p > start && !after_pathsep((char *)start, (char *)p)) {
|
||||||
mb_ptr_back(start, p);
|
MB_PTR_BACK(start, p);
|
||||||
|
}
|
||||||
|
|
||||||
if (!do_strip) {
|
if (!do_strip) {
|
||||||
/* If the component exists in the file system, check
|
/* If the component exists in the file system, check
|
||||||
|
@ -374,7 +374,7 @@ void pum_redraw(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
for (;; mb_ptr_adv(p)) {
|
for (;; MB_PTR_ADV(p)) {
|
||||||
if (s == NULL) {
|
if (s == NULL) {
|
||||||
s = p;
|
s = p;
|
||||||
}
|
}
|
||||||
@ -398,7 +398,7 @@ void pum_redraw(void)
|
|||||||
if (size > pum_width) {
|
if (size > pum_width) {
|
||||||
do {
|
do {
|
||||||
size -= has_mbyte ? (*mb_ptr2cells)(rt) : 1;
|
size -= has_mbyte ? (*mb_ptr2cells)(rt) : 1;
|
||||||
mb_ptr_adv(rt);
|
MB_PTR_ADV(rt);
|
||||||
} while (size > pum_width);
|
} while (size > pum_width);
|
||||||
|
|
||||||
if (size < pum_width) {
|
if (size < pum_width) {
|
||||||
|
@ -1142,24 +1142,28 @@ static char_u *skip_anyof(char_u *p)
|
|||||||
if (*p == ']' || *p == '-')
|
if (*p == ']' || *p == '-')
|
||||||
++p;
|
++p;
|
||||||
while (*p != NUL && *p != ']') {
|
while (*p != NUL && *p != ']') {
|
||||||
if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1)
|
if (has_mbyte && (l = (*mb_ptr2len)(p)) > 1) {
|
||||||
p += l;
|
p += l;
|
||||||
else if (*p == '-') {
|
} else if (*p == '-') {
|
||||||
++p;
|
p++;
|
||||||
if (*p != ']' && *p != NUL)
|
if (*p != ']' && *p != NUL) {
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
|
}
|
||||||
} else if (*p == '\\'
|
} else if (*p == '\\'
|
||||||
&& (vim_strchr(REGEXP_INRANGE, p[1]) != NULL
|
&& (vim_strchr(REGEXP_INRANGE, p[1]) != NULL
|
||||||
|| (!reg_cpo_lit && vim_strchr(REGEXP_ABBR, p[1]) != NULL)))
|
|| (!reg_cpo_lit
|
||||||
|
&& vim_strchr(REGEXP_ABBR, p[1]) != NULL))) {
|
||||||
p += 2;
|
p += 2;
|
||||||
else if (*p == '[') {
|
} else if (*p == '[') {
|
||||||
if (get_char_class(&p) == CLASS_NONE
|
if (get_char_class(&p) == CLASS_NONE
|
||||||
&& get_equi_class(&p) == 0
|
&& get_equi_class(&p) == 0
|
||||||
&& get_coll_element(&p) == 0
|
&& get_coll_element(&p) == 0
|
||||||
&& *p != NUL)
|
&& *p != NUL) {
|
||||||
++p; /* It is not a class name and not NUL */
|
p++; // It is not a class name and not NUL
|
||||||
} else
|
}
|
||||||
++p;
|
} else {
|
||||||
|
p++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
@ -1185,9 +1189,10 @@ char_u *skip_regexp(char_u *startp, int dirc, int magic, char_u **newp)
|
|||||||
mymagic = MAGIC_OFF;
|
mymagic = MAGIC_OFF;
|
||||||
get_cpo_flags();
|
get_cpo_flags();
|
||||||
|
|
||||||
for (; p[0] != NUL; mb_ptr_adv(p)) {
|
for (; p[0] != NUL; MB_PTR_ADV(p)) {
|
||||||
if (p[0] == dirc) /* found end of regexp */
|
if (p[0] == dirc) { // found end of regexp
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
if ((p[0] == '[' && mymagic >= MAGIC_ON)
|
if ((p[0] == '[' && mymagic >= MAGIC_ON)
|
||||||
|| (p[0] == '\\' && p[1] == '[' && mymagic <= MAGIC_OFF)) {
|
|| (p[0] == '\\' && p[1] == '[' && mymagic <= MAGIC_OFF)) {
|
||||||
p = skip_anyof(p + 1);
|
p = skip_anyof(p + 1);
|
||||||
@ -3476,14 +3481,14 @@ static long bt_regexec_both(char_u *line,
|
|||||||
if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0) {
|
if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0) {
|
||||||
break; // Found it.
|
break; // Found it.
|
||||||
}
|
}
|
||||||
mb_ptr_adv(s);
|
MB_PTR_ADV(s);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while ((s = cstrchr(s, c)) != NULL) {
|
while ((s = cstrchr(s, c)) != NULL) {
|
||||||
if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0) {
|
if (cstrncmp(s, prog->regmust, &prog->regmlen) == 0) {
|
||||||
break; // Found it.
|
break; // Found it.
|
||||||
}
|
}
|
||||||
mb_ptr_adv(s);
|
MB_PTR_ADV(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (s == NULL) { // Not present.
|
if (s == NULL) { // Not present.
|
||||||
@ -3753,7 +3758,7 @@ static int reg_match_visual(void)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ADVANCE_REGINPUT() mb_ptr_adv(reginput)
|
#define ADVANCE_REGINPUT() MB_PTR_ADV(reginput)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The arguments from BRACE_LIMITS are stored here. They are actually local
|
* The arguments from BRACE_LIMITS are stored here. They are actually local
|
||||||
@ -4287,7 +4292,7 @@ regmatch (
|
|||||||
if (enc_utf8) {
|
if (enc_utf8) {
|
||||||
// Skip composing characters.
|
// Skip composing characters.
|
||||||
while (utf_iscomposing(utf_ptr2char(reginput))) {
|
while (utf_iscomposing(utf_ptr2char(reginput))) {
|
||||||
mb_cptr_adv(reginput);
|
MB_CPTR_ADV(reginput);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -4951,21 +4956,24 @@ regmatch (
|
|||||||
(colnr_T)STRLEN(regline);
|
(colnr_T)STRLEN(regline);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (has_mbyte)
|
if (has_mbyte) {
|
||||||
rp->rs_un.regsave.rs_u.pos.col -=
|
rp->rs_un.regsave.rs_u.pos.col -=
|
||||||
(*mb_head_off)(regline, regline
|
(*mb_head_off)(regline, regline
|
||||||
+ rp->rs_un.regsave.rs_u.pos.col - 1) + 1;
|
+ rp->rs_un.regsave.rs_u.pos.col - 1) + 1;
|
||||||
else
|
} else {
|
||||||
--rp->rs_un.regsave.rs_u.pos.col;
|
rp->rs_un.regsave.rs_u.pos.col--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (rp->rs_un.regsave.rs_u.ptr == regline)
|
if (rp->rs_un.regsave.rs_u.ptr == regline) {
|
||||||
no = FAIL;
|
no = FAIL;
|
||||||
else {
|
} else {
|
||||||
mb_ptr_back(regline, rp->rs_un.regsave.rs_u.ptr);
|
MB_PTR_BACK(regline, rp->rs_un.regsave.rs_u.ptr);
|
||||||
if (limit > 0 && (long)(behind_pos.rs_u.ptr
|
if (limit > 0
|
||||||
- rp->rs_un.regsave.rs_u.ptr) > limit)
|
&& (long)(behind_pos.rs_u.ptr
|
||||||
|
- rp->rs_un.regsave.rs_u.ptr) > limit) {
|
||||||
no = FAIL;
|
no = FAIL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (no == OK) {
|
if (no == OK) {
|
||||||
@ -5025,17 +5033,18 @@ regmatch (
|
|||||||
if (--rst->count < rst->minval)
|
if (--rst->count < rst->minval)
|
||||||
break;
|
break;
|
||||||
if (reginput == regline) {
|
if (reginput == regline) {
|
||||||
/* backup to last char of previous line */
|
// backup to last char of previous line
|
||||||
--reglnum;
|
reglnum--;
|
||||||
regline = reg_getline(reglnum);
|
regline = reg_getline(reglnum);
|
||||||
/* Just in case regrepeat() didn't count
|
// Just in case regrepeat() didn't count right.
|
||||||
* right. */
|
if (regline == NULL) {
|
||||||
if (regline == NULL)
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
reginput = regline + STRLEN(regline);
|
reginput = regline + STRLEN(regline);
|
||||||
fast_breakcheck();
|
fast_breakcheck();
|
||||||
} else
|
} else {
|
||||||
mb_ptr_back(regline, reginput);
|
MB_PTR_BACK(regline, reginput);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Range is backwards, use shortest match first.
|
/* Range is backwards, use shortest match first.
|
||||||
* Careful: maxval and minval are exchanged!
|
* Careful: maxval and minval are exchanged!
|
||||||
@ -5165,8 +5174,8 @@ regrepeat (
|
|||||||
/* Matching anything means we continue until end-of-line (or
|
/* Matching anything means we continue until end-of-line (or
|
||||||
* end-of-file for ANY + ADD_NL), only limited by maxcount. */
|
* end-of-file for ANY + ADD_NL), only limited by maxcount. */
|
||||||
while (*scan != NUL && count < maxcount) {
|
while (*scan != NUL && count < maxcount) {
|
||||||
++count;
|
count++;
|
||||||
mb_ptr_adv(scan);
|
MB_PTR_ADV(scan);
|
||||||
}
|
}
|
||||||
if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline
|
if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline
|
||||||
|| rex.reg_line_lbr || count == maxcount) {
|
|| rex.reg_line_lbr || count == maxcount) {
|
||||||
@ -5188,7 +5197,7 @@ regrepeat (
|
|||||||
case SIDENT + ADD_NL:
|
case SIDENT + ADD_NL:
|
||||||
while (count < maxcount) {
|
while (count < maxcount) {
|
||||||
if (vim_isIDc(PTR2CHAR(scan)) && (testval || !ascii_isdigit(*scan))) {
|
if (vim_isIDc(PTR2CHAR(scan)) && (testval || !ascii_isdigit(*scan))) {
|
||||||
mb_ptr_adv(scan);
|
MB_PTR_ADV(scan);
|
||||||
} else if (*scan == NUL) {
|
} else if (*scan == NUL) {
|
||||||
if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline
|
if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline
|
||||||
|| rex.reg_line_lbr) {
|
|| rex.reg_line_lbr) {
|
||||||
@ -5216,7 +5225,7 @@ regrepeat (
|
|||||||
while (count < maxcount) {
|
while (count < maxcount) {
|
||||||
if (vim_iswordp_buf(scan, rex.reg_buf)
|
if (vim_iswordp_buf(scan, rex.reg_buf)
|
||||||
&& (testval || !ascii_isdigit(*scan))) {
|
&& (testval || !ascii_isdigit(*scan))) {
|
||||||
mb_ptr_adv(scan);
|
MB_PTR_ADV(scan);
|
||||||
} else if (*scan == NUL) {
|
} else if (*scan == NUL) {
|
||||||
if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline
|
if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline
|
||||||
|| rex.reg_line_lbr) {
|
|| rex.reg_line_lbr) {
|
||||||
@ -5244,7 +5253,7 @@ regrepeat (
|
|||||||
case SFNAME + ADD_NL:
|
case SFNAME + ADD_NL:
|
||||||
while (count < maxcount) {
|
while (count < maxcount) {
|
||||||
if (vim_isfilec(PTR2CHAR(scan)) && (testval || !ascii_isdigit(*scan))) {
|
if (vim_isfilec(PTR2CHAR(scan)) && (testval || !ascii_isdigit(*scan))) {
|
||||||
mb_ptr_adv(scan);
|
MB_PTR_ADV(scan);
|
||||||
} else if (*scan == NUL) {
|
} else if (*scan == NUL) {
|
||||||
if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline
|
if (!REG_MULTI || !WITH_NL(OP(p)) || reglnum > rex.reg_maxline
|
||||||
|| rex.reg_line_lbr) {
|
|| rex.reg_line_lbr) {
|
||||||
@ -5283,7 +5292,7 @@ regrepeat (
|
|||||||
}
|
}
|
||||||
} else if (vim_isprintc(PTR2CHAR(scan)) == 1
|
} else if (vim_isprintc(PTR2CHAR(scan)) == 1
|
||||||
&& (testval || !ascii_isdigit(*scan))) {
|
&& (testval || !ascii_isdigit(*scan))) {
|
||||||
mb_ptr_adv(scan);
|
MB_PTR_ADV(scan);
|
||||||
} else if (rex.reg_line_lbr && *scan == '\n' && WITH_NL(OP(p))) {
|
} else if (rex.reg_line_lbr && *scan == '\n' && WITH_NL(OP(p))) {
|
||||||
scan++;
|
scan++;
|
||||||
} else {
|
} else {
|
||||||
@ -6679,7 +6688,7 @@ static int vim_regsub_both(char_u *source, typval_T *expr, char_u *dest,
|
|||||||
if (eval_result != NULL) {
|
if (eval_result != NULL) {
|
||||||
int had_backslash = FALSE;
|
int had_backslash = FALSE;
|
||||||
|
|
||||||
for (s = eval_result; *s != NUL; mb_ptr_adv(s)) {
|
for (s = eval_result; *s != NUL; MB_PTR_ADV(s)) {
|
||||||
// Change NL to CR, so that it becomes a line break,
|
// Change NL to CR, so that it becomes a line break,
|
||||||
// unless called from vim_regexec_nl().
|
// unless called from vim_regexec_nl().
|
||||||
// Skip over a backslashed character.
|
// Skip over a backslashed character.
|
||||||
|
@ -1323,7 +1323,7 @@ static int nfa_regatom(void)
|
|||||||
EMSG(_(e_nopresub));
|
EMSG(_(e_nopresub));
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
for (lp = reg_prev_sub; *lp != NUL; mb_cptr_adv(lp)) {
|
for (lp = reg_prev_sub; *lp != NUL; MB_CPTR_ADV(lp)) {
|
||||||
EMIT(PTR2CHAR(lp));
|
EMIT(PTR2CHAR(lp));
|
||||||
if (lp != reg_prev_sub)
|
if (lp != reg_prev_sub)
|
||||||
EMIT(NFA_CONCAT);
|
EMIT(NFA_CONCAT);
|
||||||
@ -1557,7 +1557,7 @@ collection:
|
|||||||
} else
|
} else
|
||||||
EMIT(result);
|
EMIT(result);
|
||||||
regparse = endp;
|
regparse = endp;
|
||||||
mb_ptr_adv(regparse);
|
MB_PTR_ADV(regparse);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
@ -1565,10 +1565,10 @@ collection:
|
|||||||
* version that turns [abc] into 'a' OR 'b' OR 'c'
|
* version that turns [abc] into 'a' OR 'b' OR 'c'
|
||||||
*/
|
*/
|
||||||
startc = endc = oldstartc = -1;
|
startc = endc = oldstartc = -1;
|
||||||
negated = FALSE;
|
negated = false;
|
||||||
if (*regparse == '^') { /* negated range */
|
if (*regparse == '^') { // negated range
|
||||||
negated = TRUE;
|
negated = true;
|
||||||
mb_ptr_adv(regparse);
|
MB_PTR_ADV(regparse);
|
||||||
EMIT(NFA_START_NEG_COLL);
|
EMIT(NFA_START_NEG_COLL);
|
||||||
} else
|
} else
|
||||||
EMIT(NFA_START_COLL);
|
EMIT(NFA_START_COLL);
|
||||||
@ -1576,7 +1576,7 @@ collection:
|
|||||||
startc = '-';
|
startc = '-';
|
||||||
EMIT(startc);
|
EMIT(startc);
|
||||||
EMIT(NFA_CONCAT);
|
EMIT(NFA_CONCAT);
|
||||||
mb_ptr_adv(regparse);
|
MB_PTR_ADV(regparse);
|
||||||
}
|
}
|
||||||
/* Emit the OR branches for each character in the [] */
|
/* Emit the OR branches for each character in the [] */
|
||||||
emit_range = FALSE;
|
emit_range = FALSE;
|
||||||
@ -1666,8 +1666,8 @@ collection:
|
|||||||
if (*regparse == '-' && oldstartc != -1) {
|
if (*regparse == '-' && oldstartc != -1) {
|
||||||
emit_range = TRUE;
|
emit_range = TRUE;
|
||||||
startc = oldstartc;
|
startc = oldstartc;
|
||||||
mb_ptr_adv(regparse);
|
MB_PTR_ADV(regparse);
|
||||||
continue; /* reading the end of the range */
|
continue; // reading the end of the range
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now handle simple and escaped characters.
|
/* Now handle simple and escaped characters.
|
||||||
@ -1683,7 +1683,7 @@ collection:
|
|||||||
!= NULL)
|
!= NULL)
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
mb_ptr_adv(regparse);
|
MB_PTR_ADV(regparse);
|
||||||
|
|
||||||
if (*regparse == 'n')
|
if (*regparse == 'n')
|
||||||
startc = reg_string ? NL : NFA_NEWL;
|
startc = reg_string ? NL : NFA_NEWL;
|
||||||
@ -1695,8 +1695,8 @@ collection:
|
|||||||
) {
|
) {
|
||||||
/* TODO(RE) This needs more testing */
|
/* TODO(RE) This needs more testing */
|
||||||
startc = coll_get_char();
|
startc = coll_get_char();
|
||||||
got_coll_char = TRUE;
|
got_coll_char = true;
|
||||||
mb_ptr_back(old_regparse, regparse);
|
MB_PTR_BACK(old_regparse, regparse);
|
||||||
} else {
|
} else {
|
||||||
/* \r,\t,\e,\b */
|
/* \r,\t,\e,\b */
|
||||||
startc = backslash_trans(*regparse);
|
startc = backslash_trans(*regparse);
|
||||||
@ -1768,18 +1768,18 @@ collection:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mb_ptr_adv(regparse);
|
MB_PTR_ADV(regparse);
|
||||||
} /* while (p < endp) */
|
} // while (p < endp)
|
||||||
|
|
||||||
mb_ptr_back(old_regparse, regparse);
|
MB_PTR_BACK(old_regparse, regparse);
|
||||||
if (*regparse == '-') { /* if last, '-' is just a char */
|
if (*regparse == '-') { // if last, '-' is just a char
|
||||||
EMIT('-');
|
EMIT('-');
|
||||||
EMIT(NFA_CONCAT);
|
EMIT(NFA_CONCAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip the trailing ] */
|
/* skip the trailing ] */
|
||||||
regparse = endp;
|
regparse = endp;
|
||||||
mb_ptr_adv(regparse);
|
MB_PTR_ADV(regparse);
|
||||||
|
|
||||||
/* Mark end of the collection. */
|
/* Mark end of the collection. */
|
||||||
if (negated == TRUE)
|
if (negated == TRUE)
|
||||||
|
@ -2474,7 +2474,7 @@ win_line (
|
|||||||
c = win_lbr_chartabsize(wp, line, ptr, (colnr_T)vcol, NULL);
|
c = win_lbr_chartabsize(wp, line, ptr, (colnr_T)vcol, NULL);
|
||||||
vcol += c;
|
vcol += c;
|
||||||
prev_ptr = ptr;
|
prev_ptr = ptr;
|
||||||
mb_ptr_adv(ptr);
|
MB_PTR_ADV(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
// When:
|
// When:
|
||||||
@ -4549,7 +4549,7 @@ static int status_match_len(expand_T *xp, char_u *s)
|
|||||||
while (*s != NUL) {
|
while (*s != NUL) {
|
||||||
s += skip_status_match_char(xp, s);
|
s += skip_status_match_char(xp, s);
|
||||||
len += ptr2cells(s);
|
len += ptr2cells(s);
|
||||||
mb_ptr_adv(s);
|
MB_PTR_ADV(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
@ -6671,7 +6671,7 @@ static void draw_tabline(void)
|
|||||||
if (has_mbyte)
|
if (has_mbyte)
|
||||||
while (len > room) {
|
while (len > room) {
|
||||||
len -= ptr2cells(p);
|
len -= ptr2cells(p);
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
}
|
}
|
||||||
else if (len > room) {
|
else if (len > room) {
|
||||||
p += len - room;
|
p += len - room;
|
||||||
|
@ -3239,35 +3239,41 @@ static int in_html_tag(int end_tag)
|
|||||||
|
|
||||||
/* We search forward until the cursor, because searching backwards is
|
/* We search forward until the cursor, because searching backwards is
|
||||||
* very slow for DBCS encodings. */
|
* very slow for DBCS encodings. */
|
||||||
for (p = line; p < line + curwin->w_cursor.col; mb_ptr_adv(p))
|
for (p = line; p < line + curwin->w_cursor.col; MB_PTR_ADV(p)) {
|
||||||
if (*p == '>' || *p == '<') {
|
if (*p == '>' || *p == '<') {
|
||||||
lc = *p;
|
lc = *p;
|
||||||
lp = p;
|
lp = p;
|
||||||
}
|
}
|
||||||
if (*p != '<') { /* check for '<' under cursor */
|
}
|
||||||
if (lc != '<')
|
if (*p != '<') { // check for '<' under cursor
|
||||||
return FALSE;
|
if (lc != '<') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
p = lp;
|
p = lp;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (p = line + curwin->w_cursor.col; p > line; ) {
|
for (p = line + curwin->w_cursor.col; p > line; ) {
|
||||||
if (*p == '<') /* find '<' under/before cursor */
|
if (*p == '<') { // find '<' under/before cursor
|
||||||
break;
|
break;
|
||||||
mb_ptr_back(line, p);
|
}
|
||||||
if (*p == '>') /* find '>' before cursor */
|
MB_PTR_BACK(line, p);
|
||||||
|
if (*p == '>') { // find '>' before cursor
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (*p != '<') {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (*p != '<')
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pos.lnum = curwin->w_cursor.lnum;
|
pos.lnum = curwin->w_cursor.lnum;
|
||||||
pos.col = (colnr_T)(p - line);
|
pos.col = (colnr_T)(p - line);
|
||||||
|
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
if (end_tag)
|
if (end_tag) {
|
||||||
/* check that there is a '/' after the '<' */
|
// check that there is a '/' after the '<'
|
||||||
return *p == '/';
|
return *p == '/';
|
||||||
|
}
|
||||||
|
|
||||||
/* check that there is no '/' after the '<' */
|
/* check that there is no '/' after the '<' */
|
||||||
if (*p == '/')
|
if (*p == '/')
|
||||||
@ -3371,8 +3377,10 @@ again:
|
|||||||
*/
|
*/
|
||||||
inc_cursor();
|
inc_cursor();
|
||||||
p = get_cursor_pos_ptr();
|
p = get_cursor_pos_ptr();
|
||||||
for (cp = p; *cp != NUL && *cp != '>' && !ascii_iswhite(*cp); mb_ptr_adv(cp))
|
for (cp = p;
|
||||||
;
|
*cp != NUL && *cp != '>' && !ascii_iswhite(*cp);
|
||||||
|
MB_PTR_ADV(cp)) {
|
||||||
|
}
|
||||||
len = (int)(cp - p);
|
len = (int)(cp - p);
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
curwin->w_cursor = old_pos;
|
curwin->w_cursor = old_pos;
|
||||||
|
131
src/nvim/spell.c
131
src/nvim/spell.c
@ -395,7 +395,7 @@ size_t spell_check(
|
|||||||
mi.mi_fend = ptr;
|
mi.mi_fend = ptr;
|
||||||
if (spell_iswordp(mi.mi_fend, wp)) {
|
if (spell_iswordp(mi.mi_fend, wp)) {
|
||||||
do {
|
do {
|
||||||
mb_ptr_adv(mi.mi_fend);
|
MB_PTR_ADV(mi.mi_fend);
|
||||||
} while (*mi.mi_fend != NUL && spell_iswordp(mi.mi_fend, wp));
|
} while (*mi.mi_fend != NUL && spell_iswordp(mi.mi_fend, wp));
|
||||||
|
|
||||||
if (capcol != NULL && *capcol == 0 && wp->w_s->b_cap_prog != NULL) {
|
if (capcol != NULL && *capcol == 0 && wp->w_s->b_cap_prog != NULL) {
|
||||||
@ -422,7 +422,7 @@ size_t spell_check(
|
|||||||
// case-fold the word with one non-word character, so that we can check
|
// case-fold the word with one non-word character, so that we can check
|
||||||
// for the word end.
|
// for the word end.
|
||||||
if (*mi.mi_fend != NUL) {
|
if (*mi.mi_fend != NUL) {
|
||||||
mb_ptr_adv(mi.mi_fend);
|
MB_PTR_ADV(mi.mi_fend);
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)spell_casefold(ptr, (int)(mi.mi_fend - ptr), mi.mi_fword, MAXWLEN + 1);
|
(void)spell_casefold(ptr, (int)(mi.mi_fend - ptr), mi.mi_fword, MAXWLEN + 1);
|
||||||
@ -499,7 +499,7 @@ size_t spell_check(
|
|||||||
} else if (mi.mi_end == ptr) {
|
} else if (mi.mi_end == ptr) {
|
||||||
// Always include at least one character. Required for when there
|
// Always include at least one character. Required for when there
|
||||||
// is a mixup in "midword".
|
// is a mixup in "midword".
|
||||||
mb_ptr_adv(mi.mi_end);
|
MB_PTR_ADV(mi.mi_end);
|
||||||
} else if (mi.mi_result == SP_BAD
|
} else if (mi.mi_result == SP_BAD
|
||||||
&& LANGP_ENTRY(wp->w_s->b_langp, 0)->lp_slang->sl_nobreak) {
|
&& LANGP_ENTRY(wp->w_s->b_langp, 0)->lp_slang->sl_nobreak) {
|
||||||
char_u *p, *fp;
|
char_u *p, *fp;
|
||||||
@ -512,8 +512,8 @@ size_t spell_check(
|
|||||||
p = mi.mi_word;
|
p = mi.mi_word;
|
||||||
fp = mi.mi_fword;
|
fp = mi.mi_fword;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
mb_ptr_adv(fp);
|
MB_PTR_ADV(fp);
|
||||||
if (p >= mi.mi_end) {
|
if (p >= mi.mi_end) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -706,8 +706,9 @@ static void find_word(matchinf_T *mip, int mode)
|
|||||||
// case-folded word is equal to the keep-case word.
|
// case-folded word is equal to the keep-case word.
|
||||||
p = mip->mi_word;
|
p = mip->mi_word;
|
||||||
if (STRNCMP(ptr, p, wlen) != 0) {
|
if (STRNCMP(ptr, p, wlen) != 0) {
|
||||||
for (char_u *s = ptr; s < ptr + wlen; mb_ptr_adv(s))
|
for (char_u *s = ptr; s < ptr + wlen; MB_PTR_ADV(s)) {
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
|
}
|
||||||
wlen = (int)(p - mip->mi_word);
|
wlen = (int)(p - mip->mi_word);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -814,10 +815,12 @@ static void find_word(matchinf_T *mip, int mode)
|
|||||||
mip->mi_compoff) != 0) {
|
mip->mi_compoff) != 0) {
|
||||||
// case folding may have changed the length
|
// case folding may have changed the length
|
||||||
p = mip->mi_word;
|
p = mip->mi_word;
|
||||||
for (char_u *s = ptr; s < ptr + mip->mi_compoff; mb_ptr_adv(s))
|
for (char_u *s = ptr; s < ptr + mip->mi_compoff; MB_PTR_ADV(s)) {
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
} else
|
}
|
||||||
|
} else {
|
||||||
p = mip->mi_word + mip->mi_compoff;
|
p = mip->mi_word + mip->mi_compoff;
|
||||||
|
}
|
||||||
capflags = captype(p, mip->mi_word + wlen);
|
capflags = captype(p, mip->mi_word + wlen);
|
||||||
if (capflags == WF_KEEPCAP || (capflags == WF_ALLCAP
|
if (capflags == WF_KEEPCAP || (capflags == WF_ALLCAP
|
||||||
&& (flags & WF_FIXCAP) != 0))
|
&& (flags & WF_FIXCAP) != 0))
|
||||||
@ -828,12 +831,13 @@ static void find_word(matchinf_T *mip, int mode)
|
|||||||
// character we do not accept a Onecap word. We do
|
// character we do not accept a Onecap word. We do
|
||||||
// accept a no-caps word, even when the dictionary
|
// accept a no-caps word, even when the dictionary
|
||||||
// word specifies ONECAP.
|
// word specifies ONECAP.
|
||||||
mb_ptr_back(mip->mi_word, p);
|
MB_PTR_BACK(mip->mi_word, p);
|
||||||
if (spell_iswordp_nmw(p, mip->mi_win)
|
if (spell_iswordp_nmw(p, mip->mi_win)
|
||||||
? capflags == WF_ONECAP
|
? capflags == WF_ONECAP
|
||||||
: (flags & WF_ONECAP) != 0
|
: (flags & WF_ONECAP) != 0
|
||||||
&& capflags != WF_ONECAP)
|
&& capflags != WF_ONECAP) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -888,8 +892,9 @@ static void find_word(matchinf_T *mip, int mode)
|
|||||||
// the case-folded word is equal to the keep-case word.
|
// the case-folded word is equal to the keep-case word.
|
||||||
p = mip->mi_fword;
|
p = mip->mi_fword;
|
||||||
if (STRNCMP(ptr, p, wlen) != 0) {
|
if (STRNCMP(ptr, p, wlen) != 0) {
|
||||||
for (char_u *s = ptr; s < ptr + wlen; mb_ptr_adv(s))
|
for (char_u *s = ptr; s < ptr + wlen; MB_PTR_ADV(s)) {
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
|
}
|
||||||
mip->mi_compoff = (int)(p - mip->mi_fword);
|
mip->mi_compoff = (int)(p - mip->mi_fword);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1288,12 +1293,13 @@ static int fold_more(matchinf_T *mip)
|
|||||||
|
|
||||||
p = mip->mi_fend;
|
p = mip->mi_fend;
|
||||||
do {
|
do {
|
||||||
mb_ptr_adv(mip->mi_fend);
|
MB_PTR_ADV(mip->mi_fend);
|
||||||
} while (*mip->mi_fend != NUL && spell_iswordp(mip->mi_fend, mip->mi_win));
|
} while (*mip->mi_fend != NUL && spell_iswordp(mip->mi_fend, mip->mi_win));
|
||||||
|
|
||||||
// Include the non-word character so that we can check for the word end.
|
// Include the non-word character so that we can check for the word end.
|
||||||
if (*mip->mi_fend != NUL)
|
if (*mip->mi_fend != NUL) {
|
||||||
mb_ptr_adv(mip->mi_fend);
|
MB_PTR_ADV(mip->mi_fend);
|
||||||
|
}
|
||||||
|
|
||||||
(void)spell_casefold(p, (int)(mip->mi_fend - p),
|
(void)spell_casefold(p, (int)(mip->mi_fend - p),
|
||||||
mip->mi_fword + mip->mi_fwordlen,
|
mip->mi_fword + mip->mi_fwordlen,
|
||||||
@ -2312,9 +2318,11 @@ int captype(char_u *word, char_u *end)
|
|||||||
bool past_second = false; // past second word char
|
bool past_second = false; // past second word char
|
||||||
|
|
||||||
// find first letter
|
// find first letter
|
||||||
for (p = word; !spell_iswordp_nmw(p, curwin); mb_ptr_adv(p))
|
for (p = word; !spell_iswordp_nmw(p, curwin); MB_PTR_ADV(p)) {
|
||||||
if (end == NULL ? *p == NUL : p >= end)
|
if (end == NULL ? *p == NUL : p >= end) {
|
||||||
return 0; // only non-word characters, illegal word
|
return 0; // only non-word characters, illegal word
|
||||||
|
}
|
||||||
|
}
|
||||||
if (has_mbyte) {
|
if (has_mbyte) {
|
||||||
c = mb_ptr2char_adv((const char_u **)&p);
|
c = mb_ptr2char_adv((const char_u **)&p);
|
||||||
} else {
|
} else {
|
||||||
@ -2324,19 +2332,22 @@ int captype(char_u *word, char_u *end)
|
|||||||
|
|
||||||
// Need to check all letters to find a word with mixed upper/lower.
|
// Need to check all letters to find a word with mixed upper/lower.
|
||||||
// But a word with an upper char only at start is a ONECAP.
|
// But a word with an upper char only at start is a ONECAP.
|
||||||
for (; end == NULL ? *p != NUL : p < end; mb_ptr_adv(p))
|
for (; end == NULL ? *p != NUL : p < end; MB_PTR_ADV(p)) {
|
||||||
if (spell_iswordp_nmw(p, curwin)) {
|
if (spell_iswordp_nmw(p, curwin)) {
|
||||||
c = PTR2CHAR(p);
|
c = PTR2CHAR(p);
|
||||||
if (!SPELL_ISUPPER(c)) {
|
if (!SPELL_ISUPPER(c)) {
|
||||||
// UUl -> KEEPCAP
|
// UUl -> KEEPCAP
|
||||||
if (past_second && allcap)
|
if (past_second && allcap) {
|
||||||
return WF_KEEPCAP;
|
return WF_KEEPCAP;
|
||||||
|
}
|
||||||
allcap = false;
|
allcap = false;
|
||||||
} else if (!allcap)
|
} else if (!allcap) {
|
||||||
// UlU -> KEEPCAP
|
// UlU -> KEEPCAP
|
||||||
return WF_KEEPCAP;
|
return WF_KEEPCAP;
|
||||||
|
}
|
||||||
past_second = true;
|
past_second = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (allcap)
|
if (allcap)
|
||||||
return WF_ALLCAP;
|
return WF_ALLCAP;
|
||||||
@ -2360,7 +2371,7 @@ static int badword_captype(char_u *word, char_u *end)
|
|||||||
// Count the number of UPPER and lower case letters.
|
// Count the number of UPPER and lower case letters.
|
||||||
l = u = 0;
|
l = u = 0;
|
||||||
first = false;
|
first = false;
|
||||||
for (p = word; p < end; mb_ptr_adv(p)) {
|
for (p = word; p < end; MB_PTR_ADV(p)) {
|
||||||
c = PTR2CHAR(p);
|
c = PTR2CHAR(p);
|
||||||
if (SPELL_ISUPPER(c)) {
|
if (SPELL_ISUPPER(c)) {
|
||||||
++u;
|
++u;
|
||||||
@ -2764,11 +2775,12 @@ void spell_suggest(int count)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
badlen = (int)curwin->w_cursor.col - (int)VIsual.col;
|
badlen = (int)curwin->w_cursor.col - (int)VIsual.col;
|
||||||
if (badlen < 0)
|
if (badlen < 0) {
|
||||||
badlen = -badlen;
|
badlen = -badlen;
|
||||||
else
|
} else {
|
||||||
curwin->w_cursor.col = VIsual.col;
|
curwin->w_cursor.col = VIsual.col;
|
||||||
++badlen;
|
}
|
||||||
|
badlen++;
|
||||||
end_visual_mode();
|
end_visual_mode();
|
||||||
} else
|
} else
|
||||||
// Find the start of the badly spelled word.
|
// Find the start of the badly spelled word.
|
||||||
@ -2780,11 +2792,13 @@ void spell_suggest(int count)
|
|||||||
line = get_cursor_line_ptr();
|
line = get_cursor_line_ptr();
|
||||||
p = line + curwin->w_cursor.col;
|
p = line + curwin->w_cursor.col;
|
||||||
// Backup to before start of word.
|
// Backup to before start of word.
|
||||||
while (p > line && spell_iswordp_nmw(p, curwin))
|
while (p > line && spell_iswordp_nmw(p, curwin)) {
|
||||||
mb_ptr_back(line, p);
|
MB_PTR_BACK(line, p);
|
||||||
|
}
|
||||||
// Forward to start of word.
|
// Forward to start of word.
|
||||||
while (*p != NUL && !spell_iswordp_nmw(p, curwin))
|
while (*p != NUL && !spell_iswordp_nmw(p, curwin)) {
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
|
}
|
||||||
|
|
||||||
if (!spell_iswordp_nmw(p, curwin)) { // No word found.
|
if (!spell_iswordp_nmw(p, curwin)) { // No word found.
|
||||||
beep_flush();
|
beep_flush();
|
||||||
@ -2973,8 +2987,9 @@ static bool check_need_cap(linenr_T lnum, colnr_T col)
|
|||||||
endcol = (colnr_T)STRLEN(line);
|
endcol = (colnr_T)STRLEN(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else {
|
||||||
endcol = col;
|
endcol = col;
|
||||||
|
}
|
||||||
|
|
||||||
if (endcol > 0) {
|
if (endcol > 0) {
|
||||||
// Check if sentence ends before the bad word.
|
// Check if sentence ends before the bad word.
|
||||||
@ -2982,9 +2997,10 @@ static bool check_need_cap(linenr_T lnum, colnr_T col)
|
|||||||
regmatch.rm_ic = FALSE;
|
regmatch.rm_ic = FALSE;
|
||||||
p = line + endcol;
|
p = line + endcol;
|
||||||
for (;; ) {
|
for (;; ) {
|
||||||
mb_ptr_back(line, p);
|
MB_PTR_BACK(line, p);
|
||||||
if (p == line || spell_iswordp_nmw(p, curwin))
|
if (p == line || spell_iswordp_nmw(p, curwin)) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
if (vim_regexec(®match, p, 0)
|
if (vim_regexec(®match, p, 0)
|
||||||
&& regmatch.endp[0] == line + endcol) {
|
&& regmatch.endp[0] == line + endcol) {
|
||||||
need_cap = true;
|
need_cap = true;
|
||||||
@ -3861,7 +3877,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
|
|
||||||
// Get pointer to last char of previous word.
|
// Get pointer to last char of previous word.
|
||||||
p = preword + sp->ts_prewordlen;
|
p = preword + sp->ts_prewordlen;
|
||||||
mb_ptr_back(preword, p);
|
MB_PTR_BACK(preword, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3947,12 +3963,13 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
// Give a penalty when changing non-word char to word
|
// Give a penalty when changing non-word char to word
|
||||||
// char, e.g., "thes," -> "these".
|
// char, e.g., "thes," -> "these".
|
||||||
p = fword + sp->ts_fidx;
|
p = fword + sp->ts_fidx;
|
||||||
mb_ptr_back(fword, p);
|
MB_PTR_BACK(fword, p);
|
||||||
if (!spell_iswordp(p, curwin)) {
|
if (!spell_iswordp(p, curwin)) {
|
||||||
p = preword + STRLEN(preword);
|
p = preword + STRLEN(preword);
|
||||||
mb_ptr_back(preword, p);
|
MB_PTR_BACK(preword, p);
|
||||||
if (spell_iswordp(p, curwin))
|
if (spell_iswordp(p, curwin)) {
|
||||||
newscore += SCORE_NONWORD;
|
newscore += SCORE_NONWORD;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Give a bonus to words seen before.
|
// Give a bonus to words seen before.
|
||||||
@ -4301,10 +4318,10 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
// to the score. Also for the soundfold
|
// to the score. Also for the soundfold
|
||||||
// tree (might seem illogical but does
|
// tree (might seem illogical but does
|
||||||
// give better scores).
|
// give better scores).
|
||||||
mb_ptr_back(tword, p);
|
MB_PTR_BACK(tword, p);
|
||||||
if (c == mb_ptr2char(p))
|
if (c == mb_ptr2char(p)) {
|
||||||
sp->ts_score -= SCORE_INS
|
sp->ts_score -= SCORE_INS - SCORE_INSDUP;
|
||||||
- SCORE_INSDUP;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4894,10 +4911,12 @@ static int nofold_len(char_u *fword, int flen, char_u *word)
|
|||||||
char_u *p;
|
char_u *p;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for (p = fword; p < fword + flen; mb_ptr_adv(p))
|
for (p = fword; p < fword + flen; MB_PTR_ADV(p)) {
|
||||||
++i;
|
i++;
|
||||||
for (p = word; i > 0; mb_ptr_adv(p))
|
}
|
||||||
--i;
|
for (p = word; i > 0; MB_PTR_ADV(p)) {
|
||||||
|
i--;
|
||||||
|
}
|
||||||
return (int)(p - word);
|
return (int)(p - word);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5630,8 +5649,8 @@ add_suggestion (
|
|||||||
badlen = (int)(pbad - su->su_badptr);
|
badlen = (int)(pbad - su->su_badptr);
|
||||||
if (goodlen <= 0 || badlen <= 0)
|
if (goodlen <= 0 || badlen <= 0)
|
||||||
break;
|
break;
|
||||||
mb_ptr_back(goodword, pgood);
|
MB_PTR_BACK(goodword, pgood);
|
||||||
mb_ptr_back(su->su_badptr, pbad);
|
MB_PTR_BACK(su->su_badptr, pbad);
|
||||||
if (has_mbyte) {
|
if (has_mbyte) {
|
||||||
if (mb_ptr2char(pgood) != mb_ptr2char(pbad))
|
if (mb_ptr2char(pgood) != mb_ptr2char(pbad))
|
||||||
break;
|
break;
|
||||||
@ -7517,8 +7536,9 @@ char_u *spell_to_word_end(char_u *start, win_T *win)
|
|||||||
{
|
{
|
||||||
char_u *p = start;
|
char_u *p = start;
|
||||||
|
|
||||||
while (*p != NUL && spell_iswordp(p, win))
|
while (*p != NUL && spell_iswordp(p, win)) {
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
|
}
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -7533,23 +7553,26 @@ int spell_word_start(int startcol)
|
|||||||
char_u *p;
|
char_u *p;
|
||||||
int col = 0;
|
int col = 0;
|
||||||
|
|
||||||
if (no_spell_checking(curwin))
|
if (no_spell_checking(curwin)) {
|
||||||
return startcol;
|
return startcol;
|
||||||
|
}
|
||||||
|
|
||||||
// Find a word character before "startcol".
|
// Find a word character before "startcol".
|
||||||
line = get_cursor_line_ptr();
|
line = get_cursor_line_ptr();
|
||||||
for (p = line + startcol; p > line; ) {
|
for (p = line + startcol; p > line; ) {
|
||||||
mb_ptr_back(line, p);
|
MB_PTR_BACK(line, p);
|
||||||
if (spell_iswordp_nmw(p, curwin))
|
if (spell_iswordp_nmw(p, curwin)) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go back to start of the word.
|
// Go back to start of the word.
|
||||||
while (p > line) {
|
while (p > line) {
|
||||||
col = (int)(p - line);
|
col = (int)(p - line);
|
||||||
mb_ptr_back(line, p);
|
MB_PTR_BACK(line, p);
|
||||||
if (!spell_iswordp(p, curwin))
|
if (!spell_iswordp(p, curwin)) {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
col = 0;
|
col = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1507,9 +1507,10 @@ static int set_sofo(slang_T *lp, char_u *from, char_u *to)
|
|||||||
// sl_sal_first[] for this.
|
// sl_sal_first[] for this.
|
||||||
for (p = from, s = to; *p != NUL && *s != NUL; ) {
|
for (p = from, s = to; *p != NUL && *s != NUL; ) {
|
||||||
c = mb_cptr2char_adv((const char_u **)&p);
|
c = mb_cptr2char_adv((const char_u **)&p);
|
||||||
mb_cptr_adv(s);
|
MB_CPTR_ADV(s);
|
||||||
if (c >= 256)
|
if (c >= 256) {
|
||||||
++lp->sl_sal_first[c & 0xff];
|
lp->sl_sal_first[c & 0xff]++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (*p != NUL || *s != NUL) // lengths differ
|
if (*p != NUL || *s != NUL) // lengths differ
|
||||||
return SP_FORMERROR;
|
return SP_FORMERROR;
|
||||||
@ -2427,7 +2428,7 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
|||||||
|| PTR2CHAR(aff_entry->ae_cond) == c)) {
|
|| PTR2CHAR(aff_entry->ae_cond) == c)) {
|
||||||
p = aff_entry->ae_add
|
p = aff_entry->ae_add
|
||||||
+ STRLEN(aff_entry->ae_add);
|
+ STRLEN(aff_entry->ae_add);
|
||||||
mb_ptr_back(aff_entry->ae_add, p);
|
MB_PTR_BACK(aff_entry->ae_add, p);
|
||||||
if (PTR2CHAR(p) == c_up) {
|
if (PTR2CHAR(p) == c_up) {
|
||||||
upper = true;
|
upper = true;
|
||||||
aff_entry->ae_chop = NULL;
|
aff_entry->ae_chop = NULL;
|
||||||
@ -2528,12 +2529,16 @@ static afffile_T *spell_read_aff(spellinfo_T *spin, char_u *fname)
|
|||||||
if (items[0][3] == 'S' ? do_repsal : do_rep) {
|
if (items[0][3] == 'S' ? do_repsal : do_rep) {
|
||||||
// Replace underscore with space (can't include a space
|
// Replace underscore with space (can't include a space
|
||||||
// directly).
|
// directly).
|
||||||
for (p = items[1]; *p != NUL; mb_ptr_adv(p))
|
for (p = items[1]; *p != NUL; MB_PTR_ADV(p)) {
|
||||||
if (*p == '_')
|
if (*p == '_') {
|
||||||
*p = ' ';
|
*p = ' ';
|
||||||
for (p = items[2]; *p != NUL; mb_ptr_adv(p))
|
}
|
||||||
if (*p == '_')
|
}
|
||||||
|
for (p = items[2]; *p != NUL; MB_PTR_ADV(p)) {
|
||||||
|
if (*p == '_') {
|
||||||
*p = ' ';
|
*p = ' ';
|
||||||
|
}
|
||||||
|
}
|
||||||
add_fromto(spin, items[0][3] == 'S'
|
add_fromto(spin, items[0][3] == 'S'
|
||||||
? &spin->si_repsal
|
? &spin->si_repsal
|
||||||
: &spin->si_rep, items[1], items[2]);
|
: &spin->si_rep, items[1], items[2]);
|
||||||
@ -3070,10 +3075,10 @@ static int spell_read_dic(spellinfo_T *spin, char_u *fname, afffile_T *affile)
|
|||||||
// Truncate the word at the "/", set "afflist" to what follows.
|
// Truncate the word at the "/", set "afflist" to what follows.
|
||||||
// Replace "\/" by "/" and "\\" by "\".
|
// Replace "\/" by "/" and "\\" by "\".
|
||||||
afflist = NULL;
|
afflist = NULL;
|
||||||
for (p = w; *p != NUL; mb_ptr_adv(p)) {
|
for (p = w; *p != NUL; MB_PTR_ADV(p)) {
|
||||||
if (*p == '\\' && (p[1] == '\\' || p[1] == '/'))
|
if (*p == '\\' && (p[1] == '\\' || p[1] == '/')) {
|
||||||
STRMOVE(p, p + 1);
|
STRMOVE(p, p + 1);
|
||||||
else if (*p == '/') {
|
} else if (*p == '/') {
|
||||||
*p = NUL;
|
*p = NUL;
|
||||||
afflist = p + 1;
|
afflist = p + 1;
|
||||||
break;
|
break;
|
||||||
@ -3343,19 +3348,22 @@ store_aff_word (
|
|||||||
// Match. Remove the chop and add the affix.
|
// Match. Remove the chop and add the affix.
|
||||||
if (xht == NULL) {
|
if (xht == NULL) {
|
||||||
// prefix: chop/add at the start of the word
|
// prefix: chop/add at the start of the word
|
||||||
if (ae->ae_add == NULL)
|
if (ae->ae_add == NULL) {
|
||||||
*newword = NUL;
|
*newword = NUL;
|
||||||
else
|
} else {
|
||||||
STRLCPY(newword, ae->ae_add, MAXWLEN);
|
STRLCPY(newword, ae->ae_add, MAXWLEN);
|
||||||
|
}
|
||||||
p = word;
|
p = word;
|
||||||
if (ae->ae_chop != NULL) {
|
if (ae->ae_chop != NULL) {
|
||||||
// Skip chop string.
|
// Skip chop string.
|
||||||
if (has_mbyte) {
|
if (has_mbyte) {
|
||||||
i = mb_charlen(ae->ae_chop);
|
i = mb_charlen(ae->ae_chop);
|
||||||
for (; i > 0; --i)
|
for (; i > 0; i--) {
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
} else
|
}
|
||||||
|
} else {
|
||||||
p += STRLEN(ae->ae_chop);
|
p += STRLEN(ae->ae_chop);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
STRCAT(newword, p);
|
STRCAT(newword, p);
|
||||||
} else {
|
} else {
|
||||||
@ -3365,8 +3373,9 @@ store_aff_word (
|
|||||||
// Remove chop string.
|
// Remove chop string.
|
||||||
p = newword + STRLEN(newword);
|
p = newword + STRLEN(newword);
|
||||||
i = (int)MB_CHARLEN(ae->ae_chop);
|
i = (int)MB_CHARLEN(ae->ae_chop);
|
||||||
for (; i > 0; --i)
|
for (; i > 0; i--) {
|
||||||
mb_ptr_back(newword, p);
|
MB_PTR_BACK(newword, p);
|
||||||
|
}
|
||||||
*p = NUL;
|
*p = NUL;
|
||||||
}
|
}
|
||||||
if (ae->ae_add != NULL)
|
if (ae->ae_add != NULL)
|
||||||
|
@ -207,7 +207,7 @@ char_u *vim_strsave_shellescape(const char_u *string,
|
|||||||
|
|
||||||
/* First count the number of extra bytes required. */
|
/* First count the number of extra bytes required. */
|
||||||
size_t length = STRLEN(string) + 3; // two quotes and a trailing NUL
|
size_t length = STRLEN(string) + 3; // two quotes and a trailing NUL
|
||||||
for (const char_u *p = string; *p != NUL; mb_ptr_adv(p)) {
|
for (const char_u *p = string; *p != NUL; MB_PTR_ADV(p)) {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if (!p_ssl) {
|
if (!p_ssl) {
|
||||||
if (*p == '"') {
|
if (*p == '"') {
|
||||||
@ -469,7 +469,7 @@ char_u *vim_strrchr(const char_u *string, int c)
|
|||||||
while (*p) {
|
while (*p) {
|
||||||
if (*p == c)
|
if (*p == c)
|
||||||
retval = p;
|
retval = p;
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
}
|
}
|
||||||
return (char_u *) retval;
|
return (char_u *) retval;
|
||||||
}
|
}
|
||||||
|
@ -2824,11 +2824,12 @@ syn_add_end_off (
|
|||||||
base = ml_get_buf(syn_buf, result->lnum, FALSE);
|
base = ml_get_buf(syn_buf, result->lnum, FALSE);
|
||||||
p = base + col;
|
p = base + col;
|
||||||
if (off > 0) {
|
if (off > 0) {
|
||||||
while (off-- > 0 && *p != NUL)
|
while (off-- > 0 && *p != NUL) {
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
while (off++ < 0 && base < p) {
|
while (off++ < 0 && base < p) {
|
||||||
mb_ptr_back(base, p);
|
MB_PTR_BACK(base, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
col = (int)(p - base);
|
col = (int)(p - base);
|
||||||
@ -2873,11 +2874,11 @@ syn_add_start_off (
|
|||||||
p = base + col;
|
p = base + col;
|
||||||
if (off > 0) {
|
if (off > 0) {
|
||||||
while (off-- && *p != NUL) {
|
while (off-- && *p != NUL) {
|
||||||
mb_ptr_adv(p);
|
MB_PTR_ADV(p);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
while (off++ && base < p) {
|
while (off++ && base < p) {
|
||||||
mb_ptr_back(base, p);
|
MB_PTR_BACK(base, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
col = (int)(p - base);
|
col = (int)(p - base);
|
||||||
|
@ -703,7 +703,7 @@ char *u_get_undo_file_name(const char *const buf_ffname, const bool reading)
|
|||||||
if (has_directory) {
|
if (has_directory) {
|
||||||
if (munged_name == NULL) {
|
if (munged_name == NULL) {
|
||||||
munged_name = xstrdup(ffname);
|
munged_name = xstrdup(ffname);
|
||||||
for (char *p = munged_name; *p != NUL; mb_ptr_adv(p)) {
|
for (char *p = munged_name; *p != NUL; MB_PTR_ADV(p)) {
|
||||||
if (vim_ispathsep(*p)) {
|
if (vim_ispathsep(*p)) {
|
||||||
*p = '%';
|
*p = '%';
|
||||||
}
|
}
|
||||||
|
@ -5101,11 +5101,13 @@ file_name_in_line (
|
|||||||
* search forward for what could be the start of a file name
|
* search forward for what could be the start of a file name
|
||||||
*/
|
*/
|
||||||
ptr = line + col;
|
ptr = line + col;
|
||||||
while (*ptr != NUL && !vim_isfilec(*ptr))
|
while (*ptr != NUL && !vim_isfilec(*ptr)) {
|
||||||
mb_ptr_adv(ptr);
|
MB_PTR_ADV(ptr);
|
||||||
if (*ptr == NUL) { /* nothing found */
|
}
|
||||||
if (options & FNAME_MESS)
|
if (*ptr == NUL) { // nothing found
|
||||||
|
if (options & FNAME_MESS) {
|
||||||
EMSG(_("E446: No file name under cursor"));
|
EMSG(_("E446: No file name under cursor"));
|
||||||
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user