mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
refactor: reduce scope of locals as per the style guide (#22211)
This commit is contained in:
parent
224a3c77ca
commit
27177e5819
@ -222,10 +222,8 @@ static void ExpandEscape(expand_T *xp, char *str, int numfiles, char **files, in
|
|||||||
int nextwild(expand_T *xp, int type, int options, bool escape)
|
int nextwild(expand_T *xp, int type, int options, bool escape)
|
||||||
{
|
{
|
||||||
CmdlineInfo *const ccline = get_cmdline_info();
|
CmdlineInfo *const ccline = get_cmdline_info();
|
||||||
int i, j;
|
int i;
|
||||||
char *p1;
|
|
||||||
char *p2;
|
char *p2;
|
||||||
int difflen;
|
|
||||||
|
|
||||||
if (xp->xp_numfiles == -1) {
|
if (xp->xp_numfiles == -1) {
|
||||||
set_expand_context(xp);
|
set_expand_context(xp);
|
||||||
@ -258,6 +256,7 @@ int nextwild(expand_T *xp, int type, int options, bool escape)
|
|||||||
// Get next/previous match for a previous expanded pattern.
|
// Get next/previous match for a previous expanded pattern.
|
||||||
p2 = ExpandOne(xp, NULL, NULL, 0, type);
|
p2 = ExpandOne(xp, NULL, NULL, 0, type);
|
||||||
} else {
|
} else {
|
||||||
|
char *p1;
|
||||||
if (cmdline_fuzzy_completion_supported(xp)) {
|
if (cmdline_fuzzy_completion_supported(xp)) {
|
||||||
// If fuzzy matching, don't modify the search string
|
// If fuzzy matching, don't modify the search string
|
||||||
p1 = xstrdup(xp->xp_pattern);
|
p1 = xstrdup(xp->xp_pattern);
|
||||||
@ -282,6 +281,7 @@ int nextwild(expand_T *xp, int type, int options, bool escape)
|
|||||||
|
|
||||||
// Longest match: make sure it is not shorter, happens with :help.
|
// Longest match: make sure it is not shorter, happens with :help.
|
||||||
if (p2 != NULL && type == WILD_LONGEST) {
|
if (p2 != NULL && type == WILD_LONGEST) {
|
||||||
|
int j;
|
||||||
for (j = 0; (size_t)j < xp->xp_pattern_len; j++) {
|
for (j = 0; (size_t)j < xp->xp_pattern_len; j++) {
|
||||||
if (ccline->cmdbuff[i + j] == '*'
|
if (ccline->cmdbuff[i + j] == '*'
|
||||||
|| ccline->cmdbuff[i + j] == '?') {
|
|| ccline->cmdbuff[i + j] == '?') {
|
||||||
@ -295,7 +295,7 @@ int nextwild(expand_T *xp, int type, int options, bool escape)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (p2 != NULL && !got_int) {
|
if (p2 != NULL && !got_int) {
|
||||||
difflen = (int)strlen(p2) - (int)(xp->xp_pattern_len);
|
int difflen = (int)strlen(p2) - (int)(xp->xp_pattern_len);
|
||||||
if (ccline->cmdlen + difflen + 4 > ccline->cmdbufflen) {
|
if (ccline->cmdlen + difflen + 4 > ccline->cmdbufflen) {
|
||||||
realloc_cmdbuff(ccline->cmdlen + difflen + 4);
|
realloc_cmdbuff(ccline->cmdlen + difflen + 4);
|
||||||
xp->xp_pattern = ccline->cmdbuff + i;
|
xp->xp_pattern = ccline->cmdbuff + i;
|
||||||
@ -454,8 +454,6 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m
|
|||||||
char *selend = NULL;
|
char *selend = NULL;
|
||||||
static int first_match = 0;
|
static int first_match = 0;
|
||||||
bool add_left = false;
|
bool add_left = false;
|
||||||
char *s;
|
|
||||||
int emenu;
|
|
||||||
int l;
|
int l;
|
||||||
|
|
||||||
if (matches == NULL) { // interrupted completion?
|
if (matches == NULL) { // interrupted completion?
|
||||||
@ -528,10 +526,9 @@ static void redraw_wildmenu(expand_T *xp, int num_matches, char **matches, int m
|
|||||||
selstart_col = clen;
|
selstart_col = clen;
|
||||||
}
|
}
|
||||||
|
|
||||||
s = SHOW_MATCH(i);
|
char *s = SHOW_MATCH(i);
|
||||||
// Check for menu separators - replace with '|'
|
// Check for menu separators - replace with '|'
|
||||||
emenu = (xp->xp_context == EXPAND_MENUS
|
int emenu = (xp->xp_context == EXPAND_MENUS || xp->xp_context == EXPAND_MENUNAMES);
|
||||||
|| xp->xp_context == EXPAND_MENUNAMES);
|
|
||||||
if (emenu && menu_is_separator(s)) {
|
if (emenu && menu_is_separator(s)) {
|
||||||
STRCPY(buf + len, transchar('|'));
|
STRCPY(buf + len, transchar('|'));
|
||||||
l = (int)strlen(buf + len);
|
l = (int)strlen(buf + len);
|
||||||
@ -847,7 +844,6 @@ char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode)
|
|||||||
static int findex;
|
static int findex;
|
||||||
static char *orig_save = NULL; // kept value of orig
|
static char *orig_save = NULL; // kept value of orig
|
||||||
int orig_saved = false;
|
int orig_saved = false;
|
||||||
int i;
|
|
||||||
|
|
||||||
// first handle the case of using an old match
|
// first handle the case of using an old match
|
||||||
if (mode == WILD_NEXT || mode == WILD_PREV
|
if (mode == WILD_NEXT || mode == WILD_PREV
|
||||||
@ -900,12 +896,12 @@ char *ExpandOne(expand_T *xp, char *str, char *orig, int options, int mode)
|
|||||||
// TODO(philix): use xstpcpy instead of strcat in a loop (ExpandOne)
|
// TODO(philix): use xstpcpy instead of strcat in a loop (ExpandOne)
|
||||||
if (mode == WILD_ALL && xp->xp_numfiles > 0 && !got_int) {
|
if (mode == WILD_ALL && xp->xp_numfiles > 0 && !got_int) {
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
for (i = 0; i < xp->xp_numfiles; i++) {
|
for (int i = 0; i < xp->xp_numfiles; i++) {
|
||||||
len += strlen(xp->xp_files[i]) + 1;
|
len += strlen(xp->xp_files[i]) + 1;
|
||||||
}
|
}
|
||||||
ss = xmalloc(len);
|
ss = xmalloc(len);
|
||||||
*ss = NUL;
|
*ss = NUL;
|
||||||
for (i = 0; i < xp->xp_numfiles; i++) {
|
for (int i = 0; i < xp->xp_numfiles; i++) {
|
||||||
STRCAT(ss, xp->xp_files[i]);
|
STRCAT(ss, xp->xp_files[i]);
|
||||||
if (i != xp->xp_numfiles - 1) {
|
if (i != xp->xp_numfiles - 1) {
|
||||||
STRCAT(ss, (options & WILD_USE_NL) ? "\n" : " ");
|
STRCAT(ss, (options & WILD_USE_NL) ? "\n" : " ");
|
||||||
@ -1375,7 +1371,6 @@ void set_expand_context(expand_T *xp)
|
|||||||
static const char *set_cmd_index(const char *cmd, exarg_T *eap, expand_T *xp, int *complp)
|
static const char *set_cmd_index(const char *cmd, exarg_T *eap, expand_T *xp, int *complp)
|
||||||
{
|
{
|
||||||
const char *p = NULL;
|
const char *p = NULL;
|
||||||
size_t len = 0;
|
|
||||||
const bool fuzzy = cmdline_fuzzy_complete(cmd);
|
const bool fuzzy = cmdline_fuzzy_complete(cmd);
|
||||||
|
|
||||||
// Isolate the command and search for it in the command table.
|
// Isolate the command and search for it in the command table.
|
||||||
@ -1410,7 +1405,7 @@ static const char *set_cmd_index(const char *cmd, exarg_T *eap, expand_T *xp, in
|
|||||||
if (p == cmd && vim_strchr("@*!=><&~#", (uint8_t)(*p)) != NULL) {
|
if (p == cmd && vim_strchr("@*!=><&~#", (uint8_t)(*p)) != NULL) {
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
len = (size_t)(p - cmd);
|
size_t len = (size_t)(p - cmd);
|
||||||
|
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
xp->xp_context = EXPAND_UNSUCCESSFUL;
|
xp->xp_context = EXPAND_UNSUCCESSFUL;
|
||||||
@ -2955,7 +2950,6 @@ static void expand_shellcmd(char *filepat, char ***matches, int *numMatches, int
|
|||||||
char *path = NULL;
|
char *path = NULL;
|
||||||
garray_T ga;
|
garray_T ga;
|
||||||
char *buf = xmalloc(MAXPATHL);
|
char *buf = xmalloc(MAXPATHL);
|
||||||
size_t l;
|
|
||||||
char *s, *e;
|
char *s, *e;
|
||||||
int flags = flagsarg;
|
int flags = flagsarg;
|
||||||
bool did_curdir = false;
|
bool did_curdir = false;
|
||||||
@ -3013,7 +3007,7 @@ static void expand_shellcmd(char *filepat, char ***matches, int *numMatches, int
|
|||||||
flags &= ~EW_DIR;
|
flags &= ~EW_DIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
l = (size_t)(e - s);
|
size_t l = (size_t)(e - s);
|
||||||
if (l > MAXPATHL - 5) {
|
if (l > MAXPATHL - 5) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1620,8 +1620,6 @@ static void win_update(win_T *wp, DecorProviders *providers)
|
|||||||
&& !(dollar_vcol >= 0 && mod_bot == mod_top + 1)
|
&& !(dollar_vcol >= 0 && mod_bot == mod_top + 1)
|
||||||
&& row >= top_end) {
|
&& row >= top_end) {
|
||||||
int old_rows = 0;
|
int old_rows = 0;
|
||||||
int new_rows = 0;
|
|
||||||
int xtra_rows;
|
|
||||||
linenr_T l;
|
linenr_T l;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@ -1656,6 +1654,7 @@ static void win_update(win_T *wp, DecorProviders *providers)
|
|||||||
bot_start = 0;
|
bot_start = 0;
|
||||||
bot_scroll_start = 0;
|
bot_scroll_start = 0;
|
||||||
} else {
|
} else {
|
||||||
|
int new_rows = 0;
|
||||||
// Able to count old number of rows: Count new window
|
// Able to count old number of rows: Count new window
|
||||||
// rows, and may insert/delete lines
|
// rows, and may insert/delete lines
|
||||||
long j = idx;
|
long j = idx;
|
||||||
@ -1674,7 +1673,7 @@ static void win_update(win_T *wp, DecorProviders *providers)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xtra_rows = new_rows - old_rows;
|
int xtra_rows = new_rows - old_rows;
|
||||||
if (xtra_rows < 0) {
|
if (xtra_rows < 0) {
|
||||||
// May scroll text up. If there is not enough
|
// May scroll text up. If there is not enough
|
||||||
// remaining text or scrolling fails, must redraw the
|
// remaining text or scrolling fails, must redraw the
|
||||||
|
@ -729,7 +729,6 @@ static void cleanup_function_call(funccall_T *fc)
|
|||||||
/// @param[in] force When true, we are exiting.
|
/// @param[in] force When true, we are exiting.
|
||||||
static void funccal_unref(funccall_T *fc, ufunc_T *fp, bool force)
|
static void funccal_unref(funccall_T *fc, ufunc_T *fp, bool force)
|
||||||
{
|
{
|
||||||
funccall_T **pfc;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (fc == NULL) {
|
if (fc == NULL) {
|
||||||
@ -738,7 +737,7 @@ static void funccal_unref(funccall_T *fc, ufunc_T *fp, bool force)
|
|||||||
|
|
||||||
fc->fc_refcount--;
|
fc->fc_refcount--;
|
||||||
if (force ? fc->fc_refcount <= 0 : !fc_referenced(fc)) {
|
if (force ? fc->fc_refcount <= 0 : !fc_referenced(fc)) {
|
||||||
for (pfc = &previous_funccal; *pfc != NULL; pfc = &(*pfc)->caller) {
|
for (funccall_T **pfc = &previous_funccal; *pfc != NULL; pfc = &(*pfc)->caller) {
|
||||||
if (fc == *pfc) {
|
if (fc == *pfc) {
|
||||||
*pfc = fc->caller;
|
*pfc = fc->caller;
|
||||||
free_funccal_contents(fc);
|
free_funccal_contents(fc);
|
||||||
@ -3289,7 +3288,6 @@ int func_has_abort(void *cookie)
|
|||||||
/// Changes "rettv" in-place.
|
/// Changes "rettv" in-place.
|
||||||
void make_partial(dict_T *const selfdict, typval_T *const rettv)
|
void make_partial(dict_T *const selfdict, typval_T *const rettv)
|
||||||
{
|
{
|
||||||
char *fname;
|
|
||||||
char *tofree = NULL;
|
char *tofree = NULL;
|
||||||
ufunc_T *fp;
|
ufunc_T *fp;
|
||||||
char fname_buf[FLEN_FIXED + 1];
|
char fname_buf[FLEN_FIXED + 1];
|
||||||
@ -3298,7 +3296,7 @@ void make_partial(dict_T *const selfdict, typval_T *const rettv)
|
|||||||
if (rettv->v_type == VAR_PARTIAL && rettv->vval.v_partial->pt_func != NULL) {
|
if (rettv->v_type == VAR_PARTIAL && rettv->vval.v_partial->pt_func != NULL) {
|
||||||
fp = rettv->vval.v_partial->pt_func;
|
fp = rettv->vval.v_partial->pt_func;
|
||||||
} else {
|
} else {
|
||||||
fname = rettv->v_type == VAR_FUNC || rettv->v_type == VAR_STRING
|
char *fname = rettv->v_type == VAR_FUNC || rettv->v_type == VAR_STRING
|
||||||
? rettv->vval.v_string
|
? rettv->vval.v_string
|
||||||
: rettv->vval.v_partial->pt_name;
|
: rettv->vval.v_partial->pt_name;
|
||||||
// Translate "s:func" to the stored function name.
|
// Translate "s:func" to the stored function name.
|
||||||
@ -3319,7 +3317,6 @@ void make_partial(dict_T *const selfdict, typval_T *const rettv)
|
|||||||
pt->pt_name = rettv->vval.v_string;
|
pt->pt_name = rettv->vval.v_string;
|
||||||
} else {
|
} else {
|
||||||
partial_T *ret_pt = rettv->vval.v_partial;
|
partial_T *ret_pt = rettv->vval.v_partial;
|
||||||
int i;
|
|
||||||
|
|
||||||
// Partial: copy the function name, use selfdict and copy
|
// Partial: copy the function name, use selfdict and copy
|
||||||
// args. Can't take over name or args, the partial might
|
// args. Can't take over name or args, the partial might
|
||||||
@ -3335,7 +3332,7 @@ void make_partial(dict_T *const selfdict, typval_T *const rettv)
|
|||||||
size_t arg_size = sizeof(typval_T) * (size_t)ret_pt->pt_argc;
|
size_t arg_size = sizeof(typval_T) * (size_t)ret_pt->pt_argc;
|
||||||
pt->pt_argv = (typval_T *)xmalloc(arg_size);
|
pt->pt_argv = (typval_T *)xmalloc(arg_size);
|
||||||
pt->pt_argc = ret_pt->pt_argc;
|
pt->pt_argc = ret_pt->pt_argc;
|
||||||
for (i = 0; i < pt->pt_argc; i++) {
|
for (int i = 0; i < pt->pt_argc; i++) {
|
||||||
tv_copy(&ret_pt->pt_argv[i], &pt->pt_argv[i]);
|
tv_copy(&ret_pt->pt_argv[i], &pt->pt_argv[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3641,14 +3638,13 @@ bool set_ref_in_func(char *name, ufunc_T *fp_in, int copyID)
|
|||||||
int error = FCERR_NONE;
|
int error = FCERR_NONE;
|
||||||
char fname_buf[FLEN_FIXED + 1];
|
char fname_buf[FLEN_FIXED + 1];
|
||||||
char *tofree = NULL;
|
char *tofree = NULL;
|
||||||
char *fname;
|
|
||||||
bool abort = false;
|
bool abort = false;
|
||||||
if (name == NULL && fp_in == NULL) {
|
if (name == NULL && fp_in == NULL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fp_in == NULL) {
|
if (fp_in == NULL) {
|
||||||
fname = fname_trans_sid(name, fname_buf, &tofree, &error);
|
char *fname = fname_trans_sid(name, fname_buf, &tofree, &error);
|
||||||
fp = find_func(fname);
|
fp = find_func(fname);
|
||||||
}
|
}
|
||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
|
@ -369,12 +369,10 @@ int ex_let_vars(char *arg_start, typval_T *tv, int copy, int semicolon, int var_
|
|||||||
/// @return NULL for an error.
|
/// @return NULL for an error.
|
||||||
const char *skip_var_list(const char *arg, int *var_count, int *semicolon)
|
const char *skip_var_list(const char *arg, int *var_count, int *semicolon)
|
||||||
{
|
{
|
||||||
const char *p;
|
|
||||||
const char *s;
|
|
||||||
|
|
||||||
if (*arg == '[') {
|
if (*arg == '[') {
|
||||||
|
const char *s;
|
||||||
// "[var, var]": find the matching ']'.
|
// "[var, var]": find the matching ']'.
|
||||||
p = arg;
|
const char *p = arg;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
p = skipwhite(p + 1); // skip whites after '[', ';' or ','
|
p = skipwhite(p + 1); // skip whites after '[', ';' or ','
|
||||||
s = skip_var_one((char *)p);
|
s = skip_var_one((char *)p);
|
||||||
@ -575,7 +573,6 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo
|
|||||||
FUNC_ATTR_NONNULL_ARG(1, 2) FUNC_ATTR_WARN_UNUSED_RESULT
|
FUNC_ATTR_NONNULL_ARG(1, 2) FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
{
|
{
|
||||||
char *arg_end = NULL;
|
char *arg_end = NULL;
|
||||||
int len;
|
|
||||||
|
|
||||||
// ":let $VAR = expr": Set environment variable.
|
// ":let $VAR = expr": Set environment variable.
|
||||||
if (*arg == '$') {
|
if (*arg == '$') {
|
||||||
@ -586,7 +583,7 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo
|
|||||||
// Find the end of the name.
|
// Find the end of the name.
|
||||||
arg++;
|
arg++;
|
||||||
char *name = arg;
|
char *name = arg;
|
||||||
len = get_env_len((const char **)&arg);
|
int len = get_env_len((const char **)&arg);
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
semsg(_(e_invarg2), name - 1);
|
semsg(_(e_invarg2), name - 1);
|
||||||
} else {
|
} else {
|
||||||
@ -722,12 +719,10 @@ static char *ex_let_one(char *arg, typval_T *const tv, const bool copy, const bo
|
|||||||
&& vim_strchr(endchars, (uint8_t)(*skipwhite(arg + 1))) == NULL) {
|
&& vim_strchr(endchars, (uint8_t)(*skipwhite(arg + 1))) == NULL) {
|
||||||
emsg(_(e_letunexp));
|
emsg(_(e_letunexp));
|
||||||
} else {
|
} else {
|
||||||
char *s;
|
|
||||||
|
|
||||||
char *ptofree = NULL;
|
char *ptofree = NULL;
|
||||||
const char *p = tv_get_string_chk(tv);
|
const char *p = tv_get_string_chk(tv);
|
||||||
if (p != NULL && op != NULL && *op == '.') {
|
if (p != NULL && op != NULL && *op == '.') {
|
||||||
s = get_reg_contents(*arg == '@' ? '"' : *arg, kGRegExprSrc);
|
char *s = get_reg_contents(*arg == '@' ? '"' : *arg, kGRegExprSrc);
|
||||||
if (s != NULL) {
|
if (s != NULL) {
|
||||||
ptofree = concat_str(s, p);
|
ptofree = concat_str(s, p);
|
||||||
p = (const char *)ptofree;
|
p = (const char *)ptofree;
|
||||||
@ -861,10 +856,9 @@ static int do_unlet_var(lval_T *lp, char *name_end, exarg_T *eap, int deep FUNC_
|
|||||||
{
|
{
|
||||||
int forceit = eap->forceit;
|
int forceit = eap->forceit;
|
||||||
int ret = OK;
|
int ret = OK;
|
||||||
int cc;
|
|
||||||
|
|
||||||
if (lp->ll_tv == NULL) {
|
if (lp->ll_tv == NULL) {
|
||||||
cc = (uint8_t)(*name_end);
|
int cc = (uint8_t)(*name_end);
|
||||||
*name_end = NUL;
|
*name_end = NUL;
|
||||||
|
|
||||||
// Environment variable, normal name or expanded name.
|
// Environment variable, normal name or expanded name.
|
||||||
|
@ -204,15 +204,11 @@ void grid_puts_len(ScreenGrid *grid, char *text, int textlen, int row, int col,
|
|||||||
int len = textlen;
|
int len = textlen;
|
||||||
int c;
|
int c;
|
||||||
size_t max_off;
|
size_t max_off;
|
||||||
int mbyte_blen = 1;
|
|
||||||
int mbyte_cells = 1;
|
|
||||||
int u8c = 0;
|
|
||||||
int u8cc[MAX_MCO];
|
int u8cc[MAX_MCO];
|
||||||
bool clear_next_cell = false;
|
bool clear_next_cell = false;
|
||||||
int prev_c = 0; // previous Arabic character
|
int prev_c = 0; // previous Arabic character
|
||||||
int pc, nc, nc1;
|
int pc, nc, nc1;
|
||||||
int pcc[MAX_MCO];
|
int pcc[MAX_MCO];
|
||||||
int need_redraw;
|
|
||||||
bool do_flush = false;
|
bool do_flush = false;
|
||||||
|
|
||||||
grid_adjust(&grid, &row, &col);
|
grid_adjust(&grid, &row, &col);
|
||||||
@ -249,13 +245,13 @@ void grid_puts_len(ScreenGrid *grid, char *text, int textlen, int row, int col,
|
|||||||
&& *ptr != NUL) {
|
&& *ptr != NUL) {
|
||||||
c = (unsigned char)(*ptr);
|
c = (unsigned char)(*ptr);
|
||||||
// check if this is the first byte of a multibyte
|
// check if this is the first byte of a multibyte
|
||||||
mbyte_blen = len > 0
|
int mbyte_blen = len > 0
|
||||||
? utfc_ptr2len_len(ptr, (int)((text + len) - ptr))
|
? utfc_ptr2len_len(ptr, (int)((text + len) - ptr))
|
||||||
: utfc_ptr2len(ptr);
|
: utfc_ptr2len(ptr);
|
||||||
u8c = len >= 0
|
int u8c = len >= 0
|
||||||
? utfc_ptr2char_len(ptr, u8cc, (int)((text + len) - ptr))
|
? utfc_ptr2char_len(ptr, u8cc, (int)((text + len) - ptr))
|
||||||
: utfc_ptr2char(ptr, u8cc);
|
: utfc_ptr2char(ptr, u8cc);
|
||||||
mbyte_cells = utf_char2cells(u8c);
|
int mbyte_cells = utf_char2cells(u8c);
|
||||||
if (p_arshape && !p_tbidi && ARABIC_CHAR(u8c)) {
|
if (p_arshape && !p_tbidi && ARABIC_CHAR(u8c)) {
|
||||||
// Do Arabic shaping.
|
// Do Arabic shaping.
|
||||||
if (len >= 0 && (int)(ptr - text) + mbyte_blen >= len) {
|
if (len >= 0 && (int)(ptr - text) + mbyte_blen >= len) {
|
||||||
@ -287,11 +283,11 @@ void grid_puts_len(ScreenGrid *grid, char *text, int textlen, int row, int col,
|
|||||||
schar_T buf;
|
schar_T buf;
|
||||||
schar_from_cc(buf, u8c, u8cc);
|
schar_from_cc(buf, u8c, u8cc);
|
||||||
|
|
||||||
need_redraw = schar_cmp(grid->chars[off], buf)
|
int need_redraw = schar_cmp(grid->chars[off], buf)
|
||||||
|| (mbyte_cells == 2 && grid->chars[off + 1][0] != 0)
|
|| (mbyte_cells == 2 && grid->chars[off + 1][0] != 0)
|
||||||
|| grid->attrs[off] != attr
|
|| grid->attrs[off] != attr
|
||||||
|| exmode_active
|
|| exmode_active
|
||||||
|| rdb_flags & RDB_NODELTA;
|
|| rdb_flags & RDB_NODELTA;
|
||||||
|
|
||||||
if (need_redraw) {
|
if (need_redraw) {
|
||||||
// When at the end of the text and overwriting a two-cell
|
// When at the end of the text and overwriting a two-cell
|
||||||
@ -497,7 +493,6 @@ void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, int cle
|
|||||||
size_t max_off_from;
|
size_t max_off_from;
|
||||||
size_t max_off_to;
|
size_t max_off_to;
|
||||||
int col = 0;
|
int col = 0;
|
||||||
bool redraw_this; // Does character need redraw?
|
|
||||||
bool redraw_next; // redraw_this for next character
|
bool redraw_next; // redraw_this for next character
|
||||||
bool clear_next = false;
|
bool clear_next = false;
|
||||||
int char_cells; // 1: normal char
|
int char_cells; // 1: normal char
|
||||||
@ -559,7 +554,7 @@ void grid_put_linebuf(ScreenGrid *grid, int row, int coloff, int endcol, int cle
|
|||||||
if (col + 1 < endcol) {
|
if (col + 1 < endcol) {
|
||||||
char_cells = line_off2cells(linebuf_char, off_from, max_off_from);
|
char_cells = line_off2cells(linebuf_char, off_from, max_off_from);
|
||||||
}
|
}
|
||||||
redraw_this = redraw_next;
|
bool redraw_this = redraw_next; // Does character need redraw?
|
||||||
redraw_next = grid_char_needs_redraw(grid, off_from + (size_t)char_cells,
|
redraw_next = grid_char_needs_redraw(grid, off_from + (size_t)char_cells,
|
||||||
off_to + (size_t)char_cells,
|
off_to + (size_t)char_cells,
|
||||||
endcol - col - char_cells);
|
endcol - col - char_cells);
|
||||||
|
@ -88,7 +88,6 @@ int get_keystroke(MultiQueue *events)
|
|||||||
{
|
{
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
int buflen = 150;
|
int buflen = 150;
|
||||||
int maxlen;
|
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int n;
|
int n;
|
||||||
int save_mapped_ctrl_c = mapped_ctrl_c;
|
int save_mapped_ctrl_c = mapped_ctrl_c;
|
||||||
@ -100,7 +99,7 @@ int get_keystroke(MultiQueue *events)
|
|||||||
// Leave some room for check_termcode() to insert a key code into (max
|
// Leave some room for check_termcode() to insert a key code into (max
|
||||||
// 5 chars plus NUL). And fix_input_buffer() can triple the number of
|
// 5 chars plus NUL). And fix_input_buffer() can triple the number of
|
||||||
// bytes.
|
// bytes.
|
||||||
maxlen = (buflen - 6 - len) / 3;
|
int maxlen = (buflen - 6 - len) / 3;
|
||||||
if (buf == NULL) {
|
if (buf == NULL) {
|
||||||
buf = xmalloc((size_t)buflen);
|
buf = xmalloc((size_t)buflen);
|
||||||
} else if (maxlen < 10) {
|
} else if (maxlen < 10) {
|
||||||
@ -166,7 +165,6 @@ int get_keystroke(MultiQueue *events)
|
|||||||
int get_number(int colon, int *mouse_used)
|
int get_number(int colon, int *mouse_used)
|
||||||
{
|
{
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int c;
|
|
||||||
int typed = 0;
|
int typed = 0;
|
||||||
|
|
||||||
if (mouse_used != NULL) {
|
if (mouse_used != NULL) {
|
||||||
@ -183,7 +181,7 @@ int get_number(int colon, int *mouse_used)
|
|||||||
allow_keys++; // no mapping here, but recognize keys
|
allow_keys++; // no mapping here, but recognize keys
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ui_cursor_goto(msg_row, msg_col);
|
ui_cursor_goto(msg_row, msg_col);
|
||||||
c = safe_vgetc();
|
int c = safe_vgetc();
|
||||||
if (ascii_isdigit(c)) {
|
if (ascii_isdigit(c)) {
|
||||||
n = n * 10 + c - '0';
|
n = n * 10 + c - '0';
|
||||||
msg_putchar(c);
|
msg_putchar(c);
|
||||||
|
@ -1766,13 +1766,12 @@ bool nlua_exec_file(const char *path)
|
|||||||
|
|
||||||
StringBuilder sb = KV_INITIAL_VALUE;
|
StringBuilder sb = KV_INITIAL_VALUE;
|
||||||
kv_resize(sb, 64);
|
kv_resize(sb, 64);
|
||||||
ptrdiff_t read_size = -1;
|
|
||||||
// Read all input from stdin, unless interrupted (ctrl-c).
|
// Read all input from stdin, unless interrupted (ctrl-c).
|
||||||
while (true) {
|
while (true) {
|
||||||
if (got_int) { // User canceled.
|
if (got_int) { // User canceled.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
read_size = file_read(stdin_dup, IObuff, 64);
|
ptrdiff_t read_size = file_read(stdin_dup, IObuff, 64);
|
||||||
if (read_size < 0) { // Error.
|
if (read_size < 0) { // Error.
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,6 @@ int nlua_spell_check(lua_State *lstate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
hlf_T attr = HLF_COUNT;
|
hlf_T attr = HLF_COUNT;
|
||||||
size_t len = 0;
|
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
int capcol = -1;
|
int capcol = -1;
|
||||||
int no_res = 0;
|
int no_res = 0;
|
||||||
@ -61,7 +60,7 @@ int nlua_spell_check(lua_State *lstate)
|
|||||||
|
|
||||||
while (*str != NUL) {
|
while (*str != NUL) {
|
||||||
attr = HLF_COUNT;
|
attr = HLF_COUNT;
|
||||||
len = spell_check(curwin, (char *)str, &attr, &capcol, false);
|
size_t len = spell_check(curwin, (char *)str, &attr, &capcol, false);
|
||||||
assert(len <= INT_MAX);
|
assert(len <= INT_MAX);
|
||||||
|
|
||||||
if (attr != HLF_COUNT) {
|
if (attr != HLF_COUNT) {
|
||||||
|
@ -920,9 +920,8 @@ static void remote_request(mparm_T *params, int remote_args, char *server_addr,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Array args = ARRAY_DICT_INIT;
|
Array args = ARRAY_DICT_INIT;
|
||||||
String arg_s;
|
|
||||||
for (int t_argc = remote_args; t_argc < argc; t_argc++) {
|
for (int t_argc = remote_args; t_argc < argc; t_argc++) {
|
||||||
arg_s = cstr_to_string(argv[t_argc]);
|
String arg_s = cstr_to_string(argv[t_argc]);
|
||||||
ADD(args, STRING_OBJ(arg_s));
|
ADD(args, STRING_OBJ(arg_s));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1620,9 +1619,6 @@ static void open_script_files(mparm_T *parmp)
|
|||||||
// Also does recovery if "recoverymode" set.
|
// Also does recovery if "recoverymode" set.
|
||||||
static void create_windows(mparm_T *parmp)
|
static void create_windows(mparm_T *parmp)
|
||||||
{
|
{
|
||||||
int dorewind;
|
|
||||||
int done = 0;
|
|
||||||
|
|
||||||
// Create the number of windows that was requested.
|
// Create the number of windows that was requested.
|
||||||
if (parmp->window_count == -1) { // was not set
|
if (parmp->window_count == -1) { // was not set
|
||||||
parmp->window_count = 1;
|
parmp->window_count = 1;
|
||||||
@ -1658,6 +1654,7 @@ static void create_windows(mparm_T *parmp)
|
|||||||
}
|
}
|
||||||
do_modelines(0); // do modelines
|
do_modelines(0); // do modelines
|
||||||
} else {
|
} else {
|
||||||
|
int done = 0;
|
||||||
// Open a buffer for windows that don't have one yet.
|
// Open a buffer for windows that don't have one yet.
|
||||||
// Commands in the vimrc might have loaded a file or split the window.
|
// Commands in the vimrc might have loaded a file or split the window.
|
||||||
// Watch out for autocommands that delete a window.
|
// Watch out for autocommands that delete a window.
|
||||||
@ -1665,7 +1662,7 @@ static void create_windows(mparm_T *parmp)
|
|||||||
// Don't execute Win/Buf Enter/Leave autocommands here
|
// Don't execute Win/Buf Enter/Leave autocommands here
|
||||||
autocmd_no_enter++;
|
autocmd_no_enter++;
|
||||||
autocmd_no_leave++;
|
autocmd_no_leave++;
|
||||||
dorewind = true;
|
int dorewind = true;
|
||||||
while (done++ < 1000) {
|
while (done++ < 1000) {
|
||||||
if (dorewind) {
|
if (dorewind) {
|
||||||
if (parmp->window_layout == WIN_TABS) {
|
if (parmp->window_layout == WIN_TABS) {
|
||||||
|
@ -521,11 +521,10 @@ fmark_T *pos_to_mark(buf_T *buf, fmark_T *fmp, pos_T pos)
|
|||||||
/// @return whether the buffer was switched or not.
|
/// @return whether the buffer was switched or not.
|
||||||
static MarkMoveRes switch_to_mark_buf(fmark_T *fm, bool pcmark_on_switch)
|
static MarkMoveRes switch_to_mark_buf(fmark_T *fm, bool pcmark_on_switch)
|
||||||
{
|
{
|
||||||
bool res;
|
|
||||||
if (fm->fnum != curbuf->b_fnum) {
|
if (fm->fnum != curbuf->b_fnum) {
|
||||||
// Switch to another file.
|
// Switch to another file.
|
||||||
int getfile_flag = pcmark_on_switch ? GETF_SETMARK : 0;
|
int getfile_flag = pcmark_on_switch ? GETF_SETMARK : 0;
|
||||||
res = buflist_getfile(fm->fnum, (linenr_T)1, getfile_flag, false) == OK;
|
bool res = buflist_getfile(fm->fnum, (linenr_T)1, getfile_flag, false) == OK;
|
||||||
return res == true ? kMarkSwitchedBuf : kMarkMoveFailed;
|
return res == true ? kMarkSwitchedBuf : kMarkMoveFailed;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -419,7 +419,6 @@ static void next_search_hl(win_T *win, match_T *search_hl, match_T *shl, linenr_
|
|||||||
colnr_T mincol, matchitem_T *cur)
|
colnr_T mincol, matchitem_T *cur)
|
||||||
FUNC_ATTR_NONNULL_ARG(2)
|
FUNC_ATTR_NONNULL_ARG(2)
|
||||||
{
|
{
|
||||||
linenr_T l;
|
|
||||||
colnr_T matchcol;
|
colnr_T matchcol;
|
||||||
long nmatched = 0;
|
long nmatched = 0;
|
||||||
const int called_emsg_before = called_emsg;
|
const int called_emsg_before = called_emsg;
|
||||||
@ -435,7 +434,7 @@ static void next_search_hl(win_T *win, match_T *search_hl, match_T *shl, linenr_
|
|||||||
// 1. If the "lnum" is below a previous match, start a new search.
|
// 1. If the "lnum" is below a previous match, start a new search.
|
||||||
// 2. If the previous match includes "mincol", use it.
|
// 2. If the previous match includes "mincol", use it.
|
||||||
// 3. Continue after the previous match.
|
// 3. Continue after the previous match.
|
||||||
l = shl->lnum + shl->rm.endpos[0].lnum - shl->rm.startpos[0].lnum;
|
linenr_T l = shl->lnum + shl->rm.endpos[0].lnum - shl->rm.startpos[0].lnum;
|
||||||
if (lnum > l) {
|
if (lnum > l) {
|
||||||
shl->lnum = 0;
|
shl->lnum = 0;
|
||||||
} else if (lnum < l || shl->rm.endpos[0].col > mincol) {
|
} else if (lnum < l || shl->rm.endpos[0].col > mincol) {
|
||||||
|
@ -603,11 +603,9 @@ static int mf_read(memfile_T *mfp, bhdr_T *hp)
|
|||||||
static int mf_write(memfile_T *mfp, bhdr_T *hp)
|
static int mf_write(memfile_T *mfp, bhdr_T *hp)
|
||||||
{
|
{
|
||||||
off_T offset; // offset in the file
|
off_T offset; // offset in the file
|
||||||
blocknr_T nr; // block nr which is being written
|
|
||||||
bhdr_T *hp2;
|
bhdr_T *hp2;
|
||||||
unsigned page_size; // number of bytes in a page
|
unsigned page_size; // number of bytes in a page
|
||||||
unsigned page_count; // number of pages written
|
unsigned page_count; // number of pages written
|
||||||
unsigned size; // number of bytes written
|
|
||||||
|
|
||||||
if (mfp->mf_fd < 0) { // there is no file, can't write
|
if (mfp->mf_fd < 0) { // there is no file, can't write
|
||||||
return FAIL;
|
return FAIL;
|
||||||
@ -626,7 +624,7 @@ static int mf_write(memfile_T *mfp, bhdr_T *hp)
|
|||||||
/// If block 'mf_infile_count' is not in the hash list, it has been
|
/// If block 'mf_infile_count' is not in the hash list, it has been
|
||||||
/// freed. Fill the space in the file with data from the current block.
|
/// freed. Fill the space in the file with data from the current block.
|
||||||
for (;;) {
|
for (;;) {
|
||||||
nr = hp->bh_bnum;
|
blocknr_T nr = hp->bh_bnum; // block nr which is being written
|
||||||
if (nr > mfp->mf_infile_count) { // beyond end of file
|
if (nr > mfp->mf_infile_count) { // beyond end of file
|
||||||
nr = mfp->mf_infile_count;
|
nr = mfp->mf_infile_count;
|
||||||
hp2 = mf_find_hash(mfp, nr); // NULL caught below
|
hp2 = mf_find_hash(mfp, nr); // NULL caught below
|
||||||
@ -645,7 +643,7 @@ static int mf_write(memfile_T *mfp, bhdr_T *hp)
|
|||||||
} else {
|
} else {
|
||||||
page_count = hp2->bh_page_count;
|
page_count = hp2->bh_page_count;
|
||||||
}
|
}
|
||||||
size = page_size * page_count;
|
unsigned size = page_size * page_count; // number of bytes written
|
||||||
void *data = (hp2 == NULL) ? hp->bh_data : hp2->bh_data;
|
void *data = (hp2 == NULL) ? hp->bh_data : hp2->bh_data;
|
||||||
if ((unsigned)write_eintr(mfp->mf_fd, data, size) != size) {
|
if ((unsigned)write_eintr(mfp->mf_fd, data, size) != size) {
|
||||||
/// Avoid repeating the error message, this mostly happens when the
|
/// Avoid repeating the error message, this mostly happens when the
|
||||||
|
@ -2022,7 +2022,6 @@ static int ml_append_int(buf_T *buf, linenr_T lnum, char *line, colnr_T len, boo
|
|||||||
int lineadd;
|
int lineadd;
|
||||||
blocknr_T bnum_left, bnum_right;
|
blocknr_T bnum_left, bnum_right;
|
||||||
linenr_T lnum_left, lnum_right;
|
linenr_T lnum_left, lnum_right;
|
||||||
int pb_idx;
|
|
||||||
PTR_BL *pp_new;
|
PTR_BL *pp_new;
|
||||||
|
|
||||||
// We are going to allocate a new data block. Depending on the
|
// We are going to allocate a new data block. Depending on the
|
||||||
@ -2156,7 +2155,7 @@ static int ml_append_int(buf_T *buf, linenr_T lnum, char *line, colnr_T len, boo
|
|||||||
// update pointer blocks for the new data block
|
// update pointer blocks for the new data block
|
||||||
for (stack_idx = buf->b_ml.ml_stack_top - 1; stack_idx >= 0; stack_idx--) {
|
for (stack_idx = buf->b_ml.ml_stack_top - 1; stack_idx >= 0; stack_idx--) {
|
||||||
infoptr_T *ip = &(buf->b_ml.ml_stack[stack_idx]);
|
infoptr_T *ip = &(buf->b_ml.ml_stack[stack_idx]);
|
||||||
pb_idx = ip->ip_index;
|
int pb_idx = ip->ip_index;
|
||||||
if ((hp = mf_get(mfp, ip->ip_bnum, 1)) == NULL) {
|
if ((hp = mf_get(mfp, ip->ip_bnum, 1)) == NULL) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -3211,7 +3210,6 @@ static int do_swapexists(buf_T *buf, char *fname)
|
|||||||
static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_existing_dir)
|
static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_existing_dir)
|
||||||
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(1, 2, 4)
|
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ARG(1, 2, 4)
|
||||||
{
|
{
|
||||||
size_t n;
|
|
||||||
char *buf_fname = buf->b_fname;
|
char *buf_fname = buf->b_fname;
|
||||||
|
|
||||||
// Isolate a directory name from *dirp and put it in dir_name.
|
// Isolate a directory name from *dirp and put it in dir_name.
|
||||||
@ -3224,6 +3222,7 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname, bool *found_
|
|||||||
char *fname = makeswapname(buf_fname, buf->b_ffname, buf, dir_name);
|
char *fname = makeswapname(buf_fname, buf->b_ffname, buf, dir_name);
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
size_t n;
|
||||||
if (fname == NULL) { // must be out of memory
|
if (fname == NULL) { // must be out of memory
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -3605,11 +3604,8 @@ static void ml_updatechunk(buf_T *buf, linenr_T line, long len, int updtype)
|
|||||||
|
|
||||||
linenr_T curline = ml_upd_lastcurline;
|
linenr_T curline = ml_upd_lastcurline;
|
||||||
int curix = ml_upd_lastcurix;
|
int curix = ml_upd_lastcurix;
|
||||||
long size;
|
|
||||||
chunksize_T *curchnk;
|
chunksize_T *curchnk;
|
||||||
int rest;
|
|
||||||
bhdr_T *hp;
|
bhdr_T *hp;
|
||||||
DATA_BL *dp;
|
|
||||||
|
|
||||||
if (buf->b_ml.ml_usedchunks == -1 || len == 0) {
|
if (buf->b_ml.ml_usedchunks == -1 || len == 0) {
|
||||||
return;
|
return;
|
||||||
@ -3655,6 +3651,8 @@ static void ml_updatechunk(buf_T *buf, linenr_T line, long len, int updtype)
|
|||||||
}
|
}
|
||||||
curchnk->mlcs_totalsize += len;
|
curchnk->mlcs_totalsize += len;
|
||||||
if (updtype == ML_CHNK_ADDLINE) {
|
if (updtype == ML_CHNK_ADDLINE) {
|
||||||
|
int rest;
|
||||||
|
DATA_BL *dp;
|
||||||
curchnk->mlcs_numlines++;
|
curchnk->mlcs_numlines++;
|
||||||
|
|
||||||
// May resize here so we don't have to do it in both cases below
|
// May resize here so we don't have to do it in both cases below
|
||||||
@ -3665,17 +3663,14 @@ static void ml_updatechunk(buf_T *buf, linenr_T line, long len, int updtype)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (buf->b_ml.ml_chunksize[curix].mlcs_numlines >= MLCS_MAXL) {
|
if (buf->b_ml.ml_chunksize[curix].mlcs_numlines >= MLCS_MAXL) {
|
||||||
int count; // number of entries in block
|
|
||||||
int idx;
|
|
||||||
int text_end;
|
int text_end;
|
||||||
int linecnt;
|
|
||||||
|
|
||||||
memmove(buf->b_ml.ml_chunksize + curix + 1,
|
memmove(buf->b_ml.ml_chunksize + curix + 1,
|
||||||
buf->b_ml.ml_chunksize + curix,
|
buf->b_ml.ml_chunksize + curix,
|
||||||
(size_t)(buf->b_ml.ml_usedchunks - curix) * sizeof(chunksize_T));
|
(size_t)(buf->b_ml.ml_usedchunks - curix) * sizeof(chunksize_T));
|
||||||
// Compute length of first half of lines in the split chunk
|
// Compute length of first half of lines in the split chunk
|
||||||
size = 0;
|
long size = 0;
|
||||||
linecnt = 0;
|
int linecnt = 0;
|
||||||
while (curline < buf->b_ml.ml_line_count
|
while (curline < buf->b_ml.ml_line_count
|
||||||
&& linecnt < MLCS_MINL) {
|
&& linecnt < MLCS_MINL) {
|
||||||
if ((hp = ml_find_line(buf, curline, ML_FIND)) == NULL) {
|
if ((hp = ml_find_line(buf, curline, ML_FIND)) == NULL) {
|
||||||
@ -3683,8 +3678,9 @@ static void ml_updatechunk(buf_T *buf, linenr_T line, long len, int updtype)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
dp = hp->bh_data;
|
dp = hp->bh_data;
|
||||||
count = buf->b_ml.ml_locked_high - buf->b_ml.ml_locked_low + 1;
|
int count
|
||||||
idx = curline - buf->b_ml.ml_locked_low;
|
= buf->b_ml.ml_locked_high - buf->b_ml.ml_locked_low + 1; // number of entries in block
|
||||||
|
int idx = curline - buf->b_ml.ml_locked_low;
|
||||||
curline = buf->b_ml.ml_locked_high + 1;
|
curline = buf->b_ml.ml_locked_high + 1;
|
||||||
if (idx == 0) { // first line in block, text at the end
|
if (idx == 0) { // first line in block, text at the end
|
||||||
text_end = (int)dp->db_txt_end;
|
text_end = (int)dp->db_txt_end;
|
||||||
@ -3793,13 +3789,8 @@ long ml_find_line_or_offset(buf_T *buf, linenr_T lnum, long *offp, bool no_ff)
|
|||||||
int curix;
|
int curix;
|
||||||
long size;
|
long size;
|
||||||
bhdr_T *hp;
|
bhdr_T *hp;
|
||||||
DATA_BL *dp;
|
|
||||||
int count; // number of entries in block
|
|
||||||
int idx;
|
|
||||||
int start_idx;
|
|
||||||
int text_end;
|
int text_end;
|
||||||
long offset;
|
long offset;
|
||||||
int len;
|
|
||||||
int ffdos = !no_ff && (get_fileformat(buf) == EOL_DOS);
|
int ffdos = !no_ff && (get_fileformat(buf) == EOL_DOS);
|
||||||
int extra = 0;
|
int extra = 0;
|
||||||
|
|
||||||
@ -3859,9 +3850,11 @@ long ml_find_line_or_offset(buf_T *buf, linenr_T lnum, long *offp, bool no_ff)
|
|||||||
|| (hp = ml_find_line(buf, curline, ML_FIND)) == NULL) {
|
|| (hp = ml_find_line(buf, curline, ML_FIND)) == NULL) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
dp = hp->bh_data;
|
DATA_BL *dp = hp->bh_data;
|
||||||
count = buf->b_ml.ml_locked_high - buf->b_ml.ml_locked_low + 1;
|
int count
|
||||||
start_idx = idx = curline - buf->b_ml.ml_locked_low;
|
= buf->b_ml.ml_locked_high - buf->b_ml.ml_locked_low + 1; // number of entries in block
|
||||||
|
int idx;
|
||||||
|
int start_idx = idx = curline - buf->b_ml.ml_locked_low;
|
||||||
if (idx == 0) { // first line in block, text at the end
|
if (idx == 0) { // first line in block, text at the end
|
||||||
text_end = (int)dp->db_txt_end;
|
text_end = (int)dp->db_txt_end;
|
||||||
} else {
|
} else {
|
||||||
@ -3889,7 +3882,7 @@ long ml_find_line_or_offset(buf_T *buf, linenr_T lnum, long *offp, bool no_ff)
|
|||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
len = text_end - (int)((dp->db_index[idx]) & DB_INDEX_MASK);
|
int len = text_end - (int)((dp->db_index[idx]) & DB_INDEX_MASK);
|
||||||
size += len;
|
size += len;
|
||||||
if (offset != 0 && size >= offset) {
|
if (offset != 0 && size >= offset) {
|
||||||
if (size + ffdos == offset) {
|
if (size + ffdos == offset) {
|
||||||
|
@ -815,7 +815,6 @@ static int show_menus(char *const path_name, int modes)
|
|||||||
static void show_menus_recursive(vimmenu_T *menu, int modes, int depth)
|
static void show_menus_recursive(vimmenu_T *menu, int modes, int depth)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int bit;
|
|
||||||
|
|
||||||
if (menu != NULL && (menu->modes & modes) == 0x0) {
|
if (menu != NULL && (menu->modes & modes) == 0x0) {
|
||||||
return;
|
return;
|
||||||
@ -838,7 +837,7 @@ static void show_menus_recursive(vimmenu_T *menu, int modes, int depth)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (menu != NULL && menu->children == NULL) {
|
if (menu != NULL && menu->children == NULL) {
|
||||||
for (bit = 0; bit < MENU_MODES; bit++) {
|
for (int bit = 0; bit < MENU_MODES; bit++) {
|
||||||
if ((menu->modes & modes & (1 << bit)) != 0) {
|
if ((menu->modes & modes & (1 << bit)) != 0) {
|
||||||
msg_putchar('\n');
|
msg_putchar('\n');
|
||||||
if (got_int) { // "q" hit for "--more--"
|
if (got_int) { // "q" hit for "--more--"
|
||||||
@ -902,7 +901,6 @@ char *set_context_in_menu_cmd(expand_T *xp, const char *cmd, char *arg, bool for
|
|||||||
char *after_dot;
|
char *after_dot;
|
||||||
char *p;
|
char *p;
|
||||||
char *path_name = NULL;
|
char *path_name = NULL;
|
||||||
char *name;
|
|
||||||
int unmenu;
|
int unmenu;
|
||||||
vimmenu_T *menu;
|
vimmenu_T *menu;
|
||||||
int expand_menus;
|
int expand_menus;
|
||||||
@ -963,7 +961,7 @@ char *set_context_in_menu_cmd(expand_T *xp, const char *cmd, char *arg, bool for
|
|||||||
path_name = xmalloc(path_len);
|
path_name = xmalloc(path_len);
|
||||||
xstrlcpy(path_name, arg, path_len);
|
xstrlcpy(path_name, arg, path_len);
|
||||||
}
|
}
|
||||||
name = path_name;
|
char *name = path_name;
|
||||||
while (name != NULL && *name) {
|
while (name != NULL && *name) {
|
||||||
p = menu_name_skip(name);
|
p = menu_name_skip(name);
|
||||||
while (menu != NULL) {
|
while (menu != NULL) {
|
||||||
|
@ -369,14 +369,13 @@ bool msg_attr_keep(const char *s, int attr, bool keep, bool multiline)
|
|||||||
char *msg_strtrunc(char *s, int force)
|
char *msg_strtrunc(char *s, int force)
|
||||||
{
|
{
|
||||||
char *buf = NULL;
|
char *buf = NULL;
|
||||||
int len;
|
|
||||||
int room;
|
|
||||||
|
|
||||||
// May truncate message to avoid a hit-return prompt
|
// May truncate message to avoid a hit-return prompt
|
||||||
if ((!msg_scroll && !need_wait_return && shortmess(SHM_TRUNCALL)
|
if ((!msg_scroll && !need_wait_return && shortmess(SHM_TRUNCALL)
|
||||||
&& !exmode_active && msg_silent == 0 && !ui_has(kUIMessages))
|
&& !exmode_active && msg_silent == 0 && !ui_has(kUIMessages))
|
||||||
|| force) {
|
|| force) {
|
||||||
len = vim_strsize(s);
|
int room;
|
||||||
|
int len = vim_strsize(s);
|
||||||
if (msg_scrolled != 0) {
|
if (msg_scrolled != 0) {
|
||||||
// Use all the columns.
|
// Use all the columns.
|
||||||
room = (Rows - msg_row) * Columns - 1;
|
room = (Rows - msg_row) * Columns - 1;
|
||||||
@ -1033,7 +1032,6 @@ void ex_messages(void *const eap_p)
|
|||||||
{
|
{
|
||||||
const exarg_T *const eap = (const exarg_T *)eap_p;
|
const exarg_T *const eap = (const exarg_T *)eap_p;
|
||||||
struct msg_hist *p;
|
struct msg_hist *p;
|
||||||
int c = 0;
|
|
||||||
|
|
||||||
if (strcmp(eap->arg, "clear") == 0) {
|
if (strcmp(eap->arg, "clear") == 0) {
|
||||||
int keep = eap->addr_count == 0 ? 0 : eap->line2;
|
int keep = eap->addr_count == 0 ? 0 : eap->line2;
|
||||||
@ -1052,6 +1050,7 @@ void ex_messages(void *const eap_p)
|
|||||||
p = first_msg_hist;
|
p = first_msg_hist;
|
||||||
|
|
||||||
if (eap->addr_count != 0) {
|
if (eap->addr_count != 0) {
|
||||||
|
int c = 0;
|
||||||
// Count total messages
|
// Count total messages
|
||||||
for (; p != NULL && !got_int; p = p->next) {
|
for (; p != NULL && !got_int; p = p->next) {
|
||||||
c++;
|
c++;
|
||||||
@ -1542,7 +1541,6 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr)
|
|||||||
const char *str = msgstr;
|
const char *str = msgstr;
|
||||||
const char *plain_start = msgstr;
|
const char *plain_start = msgstr;
|
||||||
char *s;
|
char *s;
|
||||||
int mb_l;
|
|
||||||
int c;
|
int c;
|
||||||
int save_got_int = got_int;
|
int save_got_int = got_int;
|
||||||
|
|
||||||
@ -1565,7 +1563,7 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr)
|
|||||||
// Normal characters are printed several at a time.
|
// Normal characters are printed several at a time.
|
||||||
while (--len >= 0 && !got_int) {
|
while (--len >= 0 && !got_int) {
|
||||||
// Don't include composing chars after the end.
|
// Don't include composing chars after the end.
|
||||||
mb_l = utfc_ptr2len_len(str, len + 1);
|
int mb_l = utfc_ptr2len_len(str, len + 1);
|
||||||
if (mb_l > 1) {
|
if (mb_l > 1) {
|
||||||
c = utf_ptr2char(str);
|
c = utf_ptr2char(str);
|
||||||
if (vim_isprintc(c)) {
|
if (vim_isprintc(c)) {
|
||||||
@ -2652,12 +2650,11 @@ void msg_sb_eol(void)
|
|||||||
static msgchunk_T *disp_sb_line(int row, msgchunk_T *smp)
|
static msgchunk_T *disp_sb_line(int row, msgchunk_T *smp)
|
||||||
{
|
{
|
||||||
msgchunk_T *mp = smp;
|
msgchunk_T *mp = smp;
|
||||||
char *p;
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
msg_row = row;
|
msg_row = row;
|
||||||
msg_col = mp->sb_msg_col;
|
msg_col = mp->sb_msg_col;
|
||||||
p = mp->sb_text;
|
char *p = mp->sb_text;
|
||||||
if (*p == '\n') { // don't display the line break
|
if (*p == '\n') { // don't display the line break
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
@ -2767,7 +2764,6 @@ static int do_more_prompt(int typed_char)
|
|||||||
int oldState = State;
|
int oldState = State;
|
||||||
int c;
|
int c;
|
||||||
int retval = false;
|
int retval = false;
|
||||||
int toscroll;
|
|
||||||
bool to_redraw = false;
|
bool to_redraw = false;
|
||||||
msgchunk_T *mp_last = NULL;
|
msgchunk_T *mp_last = NULL;
|
||||||
msgchunk_T *mp;
|
msgchunk_T *mp;
|
||||||
@ -2809,7 +2805,7 @@ static int do_more_prompt(int typed_char)
|
|||||||
c = get_keystroke(resize_events);
|
c = get_keystroke(resize_events);
|
||||||
}
|
}
|
||||||
|
|
||||||
toscroll = 0;
|
int toscroll = 0;
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case BS: // scroll one line back
|
case BS: // scroll one line back
|
||||||
case K_BS:
|
case K_BS:
|
||||||
@ -3507,7 +3503,6 @@ int do_dialog(int type, char *title, char *message, char *buttons, int dfltbutto
|
|||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
char *hotkeys;
|
char *hotkeys;
|
||||||
int c;
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if (silent_mode // No dialogs in silent mode ("ex -s")
|
if (silent_mode // No dialogs in silent mode ("ex -s")
|
||||||
@ -3530,7 +3525,7 @@ int do_dialog(int type, char *title, char *message, char *buttons, int dfltbutto
|
|||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
// Get a typed character directly from the user.
|
// Get a typed character directly from the user.
|
||||||
c = get_keystroke(NULL);
|
int c = get_keystroke(NULL);
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case CAR: // User accepts default option
|
case CAR: // User accepts default option
|
||||||
case NL:
|
case NL:
|
||||||
|
@ -145,7 +145,6 @@ void update_topline(win_T *wp)
|
|||||||
{
|
{
|
||||||
linenr_T old_topline;
|
linenr_T old_topline;
|
||||||
int old_topfill;
|
int old_topfill;
|
||||||
bool check_topline = false;
|
|
||||||
bool check_botline = false;
|
bool check_botline = false;
|
||||||
long *so_ptr = wp->w_p_so >= 0 ? &wp->w_p_so : &p_so;
|
long *so_ptr = wp->w_p_so >= 0 ? &wp->w_p_so : &p_so;
|
||||||
long save_so = *so_ptr;
|
long save_so = *so_ptr;
|
||||||
@ -189,6 +188,7 @@ void update_topline(win_T *wp)
|
|||||||
wp->w_viewport_invalid = true;
|
wp->w_viewport_invalid = true;
|
||||||
wp->w_scbind_pos = 1;
|
wp->w_scbind_pos = 1;
|
||||||
} else {
|
} else {
|
||||||
|
bool check_topline = false;
|
||||||
// If the cursor is above or near the top of the window, scroll the window
|
// If the cursor is above or near the top of the window, scroll the window
|
||||||
// to show the line the cursor is in, with 'scrolloff' context.
|
// to show the line the cursor is in, with 'scrolloff' context.
|
||||||
if (wp->w_topline > 1) {
|
if (wp->w_topline > 1) {
|
||||||
|
@ -401,10 +401,8 @@ void init_normal_cmds(void)
|
|||||||
/// @return -1 for invalid command.
|
/// @return -1 for invalid command.
|
||||||
static int find_command(int cmdchar)
|
static int find_command(int cmdchar)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
int idx;
|
int idx;
|
||||||
int top, bot;
|
int top, bot;
|
||||||
int c;
|
|
||||||
|
|
||||||
// A multi-byte character is never a command.
|
// A multi-byte character is never a command.
|
||||||
if (cmdchar >= 0x100) {
|
if (cmdchar >= 0x100) {
|
||||||
@ -429,8 +427,8 @@ static int find_command(int cmdchar)
|
|||||||
top = NV_CMDS_SIZE - 1;
|
top = NV_CMDS_SIZE - 1;
|
||||||
idx = -1;
|
idx = -1;
|
||||||
while (bot <= top) {
|
while (bot <= top) {
|
||||||
i = (top + bot) / 2;
|
int i = (top + bot) / 2;
|
||||||
c = nv_cmds[nv_cmd_idx[i]].cmd_char;
|
int c = nv_cmds[nv_cmd_idx[i]].cmd_char;
|
||||||
if (c < 0) {
|
if (c < 0) {
|
||||||
c = -c;
|
c = -c;
|
||||||
}
|
}
|
||||||
@ -693,7 +691,6 @@ static void normal_get_additional_char(NormalState *s)
|
|||||||
int *cp;
|
int *cp;
|
||||||
bool repl = false; // get character for replace mode
|
bool repl = false; // get character for replace mode
|
||||||
bool lit = false; // get extra character literally
|
bool lit = false; // get extra character literally
|
||||||
bool langmap_active = false; // using :lmap mappings
|
|
||||||
int lang; // getting a text character
|
int lang; // getting a text character
|
||||||
|
|
||||||
no_mapping++;
|
no_mapping++;
|
||||||
@ -729,6 +726,7 @@ static void normal_get_additional_char(NormalState *s)
|
|||||||
|
|
||||||
// Get a second or third character.
|
// Get a second or third character.
|
||||||
if (cp != NULL) {
|
if (cp != NULL) {
|
||||||
|
bool langmap_active = false; // using :lmap mappings
|
||||||
if (repl) {
|
if (repl) {
|
||||||
State = MODE_REPLACE; // pretend Replace mode
|
State = MODE_REPLACE; // pretend Replace mode
|
||||||
ui_cursor_shape(); // show different cursor shape
|
ui_cursor_shape(); // show different cursor shape
|
||||||
@ -1848,7 +1846,6 @@ void clear_showcmd(void)
|
|||||||
snprintf(showcmd_buf, SHOWCMD_BUFLEN, "%" PRId64, (int64_t)lines);
|
snprintf(showcmd_buf, SHOWCMD_BUFLEN, "%" PRId64, (int64_t)lines);
|
||||||
} else {
|
} else {
|
||||||
char *s, *e;
|
char *s, *e;
|
||||||
int l;
|
|
||||||
int bytes = 0;
|
int bytes = 0;
|
||||||
int chars = 0;
|
int chars = 0;
|
||||||
|
|
||||||
@ -1860,7 +1857,7 @@ void clear_showcmd(void)
|
|||||||
e = ml_get_pos(&VIsual);
|
e = ml_get_pos(&VIsual);
|
||||||
}
|
}
|
||||||
while ((*p_sel != 'e') ? s <= e : s < e) {
|
while ((*p_sel != 'e') ? s <= e : s < e) {
|
||||||
l = utfc_ptr2len(s);
|
int l = utfc_ptr2len(s);
|
||||||
if (l == 0) {
|
if (l == 0) {
|
||||||
bytes++;
|
bytes++;
|
||||||
chars++;
|
chars++;
|
||||||
@ -2427,7 +2424,6 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist)
|
|||||||
int linelen = linetabsize(get_cursor_line_ptr());
|
int linelen = linetabsize(get_cursor_line_ptr());
|
||||||
bool retval = true;
|
bool retval = true;
|
||||||
bool atend = false;
|
bool atend = false;
|
||||||
int n;
|
|
||||||
int col_off1; // margin offset for first screen line
|
int col_off1; // margin offset for first screen line
|
||||||
int col_off2; // margin offset for wrapped screen line
|
int col_off2; // margin offset for wrapped screen line
|
||||||
int width1; // text width for first screen line
|
int width1; // text width for first screen line
|
||||||
@ -2446,6 +2442,7 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (curwin->w_width_inner != 0) {
|
if (curwin->w_width_inner != 0) {
|
||||||
|
int n;
|
||||||
// Instead of sticking at the last character of the buffer line we
|
// Instead of sticking at the last character of the buffer line we
|
||||||
// try to stick in the last column of the screen.
|
// try to stick in the last column of the screen.
|
||||||
if (curwin->w_curswant == MAXCOL) {
|
if (curwin->w_curswant == MAXCOL) {
|
||||||
@ -2793,7 +2790,6 @@ static int nv_zg_zw(cmdarg_T *cap, int nchar)
|
|||||||
/// Commands that start with "z".
|
/// Commands that start with "z".
|
||||||
static void nv_zet(cmdarg_T *cap)
|
static void nv_zet(cmdarg_T *cap)
|
||||||
{
|
{
|
||||||
int n;
|
|
||||||
colnr_T col;
|
colnr_T col;
|
||||||
int nchar = cap->nchar;
|
int nchar = cap->nchar;
|
||||||
long old_fdl = curwin->w_p_fdl;
|
long old_fdl = curwin->w_p_fdl;
|
||||||
@ -2949,7 +2945,7 @@ static void nv_zet(cmdarg_T *cap)
|
|||||||
} else {
|
} else {
|
||||||
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &col);
|
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &col);
|
||||||
}
|
}
|
||||||
n = curwin->w_width_inner - curwin_col_off();
|
int n = curwin->w_width_inner - curwin_col_off();
|
||||||
if (col + siso < n) {
|
if (col + siso < n) {
|
||||||
col = 0;
|
col = 0;
|
||||||
} else {
|
} else {
|
||||||
@ -3438,7 +3434,6 @@ static void nv_ident(cmdarg_T *cap)
|
|||||||
int cmdchar;
|
int cmdchar;
|
||||||
bool g_cmd; // "g" command
|
bool g_cmd; // "g" command
|
||||||
bool tag_cmd = false;
|
bool tag_cmd = false;
|
||||||
char *aux_ptr;
|
|
||||||
|
|
||||||
if (cap->cmdchar == 'g') { // "g*", "g#", "g]" and "gCTRL-]"
|
if (cap->cmdchar == 'g') { // "g*", "g#", "g]" and "gCTRL-]"
|
||||||
cmdchar = cap->nchar;
|
cmdchar = cap->nchar;
|
||||||
@ -3542,6 +3537,7 @@ static void nv_ident(cmdarg_T *cap)
|
|||||||
STRCAT(buf, p);
|
STRCAT(buf, p);
|
||||||
xfree(p);
|
xfree(p);
|
||||||
} else {
|
} else {
|
||||||
|
char *aux_ptr;
|
||||||
if (cmdchar == '*') {
|
if (cmdchar == '*') {
|
||||||
aux_ptr = (magic_isset() ? "/.*~[^$\\" : "/^$\\");
|
aux_ptr = (magic_isset() ? "/.*~[^$\\" : "/^$\\");
|
||||||
} else if (cmdchar == '#') {
|
} else if (cmdchar == '#') {
|
||||||
@ -3653,10 +3649,8 @@ static void nv_tagpop(cmdarg_T *cap)
|
|||||||
/// Handle scrolling command 'H', 'L' and 'M'.
|
/// Handle scrolling command 'H', 'L' and 'M'.
|
||||||
static void nv_scroll(cmdarg_T *cap)
|
static void nv_scroll(cmdarg_T *cap)
|
||||||
{
|
{
|
||||||
int used = 0;
|
|
||||||
long n;
|
long n;
|
||||||
linenr_T lnum;
|
linenr_T lnum;
|
||||||
int half;
|
|
||||||
|
|
||||||
cap->oap->motion_type = kMTLineWise;
|
cap->oap->motion_type = kMTLineWise;
|
||||||
setpcmark();
|
setpcmark();
|
||||||
@ -3683,11 +3677,12 @@ static void nv_scroll(cmdarg_T *cap)
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (cap->cmdchar == 'M') {
|
if (cap->cmdchar == 'M') {
|
||||||
|
int used = 0;
|
||||||
// Don't count filler lines above the window.
|
// Don't count filler lines above the window.
|
||||||
used -= win_get_fill(curwin, curwin->w_topline)
|
used -= win_get_fill(curwin, curwin->w_topline)
|
||||||
- curwin->w_topfill;
|
- curwin->w_topfill;
|
||||||
validate_botline(curwin); // make sure w_empty_rows is valid
|
validate_botline(curwin); // make sure w_empty_rows is valid
|
||||||
half = (curwin->w_height_inner - curwin->w_empty_rows + 1) / 2;
|
int half = (curwin->w_height_inner - curwin->w_empty_rows + 1) / 2;
|
||||||
for (n = 0; curwin->w_topline + n < curbuf->b_ml.ml_line_count; n++) {
|
for (n = 0; curwin->w_topline + n < curbuf->b_ml.ml_line_count; n++) {
|
||||||
// Count half the number of filler lines to be "below this
|
// Count half the number of filler lines to be "below this
|
||||||
// line" and half to be "above the next line".
|
// line" and half to be "above the next line".
|
||||||
@ -4115,7 +4110,6 @@ static void nv_bracket_block(cmdarg_T *cap, const pos_T *old_pos)
|
|||||||
pos_T prev_pos;
|
pos_T prev_pos;
|
||||||
long n;
|
long n;
|
||||||
int findc;
|
int findc;
|
||||||
int c;
|
|
||||||
|
|
||||||
if (cap->nchar == '*') {
|
if (cap->nchar == '*') {
|
||||||
cap->nchar = '/';
|
cap->nchar = '/';
|
||||||
@ -4155,6 +4149,7 @@ static void nv_bracket_block(cmdarg_T *cap, const pos_T *old_pos)
|
|||||||
// Try finding the '{' or '}' we want to be at.
|
// Try finding the '{' or '}' we want to be at.
|
||||||
// Also repeat for the given count.
|
// Also repeat for the given count.
|
||||||
if (cap->nchar == 'm' || cap->nchar == 'M') {
|
if (cap->nchar == 'm' || cap->nchar == 'M') {
|
||||||
|
int c;
|
||||||
// norm is true for "]M" and "[m"
|
// norm is true for "]M" and "[m"
|
||||||
int norm = ((findc == '{') == (cap->nchar == 'm'));
|
int norm = ((findc == '{') == (cap->nchar == 'm'));
|
||||||
|
|
||||||
@ -4361,7 +4356,6 @@ static void nv_brackets(cmdarg_T *cap)
|
|||||||
/// Handle Normal mode "%" command.
|
/// Handle Normal mode "%" command.
|
||||||
static void nv_percent(cmdarg_T *cap)
|
static void nv_percent(cmdarg_T *cap)
|
||||||
{
|
{
|
||||||
pos_T *pos;
|
|
||||||
linenr_T lnum = curwin->w_cursor.lnum;
|
linenr_T lnum = curwin->w_cursor.lnum;
|
||||||
|
|
||||||
cap->oap->inclusive = true;
|
cap->oap->inclusive = true;
|
||||||
@ -4391,6 +4385,7 @@ static void nv_percent(cmdarg_T *cap)
|
|||||||
beginline(BL_SOL | BL_FIX);
|
beginline(BL_SOL | BL_FIX);
|
||||||
}
|
}
|
||||||
} else { // "%" : go to matching paren
|
} else { // "%" : go to matching paren
|
||||||
|
pos_T *pos;
|
||||||
cap->oap->motion_type = kMTCharWise;
|
cap->oap->motion_type = kMTCharWise;
|
||||||
cap->oap->use_reg_one = true;
|
cap->oap->use_reg_one = true;
|
||||||
if ((pos = findmatch(cap->oap, NUL)) == NULL) {
|
if ((pos = findmatch(cap->oap, NUL)) == NULL) {
|
||||||
@ -6046,9 +6041,8 @@ static void adjust_for_sel(cmdarg_T *cap)
|
|||||||
/// @return true when backed up to the previous line.
|
/// @return true when backed up to the previous line.
|
||||||
bool unadjust_for_sel(void)
|
bool unadjust_for_sel(void)
|
||||||
{
|
{
|
||||||
pos_T *pp;
|
|
||||||
|
|
||||||
if (*p_sel == 'e' && !equalpos(VIsual, curwin->w_cursor)) {
|
if (*p_sel == 'e' && !equalpos(VIsual, curwin->w_cursor)) {
|
||||||
|
pos_T *pp;
|
||||||
if (lt(VIsual, curwin->w_cursor)) {
|
if (lt(VIsual, curwin->w_cursor)) {
|
||||||
pp = &curwin->w_cursor;
|
pp = &curwin->w_cursor;
|
||||||
} else {
|
} else {
|
||||||
@ -6460,7 +6454,6 @@ static void nv_put(cmdarg_T *cap)
|
|||||||
/// @param fix_indent true for "[p", "[P", "]p" and "]P".
|
/// @param fix_indent true for "[p", "[P", "]p" and "]P".
|
||||||
static void nv_put_opt(cmdarg_T *cap, bool fix_indent)
|
static void nv_put_opt(cmdarg_T *cap, bool fix_indent)
|
||||||
{
|
{
|
||||||
int regname = 0;
|
|
||||||
yankreg_T *savereg = NULL;
|
yankreg_T *savereg = NULL;
|
||||||
bool empty = false;
|
bool empty = false;
|
||||||
bool was_visual = false;
|
bool was_visual = false;
|
||||||
@ -6506,7 +6499,7 @@ static void nv_put_opt(cmdarg_T *cap, bool fix_indent)
|
|||||||
// Need to save and restore the registers that the delete
|
// Need to save and restore the registers that the delete
|
||||||
// overwrites if the old contents is being put.
|
// overwrites if the old contents is being put.
|
||||||
was_visual = true;
|
was_visual = true;
|
||||||
regname = cap->oap->regname;
|
int regname = cap->oap->regname;
|
||||||
bool keep_registers = cap->cmdchar == 'P';
|
bool keep_registers = cap->cmdchar == 'P';
|
||||||
// '+' and '*' could be the same selection
|
// '+' and '*' could be the same selection
|
||||||
bool clipoverwrite = (regname == '+' || regname == '*') && (cb_flags & CB_UNNAMEDMASK);
|
bool clipoverwrite = (regname == '+' || regname == '*') && (cb_flags & CB_UNNAMEDMASK);
|
||||||
|
@ -4850,10 +4850,9 @@ int ExpandSettings(expand_T *xp, regmatch_T *regmatch, char *fuzzystr, int *numM
|
|||||||
// loop == 0: count the number of matching options
|
// loop == 0: count the number of matching options
|
||||||
// loop == 1: copy the matching options into allocated memory
|
// loop == 1: copy the matching options into allocated memory
|
||||||
for (int loop = 0; loop <= 1; loop++) {
|
for (int loop = 0; loop <= 1; loop++) {
|
||||||
int match;
|
|
||||||
regmatch->rm_ic = ic;
|
regmatch->rm_ic = ic;
|
||||||
if (xp->xp_context != EXPAND_BOOL_SETTINGS) {
|
if (xp->xp_context != EXPAND_BOOL_SETTINGS) {
|
||||||
for (match = 0; match < (int)ARRAY_SIZE(names);
|
for (int match = 0; match < (int)ARRAY_SIZE(names);
|
||||||
match++) {
|
match++) {
|
||||||
if (match_str(names[match], regmatch, *matches,
|
if (match_str(names[match], regmatch, *matches,
|
||||||
count, (loop == 0), fuzzy, fuzzystr, fuzmatch)) {
|
count, (loop == 0), fuzzy, fuzzystr, fuzmatch)) {
|
||||||
|
@ -330,7 +330,6 @@ void set_string_option_direct(const char *name, int opt_idx, const char *val, in
|
|||||||
int set_sid)
|
int set_sid)
|
||||||
{
|
{
|
||||||
char *s;
|
char *s;
|
||||||
char **varp;
|
|
||||||
int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
|
int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
|
||||||
int idx = opt_idx;
|
int idx = opt_idx;
|
||||||
|
|
||||||
@ -353,7 +352,7 @@ void set_string_option_direct(const char *name, int opt_idx, const char *val, in
|
|||||||
|
|
||||||
s = xstrdup(val);
|
s = xstrdup(val);
|
||||||
{
|
{
|
||||||
varp = (char **)get_varp_scope(opt, both ? OPT_LOCAL : opt_flags);
|
char **varp = (char **)get_varp_scope(opt, both ? OPT_LOCAL : opt_flags);
|
||||||
if ((opt_flags & OPT_FREE) && (opt->flags & P_ALLOCED)) {
|
if ((opt_flags & OPT_FREE) && (opt->flags & P_ALLOCED)) {
|
||||||
free_string_option(*varp);
|
free_string_option(*varp);
|
||||||
}
|
}
|
||||||
|
@ -356,14 +356,9 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp)
|
|||||||
char *s = cts->cts_ptr;
|
char *s = cts->cts_ptr;
|
||||||
colnr_T vcol = cts->cts_vcol;
|
colnr_T vcol = cts->cts_vcol;
|
||||||
|
|
||||||
colnr_T col2;
|
|
||||||
colnr_T col_adj = 0; // vcol + screen size of tab
|
colnr_T col_adj = 0; // vcol + screen size of tab
|
||||||
colnr_T colmax;
|
|
||||||
int added;
|
|
||||||
int mb_added = 0;
|
int mb_added = 0;
|
||||||
int numberextra;
|
int numberextra;
|
||||||
char *ps;
|
|
||||||
int n;
|
|
||||||
|
|
||||||
cts->cts_cur_text_width = 0;
|
cts->cts_cur_text_width = 0;
|
||||||
|
|
||||||
@ -397,12 +392,12 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp)
|
|||||||
// Count all characters from first non-blank after a blank up to next
|
// Count all characters from first non-blank after a blank up to next
|
||||||
// non-blank after a blank.
|
// non-blank after a blank.
|
||||||
numberextra = win_col_off(wp);
|
numberextra = win_col_off(wp);
|
||||||
col2 = vcol;
|
colnr_T col2 = vcol;
|
||||||
colmax = (colnr_T)(wp->w_width_inner - numberextra - col_adj);
|
colnr_T colmax = (colnr_T)(wp->w_width_inner - numberextra - col_adj);
|
||||||
|
|
||||||
if (vcol >= colmax) {
|
if (vcol >= colmax) {
|
||||||
colmax += col_adj;
|
colmax += col_adj;
|
||||||
n = colmax + win_col_off2(wp);
|
int n = colmax + win_col_off2(wp);
|
||||||
|
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
colmax += (((vcol - colmax) / n) + 1) * n - col_adj;
|
colmax += (((vcol - colmax) / n) + 1) * n - col_adj;
|
||||||
@ -410,7 +405,7 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ps = s;
|
char *ps = s;
|
||||||
MB_PTR_ADV(s);
|
MB_PTR_ADV(s);
|
||||||
c = (uint8_t)(*s);
|
c = (uint8_t)(*s);
|
||||||
|
|
||||||
@ -439,7 +434,7 @@ int win_lbr_chartabsize(chartabsize_T *cts, int *headp)
|
|||||||
// string at start of line.
|
// string at start of line.
|
||||||
// Set *headp to the size of what we add.
|
// Set *headp to the size of what we add.
|
||||||
// Do not use 'showbreak' at the NUL after the text.
|
// Do not use 'showbreak' at the NUL after the text.
|
||||||
added = 0;
|
int added = 0;
|
||||||
char *const sbr = c == NUL ? empty_option : get_showbreak_value(wp);
|
char *const sbr = c == NUL ? empty_option : get_showbreak_value(wp);
|
||||||
if ((*sbr != NUL || wp->w_p_bri) && wp->w_p_wrap && vcol != 0) {
|
if ((*sbr != NUL || wp->w_p_bri) && wp->w_p_wrap && vcol != 0) {
|
||||||
colnr_T sbrlen = 0;
|
colnr_T sbrlen = 0;
|
||||||
|
@ -276,10 +276,8 @@ static void source_callback(char *fname, void *cookie)
|
|||||||
/// return FAIL when no file could be sourced, OK otherwise.
|
/// return FAIL when no file could be sourced, OK otherwise.
|
||||||
int do_in_path(char *path, char *name, int flags, DoInRuntimepathCB callback, void *cookie)
|
int do_in_path(char *path, char *name, int flags, DoInRuntimepathCB callback, void *cookie)
|
||||||
{
|
{
|
||||||
char *tail;
|
|
||||||
int num_files;
|
int num_files;
|
||||||
char **files;
|
char **files;
|
||||||
int i;
|
|
||||||
bool did_one = false;
|
bool did_one = false;
|
||||||
|
|
||||||
// Make a copy of 'runtimepath'. Invoking the callback may change the
|
// Make a copy of 'runtimepath'. Invoking the callback may change the
|
||||||
@ -287,6 +285,8 @@ int do_in_path(char *path, char *name, int flags, DoInRuntimepathCB callback, vo
|
|||||||
char *rtp_copy = xstrdup(path);
|
char *rtp_copy = xstrdup(path);
|
||||||
char *buf = xmallocz(MAXPATHL);
|
char *buf = xmallocz(MAXPATHL);
|
||||||
{
|
{
|
||||||
|
char *tail;
|
||||||
|
int i;
|
||||||
if (p_verbose > 10 && name != NULL) {
|
if (p_verbose > 10 && name != NULL) {
|
||||||
verbose_enter();
|
verbose_enter();
|
||||||
smsg(_("Searching for \"%s\" in \"%s\""), name, path);
|
smsg(_("Searching for \"%s\" in \"%s\""), name, path);
|
||||||
@ -2329,7 +2329,6 @@ char *getsourceline(int c, void *cookie, int indent, bool do_concat)
|
|||||||
{
|
{
|
||||||
struct source_cookie *sp = (struct source_cookie *)cookie;
|
struct source_cookie *sp = (struct source_cookie *)cookie;
|
||||||
char *line;
|
char *line;
|
||||||
char *p;
|
|
||||||
|
|
||||||
// If breakpoints have been added/deleted need to check for it.
|
// If breakpoints have been added/deleted need to check for it.
|
||||||
if (sp->dbg_tick < debug_tick) {
|
if (sp->dbg_tick < debug_tick) {
|
||||||
@ -2359,6 +2358,7 @@ char *getsourceline(int c, void *cookie, int indent, bool do_concat)
|
|||||||
// Only concatenate lines starting with a \ when 'cpoptions' doesn't
|
// Only concatenate lines starting with a \ when 'cpoptions' doesn't
|
||||||
// contain the 'C' flag.
|
// contain the 'C' flag.
|
||||||
if (line != NULL && do_concat && (vim_strchr(p_cpo, CPO_CONCAT) == NULL)) {
|
if (line != NULL && do_concat && (vim_strchr(p_cpo, CPO_CONCAT) == NULL)) {
|
||||||
|
char *p;
|
||||||
// compensate for the one line read-ahead
|
// compensate for the one line read-ahead
|
||||||
sp->sourcing_lnum--;
|
sp->sourcing_lnum--;
|
||||||
|
|
||||||
|
@ -153,11 +153,10 @@ static int sign_group_get_next_signid(buf_T *buf, const char *groupname)
|
|||||||
int id = 1;
|
int id = 1;
|
||||||
signgroup_T *group = NULL;
|
signgroup_T *group = NULL;
|
||||||
sign_entry_T *sign;
|
sign_entry_T *sign;
|
||||||
hashitem_T *hi;
|
|
||||||
int found = false;
|
int found = false;
|
||||||
|
|
||||||
if (groupname != NULL) {
|
if (groupname != NULL) {
|
||||||
hi = hash_find(&sg_table, (char *)groupname);
|
hashitem_T *hi = hash_find(&sg_table, (char *)groupname);
|
||||||
if (HASHITEM_EMPTY(hi)) {
|
if (HASHITEM_EMPTY(hi)) {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
@ -1198,7 +1197,6 @@ static linenr_T sign_jump(int sign_id, char *sign_group, buf_T *buf)
|
|||||||
/// ":sign define {name} ..." command
|
/// ":sign define {name} ..." command
|
||||||
static void sign_define_cmd(char *sign_name, char *cmdline)
|
static void sign_define_cmd(char *sign_name, char *cmdline)
|
||||||
{
|
{
|
||||||
char *arg;
|
|
||||||
char *p = cmdline;
|
char *p = cmdline;
|
||||||
char *icon = NULL;
|
char *icon = NULL;
|
||||||
char *text = NULL;
|
char *text = NULL;
|
||||||
@ -1210,7 +1208,7 @@ static void sign_define_cmd(char *sign_name, char *cmdline)
|
|||||||
|
|
||||||
// set values for a defined sign.
|
// set values for a defined sign.
|
||||||
for (;;) {
|
for (;;) {
|
||||||
arg = skipwhite(p);
|
char *arg = skipwhite(p);
|
||||||
if (*arg == NUL) {
|
if (*arg == NUL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1585,7 +1583,6 @@ static void sign_getinfo(sign_T *sp, dict_T *retdict)
|
|||||||
static void sign_getlist(const char *name, list_T *retlist)
|
static void sign_getlist(const char *name, list_T *retlist)
|
||||||
{
|
{
|
||||||
sign_T *sp = first_sign;
|
sign_T *sp = first_sign;
|
||||||
dict_T *dict;
|
|
||||||
|
|
||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
sp = sign_find((char *)name, NULL);
|
sp = sign_find((char *)name, NULL);
|
||||||
@ -1595,7 +1592,7 @@ static void sign_getlist(const char *name, list_T *retlist)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (; sp != NULL && !got_int; sp = sp->sn_next) {
|
for (; sp != NULL && !got_int; sp = sp->sn_next) {
|
||||||
dict = tv_dict_alloc();
|
dict_T *dict = tv_dict_alloc();
|
||||||
tv_list_append_dict(retlist, dict);
|
tv_list_append_dict(retlist, dict);
|
||||||
sign_getinfo(sp, dict);
|
sign_getinfo(sp, dict);
|
||||||
|
|
||||||
@ -1610,11 +1607,10 @@ list_T *get_buffer_signs(buf_T *buf)
|
|||||||
FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
|
FUNC_ATTR_NONNULL_RET FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
{
|
{
|
||||||
sign_entry_T *sign;
|
sign_entry_T *sign;
|
||||||
dict_T *d;
|
|
||||||
list_T *const l = tv_list_alloc(kListLenMayKnow);
|
list_T *const l = tv_list_alloc(kListLenMayKnow);
|
||||||
|
|
||||||
FOR_ALL_SIGNS_IN_BUF(buf, sign) {
|
FOR_ALL_SIGNS_IN_BUF(buf, sign) {
|
||||||
d = sign_get_info(sign);
|
dict_T *d = sign_get_info(sign);
|
||||||
tv_list_append_dict(l, d);
|
tv_list_append_dict(l, d);
|
||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
@ -2055,7 +2051,6 @@ void f_sign_getdefined(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
void f_sign_getplaced(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
void f_sign_getplaced(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||||
{
|
{
|
||||||
buf_T *buf = NULL;
|
buf_T *buf = NULL;
|
||||||
dict_T *dict;
|
|
||||||
dictitem_T *di;
|
dictitem_T *di;
|
||||||
linenr_T lnum = 0;
|
linenr_T lnum = 0;
|
||||||
int sign_id = 0;
|
int sign_id = 0;
|
||||||
@ -2072,6 +2067,7 @@ void f_sign_getplaced(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (argvars[1].v_type != VAR_UNKNOWN) {
|
if (argvars[1].v_type != VAR_UNKNOWN) {
|
||||||
|
dict_T *dict;
|
||||||
if (argvars[1].v_type != VAR_DICT
|
if (argvars[1].v_type != VAR_DICT
|
||||||
|| ((dict = argvars[1].vval.v_dict) == NULL)) {
|
|| ((dict = argvars[1].vval.v_dict) == NULL)) {
|
||||||
emsg(_(e_dictreq));
|
emsg(_(e_dictreq));
|
||||||
@ -2327,8 +2323,6 @@ static void sign_undefine_multiple(list_T *l, list_T *retlist)
|
|||||||
/// "sign_undefine()" function
|
/// "sign_undefine()" function
|
||||||
void f_sign_undefine(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
void f_sign_undefine(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
||||||
{
|
{
|
||||||
const char *name;
|
|
||||||
|
|
||||||
if (argvars[0].v_type == VAR_LIST && argvars[1].v_type == VAR_UNKNOWN) {
|
if (argvars[0].v_type == VAR_LIST && argvars[1].v_type == VAR_UNKNOWN) {
|
||||||
// Undefine multiple signs
|
// Undefine multiple signs
|
||||||
tv_list_alloc_ret(rettv, kListLenMayKnow);
|
tv_list_alloc_ret(rettv, kListLenMayKnow);
|
||||||
@ -2345,7 +2339,7 @@ void f_sign_undefine(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
rettv->vval.v_number = 0;
|
rettv->vval.v_number = 0;
|
||||||
} else {
|
} else {
|
||||||
// Free only the specified sign
|
// Free only the specified sign
|
||||||
name = tv_get_string_chk(&argvars[0]);
|
const char *name = tv_get_string_chk(&argvars[0]);
|
||||||
if (name == NULL) {
|
if (name == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -271,7 +271,6 @@ static bool can_be_compound(trystate_T *sp, slang_T *slang, char_u *compflags, i
|
|||||||
/// @param split word was split, less bonus
|
/// @param split word was split, less bonus
|
||||||
static int score_wordcount_adj(slang_T *slang, int score, char *word, bool split)
|
static int score_wordcount_adj(slang_T *slang, int score, char *word, bool split)
|
||||||
{
|
{
|
||||||
wordcount_T *wc;
|
|
||||||
int bonus;
|
int bonus;
|
||||||
int newscore;
|
int newscore;
|
||||||
|
|
||||||
@ -280,7 +279,7 @@ static int score_wordcount_adj(slang_T *slang, int score, char *word, bool split
|
|||||||
return score;
|
return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
wc = HI2WC(hi);
|
wordcount_T *wc = HI2WC(hi);
|
||||||
if (wc->wc_count < SCORE_THRES2) {
|
if (wc->wc_count < SCORE_THRES2) {
|
||||||
bonus = SCORE_COMMON1;
|
bonus = SCORE_COMMON1;
|
||||||
} else if (wc->wc_count < SCORE_THRES3) {
|
} else if (wc->wc_count < SCORE_THRES3) {
|
||||||
@ -306,20 +305,17 @@ static int badword_captype(char *word, char *end)
|
|||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
int flags = captype(word, end);
|
int flags = captype(word, end);
|
||||||
int c;
|
|
||||||
int l, u;
|
|
||||||
bool first;
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
if (!(flags & WF_KEEPCAP)) {
|
if (!(flags & WF_KEEPCAP)) {
|
||||||
return flags;
|
return flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Count the number of UPPER and lower case letters.
|
// Count the number of UPPER and lower case letters.
|
||||||
l = u = 0;
|
int l= 0;
|
||||||
first = false;
|
int u= 0;
|
||||||
for (p = word; p < end; MB_PTR_ADV(p)) {
|
bool first = false;
|
||||||
c = utf_ptr2char(p);
|
for (char *p = word; p < end; MB_PTR_ADV(p)) {
|
||||||
|
int c = utf_ptr2char(p);
|
||||||
if (SPELL_ISUPPER(c)) {
|
if (SPELL_ISUPPER(c)) {
|
||||||
u++;
|
u++;
|
||||||
if (p == word) {
|
if (p == word) {
|
||||||
@ -355,9 +351,8 @@ static int bytes2offset(char **pp)
|
|||||||
{
|
{
|
||||||
char_u *p = (char_u *)(*pp);
|
char_u *p = (char_u *)(*pp);
|
||||||
int nr;
|
int nr;
|
||||||
int c;
|
|
||||||
|
|
||||||
c = *p++;
|
int c = *p++;
|
||||||
if ((c & 0x80) == 0x00) { // 1 byte
|
if ((c & 0x80) == 0x00) { // 1 byte
|
||||||
nr = c - 1;
|
nr = c - 1;
|
||||||
} else if ((c & 0xc0) == 0x80) { // 2 bytes
|
} else if ((c & 0xc0) == 0x80) { // 2 bytes
|
||||||
@ -392,18 +387,16 @@ static int sps_limit = 9999; ///< max nr of suggestions given
|
|||||||
/// Sets "sps_flags" and "sps_limit".
|
/// Sets "sps_flags" and "sps_limit".
|
||||||
int spell_check_sps(void)
|
int spell_check_sps(void)
|
||||||
{
|
{
|
||||||
char *p;
|
|
||||||
char *s;
|
char *s;
|
||||||
char buf[MAXPATHL];
|
char buf[MAXPATHL];
|
||||||
int f;
|
|
||||||
|
|
||||||
sps_flags = 0;
|
sps_flags = 0;
|
||||||
sps_limit = 9999;
|
sps_limit = 9999;
|
||||||
|
|
||||||
for (p = p_sps; *p != NUL;) {
|
for (char *p = p_sps; *p != NUL;) {
|
||||||
copy_option_part(&p, buf, MAXPATHL, ",");
|
copy_option_part(&p, buf, MAXPATHL, ",");
|
||||||
|
|
||||||
f = 0;
|
int f = 0;
|
||||||
if (ascii_isdigit(*buf)) {
|
if (ascii_isdigit(*buf)) {
|
||||||
s = buf;
|
s = buf;
|
||||||
sps_limit = getdigits_int(&s, true, 0);
|
sps_limit = getdigits_int(&s, true, 0);
|
||||||
@ -451,11 +444,9 @@ void spell_suggest(int count)
|
|||||||
pos_T prev_cursor = curwin->w_cursor;
|
pos_T prev_cursor = curwin->w_cursor;
|
||||||
char wcopy[MAXWLEN + 2];
|
char wcopy[MAXWLEN + 2];
|
||||||
char *p;
|
char *p;
|
||||||
int c;
|
|
||||||
suginfo_T sug;
|
suginfo_T sug;
|
||||||
suggest_T *stp;
|
suggest_T *stp;
|
||||||
int mouse_used;
|
int mouse_used;
|
||||||
int need_cap;
|
|
||||||
int limit;
|
int limit;
|
||||||
int selected = count;
|
int selected = count;
|
||||||
int badlen = 0;
|
int badlen = 0;
|
||||||
@ -519,7 +510,7 @@ void spell_suggest(int count)
|
|||||||
// Get the word and its length.
|
// Get the word and its length.
|
||||||
|
|
||||||
// Figure out if the word should be capitalised.
|
// Figure out if the word should be capitalised.
|
||||||
need_cap = check_need_cap(curwin->w_cursor.lnum, curwin->w_cursor.col);
|
int need_cap = check_need_cap(curwin->w_cursor.lnum, curwin->w_cursor.col);
|
||||||
|
|
||||||
// Make a copy of current line since autocommands may free the line.
|
// Make a copy of current line since autocommands may free the line.
|
||||||
line = xstrdup(get_cursor_line_ptr());
|
line = xstrdup(get_cursor_line_ptr());
|
||||||
@ -651,7 +642,7 @@ void spell_suggest(int count)
|
|||||||
|
|
||||||
// Replace the word.
|
// Replace the word.
|
||||||
p = xmalloc(strlen(line) - (size_t)stp->st_orglen + (size_t)stp->st_wordlen + 1);
|
p = xmalloc(strlen(line) - (size_t)stp->st_orglen + (size_t)stp->st_wordlen + 1);
|
||||||
c = (int)(sug.su_badptr - line);
|
int c = (int)(sug.su_badptr - line);
|
||||||
memmove(p, line, (size_t)c);
|
memmove(p, line, (size_t)c);
|
||||||
STRCPY(p + c, stp->st_word);
|
STRCPY(p + c, stp->st_word);
|
||||||
STRCAT(p, sug.su_badptr + stp->st_orglen);
|
STRCAT(p, sug.su_badptr + stp->st_orglen);
|
||||||
@ -685,7 +676,6 @@ void spell_suggest(int count)
|
|||||||
void spell_suggest_list(garray_T *gap, char *word, int maxcount, bool need_cap, bool interactive)
|
void spell_suggest_list(garray_T *gap, char *word, int maxcount, bool need_cap, bool interactive)
|
||||||
{
|
{
|
||||||
suginfo_T sug;
|
suginfo_T sug;
|
||||||
suggest_T *stp;
|
|
||||||
char *wcopy;
|
char *wcopy;
|
||||||
|
|
||||||
spell_find_suggest(word, 0, &sug, maxcount, false, need_cap, interactive);
|
spell_find_suggest(word, 0, &sug, maxcount, false, need_cap, interactive);
|
||||||
@ -694,7 +684,7 @@ void spell_suggest_list(garray_T *gap, char *word, int maxcount, bool need_cap,
|
|||||||
ga_init(gap, sizeof(char *), sug.su_ga.ga_len + 1);
|
ga_init(gap, sizeof(char *), sug.su_ga.ga_len + 1);
|
||||||
ga_grow(gap, sug.su_ga.ga_len);
|
ga_grow(gap, sug.su_ga.ga_len);
|
||||||
for (int i = 0; i < sug.su_ga.ga_len; i++) {
|
for (int i = 0; i < sug.su_ga.ga_len; i++) {
|
||||||
stp = &SUG(sug.su_ga, i);
|
suggest_T *stp = &SUG(sug.su_ga, i);
|
||||||
|
|
||||||
// The suggested word may replace only part of "word", add the not
|
// The suggested word may replace only part of "word", add the not
|
||||||
// replaced part.
|
// replaced part.
|
||||||
@ -721,11 +711,8 @@ static void spell_find_suggest(char *badptr, int badlen, suginfo_T *su, int maxc
|
|||||||
{
|
{
|
||||||
hlf_T attr = HLF_COUNT;
|
hlf_T attr = HLF_COUNT;
|
||||||
char buf[MAXPATHL];
|
char buf[MAXPATHL];
|
||||||
char *p;
|
|
||||||
bool do_combine = false;
|
bool do_combine = false;
|
||||||
char *sps_copy;
|
|
||||||
static bool expr_busy = false;
|
static bool expr_busy = false;
|
||||||
int c;
|
|
||||||
langp_T *lp;
|
langp_T *lp;
|
||||||
bool did_intern = false;
|
bool did_intern = false;
|
||||||
|
|
||||||
@ -790,7 +777,7 @@ static void spell_find_suggest(char *badptr, int badlen, suginfo_T *su, int maxc
|
|||||||
// If the word is not capitalised and spell_check() doesn't consider the
|
// If the word is not capitalised and spell_check() doesn't consider the
|
||||||
// word to be bad then it might need to be capitalised. Add a suggestion
|
// word to be bad then it might need to be capitalised. Add a suggestion
|
||||||
// for that.
|
// for that.
|
||||||
c = utf_ptr2char(su->su_badptr);
|
int c = utf_ptr2char(su->su_badptr);
|
||||||
if (!SPELL_ISUPPER(c) && attr == HLF_COUNT) {
|
if (!SPELL_ISUPPER(c) && attr == HLF_COUNT) {
|
||||||
make_case_word(su->su_badword, buf, WF_ONECAP);
|
make_case_word(su->su_badword, buf, WF_ONECAP);
|
||||||
add_suggestion(su, &su->su_ga, buf, su->su_badlen, SCORE_ICASE,
|
add_suggestion(su, &su->su_ga, buf, su->su_badlen, SCORE_ICASE,
|
||||||
@ -803,10 +790,10 @@ static void spell_find_suggest(char *badptr, int badlen, suginfo_T *su, int maxc
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Make a copy of 'spellsuggest', because the expression may change it.
|
// Make a copy of 'spellsuggest', because the expression may change it.
|
||||||
sps_copy = xstrdup(p_sps);
|
char *sps_copy = xstrdup(p_sps);
|
||||||
|
|
||||||
// Loop over the items in 'spellsuggest'.
|
// Loop over the items in 'spellsuggest'.
|
||||||
for (p = sps_copy; *p != NUL;) {
|
for (char *p = sps_copy; *p != NUL;) {
|
||||||
copy_option_part(&p, buf, MAXPATHL, ",");
|
copy_option_part(&p, buf, MAXPATHL, ",");
|
||||||
|
|
||||||
if (strncmp(buf, "expr:", 5) == 0) {
|
if (strncmp(buf, "expr:", 5) == 0) {
|
||||||
@ -845,7 +832,6 @@ static void spell_find_suggest(char *badptr, int badlen, suginfo_T *su, int maxc
|
|||||||
/// Find suggestions by evaluating expression "expr".
|
/// Find suggestions by evaluating expression "expr".
|
||||||
static void spell_suggest_expr(suginfo_T *su, char *expr)
|
static void spell_suggest_expr(suginfo_T *su, char *expr)
|
||||||
{
|
{
|
||||||
int score;
|
|
||||||
const char *p;
|
const char *p;
|
||||||
|
|
||||||
// The work is split up in a few parts to avoid having to export
|
// The work is split up in a few parts to avoid having to export
|
||||||
@ -857,7 +843,7 @@ static void spell_suggest_expr(suginfo_T *su, char *expr)
|
|||||||
TV_LIST_ITER(list, li, {
|
TV_LIST_ITER(list, li, {
|
||||||
if (TV_LIST_ITEM_TV(li)->v_type == VAR_LIST) {
|
if (TV_LIST_ITEM_TV(li)->v_type == VAR_LIST) {
|
||||||
// Get the word and the score from the items.
|
// Get the word and the score from the items.
|
||||||
score = get_spellword(TV_LIST_ITEM_TV(li)->vval.v_list, &p);
|
int score = get_spellword(TV_LIST_ITEM_TV(li)->vval.v_list, &p);
|
||||||
if (score >= 0 && score <= su->su_maxscore) {
|
if (score >= 0 && score <= su->su_maxscore) {
|
||||||
add_suggestion(su, &su->su_ga, p, su->su_badlen,
|
add_suggestion(su, &su->su_ga, p, su->su_badlen,
|
||||||
score, 0, true, su->su_sallang, false);
|
score, 0, true, su->su_sallang, false);
|
||||||
@ -875,14 +861,12 @@ static void spell_suggest_expr(suginfo_T *su, char *expr)
|
|||||||
/// Find suggestions in file "fname". Used for "file:" in 'spellsuggest'.
|
/// Find suggestions in file "fname". Used for "file:" in 'spellsuggest'.
|
||||||
static void spell_suggest_file(suginfo_T *su, char *fname)
|
static void spell_suggest_file(suginfo_T *su, char *fname)
|
||||||
{
|
{
|
||||||
FILE *fd;
|
|
||||||
char line[MAXWLEN * 2];
|
char line[MAXWLEN * 2];
|
||||||
char *p;
|
|
||||||
int len;
|
int len;
|
||||||
char cword[MAXWLEN];
|
char cword[MAXWLEN];
|
||||||
|
|
||||||
// Open the file.
|
// Open the file.
|
||||||
fd = os_fopen(fname, "r");
|
FILE *fd = os_fopen(fname, "r");
|
||||||
if (fd == NULL) {
|
if (fd == NULL) {
|
||||||
semsg(_(e_notopen), fname);
|
semsg(_(e_notopen), fname);
|
||||||
return;
|
return;
|
||||||
@ -892,7 +876,7 @@ static void spell_suggest_file(suginfo_T *su, char *fname)
|
|||||||
while (!vim_fgets(line, MAXWLEN * 2, fd) && !got_int) {
|
while (!vim_fgets(line, MAXWLEN * 2, fd) && !got_int) {
|
||||||
line_breakcheck();
|
line_breakcheck();
|
||||||
|
|
||||||
p = vim_strchr(line, '/');
|
char *p = vim_strchr(line, '/');
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
continue; // No Tab found, just skip the line.
|
continue; // No Tab found, just skip the line.
|
||||||
}
|
}
|
||||||
@ -1013,7 +997,6 @@ static void spell_find_cleanup(suginfo_T *su)
|
|||||||
/// Try finding suggestions by recognizing specific situations.
|
/// Try finding suggestions by recognizing specific situations.
|
||||||
static void suggest_try_special(suginfo_T *su)
|
static void suggest_try_special(suginfo_T *su)
|
||||||
{
|
{
|
||||||
char c;
|
|
||||||
char word[MAXWLEN];
|
char word[MAXWLEN];
|
||||||
|
|
||||||
// Recognize a word that is repeated: "the the".
|
// Recognize a word that is repeated: "the the".
|
||||||
@ -1023,7 +1006,7 @@ static void suggest_try_special(suginfo_T *su)
|
|||||||
if (strlen(p) == len && strncmp(su->su_fbadword, p, len) == 0) {
|
if (strlen(p) == len && strncmp(su->su_fbadword, p, len) == 0) {
|
||||||
// Include badflags: if the badword is onecap or allcap
|
// Include badflags: if the badword is onecap or allcap
|
||||||
// use that for the goodword too: "The the" -> "The".
|
// use that for the goodword too: "The the" -> "The".
|
||||||
c = su->su_fbadword[len];
|
char c = su->su_fbadword[len];
|
||||||
su->su_fbadword[len] = NUL;
|
su->su_fbadword[len] = NUL;
|
||||||
make_case_word(su->su_fbadword, word, su->su_badflags);
|
make_case_word(su->su_fbadword, word, su->su_badflags);
|
||||||
su->su_fbadword[len] = c;
|
su->su_fbadword[len] = c;
|
||||||
@ -1084,16 +1067,14 @@ static void prof_report(char *name)
|
|||||||
static void suggest_try_change(suginfo_T *su)
|
static void suggest_try_change(suginfo_T *su)
|
||||||
{
|
{
|
||||||
char fword[MAXWLEN]; // copy of the bad word, case-folded
|
char fword[MAXWLEN]; // copy of the bad word, case-folded
|
||||||
int n;
|
|
||||||
char *p;
|
|
||||||
langp_T *lp;
|
langp_T *lp;
|
||||||
|
|
||||||
// We make a copy of the case-folded bad word, so that we can modify it
|
// We make a copy of the case-folded bad word, so that we can modify it
|
||||||
// to find matches (esp. REP items). Append some more text, changing
|
// to find matches (esp. REP items). Append some more text, changing
|
||||||
// chars after the bad word may help.
|
// chars after the bad word may help.
|
||||||
STRCPY(fword, su->su_fbadword);
|
STRCPY(fword, su->su_fbadword);
|
||||||
n = (int)strlen(fword);
|
int n = (int)strlen(fword);
|
||||||
p = su->su_badptr + su->su_badlen;
|
char *p = su->su_badptr + su->su_badlen;
|
||||||
(void)spell_casefold(curwin, p, (int)strlen(p), fword + n, MAXWLEN - n);
|
(void)spell_casefold(curwin, p, (int)strlen(p), fword + n, MAXWLEN - n);
|
||||||
|
|
||||||
// Make sure the resulting text is not longer than the original text.
|
// Make sure the resulting text is not longer than the original text.
|
||||||
@ -1165,12 +1146,10 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
|
|||||||
// when going deeper but not when coming
|
// when going deeper but not when coming
|
||||||
// back.
|
// back.
|
||||||
char_u compflags[MAXWLEN]; // compound flags, one for each word
|
char_u compflags[MAXWLEN]; // compound flags, one for each word
|
||||||
trystate_T *sp;
|
|
||||||
int newscore;
|
int newscore;
|
||||||
int score;
|
int score;
|
||||||
char_u *byts, *fbyts, *pbyts;
|
char_u *byts, *fbyts, *pbyts;
|
||||||
idx_T *idxs, *fidxs, *pidxs;
|
idx_T *idxs, *fidxs, *pidxs;
|
||||||
int depth;
|
|
||||||
int c, c2, c3;
|
int c, c2, c3;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
int flags;
|
int flags;
|
||||||
@ -1195,8 +1174,8 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char *fword, bool soun
|
|||||||
// "tword[]" contains the word collected from nodes in the tree.
|
// "tword[]" contains the word collected from nodes in the tree.
|
||||||
// "fword[]" the word we are trying to match with (initially the bad
|
// "fword[]" the word we are trying to match with (initially the bad
|
||||||
// word).
|
// word).
|
||||||
depth = 0;
|
int depth = 0;
|
||||||
sp = &stack[0];
|
trystate_T *sp = &stack[0];
|
||||||
CLEAR_POINTER(sp); // -V1068
|
CLEAR_POINTER(sp); // -V1068
|
||||||
sp->ts_curi = 1;
|
sp->ts_curi = 1;
|
||||||
|
|
||||||
@ -2387,7 +2366,6 @@ static void go_deeper(trystate_T *stack, int depth, int score_add)
|
|||||||
static void find_keepcap_word(slang_T *slang, char *fword, char *kword)
|
static void find_keepcap_word(slang_T *slang, char *fword, char *kword)
|
||||||
{
|
{
|
||||||
char uword[MAXWLEN]; // "fword" in upper-case
|
char uword[MAXWLEN]; // "fword" in upper-case
|
||||||
int depth;
|
|
||||||
idx_T tryidx;
|
idx_T tryidx;
|
||||||
|
|
||||||
// The following arrays are used at each depth in the tree.
|
// The following arrays are used at each depth in the tree.
|
||||||
@ -2418,7 +2396,7 @@ static void find_keepcap_word(slang_T *slang, char *fword, char *kword)
|
|||||||
// Each character needs to be tried both case-folded and upper-case.
|
// Each character needs to be tried both case-folded and upper-case.
|
||||||
// All this gets very complicated if we keep in mind that changing case
|
// All this gets very complicated if we keep in mind that changing case
|
||||||
// may change the byte length of a multi-byte character...
|
// may change the byte length of a multi-byte character...
|
||||||
depth = 0;
|
int depth = 0;
|
||||||
arridx[0] = 0;
|
arridx[0] = 0;
|
||||||
round[0] = 0;
|
round[0] = 0;
|
||||||
fwordidx[0] = 0;
|
fwordidx[0] = 0;
|
||||||
@ -2656,16 +2634,14 @@ static void score_combine(suginfo_T *su)
|
|||||||
/// @param badsound sound-folded badword
|
/// @param badsound sound-folded badword
|
||||||
static int stp_sal_score(suggest_T *stp, suginfo_T *su, slang_T *slang, char *badsound)
|
static int stp_sal_score(suggest_T *stp, suginfo_T *su, slang_T *slang, char *badsound)
|
||||||
{
|
{
|
||||||
char *p;
|
|
||||||
char *pbad;
|
char *pbad;
|
||||||
char *pgood;
|
char *pgood;
|
||||||
char badsound2[MAXWLEN];
|
char badsound2[MAXWLEN];
|
||||||
char fword[MAXWLEN];
|
char fword[MAXWLEN];
|
||||||
char goodsound[MAXWLEN];
|
char goodsound[MAXWLEN];
|
||||||
char goodword[MAXWLEN];
|
char goodword[MAXWLEN];
|
||||||
int lendiff;
|
|
||||||
|
|
||||||
lendiff = su->su_badlen - stp->st_orglen;
|
int lendiff = su->su_badlen - stp->st_orglen;
|
||||||
if (lendiff >= 0) {
|
if (lendiff >= 0) {
|
||||||
pbad = badsound;
|
pbad = badsound;
|
||||||
} else {
|
} else {
|
||||||
@ -2678,7 +2654,7 @@ static int stp_sal_score(suggest_T *stp, suginfo_T *su, slang_T *slang, char *ba
|
|||||||
// space.
|
// space.
|
||||||
if (ascii_iswhite(su->su_badptr[su->su_badlen])
|
if (ascii_iswhite(su->su_badptr[su->su_badlen])
|
||||||
&& *skiptowhite(stp->st_word) == NUL) {
|
&& *skiptowhite(stp->st_word) == NUL) {
|
||||||
for (p = fword; *(p = skiptowhite(p)) != NUL;) {
|
for (char *p = fword; *(p = skiptowhite(p)) != NUL;) {
|
||||||
STRMOVE(p, p + 1);
|
STRMOVE(p, p + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2801,9 +2777,6 @@ static void suggest_try_soundalike_finish(void)
|
|||||||
static void add_sound_suggest(suginfo_T *su, char *goodword, int score, langp_T *lp)
|
static void add_sound_suggest(suginfo_T *su, char *goodword, int score, langp_T *lp)
|
||||||
{
|
{
|
||||||
slang_T *slang = lp->lp_slang; // language for sound folding
|
slang_T *slang = lp->lp_slang; // language for sound folding
|
||||||
int sfwordnr;
|
|
||||||
char *nrline;
|
|
||||||
int orgnr;
|
|
||||||
char theword[MAXWLEN];
|
char theword[MAXWLEN];
|
||||||
int i;
|
int i;
|
||||||
int wlen;
|
int wlen;
|
||||||
@ -2813,8 +2786,6 @@ static void add_sound_suggest(suginfo_T *su, char *goodword, int score, langp_T
|
|||||||
int wordcount;
|
int wordcount;
|
||||||
int wc;
|
int wc;
|
||||||
int goodscore;
|
int goodscore;
|
||||||
hash_T hash;
|
|
||||||
hashitem_T *hi;
|
|
||||||
sftword_T *sft;
|
sftword_T *sft;
|
||||||
int bc, gc;
|
int bc, gc;
|
||||||
int limit;
|
int limit;
|
||||||
@ -2823,10 +2794,9 @@ static void add_sound_suggest(suginfo_T *su, char *goodword, int score, langp_T
|
|||||||
// times with different scores. Since the following is quite slow only do
|
// times with different scores. Since the following is quite slow only do
|
||||||
// the words that have a better score than before. Use a hashtable to
|
// the words that have a better score than before. Use a hashtable to
|
||||||
// remember the words that have been done.
|
// remember the words that have been done.
|
||||||
hash = hash_hash(goodword);
|
hash_T hash = hash_hash(goodword);
|
||||||
const size_t goodword_len = strlen(goodword);
|
const size_t goodword_len = strlen(goodword);
|
||||||
hi = hash_lookup(&slang->sl_sounddone, (const char *)goodword, goodword_len,
|
hashitem_T *hi = hash_lookup(&slang->sl_sounddone, (const char *)goodword, goodword_len, hash);
|
||||||
hash);
|
|
||||||
if (HASHITEM_EMPTY(hi)) {
|
if (HASHITEM_EMPTY(hi)) {
|
||||||
sft = xmalloc(offsetof(sftword_T, sft_word) + goodword_len + 1);
|
sft = xmalloc(offsetof(sftword_T, sft_word) + goodword_len + 1);
|
||||||
sft->sft_score = (int16_t)score;
|
sft->sft_score = (int16_t)score;
|
||||||
@ -2841,15 +2811,15 @@ static void add_sound_suggest(suginfo_T *su, char *goodword, int score, langp_T
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Find the word nr in the soundfold tree.
|
// Find the word nr in the soundfold tree.
|
||||||
sfwordnr = soundfold_find(slang, goodword);
|
int sfwordnr = soundfold_find(slang, goodword);
|
||||||
if (sfwordnr < 0) {
|
if (sfwordnr < 0) {
|
||||||
internal_error("add_sound_suggest()");
|
internal_error("add_sound_suggest()");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Go over the list of good words that produce this soundfold word
|
// Go over the list of good words that produce this soundfold word
|
||||||
nrline = ml_get_buf(slang->sl_sugbuf, (linenr_T)sfwordnr + 1, false);
|
char *nrline = ml_get_buf(slang->sl_sugbuf, (linenr_T)sfwordnr + 1, false);
|
||||||
orgnr = 0;
|
int orgnr = 0;
|
||||||
while (*nrline != NUL) {
|
while (*nrline != NUL) {
|
||||||
// The wordnr was stored in a minimal nr of bytes as an offset to the
|
// The wordnr was stored in a minimal nr of bytes as an offset to the
|
||||||
// previous wordnr.
|
// previous wordnr.
|
||||||
@ -2984,24 +2954,20 @@ badword:
|
|||||||
static int soundfold_find(slang_T *slang, char *word)
|
static int soundfold_find(slang_T *slang, char *word)
|
||||||
{
|
{
|
||||||
idx_T arridx = 0;
|
idx_T arridx = 0;
|
||||||
int len;
|
|
||||||
int wlen = 0;
|
int wlen = 0;
|
||||||
int c;
|
|
||||||
char_u *ptr = (char_u *)word;
|
char_u *ptr = (char_u *)word;
|
||||||
char_u *byts;
|
|
||||||
idx_T *idxs;
|
|
||||||
int wordnr = 0;
|
int wordnr = 0;
|
||||||
|
|
||||||
byts = (char_u *)slang->sl_sbyts;
|
char_u *byts = (char_u *)slang->sl_sbyts;
|
||||||
idxs = slang->sl_sidxs;
|
idx_T *idxs = slang->sl_sidxs;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
// First byte is the number of possible bytes.
|
// First byte is the number of possible bytes.
|
||||||
len = byts[arridx++];
|
int len = byts[arridx++];
|
||||||
|
|
||||||
// If the first possible byte is a zero the word could end here.
|
// If the first possible byte is a zero the word could end here.
|
||||||
// If the word ends we found the word. If not skip the NUL bytes.
|
// If the word ends we found the word. If not skip the NUL bytes.
|
||||||
c = ptr[wlen];
|
int c = ptr[wlen];
|
||||||
if (byts[arridx] == NUL) {
|
if (byts[arridx] == NUL) {
|
||||||
if (c == NUL) {
|
if (c == NUL) {
|
||||||
break;
|
break;
|
||||||
@ -3212,19 +3178,17 @@ static void add_suggestion(suginfo_T *su, garray_T *gap, const char *goodword, i
|
|||||||
/// @param gap either su_ga or su_sga
|
/// @param gap either su_ga or su_sga
|
||||||
static void check_suggestions(suginfo_T *su, garray_T *gap)
|
static void check_suggestions(suginfo_T *su, garray_T *gap)
|
||||||
{
|
{
|
||||||
suggest_T *stp;
|
|
||||||
char longword[MAXWLEN + 1];
|
char longword[MAXWLEN + 1];
|
||||||
int len;
|
|
||||||
hlf_T attr;
|
hlf_T attr;
|
||||||
|
|
||||||
if (gap->ga_len == 0) {
|
if (gap->ga_len == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
stp = &SUG(*gap, 0);
|
suggest_T *stp = &SUG(*gap, 0);
|
||||||
for (int i = gap->ga_len - 1; i >= 0; i--) {
|
for (int i = gap->ga_len - 1; i >= 0; i--) {
|
||||||
// Need to append what follows to check for "the the".
|
// Need to append what follows to check for "the the".
|
||||||
xstrlcpy(longword, stp[i].st_word, MAXWLEN + 1);
|
xstrlcpy(longword, stp[i].st_word, MAXWLEN + 1);
|
||||||
len = stp[i].st_wordlen;
|
int len = stp[i].st_wordlen;
|
||||||
xstrlcpy(longword + len, su->su_badptr + stp[i].st_orglen,
|
xstrlcpy(longword + len, su->su_badptr + stp[i].st_orglen,
|
||||||
(size_t)(MAXWLEN - len + 1));
|
(size_t)(MAXWLEN - len + 1));
|
||||||
attr = HLF_COUNT;
|
attr = HLF_COUNT;
|
||||||
@ -3243,17 +3207,13 @@ static void check_suggestions(suginfo_T *su, garray_T *gap)
|
|||||||
/// Add a word to be banned.
|
/// Add a word to be banned.
|
||||||
static void add_banned(suginfo_T *su, char *word)
|
static void add_banned(suginfo_T *su, char *word)
|
||||||
{
|
{
|
||||||
char *s;
|
hash_T hash = hash_hash(word);
|
||||||
hash_T hash;
|
|
||||||
hashitem_T *hi;
|
|
||||||
|
|
||||||
hash = hash_hash(word);
|
|
||||||
const size_t word_len = strlen(word);
|
const size_t word_len = strlen(word);
|
||||||
hi = hash_lookup(&su->su_banned, word, word_len, hash);
|
hashitem_T *hi = hash_lookup(&su->su_banned, word, word_len, hash);
|
||||||
if (!HASHITEM_EMPTY(hi)) { // already present
|
if (!HASHITEM_EMPTY(hi)) { // already present
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
s = xmemdupz(word, word_len);
|
char *s = xmemdupz(word, word_len);
|
||||||
hash_add_item(&su->su_banned, hi, s, hash);
|
hash_add_item(&su->su_banned, hi, s, hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3273,19 +3233,19 @@ static void rescore_one(suginfo_T *su, suggest_T *stp)
|
|||||||
{
|
{
|
||||||
slang_T *slang = stp->st_slang;
|
slang_T *slang = stp->st_slang;
|
||||||
char sal_badword[MAXWLEN];
|
char sal_badword[MAXWLEN];
|
||||||
char *p;
|
|
||||||
|
|
||||||
// Only rescore suggestions that have no sal score yet and do have a
|
// Only rescore suggestions that have no sal score yet and do have a
|
||||||
// language.
|
// language.
|
||||||
if (slang != NULL && !GA_EMPTY(&slang->sl_sal) && !stp->st_had_bonus) {
|
if (slang != NULL && !GA_EMPTY(&slang->sl_sal) && !stp->st_had_bonus) {
|
||||||
|
char_u *p;
|
||||||
if (slang == su->su_sallang) {
|
if (slang == su->su_sallang) {
|
||||||
p = su->su_sal_badword;
|
p = (char_u *)su->su_sal_badword;
|
||||||
} else {
|
} else {
|
||||||
spell_soundfold(slang, su->su_fbadword, true, sal_badword);
|
spell_soundfold(slang, su->su_fbadword, true, sal_badword);
|
||||||
p = sal_badword;
|
p = (char_u *)sal_badword;
|
||||||
}
|
}
|
||||||
|
|
||||||
stp->st_altscore = stp_sal_score(stp, su, slang, p);
|
stp->st_altscore = stp_sal_score(stp, su, slang, (char *)p);
|
||||||
if (stp->st_altscore == SCORE_MAXMAX) {
|
if (stp->st_altscore == SCORE_MAXMAX) {
|
||||||
stp->st_altscore = SCORE_BIG;
|
stp->st_altscore = SCORE_BIG;
|
||||||
}
|
}
|
||||||
@ -3354,9 +3314,6 @@ static int soundalike_score(char *goodstart, char *badstart)
|
|||||||
{
|
{
|
||||||
char *goodsound = goodstart;
|
char *goodsound = goodstart;
|
||||||
char *badsound = badstart;
|
char *badsound = badstart;
|
||||||
int goodlen;
|
|
||||||
int badlen;
|
|
||||||
int n;
|
|
||||||
char *pl, *ps;
|
char *pl, *ps;
|
||||||
char *pl2, *ps2;
|
char *pl2, *ps2;
|
||||||
int score = 0;
|
int score = 0;
|
||||||
@ -3389,12 +3346,12 @@ static int soundalike_score(char *goodstart, char *badstart)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
goodlen = (int)strlen(goodsound);
|
int goodlen = (int)strlen(goodsound);
|
||||||
badlen = (int)strlen(badsound);
|
int badlen = (int)strlen(badsound);
|
||||||
|
|
||||||
// Return quickly if the lengths are too different to be fixed by two
|
// Return quickly if the lengths are too different to be fixed by two
|
||||||
// changes.
|
// changes.
|
||||||
n = goodlen - badlen;
|
int n = goodlen - badlen;
|
||||||
if (n < -2 || n > 2) {
|
if (n < -2 || n > 2) {
|
||||||
return SCORE_MAXMAX;
|
return SCORE_MAXMAX;
|
||||||
}
|
}
|
||||||
@ -3683,25 +3640,21 @@ static int spell_edit_score_limit_w(slang_T *slang, const char *badword, const c
|
|||||||
int limit)
|
int limit)
|
||||||
{
|
{
|
||||||
limitscore_T stack[10]; // allow for over 3 * 2 edits
|
limitscore_T stack[10]; // allow for over 3 * 2 edits
|
||||||
int stackidx;
|
|
||||||
int bi, gi;
|
|
||||||
int bi2, gi2;
|
int bi2, gi2;
|
||||||
int bc, gc;
|
int bc, gc;
|
||||||
int score;
|
|
||||||
int score_off;
|
int score_off;
|
||||||
int minscore;
|
|
||||||
int round;
|
int round;
|
||||||
int wbadword[MAXWLEN];
|
int wbadword[MAXWLEN];
|
||||||
int wgoodword[MAXWLEN];
|
int wgoodword[MAXWLEN];
|
||||||
|
|
||||||
// Get the characters from the multi-byte strings and put them in an
|
// Get the characters from the multi-byte strings and put them in an
|
||||||
// int array for easy access.
|
// int array for easy access.
|
||||||
bi = 0;
|
int bi = 0;
|
||||||
for (const char *p = badword; *p != NUL;) {
|
for (const char *p = badword; *p != NUL;) {
|
||||||
wbadword[bi++] = mb_cptr2char_adv(&p);
|
wbadword[bi++] = mb_cptr2char_adv(&p);
|
||||||
}
|
}
|
||||||
wbadword[bi++] = 0;
|
wbadword[bi++] = 0;
|
||||||
gi = 0;
|
int gi = 0;
|
||||||
for (const char *p = goodword; *p != NUL;) {
|
for (const char *p = goodword; *p != NUL;) {
|
||||||
wgoodword[gi++] = mb_cptr2char_adv(&p);
|
wgoodword[gi++] = mb_cptr2char_adv(&p);
|
||||||
}
|
}
|
||||||
@ -3714,11 +3667,11 @@ static int spell_edit_score_limit_w(slang_T *slang, const char *badword, const c
|
|||||||
// pushed unto a stack and tried later, some are tried right away. At the
|
// pushed unto a stack and tried later, some are tried right away. At the
|
||||||
// end of the word the score for one alternative is known. The lowest
|
// end of the word the score for one alternative is known. The lowest
|
||||||
// possible score is stored in "minscore".
|
// possible score is stored in "minscore".
|
||||||
stackidx = 0;
|
int stackidx = 0;
|
||||||
bi = 0;
|
bi = 0;
|
||||||
gi = 0;
|
gi = 0;
|
||||||
score = 0;
|
int score = 0;
|
||||||
minscore = limit + 1;
|
int minscore = limit + 1;
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
// Skip over an equal part, score remains the same.
|
// Skip over an equal part, score remains the same.
|
||||||
|
@ -979,27 +979,22 @@ static void print_tag_list(int new_tag, int use_tagstack, int num_matches, char
|
|||||||
/// window.
|
/// window.
|
||||||
static int add_llist_tags(char *tag, int num_matches, char **matches)
|
static int add_llist_tags(char *tag, int num_matches, char **matches)
|
||||||
{
|
{
|
||||||
list_T *list;
|
|
||||||
char tag_name[128 + 1];
|
char tag_name[128 + 1];
|
||||||
char *fname;
|
|
||||||
char *cmd;
|
|
||||||
int i;
|
int i;
|
||||||
char *p;
|
char *p;
|
||||||
tagptrs_T tagp;
|
tagptrs_T tagp;
|
||||||
|
|
||||||
fname = xmalloc(MAXPATHL + 1);
|
char *fname = xmalloc(MAXPATHL + 1);
|
||||||
cmd = xmalloc(CMDBUFFSIZE + 1);
|
char *cmd = xmalloc(CMDBUFFSIZE + 1);
|
||||||
list = tv_list_alloc(0);
|
list_T *list = tv_list_alloc(0);
|
||||||
|
|
||||||
for (i = 0; i < num_matches; i++) {
|
for (i = 0; i < num_matches; i++) {
|
||||||
int len, cmd_len;
|
|
||||||
long lnum;
|
|
||||||
dict_T *dict;
|
dict_T *dict;
|
||||||
|
|
||||||
parse_match(matches[i], &tagp);
|
parse_match(matches[i], &tagp);
|
||||||
|
|
||||||
// Save the tag name
|
// Save the tag name
|
||||||
len = (int)(tagp.tagname_end - tagp.tagname);
|
int len = (int)(tagp.tagname_end - tagp.tagname);
|
||||||
if (len > 128) {
|
if (len > 128) {
|
||||||
len = 128;
|
len = 128;
|
||||||
}
|
}
|
||||||
@ -1016,7 +1011,7 @@ static int add_llist_tags(char *tag, int num_matches, char **matches)
|
|||||||
|
|
||||||
// Get the line number or the search pattern used to locate
|
// Get the line number or the search pattern used to locate
|
||||||
// the tag.
|
// the tag.
|
||||||
lnum = 0;
|
long lnum = 0;
|
||||||
if (isdigit((uint8_t)(*tagp.command))) {
|
if (isdigit((uint8_t)(*tagp.command))) {
|
||||||
// Line number is used to locate the tag
|
// Line number is used to locate the tag
|
||||||
lnum = atol(tagp.command);
|
lnum = atol(tagp.command);
|
||||||
@ -1065,7 +1060,7 @@ static int add_llist_tags(char *tag, int num_matches, char **matches)
|
|||||||
STRCAT(cmd, "\\V");
|
STRCAT(cmd, "\\V");
|
||||||
len += 2;
|
len += 2;
|
||||||
|
|
||||||
cmd_len = (int)(cmd_end - cmd_start + 1);
|
int cmd_len = (int)(cmd_end - cmd_start + 1);
|
||||||
if (cmd_len > (CMDBUFFSIZE - 5)) {
|
if (cmd_len > (CMDBUFFSIZE - 5)) {
|
||||||
cmd_len = CMDBUFFSIZE - 5;
|
cmd_len = CMDBUFFSIZE - 5;
|
||||||
}
|
}
|
||||||
@ -1162,10 +1157,8 @@ void do_tags(exarg_T *eap)
|
|||||||
// Make sure case is folded to uppercase in comparison (like for 'sort -f')
|
// Make sure case is folded to uppercase in comparison (like for 'sort -f')
|
||||||
static int tag_strnicmp(char *s1, char *s2, size_t len)
|
static int tag_strnicmp(char *s1, char *s2, size_t len)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
|
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
i = TOUPPER_ASC((uint8_t)(*s1)) - TOUPPER_ASC((uint8_t)(*s2));
|
int i = TOUPPER_ASC((uint8_t)(*s1)) - TOUPPER_ASC((uint8_t)(*s2));
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
return i; // this character different
|
return i; // this character different
|
||||||
}
|
}
|
||||||
@ -1733,14 +1726,13 @@ static tagmatch_status_T findtags_parse_line(findtags_state_T *st, tagptrs_T *ta
|
|||||||
tagsearch_info_T *sinfo_p)
|
tagsearch_info_T *sinfo_p)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
int i;
|
|
||||||
int cmplen;
|
|
||||||
int tagcmp;
|
|
||||||
|
|
||||||
// Figure out where the different strings are in this line.
|
// Figure out where the different strings are in this line.
|
||||||
// For "normal" tags: Do a quick check if the tag matches.
|
// For "normal" tags: Do a quick check if the tag matches.
|
||||||
// This speeds up tag searching a lot!
|
// This speeds up tag searching a lot!
|
||||||
if (st->orgpat->headlen) {
|
if (st->orgpat->headlen) {
|
||||||
|
int i;
|
||||||
|
int tagcmp;
|
||||||
CLEAR_FIELD(*tagpp);
|
CLEAR_FIELD(*tagpp);
|
||||||
tagpp->tagname = st->lbuf;
|
tagpp->tagname = st->lbuf;
|
||||||
tagpp->tagname_end = vim_strchr(st->lbuf, TAB);
|
tagpp->tagname_end = vim_strchr(st->lbuf, TAB);
|
||||||
@ -1751,7 +1743,7 @@ static tagmatch_status_T findtags_parse_line(findtags_state_T *st, tagptrs_T *ta
|
|||||||
|
|
||||||
// Skip this line if the length of the tag is different and
|
// Skip this line if the length of the tag is different and
|
||||||
// there is no regexp, or the tag is too short.
|
// there is no regexp, or the tag is too short.
|
||||||
cmplen = (int)(tagpp->tagname_end - tagpp->tagname);
|
int cmplen = (int)(tagpp->tagname_end - tagpp->tagname);
|
||||||
if (p_tl != 0 && cmplen > p_tl) { // adjust for 'taglength'
|
if (p_tl != 0 && cmplen > p_tl) { // adjust for 'taglength'
|
||||||
cmplen = (int)p_tl;
|
cmplen = (int)p_tl;
|
||||||
}
|
}
|
||||||
@ -2719,7 +2711,7 @@ static int parse_match(char *lbuf, tagptrs_T *tagp)
|
|||||||
{
|
{
|
||||||
int retval;
|
int retval;
|
||||||
char *p;
|
char *p;
|
||||||
char *pc, *pt;
|
char *pt;
|
||||||
|
|
||||||
tagp->tag_fname = lbuf + 1;
|
tagp->tag_fname = lbuf + 1;
|
||||||
lbuf += strlen(tagp->tag_fname) + 2;
|
lbuf += strlen(tagp->tag_fname) + 2;
|
||||||
@ -2739,6 +2731,7 @@ static int parse_match(char *lbuf, tagptrs_T *tagp)
|
|||||||
// Try to find a kind field: "kind:<kind>" or just "<kind>"
|
// Try to find a kind field: "kind:<kind>" or just "<kind>"
|
||||||
p = tagp->command;
|
p = tagp->command;
|
||||||
if (find_extra(&p) == OK) {
|
if (find_extra(&p) == OK) {
|
||||||
|
char *pc;
|
||||||
tagp->command_end = p;
|
tagp->command_end = p;
|
||||||
if (p > tagp->command && p[-1] == '|') {
|
if (p > tagp->command && p[-1] == '|') {
|
||||||
tagp->command_end = p - 1; // drop trailing bar
|
tagp->command_end = p - 1; // drop trailing bar
|
||||||
@ -2995,7 +2988,6 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help)
|
|||||||
retval = OK;
|
retval = OK;
|
||||||
} else {
|
} else {
|
||||||
int found = 1;
|
int found = 1;
|
||||||
char cc;
|
|
||||||
|
|
||||||
// try again, ignore case now
|
// try again, ignore case now
|
||||||
p_ic = true;
|
p_ic = true;
|
||||||
@ -3004,7 +2996,7 @@ static int jumpto_tag(const char *lbuf_arg, int forceit, int keep_help)
|
|||||||
// Failed to find pattern, take a guess: "^func ("
|
// Failed to find pattern, take a guess: "^func ("
|
||||||
found = 2;
|
found = 2;
|
||||||
(void)test_for_static(&tagp);
|
(void)test_for_static(&tagp);
|
||||||
cc = *tagp.tagname_end;
|
char cc = *tagp.tagname_end;
|
||||||
*tagp.tagname_end = NUL;
|
*tagp.tagname_end = NUL;
|
||||||
snprintf(pbuf, LSIZE, "^%s\\s\\*(", tagp.tagname);
|
snprintf(pbuf, LSIZE, "^%s\\s\\*(", tagp.tagname);
|
||||||
if (!do_search(NULL, '/', '/', pbuf, (long)1, search_options, NULL)) {
|
if (!do_search(NULL, '/', '/', pbuf, (long)1, search_options, NULL)) {
|
||||||
@ -3155,10 +3147,10 @@ static char *expand_tag_fname(char *fname, char *const tag_fname, const bool exp
|
|||||||
/// file.
|
/// file.
|
||||||
static int test_for_current(char *fname, char *fname_end, char *tag_fname, char *buf_ffname)
|
static int test_for_current(char *fname, char *fname_end, char *tag_fname, char *buf_ffname)
|
||||||
{
|
{
|
||||||
char c;
|
|
||||||
int retval = false;
|
int retval = false;
|
||||||
|
|
||||||
if (buf_ffname != NULL) { // if the buffer has a name
|
if (buf_ffname != NULL) { // if the buffer has a name
|
||||||
|
char c;
|
||||||
{
|
{
|
||||||
c = *fname_end;
|
c = *fname_end;
|
||||||
*fname_end = NUL;
|
*fname_end = NUL;
|
||||||
@ -3225,7 +3217,6 @@ static void tagstack_clear_entry(taggy_T *item)
|
|||||||
/// @param tagnames expand tag names
|
/// @param tagnames expand tag names
|
||||||
int expand_tags(int tagnames, char *pat, int *num_file, char ***file)
|
int expand_tags(int tagnames, char *pat, int *num_file, char ***file)
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
int extra_flag;
|
int extra_flag;
|
||||||
char *name_buf;
|
char *name_buf;
|
||||||
size_t name_buf_size = 100;
|
size_t name_buf_size = 100;
|
||||||
@ -3251,7 +3242,7 @@ int expand_tags(int tagnames, char *pat, int *num_file, char ***file)
|
|||||||
if (ret == OK && !tagnames) {
|
if (ret == OK && !tagnames) {
|
||||||
// Reorganize the tags for display and matching as strings of:
|
// Reorganize the tags for display and matching as strings of:
|
||||||
// "<tagname>\0<kind>\0<filename>\0"
|
// "<tagname>\0<kind>\0<filename>\0"
|
||||||
for (i = 0; i < *num_file; i++) {
|
for (int i = 0; i < *num_file; i++) {
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
parse_match((*file)[i], &t_p);
|
parse_match((*file)[i], &t_p);
|
||||||
@ -3327,7 +3318,6 @@ int get_tags(list_T *list, char *pat, char *buf_fname)
|
|||||||
char *full_fname;
|
char *full_fname;
|
||||||
dict_T *dict;
|
dict_T *dict;
|
||||||
tagptrs_T tp;
|
tagptrs_T tp;
|
||||||
bool is_static;
|
|
||||||
|
|
||||||
ret = find_tags(pat, &num_matches, &matches,
|
ret = find_tags(pat, &num_matches, &matches,
|
||||||
TAG_REGEXP | TAG_NOIC, MAXCOL, buf_fname);
|
TAG_REGEXP | TAG_NOIC, MAXCOL, buf_fname);
|
||||||
@ -3342,7 +3332,7 @@ int get_tags(list_T *list, char *pat, char *buf_fname)
|
|||||||
(void)parse_result;
|
(void)parse_result;
|
||||||
assert(parse_result == OK);
|
assert(parse_result == OK);
|
||||||
|
|
||||||
is_static = test_for_static(&tp);
|
bool is_static = test_for_static(&tp);
|
||||||
|
|
||||||
// Skip pseudo-tag lines.
|
// Skip pseudo-tag lines.
|
||||||
if (strncmp(tp.tagname, "!_TAG_", 6) == 0) {
|
if (strncmp(tp.tagname, "!_TAG_", 6) == 0) {
|
||||||
@ -3377,7 +3367,7 @@ int get_tags(list_T *list, char *pat, char *buf_fname)
|
|||||||
// skip "file:" (static tag)
|
// skip "file:" (static tag)
|
||||||
p += 4;
|
p += 4;
|
||||||
} else if (!ascii_iswhite(*p)) {
|
} else if (!ascii_iswhite(*p)) {
|
||||||
char *s, *n;
|
char *n;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
// Add extra field as a dict entry. Fields are
|
// Add extra field as a dict entry. Fields are
|
||||||
@ -3388,7 +3378,7 @@ int get_tags(list_T *list, char *pat, char *buf_fname)
|
|||||||
}
|
}
|
||||||
len = (int)(p - n);
|
len = (int)(p - n);
|
||||||
if (*p == ':' && len > 0) {
|
if (*p == ':' && len > 0) {
|
||||||
s = ++p;
|
char *s = ++p;
|
||||||
while (*p != NUL && (uint8_t)(*p) >= ' ') {
|
while (*p != NUL && (uint8_t)(*p) >= ' ') {
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
@ -3447,7 +3437,6 @@ void get_tagstack(win_T *wp, dict_T *retdict)
|
|||||||
{
|
{
|
||||||
list_T *l;
|
list_T *l;
|
||||||
int i;
|
int i;
|
||||||
dict_T *d;
|
|
||||||
|
|
||||||
tv_dict_add_nr(retdict, S_LEN("length"), wp->w_tagstacklen);
|
tv_dict_add_nr(retdict, S_LEN("length"), wp->w_tagstacklen);
|
||||||
tv_dict_add_nr(retdict, S_LEN("curidx"), wp->w_tagstackidx + 1);
|
tv_dict_add_nr(retdict, S_LEN("curidx"), wp->w_tagstackidx + 1);
|
||||||
@ -3455,7 +3444,7 @@ void get_tagstack(win_T *wp, dict_T *retdict)
|
|||||||
tv_dict_add_list(retdict, S_LEN("items"), l);
|
tv_dict_add_list(retdict, S_LEN("items"), l);
|
||||||
|
|
||||||
for (i = 0; i < wp->w_tagstacklen; i++) {
|
for (i = 0; i < wp->w_tagstacklen; i++) {
|
||||||
d = tv_dict_alloc();
|
dict_T *d = tv_dict_alloc();
|
||||||
tv_list_append_dict(l, d);
|
tv_list_append_dict(l, d);
|
||||||
get_tag_details(&wp->w_tagstack[i], d);
|
get_tag_details(&wp->w_tagstack[i], d);
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,6 @@ found:
|
|||||||
bool findpar(bool *pincl, int dir, long count, int what, bool both)
|
bool findpar(bool *pincl, int dir, long count, int what, bool both)
|
||||||
{
|
{
|
||||||
linenr_T curr;
|
linenr_T curr;
|
||||||
bool did_skip; // true after separating lines have been skipped
|
|
||||||
bool first; // true on first line
|
bool first; // true on first line
|
||||||
linenr_T fold_first; // first line of a closed fold
|
linenr_T fold_first; // first line of a closed fold
|
||||||
linenr_T fold_last; // last line of a closed fold
|
linenr_T fold_last; // last line of a closed fold
|
||||||
@ -186,7 +185,7 @@ bool findpar(bool *pincl, int dir, long count, int what, bool both)
|
|||||||
curr = curwin->w_cursor.lnum;
|
curr = curwin->w_cursor.lnum;
|
||||||
|
|
||||||
while (count--) {
|
while (count--) {
|
||||||
did_skip = false;
|
bool did_skip = false; // true after separating lines have been skipped
|
||||||
for (first = true;; first = false) {
|
for (first = true;; first = false) {
|
||||||
if (*ml_get(curr) != NUL) {
|
if (*ml_get(curr) != NUL) {
|
||||||
did_skip = true;
|
did_skip = true;
|
||||||
@ -324,10 +323,6 @@ static int cls(void)
|
|||||||
/// @param bigword "W", "E" or "B"
|
/// @param bigword "W", "E" or "B"
|
||||||
int fwd_word(long count, bool bigword, bool eol)
|
int fwd_word(long count, bool bigword, bool eol)
|
||||||
{
|
{
|
||||||
int sclass; // starting class
|
|
||||||
int i;
|
|
||||||
int last_line;
|
|
||||||
|
|
||||||
curwin->w_cursor.coladd = 0;
|
curwin->w_cursor.coladd = 0;
|
||||||
cls_bigword = bigword;
|
cls_bigword = bigword;
|
||||||
while (--count >= 0) {
|
while (--count >= 0) {
|
||||||
@ -336,12 +331,12 @@ int fwd_word(long count, bool bigword, bool eol)
|
|||||||
if (hasFolding(curwin->w_cursor.lnum, NULL, &curwin->w_cursor.lnum)) {
|
if (hasFolding(curwin->w_cursor.lnum, NULL, &curwin->w_cursor.lnum)) {
|
||||||
coladvance(MAXCOL);
|
coladvance(MAXCOL);
|
||||||
}
|
}
|
||||||
sclass = cls();
|
int sclass = cls(); // starting class
|
||||||
|
|
||||||
// We always move at least one character, unless on the last
|
// We always move at least one character, unless on the last
|
||||||
// character in the buffer.
|
// character in the buffer.
|
||||||
last_line = (curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count);
|
int last_line = (curwin->w_cursor.lnum == curbuf->b_ml.ml_line_count);
|
||||||
i = inc_cursor();
|
int i = inc_cursor();
|
||||||
if (i == -1 || (i >= 1 && last_line)) { // started at last char in file
|
if (i == -1 || (i >= 1 && last_line)) { // started at last char in file
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -493,13 +488,11 @@ finished:
|
|||||||
/// @return FAIL if start of the file was reached.
|
/// @return FAIL if start of the file was reached.
|
||||||
int bckend_word(long count, bool bigword, bool eol)
|
int bckend_word(long count, bool bigword, bool eol)
|
||||||
{
|
{
|
||||||
int sclass; // starting class
|
|
||||||
int i;
|
|
||||||
|
|
||||||
curwin->w_cursor.coladd = 0;
|
curwin->w_cursor.coladd = 0;
|
||||||
cls_bigword = bigword;
|
cls_bigword = bigword;
|
||||||
while (--count >= 0) {
|
while (--count >= 0) {
|
||||||
sclass = cls();
|
int i;
|
||||||
|
int sclass = cls(); // starting class
|
||||||
if ((i = dec_cursor()) == -1) {
|
if ((i = dec_cursor()) == -1) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
@ -562,10 +555,8 @@ static void back_in_line(void)
|
|||||||
|
|
||||||
static void find_first_blank(pos_T *posp)
|
static void find_first_blank(pos_T *posp)
|
||||||
{
|
{
|
||||||
int c;
|
|
||||||
|
|
||||||
while (decl(posp) != -1) {
|
while (decl(posp) != -1) {
|
||||||
c = gchar_pos(posp);
|
int c = gchar_pos(posp);
|
||||||
if (!ascii_iswhite(c)) {
|
if (!ascii_iswhite(c)) {
|
||||||
incl(posp);
|
incl(posp);
|
||||||
break;
|
break;
|
||||||
@ -598,7 +589,6 @@ static void findsent_forward(long count, bool at_start_sent)
|
|||||||
int current_word(oparg_T *oap, long count, bool include, bool bigword)
|
int current_word(oparg_T *oap, long count, bool include, bool bigword)
|
||||||
{
|
{
|
||||||
pos_T start_pos;
|
pos_T start_pos;
|
||||||
pos_T pos;
|
|
||||||
bool inclusive = true;
|
bool inclusive = true;
|
||||||
int include_white = false;
|
int include_white = false;
|
||||||
|
|
||||||
@ -703,7 +693,7 @@ int current_word(oparg_T *oap, long count, bool include, bool bigword)
|
|||||||
// word). Also when "2daw" deletes "word." at the end of the line
|
// word). Also when "2daw" deletes "word." at the end of the line
|
||||||
// (cursor is at start of next line).
|
// (cursor is at start of next line).
|
||||||
// But don't delete white space at start of line (indent).
|
// But don't delete white space at start of line (indent).
|
||||||
pos = curwin->w_cursor; // save cursor position
|
pos_T pos = curwin->w_cursor; // save cursor position
|
||||||
curwin->w_cursor = start_pos;
|
curwin->w_cursor = start_pos;
|
||||||
if (oneleft() == OK) {
|
if (oneleft() == OK) {
|
||||||
back_in_line();
|
back_in_line();
|
||||||
@ -1042,7 +1032,6 @@ static bool in_html_tag(bool end_tag)
|
|||||||
{
|
{
|
||||||
char *line = get_cursor_line_ptr();
|
char *line = get_cursor_line_ptr();
|
||||||
char *p;
|
char *p;
|
||||||
int c;
|
|
||||||
int lc = NUL;
|
int lc = NUL;
|
||||||
pos_T pos;
|
pos_T pos;
|
||||||
|
|
||||||
@ -1078,7 +1067,7 @@ static bool in_html_tag(bool end_tag)
|
|||||||
if (inc(&pos) < 0) {
|
if (inc(&pos) < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
c = (uint8_t)(*ml_get_pos(&pos));
|
int c = (uint8_t)(*ml_get_pos(&pos));
|
||||||
if (c == '>') {
|
if (c == '>') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1443,10 +1432,8 @@ extend:
|
|||||||
/// @return column number of "quotechar" or -1 when not found.
|
/// @return column number of "quotechar" or -1 when not found.
|
||||||
static int find_next_quote(char *line, int col, int quotechar, char *escape)
|
static int find_next_quote(char *line, int col, int quotechar, char *escape)
|
||||||
{
|
{
|
||||||
int c;
|
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
c = (uint8_t)line[col];
|
int c = (uint8_t)line[col];
|
||||||
if (c == NUL) {
|
if (c == NUL) {
|
||||||
return -1;
|
return -1;
|
||||||
} else if (escape != NULL && vim_strchr(escape, c)) {
|
} else if (escape != NULL && vim_strchr(escape, c)) {
|
||||||
@ -1471,12 +1458,10 @@ static int find_next_quote(char *line, int col, int quotechar, char *escape)
|
|||||||
/// @return the found column or zero.
|
/// @return the found column or zero.
|
||||||
static int find_prev_quote(char *line, int col_start, int quotechar, char *escape)
|
static int find_prev_quote(char *line, int col_start, int quotechar, char *escape)
|
||||||
{
|
{
|
||||||
int n;
|
|
||||||
|
|
||||||
while (col_start > 0) {
|
while (col_start > 0) {
|
||||||
col_start--;
|
col_start--;
|
||||||
col_start -= utf_head_off(line, line + col_start);
|
col_start -= utf_head_off(line, line + col_start);
|
||||||
n = 0;
|
int n = 0;
|
||||||
if (escape != NULL) {
|
if (escape != NULL) {
|
||||||
while (col_start - n > 0 && vim_strchr(escape,
|
while (col_start - n > 0 && vim_strchr(escape,
|
||||||
(uint8_t)line[col_start - n - 1]) != NULL) {
|
(uint8_t)line[col_start - n - 1]) != NULL) {
|
||||||
|
Loading…
Reference in New Issue
Block a user