mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #20026 from dundargoc/refactor/char_u/7
refactor: replace char_u with char 7: remove `vim_strnsave`
This commit is contained in:
commit
69456f3414
@ -599,7 +599,7 @@ void ins_bytes_len(char *p, size_t len)
|
|||||||
size_t n;
|
size_t n;
|
||||||
for (size_t i = 0; i < len; i += n) {
|
for (size_t i = 0; i < len; i += n) {
|
||||||
// avoid reading past p[len]
|
// avoid reading past p[len]
|
||||||
n = (size_t)utfc_ptr2len_len((char_u *)p + i, (int)(len - i));
|
n = (size_t)utfc_ptr2len_len(p + i, (int)(len - i));
|
||||||
ins_char_bytes(p + i, n);
|
ins_char_bytes(p + i, n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -828,7 +828,7 @@ int del_bytes(colnr_T count, bool fixpos_arg, bool use_delcombine)
|
|||||||
col = n;
|
col = n;
|
||||||
count = utf_ptr2len(oldp + n);
|
count = utf_ptr2len(oldp + n);
|
||||||
n += count;
|
n += count;
|
||||||
} while (utf_composinglike((char_u *)oldp + col, (char_u *)oldp + n));
|
} while (utf_composinglike(oldp + col, oldp + n));
|
||||||
fixpos = false;
|
fixpos = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1036,7 +1036,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
|
|||||||
colnr_T mincol = curwin->w_cursor.col + 1;
|
colnr_T mincol = curwin->w_cursor.col + 1;
|
||||||
|
|
||||||
// make a copy of the current line so we can mess with it
|
// make a copy of the current line so we can mess with it
|
||||||
char *saved_line = (char *)vim_strsave(get_cursor_line_ptr());
|
char *saved_line = (char *)vim_strsave((char_u *)get_cursor_line_ptr());
|
||||||
|
|
||||||
if (State & VREPLACE_FLAG) {
|
if (State & VREPLACE_FLAG) {
|
||||||
// With MODE_VREPLACE we make a copy of the next line, which we will be
|
// With MODE_VREPLACE we make a copy of the next line, which we will be
|
||||||
@ -1181,7 +1181,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
|
|||||||
if ((pos = findmatch(NULL, '(')) != NULL) {
|
if ((pos = findmatch(NULL, '(')) != NULL) {
|
||||||
curwin->w_cursor.lnum = pos->lnum;
|
curwin->w_cursor.lnum = pos->lnum;
|
||||||
newindent = get_indent();
|
newindent = get_indent();
|
||||||
ptr = (char *)get_cursor_line_ptr();
|
ptr = get_cursor_line_ptr();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If last character is '{' do indent, without
|
// If last character is '{' do indent, without
|
||||||
@ -1838,7 +1838,7 @@ int open_line(int dir, int flags, int second_line_indent, bool *did_do_comment)
|
|||||||
// stuff onto the replace stack (via ins_char()).
|
// stuff onto the replace stack (via ins_char()).
|
||||||
if (State & VREPLACE_FLAG) {
|
if (State & VREPLACE_FLAG) {
|
||||||
// Put new line in p_extra
|
// Put new line in p_extra
|
||||||
p_extra = (char *)vim_strsave(get_cursor_line_ptr());
|
p_extra = xstrdup(get_cursor_line_ptr());
|
||||||
|
|
||||||
// Put back original line
|
// Put back original line
|
||||||
ml_replace(curwin->w_cursor.lnum, next_line, false);
|
ml_replace(curwin->w_cursor.lnum, next_line, false);
|
||||||
|
@ -789,7 +789,7 @@ bool vim_iswordc_buf(const int c, buf_T *const buf)
|
|||||||
bool vim_iswordp(const char_u *const p)
|
bool vim_iswordp(const char_u *const p)
|
||||||
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
return vim_iswordp_buf(p, curbuf);
|
return vim_iswordp_buf((char *)p, curbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Just like vim_iswordc_buf() but uses a pointer to the (multi-byte)
|
/// Just like vim_iswordc_buf() but uses a pointer to the (multi-byte)
|
||||||
@ -799,13 +799,13 @@ bool vim_iswordp(const char_u *const p)
|
|||||||
/// @param buf buffer whose keywords to use
|
/// @param buf buffer whose keywords to use
|
||||||
///
|
///
|
||||||
/// @return true if "p" points to a keyword character.
|
/// @return true if "p" points to a keyword character.
|
||||||
bool vim_iswordp_buf(const char_u *const p, buf_T *const buf)
|
bool vim_iswordp_buf(const char *const p, buf_T *const buf)
|
||||||
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
int c = *p;
|
int c = (uint8_t)(*p);
|
||||||
|
|
||||||
if (MB_BYTE2LEN(c) > 1) {
|
if (MB_BYTE2LEN(c) > 1) {
|
||||||
c = utf_ptr2char((char *)p);
|
c = utf_ptr2char(p);
|
||||||
}
|
}
|
||||||
return vim_iswordc_buf(c, buf);
|
return vim_iswordc_buf(c, buf);
|
||||||
}
|
}
|
||||||
@ -829,8 +829,8 @@ bool vim_isfilec(int c)
|
|||||||
bool vim_isfilec_or_wc(int c)
|
bool vim_isfilec_or_wc(int c)
|
||||||
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
{
|
{
|
||||||
char_u buf[2];
|
char buf[2];
|
||||||
buf[0] = (char_u)c;
|
buf[0] = (char)c;
|
||||||
buf[1] = NUL;
|
buf[1] = NUL;
|
||||||
return vim_isfilec(c) || c == ']' || path_has_wildcard(buf);
|
return vim_isfilec(c) || c == ']' || path_has_wildcard(buf);
|
||||||
}
|
}
|
||||||
@ -905,15 +905,15 @@ bool in_win_border(win_T *wp, colnr_T vcol)
|
|||||||
/// @param end
|
/// @param end
|
||||||
void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *end)
|
void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *end)
|
||||||
{
|
{
|
||||||
char_u *ptr; // points to current char
|
char *ptr; // points to current char
|
||||||
char_u *posptr; // points to char at pos->col
|
char *posptr; // points to char at pos->col
|
||||||
int incr;
|
int incr;
|
||||||
int head;
|
int head;
|
||||||
long *vts = wp->w_buffer->b_p_vts_array;
|
long *vts = wp->w_buffer->b_p_vts_array;
|
||||||
int ts = (int)wp->w_buffer->b_p_ts;
|
int ts = (int)wp->w_buffer->b_p_ts;
|
||||||
|
|
||||||
colnr_T vcol = 0;
|
colnr_T vcol = 0;
|
||||||
char_u *line = ptr = ml_get_buf(wp->w_buffer, pos->lnum, false); // start of the line
|
char *line = ptr = (char *)ml_get_buf(wp->w_buffer, pos->lnum, false); // start of the line
|
||||||
|
|
||||||
if (pos->col == MAXCOL) {
|
if (pos->col == MAXCOL) {
|
||||||
// continue until the NUL
|
// continue until the NUL
|
||||||
@ -927,11 +927,11 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
posptr = ptr + pos->col;
|
posptr = ptr + pos->col;
|
||||||
posptr -= utf_head_off((char *)line, (char *)posptr);
|
posptr -= utf_head_off(line, posptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
chartabsize_T cts;
|
chartabsize_T cts;
|
||||||
init_chartabsize_arg(&cts, wp, pos->lnum, 0, (char *)line, (char *)line);
|
init_chartabsize_arg(&cts, wp, pos->lnum, 0, line, line);
|
||||||
|
|
||||||
// This function is used very often, do some speed optimizations.
|
// This function is used very often, do some speed optimizations.
|
||||||
// When 'list', 'linebreak', 'showbreak' and 'breakindent' are not set
|
// When 'list', 'linebreak', 'showbreak' and 'breakindent' are not set
|
||||||
@ -944,7 +944,7 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en
|
|||||||
&& !cts.cts_has_virt_text) {
|
&& !cts.cts_has_virt_text) {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
head = 0;
|
head = 0;
|
||||||
int c = *ptr;
|
int c = (uint8_t)(*ptr);
|
||||||
|
|
||||||
// make sure we don't go past the end of the line
|
// make sure we don't go past the end of the line
|
||||||
if (c == NUL) {
|
if (c == NUL) {
|
||||||
@ -960,7 +960,7 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en
|
|||||||
// For utf-8, if the byte is >= 0x80, need to look at
|
// For utf-8, if the byte is >= 0x80, need to look at
|
||||||
// further bytes to find the cell width.
|
// further bytes to find the cell width.
|
||||||
if (c >= 0x80) {
|
if (c >= 0x80) {
|
||||||
incr = utf_ptr2cells((char *)ptr);
|
incr = utf_ptr2cells(ptr);
|
||||||
} else {
|
} else {
|
||||||
incr = g_chartab[c] & CT_CELL_MASK;
|
incr = g_chartab[c] & CT_CELL_MASK;
|
||||||
}
|
}
|
||||||
@ -970,7 +970,7 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en
|
|||||||
// cells wide.
|
// cells wide.
|
||||||
if ((incr == 2)
|
if ((incr == 2)
|
||||||
&& wp->w_p_wrap
|
&& wp->w_p_wrap
|
||||||
&& (MB_BYTE2LEN(*ptr) > 1)
|
&& (MB_BYTE2LEN((uint8_t)(*ptr)) > 1)
|
||||||
&& in_win_border(wp, vcol)) {
|
&& in_win_border(wp, vcol)) {
|
||||||
incr++;
|
incr++;
|
||||||
head = 1;
|
head = 1;
|
||||||
@ -999,7 +999,7 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((posptr != NULL) && ((char_u *)cts.cts_ptr >= posptr)) {
|
if ((posptr != NULL) && (cts.cts_ptr >= posptr)) {
|
||||||
// character at pos->col
|
// character at pos->col
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1008,7 +1008,7 @@ void getvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *en
|
|||||||
MB_PTR_ADV(cts.cts_ptr);
|
MB_PTR_ADV(cts.cts_ptr);
|
||||||
}
|
}
|
||||||
vcol = cts.cts_vcol;
|
vcol = cts.cts_vcol;
|
||||||
ptr = (char_u *)cts.cts_ptr;
|
ptr = cts.cts_ptr;
|
||||||
}
|
}
|
||||||
clear_chartabsize_arg(&cts);
|
clear_chartabsize_arg(&cts);
|
||||||
|
|
||||||
@ -1076,10 +1076,10 @@ void getvvcol(win_T *wp, pos_T *pos, colnr_T *start, colnr_T *cursor, colnr_T *e
|
|||||||
colnr_T endadd = 0;
|
colnr_T endadd = 0;
|
||||||
|
|
||||||
// Cannot put the cursor on part of a wide character.
|
// Cannot put the cursor on part of a wide character.
|
||||||
char_u *ptr = ml_get_buf(wp->w_buffer, pos->lnum, false);
|
char *ptr = (char *)ml_get_buf(wp->w_buffer, pos->lnum, false);
|
||||||
|
|
||||||
if (pos->col < (colnr_T)STRLEN(ptr)) {
|
if (pos->col < (colnr_T)STRLEN(ptr)) {
|
||||||
int c = utf_ptr2char((char *)ptr + pos->col);
|
int c = utf_ptr2char(ptr + pos->col);
|
||||||
if ((c != TAB) && vim_isprintc(c)) {
|
if ((c != TAB) && vim_isprintc(c)) {
|
||||||
endadd = (colnr_T)(char2cells(c) - 1);
|
endadd = (colnr_T)(char2cells(c) - 1);
|
||||||
if (coladd > endadd) {
|
if (coladd > endadd) {
|
||||||
@ -1182,7 +1182,7 @@ char *skipwhite_len(const char *p, size_t len)
|
|||||||
// columns (bytes) at the start of a given line
|
// columns (bytes) at the start of a given line
|
||||||
intptr_t getwhitecols_curline(void)
|
intptr_t getwhitecols_curline(void)
|
||||||
{
|
{
|
||||||
return getwhitecols((char *)get_cursor_line_ptr());
|
return getwhitecols(get_cursor_line_ptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
intptr_t getwhitecols(const char *p)
|
intptr_t getwhitecols(const char *p)
|
||||||
@ -1338,7 +1338,7 @@ char *skip_to_newline(const char *const p)
|
|||||||
|
|
||||||
/// Gets a number from a string and skips over it, signalling overflow.
|
/// Gets a number from a string and skips over it, signalling overflow.
|
||||||
///
|
///
|
||||||
/// @param[out] pp A pointer to a pointer to char_u.
|
/// @param[out] pp A pointer to a pointer to char.
|
||||||
/// It will be advanced past the read number.
|
/// It will be advanced past the read number.
|
||||||
/// @param[out] nr Number read from the string.
|
/// @param[out] nr Number read from the string.
|
||||||
///
|
///
|
||||||
@ -1355,7 +1355,7 @@ bool try_getdigits(char **pp, intmax_t *nr)
|
|||||||
|
|
||||||
/// Gets a number from a string and skips over it.
|
/// Gets a number from a string and skips over it.
|
||||||
///
|
///
|
||||||
/// @param[out] pp Pointer to a pointer to char_u.
|
/// @param[out] pp Pointer to a pointer to char.
|
||||||
/// It will be advanced past the read number.
|
/// It will be advanced past the read number.
|
||||||
/// @param strict Abort on overflow.
|
/// @param strict Abort on overflow.
|
||||||
/// @param def Default value, if parsing fails or overflow occurs.
|
/// @param def Default value, if parsing fails or overflow occurs.
|
||||||
@ -1463,14 +1463,14 @@ bool vim_isblankline(char *lbuf)
|
|||||||
/// @param strict If true, fail if the number has unexpected trailing
|
/// @param strict If true, fail if the number has unexpected trailing
|
||||||
/// alphanumeric chars: *len is set to 0 and nothing else is
|
/// alphanumeric chars: *len is set to 0 and nothing else is
|
||||||
/// returned.
|
/// returned.
|
||||||
void vim_str2nr(const char_u *const start, int *const prep, int *const len, const int what,
|
void vim_str2nr(const char *const start, int *const prep, int *const len, const int what,
|
||||||
varnumber_T *const nptr, uvarnumber_T *const unptr, const int maxlen,
|
varnumber_T *const nptr, uvarnumber_T *const unptr, const int maxlen,
|
||||||
const bool strict)
|
const bool strict)
|
||||||
FUNC_ATTR_NONNULL_ARG(1)
|
FUNC_ATTR_NONNULL_ARG(1)
|
||||||
{
|
{
|
||||||
const char *ptr = (const char *)start;
|
const char *ptr = start;
|
||||||
#define STRING_ENDED(ptr) \
|
#define STRING_ENDED(ptr) \
|
||||||
(!(maxlen == 0 || (int)((ptr) - (const char *)start) < maxlen))
|
(!(maxlen == 0 || (int)((ptr) - start) < maxlen))
|
||||||
int pre = 0; // default is decimal
|
int pre = 0; // default is decimal
|
||||||
const bool negative = (ptr[0] == '-');
|
const bool negative = (ptr[0] == '-');
|
||||||
uvarnumber_T un = 0;
|
uvarnumber_T un = 0;
|
||||||
@ -1522,7 +1522,7 @@ void vim_str2nr(const char_u *const start, int *const prep, int *const len, cons
|
|||||||
} else if ((what & (STR2NR_HEX | STR2NR_OCT | STR2NR_OOCT | STR2NR_BIN))
|
} else if ((what & (STR2NR_HEX | STR2NR_OCT | STR2NR_OOCT | STR2NR_BIN))
|
||||||
&& !STRING_ENDED(ptr + 1) && ptr[0] == '0' && ptr[1] != '8'
|
&& !STRING_ENDED(ptr + 1) && ptr[0] == '0' && ptr[1] != '8'
|
||||||
&& ptr[1] != '9') {
|
&& ptr[1] != '9') {
|
||||||
pre = (char_u)ptr[1];
|
pre = (uint8_t)ptr[1];
|
||||||
// Detect hexadecimal: 0x or 0X followed by hex digit.
|
// Detect hexadecimal: 0x or 0X followed by hex digit.
|
||||||
if ((what & STR2NR_HEX)
|
if ((what & STR2NR_HEX)
|
||||||
&& !STRING_ENDED(ptr + 2)
|
&& !STRING_ENDED(ptr + 2)
|
||||||
@ -1610,7 +1610,7 @@ vim_str2nr_hex:
|
|||||||
vim_str2nr_proceed:
|
vim_str2nr_proceed:
|
||||||
// Check for an alphanumeric character immediately following, that is
|
// Check for an alphanumeric character immediately following, that is
|
||||||
// most likely a typo.
|
// most likely a typo.
|
||||||
if (strict && ptr - (const char *)start != maxlen && ASCII_ISALNUM(*ptr)) {
|
if (strict && ptr - start != maxlen && ASCII_ISALNUM(*ptr)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1619,7 +1619,7 @@ vim_str2nr_proceed:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (len != NULL) {
|
if (len != NULL) {
|
||||||
*len = (int)(ptr - (const char *)start);
|
*len = (int)(ptr - start);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nptr != NULL) {
|
if (nptr != NULL) {
|
||||||
|
@ -177,7 +177,7 @@ int nextwild(expand_T *xp, int type, int options, bool escape)
|
|||||||
ui_flush();
|
ui_flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
i = (int)((char_u *)xp->xp_pattern - ccline->cmdbuff);
|
i = (int)(xp->xp_pattern - ccline->cmdbuff);
|
||||||
assert(ccline->cmdpos >= i);
|
assert(ccline->cmdpos >= i);
|
||||||
xp->xp_pattern_len = (size_t)ccline->cmdpos - (size_t)i;
|
xp->xp_pattern_len = (size_t)ccline->cmdpos - (size_t)i;
|
||||||
|
|
||||||
@ -186,20 +186,20 @@ int nextwild(expand_T *xp, int type, int options, bool escape)
|
|||||||
p2 = ExpandOne(xp, NULL, NULL, 0, type);
|
p2 = ExpandOne(xp, NULL, NULL, 0, type);
|
||||||
} else {
|
} else {
|
||||||
// Translate string into pattern and expand it.
|
// Translate string into pattern and expand it.
|
||||||
p1 = addstar((char_u *)xp->xp_pattern, xp->xp_pattern_len, xp->xp_context);
|
p1 = (char_u *)addstar(xp->xp_pattern, xp->xp_pattern_len, xp->xp_context);
|
||||||
const int use_options = (options
|
const int use_options = (options
|
||||||
| WILD_HOME_REPLACE
|
| WILD_HOME_REPLACE
|
||||||
| WILD_ADD_SLASH
|
| WILD_ADD_SLASH
|
||||||
| WILD_SILENT
|
| WILD_SILENT
|
||||||
| (escape ? WILD_ESCAPE : 0)
|
| (escape ? WILD_ESCAPE : 0)
|
||||||
| (p_wic ? WILD_ICASE : 0));
|
| (p_wic ? WILD_ICASE : 0));
|
||||||
p2 = ExpandOne(xp, p1, vim_strnsave(&ccline->cmdbuff[i], xp->xp_pattern_len),
|
p2 = ExpandOne(xp, p1, (char_u *)xstrnsave(&ccline->cmdbuff[i], xp->xp_pattern_len),
|
||||||
use_options, type);
|
use_options, type);
|
||||||
xfree(p1);
|
xfree(p1);
|
||||||
|
|
||||||
// xp->xp_pattern might have been modified by ExpandOne (for example,
|
// xp->xp_pattern might have been modified by ExpandOne (for example,
|
||||||
// in lua completion), so recompute the pattern index and length
|
// in lua completion), so recompute the pattern index and length
|
||||||
i = (int)((char_u *)xp->xp_pattern - ccline->cmdbuff);
|
i = (int)(xp->xp_pattern - ccline->cmdbuff);
|
||||||
xp->xp_pattern_len = (size_t)ccline->cmdpos - (size_t)i;
|
xp->xp_pattern_len = (size_t)ccline->cmdpos - (size_t)i;
|
||||||
|
|
||||||
// Longest match: make sure it is not shorter, happens with :help.
|
// Longest match: make sure it is not shorter, happens with :help.
|
||||||
@ -220,7 +220,7 @@ int nextwild(expand_T *xp, int type, int options, bool escape)
|
|||||||
difflen = (int)STRLEN(p2) - (int)(xp->xp_pattern_len);
|
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 = (char *)ccline->cmdbuff + i;
|
xp->xp_pattern = ccline->cmdbuff + i;
|
||||||
}
|
}
|
||||||
assert(ccline->cmdpos <= ccline->cmdlen);
|
assert(ccline->cmdpos <= ccline->cmdlen);
|
||||||
memmove(&ccline->cmdbuff[ccline->cmdpos + difflen],
|
memmove(&ccline->cmdbuff[ccline->cmdpos + difflen],
|
||||||
@ -573,7 +573,7 @@ int showmatches(expand_T *xp, int wildmenu)
|
|||||||
|
|
||||||
if (xp->xp_numfiles == -1) {
|
if (xp->xp_numfiles == -1) {
|
||||||
set_expand_context(xp);
|
set_expand_context(xp);
|
||||||
i = expand_cmdline(xp, ccline->cmdbuff, ccline->cmdpos,
|
i = expand_cmdline(xp, (char_u *)ccline->cmdbuff, ccline->cmdpos,
|
||||||
&num_files, &files_found);
|
&num_files, &files_found);
|
||||||
showtail = expand_showtail(xp);
|
showtail = expand_showtail(xp);
|
||||||
if (i != EXPAND_OK) {
|
if (i != EXPAND_OK) {
|
||||||
@ -602,7 +602,7 @@ int showmatches(expand_T *xp, int wildmenu)
|
|||||||
.pum_kind = NULL,
|
.pum_kind = NULL,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
char_u *endpos = (char_u *)(showtail ? sm_gettail(xp->xp_pattern, true) : xp->xp_pattern);
|
char *endpos = (showtail ? sm_gettail(xp->xp_pattern, true) : xp->xp_pattern);
|
||||||
if (ui_has(kUICmdline)) {
|
if (ui_has(kUICmdline)) {
|
||||||
compl_startcol = (int)(endpos - ccline->cmdbuff);
|
compl_startcol = (int)(endpos - ccline->cmdbuff);
|
||||||
} else {
|
} else {
|
||||||
@ -803,13 +803,13 @@ static bool expand_showtail(expand_T *xp)
|
|||||||
/// the name into allocated memory and prepend "^".
|
/// the name into allocated memory and prepend "^".
|
||||||
///
|
///
|
||||||
/// @param context EXPAND_FILES etc.
|
/// @param context EXPAND_FILES etc.
|
||||||
char_u *addstar(char_u *fname, size_t len, int context)
|
char *addstar(char *fname, size_t len, int context)
|
||||||
FUNC_ATTR_NONNULL_RET
|
FUNC_ATTR_NONNULL_RET
|
||||||
{
|
{
|
||||||
char_u *retval;
|
char *retval;
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
size_t new_len;
|
size_t new_len;
|
||||||
char_u *tail;
|
char *tail;
|
||||||
int ends_in_star;
|
int ends_in_star;
|
||||||
|
|
||||||
if (context != EXPAND_FILES
|
if (context != EXPAND_FILES
|
||||||
@ -831,7 +831,7 @@ char_u *addstar(char_u *fname, size_t len, int context)
|
|||||||
|| context == EXPAND_PACKADD
|
|| context == EXPAND_PACKADD
|
||||||
|| ((context == EXPAND_TAGS_LISTFILES || context == EXPAND_TAGS)
|
|| ((context == EXPAND_TAGS_LISTFILES || context == EXPAND_TAGS)
|
||||||
&& fname[0] == '/')) {
|
&& fname[0] == '/')) {
|
||||||
retval = vim_strnsave(fname, len);
|
retval = xstrnsave(fname, len);
|
||||||
} else {
|
} else {
|
||||||
new_len = len + 2; // +2 for '^' at start, NUL at end
|
new_len = len + 2; // +2 for '^' at start, NUL at end
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
@ -901,7 +901,7 @@ char_u *addstar(char_u *fname, size_t len, int context)
|
|||||||
// $ could be anywhere in the tail.
|
// $ could be anywhere in the tail.
|
||||||
// ` could be anywhere in the file name.
|
// ` could be anywhere in the file name.
|
||||||
// When the name ends in '$' don't add a star, remove the '$'.
|
// When the name ends in '$' don't add a star, remove the '$'.
|
||||||
tail = (char_u *)path_tail((char *)retval);
|
tail = path_tail(retval);
|
||||||
ends_in_star = (len > 0 && retval[len - 1] == '*');
|
ends_in_star = (len > 0 && retval[len - 1] == '*');
|
||||||
#ifndef BACKSLASH_IN_FILENAME
|
#ifndef BACKSLASH_IN_FILENAME
|
||||||
for (ssize_t k = (ssize_t)len - 2; k >= 0; k--) {
|
for (ssize_t k = (ssize_t)len - 2; k >= 0; k--) {
|
||||||
@ -913,8 +913,8 @@ char_u *addstar(char_u *fname, size_t len, int context)
|
|||||||
#endif
|
#endif
|
||||||
if ((*retval != '~' || tail != retval)
|
if ((*retval != '~' || tail != retval)
|
||||||
&& !ends_in_star
|
&& !ends_in_star
|
||||||
&& vim_strchr((char *)tail, '$') == NULL
|
&& vim_strchr(tail, '$') == NULL
|
||||||
&& vim_strchr((char *)retval, '`') == NULL) {
|
&& vim_strchr(retval, '`') == NULL) {
|
||||||
retval[len++] = '*';
|
retval[len++] = '*';
|
||||||
} else if (len > 0 && retval[len - 1] == '$') {
|
} else if (len > 0 && retval[len - 1] == '$') {
|
||||||
len--;
|
len--;
|
||||||
@ -976,7 +976,7 @@ void set_expand_context(expand_T *xp)
|
|||||||
xp->xp_context = EXPAND_NOTHING;
|
xp->xp_context = EXPAND_NOTHING;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
set_cmd_context(xp, ccline->cmdbuff, ccline->cmdlen, ccline->cmdpos, true);
|
set_cmd_context(xp, (char_u *)ccline->cmdbuff, ccline->cmdlen, ccline->cmdpos, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the index of a built-in or user defined command "cmd" in eap->cmdidx.
|
/// Sets the index of a built-in or user defined command "cmd" in eap->cmdidx.
|
||||||
@ -1851,7 +1851,7 @@ void set_cmd_context(expand_T *xp, char_u *str, int len, int col, int use_ccline
|
|||||||
set_context_for_expression(xp, (char *)str, CMD_SIZE);
|
set_context_for_expression(xp, (char *)str, CMD_SIZE);
|
||||||
} else if (use_ccline && ccline->input_fn) {
|
} else if (use_ccline && ccline->input_fn) {
|
||||||
xp->xp_context = ccline->xp_context;
|
xp->xp_context = ccline->xp_context;
|
||||||
xp->xp_pattern = (char *)ccline->cmdbuff;
|
xp->xp_pattern = ccline->cmdbuff;
|
||||||
xp->xp_arg = (char *)ccline->xp_arg;
|
xp->xp_arg = (char *)ccline->xp_arg;
|
||||||
} else {
|
} else {
|
||||||
while (nextcomm != NULL) {
|
while (nextcomm != NULL) {
|
||||||
@ -1898,7 +1898,7 @@ int expand_cmdline(expand_T *xp, char_u *str, int col, int *matchcount, char ***
|
|||||||
// add star to file name, or convert to regexp if not exp. files.
|
// add star to file name, or convert to regexp if not exp. files.
|
||||||
assert((str + col) - (char_u *)xp->xp_pattern >= 0);
|
assert((str + col) - (char_u *)xp->xp_pattern >= 0);
|
||||||
xp->xp_pattern_len = (size_t)((str + col) - (char_u *)xp->xp_pattern);
|
xp->xp_pattern_len = (size_t)((str + col) - (char_u *)xp->xp_pattern);
|
||||||
file_str = addstar((char_u *)xp->xp_pattern, xp->xp_pattern_len, xp->xp_context);
|
file_str = (char_u *)addstar(xp->xp_pattern, xp->xp_pattern_len, xp->xp_context);
|
||||||
|
|
||||||
if (p_wic) {
|
if (p_wic) {
|
||||||
options += WILD_ICASE;
|
options += WILD_ICASE;
|
||||||
@ -2438,9 +2438,9 @@ static void *call_user_expand_func(user_expand_func_T user_expand_func, expand_T
|
|||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
CmdlineInfo *const ccline = get_cmdline_info();
|
CmdlineInfo *const ccline = get_cmdline_info();
|
||||||
char_u keep = 0;
|
char keep = 0;
|
||||||
typval_T args[4];
|
typval_T args[4];
|
||||||
char_u *pat = NULL;
|
char *pat = NULL;
|
||||||
const sctx_T save_current_sctx = current_sctx;
|
const sctx_T save_current_sctx = current_sctx;
|
||||||
|
|
||||||
if (xp->xp_arg == NULL || xp->xp_arg[0] == '\0' || xp->xp_line == NULL) {
|
if (xp->xp_arg == NULL || xp->xp_arg[0] == '\0' || xp->xp_line == NULL) {
|
||||||
@ -2454,12 +2454,12 @@ static void *call_user_expand_func(user_expand_func_T user_expand_func, expand_T
|
|||||||
ccline->cmdbuff[ccline->cmdlen] = 0;
|
ccline->cmdbuff[ccline->cmdlen] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pat = vim_strnsave((char_u *)xp->xp_pattern, xp->xp_pattern_len);
|
pat = xstrnsave(xp->xp_pattern, xp->xp_pattern_len);
|
||||||
args[0].v_type = VAR_STRING;
|
args[0].v_type = VAR_STRING;
|
||||||
args[1].v_type = VAR_STRING;
|
args[1].v_type = VAR_STRING;
|
||||||
args[2].v_type = VAR_NUMBER;
|
args[2].v_type = VAR_NUMBER;
|
||||||
args[3].v_type = VAR_UNKNOWN;
|
args[3].v_type = VAR_UNKNOWN;
|
||||||
args[0].vval.v_string = (char *)pat;
|
args[0].vval.v_string = pat;
|
||||||
args[1].vval.v_string = xp->xp_line;
|
args[1].vval.v_string = xp->xp_line;
|
||||||
args[2].vval.v_number = xp->xp_col;
|
args[2].vval.v_number = xp->xp_col;
|
||||||
|
|
||||||
@ -2479,30 +2479,29 @@ static void *call_user_expand_func(user_expand_func_T user_expand_func, expand_T
|
|||||||
/// Expand names with a function defined by the user.
|
/// Expand names with a function defined by the user.
|
||||||
static int ExpandUserDefined(expand_T *xp, regmatch_T *regmatch, int *num_file, char ***file)
|
static int ExpandUserDefined(expand_T *xp, regmatch_T *regmatch, int *num_file, char ***file)
|
||||||
{
|
{
|
||||||
char_u *e;
|
char *e;
|
||||||
garray_T ga;
|
garray_T ga;
|
||||||
|
|
||||||
char_u *const retstr = call_user_expand_func((user_expand_func_T)call_func_retstr, xp, num_file,
|
char *const retstr = call_user_expand_func((user_expand_func_T)call_func_retstr, xp, num_file,
|
||||||
file);
|
file);
|
||||||
|
|
||||||
if (retstr == NULL) {
|
if (retstr == NULL) {
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ga_init(&ga, (int)sizeof(char *), 3);
|
ga_init(&ga, (int)sizeof(char *), 3);
|
||||||
for (char_u *s = retstr; *s != NUL; s = e) {
|
for (char *s = retstr; *s != NUL; s = e) {
|
||||||
e = (char_u *)vim_strchr((char *)s, '\n');
|
e = vim_strchr(s, '\n');
|
||||||
if (e == NULL) {
|
if (e == NULL) {
|
||||||
e = s + STRLEN(s);
|
e = s + STRLEN(s);
|
||||||
}
|
}
|
||||||
const char_u keep = *e;
|
const char keep = *e;
|
||||||
*e = NUL;
|
*e = NUL;
|
||||||
|
|
||||||
const bool skip = xp->xp_pattern[0]
|
const bool skip = xp->xp_pattern[0] && vim_regexec(regmatch, s, (colnr_T)0) == 0;
|
||||||
&& vim_regexec(regmatch, (char *)s, (colnr_T)0) == 0;
|
|
||||||
*e = keep;
|
*e = keep;
|
||||||
if (!skip) {
|
if (!skip) {
|
||||||
GA_APPEND(char_u *, &ga, vim_strnsave(s, (size_t)(e - s)));
|
GA_APPEND(char *, &ga, xstrnsave(s, (size_t)(e - s)));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (*e != NUL) {
|
if (*e != NUL) {
|
||||||
@ -2663,7 +2662,7 @@ int wildmenu_process_key(CmdlineInfo *cclp, int key, expand_T *xp)
|
|||||||
// cursor
|
// cursor
|
||||||
int found = false;
|
int found = false;
|
||||||
|
|
||||||
int j = (int)((char_u *)xp->xp_pattern - cclp->cmdbuff);
|
int j = (int)(xp->xp_pattern - cclp->cmdbuff);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
while (--j > 0) {
|
while (--j > 0) {
|
||||||
// check for start of menu name
|
// check for start of menu name
|
||||||
@ -2718,9 +2717,9 @@ int wildmenu_process_key(CmdlineInfo *cclp, int key, expand_T *xp)
|
|||||||
int found = false;
|
int found = false;
|
||||||
|
|
||||||
int j = cclp->cmdpos;
|
int j = cclp->cmdpos;
|
||||||
int i = (int)((char_u *)xp->xp_pattern - cclp->cmdbuff);
|
int i = (int)(xp->xp_pattern - cclp->cmdbuff);
|
||||||
while (--j > i) {
|
while (--j > i) {
|
||||||
j -= utf_head_off((char *)cclp->cmdbuff, (char *)cclp->cmdbuff + j);
|
j -= utf_head_off(cclp->cmdbuff, cclp->cmdbuff + j);
|
||||||
if (vim_ispathsep(cclp->cmdbuff[j])) {
|
if (vim_ispathsep(cclp->cmdbuff[j])) {
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
@ -2739,9 +2738,9 @@ int wildmenu_process_key(CmdlineInfo *cclp, int key, expand_T *xp)
|
|||||||
int found = false;
|
int found = false;
|
||||||
|
|
||||||
int j = cclp->cmdpos - 1;
|
int j = cclp->cmdpos - 1;
|
||||||
int i = (int)((char_u *)xp->xp_pattern - cclp->cmdbuff);
|
int i = (int)(xp->xp_pattern - cclp->cmdbuff);
|
||||||
while (--j > i) {
|
while (--j > i) {
|
||||||
j -= utf_head_off((char *)cclp->cmdbuff, (char *)cclp->cmdbuff + j);
|
j -= utf_head_off(cclp->cmdbuff, cclp->cmdbuff + j);
|
||||||
if (vim_ispathsep(cclp->cmdbuff[j])
|
if (vim_ispathsep(cclp->cmdbuff[j])
|
||||||
#ifdef BACKSLASH_IN_FILENAME
|
#ifdef BACKSLASH_IN_FILENAME
|
||||||
&& vim_strchr((const char_u *)" *?[{`$%#", cclp->cmdbuff[j + 1])
|
&& vim_strchr((const char_u *)" *?[{`$%#", cclp->cmdbuff[j + 1])
|
||||||
@ -2895,7 +2894,7 @@ void f_getcompletion(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
theend:
|
theend:
|
||||||
pat = addstar((char_u *)xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context);
|
pat = (char_u *)addstar(xpc.xp_pattern, xpc.xp_pattern_len, xpc.xp_context);
|
||||||
ExpandOne(&xpc, pat, NULL, options, WILD_ALL_KEEP);
|
ExpandOne(&xpc, pat, NULL, options, WILD_ALL_KEEP);
|
||||||
tv_list_alloc_ret(rettv, xpc.xp_numfiles);
|
tv_list_alloc_ret(rettv, xpc.xp_numfiles);
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@ static int in_history(int type, char_u *str, int move_to_front, int sep)
|
|||||||
|
|
||||||
// For search history, check that the separator character matches as
|
// For search history, check that the separator character matches as
|
||||||
// well.
|
// well.
|
||||||
char_u *p = history[type][i].hisstr;
|
char_u *p = (char_u *)history[type][i].hisstr;
|
||||||
if (STRCMP(str, p) == 0
|
if (STRCMP(str, p) == 0
|
||||||
&& (type != HIST_SEARCH || sep == p[STRLEN(p) + 1])) {
|
&& (type != HIST_SEARCH || sep == p[STRLEN(p) + 1])) {
|
||||||
if (!move_to_front) {
|
if (!move_to_front) {
|
||||||
@ -217,7 +217,7 @@ static int in_history(int type, char_u *str, int move_to_front, int sep)
|
|||||||
|
|
||||||
if (last_i >= 0) {
|
if (last_i >= 0) {
|
||||||
list_T *const list = history[type][i].additional_elements;
|
list_T *const list = history[type][i].additional_elements;
|
||||||
str = history[type][i].hisstr;
|
str = (char_u *)history[type][i].hisstr;
|
||||||
while (i != hisidx[type]) {
|
while (i != hisidx[type]) {
|
||||||
if (++i >= hislen) {
|
if (++i >= hislen) {
|
||||||
i = 0;
|
i = 0;
|
||||||
@ -227,7 +227,7 @@ static int in_history(int type, char_u *str, int move_to_front, int sep)
|
|||||||
}
|
}
|
||||||
tv_list_unref(list);
|
tv_list_unref(list);
|
||||||
history[type][i].hisnum = ++hisnum[type];
|
history[type][i].hisnum = ++hisnum[type];
|
||||||
history[type][i].hisstr = str;
|
history[type][i].hisstr = (char *)str;
|
||||||
history[type][i].timestamp = os_time();
|
history[type][i].timestamp = os_time();
|
||||||
history[type][i].additional_elements = NULL;
|
history[type][i].additional_elements = NULL;
|
||||||
return true;
|
return true;
|
||||||
@ -276,7 +276,7 @@ static int last_maptick = -1; // last seen maptick
|
|||||||
/// @param histype may be one of the HIST_ values.
|
/// @param histype may be one of the HIST_ values.
|
||||||
/// @param in_map consider maptick when inside a mapping
|
/// @param in_map consider maptick when inside a mapping
|
||||||
/// @param sep separator character used (search hist)
|
/// @param sep separator character used (search hist)
|
||||||
void add_to_history(int histype, char_u *new_entry, int in_map, int sep)
|
void add_to_history(int histype, char *new_entry, int in_map, int sep)
|
||||||
{
|
{
|
||||||
histentry_T *hisptr;
|
histentry_T *hisptr;
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ void add_to_history(int histype, char_u *new_entry, int in_map, int sep)
|
|||||||
}
|
}
|
||||||
last_maptick = -1;
|
last_maptick = -1;
|
||||||
}
|
}
|
||||||
if (!in_history(histype, new_entry, true, sep)) {
|
if (!in_history(histype, (char_u *)new_entry, true, sep)) {
|
||||||
if (++hisidx[histype] == hislen) {
|
if (++hisidx[histype] == hislen) {
|
||||||
hisidx[histype] = 0;
|
hisidx[histype] = 0;
|
||||||
}
|
}
|
||||||
@ -313,10 +313,10 @@ void add_to_history(int histype, char_u *new_entry, int in_map, int sep)
|
|||||||
|
|
||||||
// Store the separator after the NUL of the string.
|
// Store the separator after the NUL of the string.
|
||||||
size_t len = STRLEN(new_entry);
|
size_t len = STRLEN(new_entry);
|
||||||
hisptr->hisstr = vim_strnsave(new_entry, len + 2);
|
hisptr->hisstr = xstrnsave(new_entry, len + 2);
|
||||||
hisptr->timestamp = os_time();
|
hisptr->timestamp = os_time();
|
||||||
hisptr->additional_elements = NULL;
|
hisptr->additional_elements = NULL;
|
||||||
hisptr->hisstr[len + 1] = (char_u)sep;
|
hisptr->hisstr[len + 1] = (char)sep;
|
||||||
|
|
||||||
hisptr->hisnum = ++hisnum[histype];
|
hisptr->hisnum = ++hisnum[histype];
|
||||||
if (histype == HIST_SEARCH && in_map) {
|
if (histype == HIST_SEARCH && in_map) {
|
||||||
@ -386,7 +386,7 @@ static char_u *get_history_entry(int histype, int idx)
|
|||||||
{
|
{
|
||||||
idx = calc_hist_idx(histype, idx);
|
idx = calc_hist_idx(histype, idx);
|
||||||
if (idx >= 0) {
|
if (idx >= 0) {
|
||||||
return history[histype][idx].hisstr;
|
return (char_u *)history[histype][idx].hisstr;
|
||||||
} else {
|
} else {
|
||||||
return (char_u *)"";
|
return (char_u *)"";
|
||||||
}
|
}
|
||||||
@ -438,7 +438,7 @@ static int del_history_entry(int histype, char_u *str)
|
|||||||
if (hisptr->hisstr == NULL) {
|
if (hisptr->hisstr == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (vim_regexec(®match, (char *)hisptr->hisstr, (colnr_T)0)) {
|
if (vim_regexec(®match, hisptr->hisstr, (colnr_T)0)) {
|
||||||
found = true;
|
found = true;
|
||||||
hist_free_entry(hisptr);
|
hist_free_entry(hisptr);
|
||||||
} else {
|
} else {
|
||||||
@ -509,7 +509,7 @@ void f_histadd(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
str = tv_get_string_buf(&argvars[1], buf);
|
str = tv_get_string_buf(&argvars[1], buf);
|
||||||
if (*str != NUL) {
|
if (*str != NUL) {
|
||||||
init_history();
|
init_history();
|
||||||
add_to_history(histype, (char_u *)str, false, NUL);
|
add_to_history(histype, (char *)str, false, NUL);
|
||||||
rettv->vval.v_number = true;
|
rettv->vval.v_number = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -643,8 +643,8 @@ void ex_history(exarg_T *eap)
|
|||||||
msg_putchar('\n');
|
msg_putchar('\n');
|
||||||
snprintf((char *)IObuff, IOSIZE, "%c%6d ", i == idx ? '>' : ' ',
|
snprintf((char *)IObuff, IOSIZE, "%c%6d ", i == idx ? '>' : ' ',
|
||||||
hist[i].hisnum);
|
hist[i].hisnum);
|
||||||
if (vim_strsize((char *)hist[i].hisstr) > Columns - 10) {
|
if (vim_strsize(hist[i].hisstr) > Columns - 10) {
|
||||||
trunc_string((char *)hist[i].hisstr, (char *)IObuff + STRLEN(IObuff),
|
trunc_string(hist[i].hisstr, (char *)IObuff + STRLEN(IObuff),
|
||||||
Columns - 10, IOSIZE - (int)STRLEN(IObuff));
|
Columns - 10, IOSIZE - (int)STRLEN(IObuff));
|
||||||
} else {
|
} else {
|
||||||
STRCAT(IObuff, hist[i].hisstr);
|
STRCAT(IObuff, hist[i].hisstr);
|
||||||
|
@ -22,7 +22,7 @@ typedef enum {
|
|||||||
/// History entry definition
|
/// History entry definition
|
||||||
typedef struct hist_entry {
|
typedef struct hist_entry {
|
||||||
int hisnum; ///< Entry identifier number.
|
int hisnum; ///< Entry identifier number.
|
||||||
char_u *hisstr; ///< Actual entry, separator char after the NUL.
|
char *hisstr; ///< Actual entry, separator char after the NUL.
|
||||||
Timestamp timestamp; ///< Time when entry was added.
|
Timestamp timestamp; ///< Time when entry was added.
|
||||||
list_T *additional_elements; ///< Additional entries from ShaDa file.
|
list_T *additional_elements; ///< Additional entries from ShaDa file.
|
||||||
} histentry_T;
|
} histentry_T;
|
||||||
|
@ -493,9 +493,9 @@ void pchar_cursor(char_u c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// @return pointer to cursor line.
|
/// @return pointer to cursor line.
|
||||||
char_u *get_cursor_line_ptr(void)
|
char *get_cursor_line_ptr(void)
|
||||||
{
|
{
|
||||||
return ml_get_buf(curbuf, curwin->w_cursor.lnum, false);
|
return (char *)ml_get_buf(curbuf, curwin->w_cursor.lnum, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @return pointer to cursor position.
|
/// @return pointer to cursor position.
|
||||||
|
@ -2010,8 +2010,8 @@ void f_digraph_setlist(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
|
|
||||||
/// structure used for b_kmap_ga.ga_data
|
/// structure used for b_kmap_ga.ga_data
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char_u *from;
|
char *from;
|
||||||
char_u *to;
|
char *to;
|
||||||
} kmap_T;
|
} kmap_T;
|
||||||
|
|
||||||
#define KMAP_MAXLEN 20 // maximum length of "from" or "to"
|
#define KMAP_MAXLEN 20 // maximum length of "from" or "to"
|
||||||
@ -2064,10 +2064,10 @@ char *keymap_init(void)
|
|||||||
/// @param eap
|
/// @param eap
|
||||||
void ex_loadkeymap(exarg_T *eap)
|
void ex_loadkeymap(exarg_T *eap)
|
||||||
{
|
{
|
||||||
char_u *s;
|
char *s;
|
||||||
|
|
||||||
#define KMAP_LLEN 200 // max length of "to" and "from" together
|
#define KMAP_LLEN 200 // max length of "to" and "from" together
|
||||||
char_u buf[KMAP_LLEN + 11];
|
char buf[KMAP_LLEN + 11];
|
||||||
char *save_cpo = p_cpo;
|
char *save_cpo = p_cpo;
|
||||||
|
|
||||||
if (!getline_equal(eap->getline, eap->cookie, getsourceline)) {
|
if (!getline_equal(eap->getline, eap->cookie, getsourceline)) {
|
||||||
@ -2092,15 +2092,15 @@ void ex_loadkeymap(exarg_T *eap)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
char_u *p = (char_u *)skipwhite(line);
|
char *p = skipwhite(line);
|
||||||
|
|
||||||
if ((*p != '"') && (*p != NUL)) {
|
if ((*p != '"') && (*p != NUL)) {
|
||||||
kmap_T *kp = GA_APPEND_VIA_PTR(kmap_T, &curbuf->b_kmap_ga);
|
kmap_T *kp = GA_APPEND_VIA_PTR(kmap_T, &curbuf->b_kmap_ga);
|
||||||
s = (char_u *)skiptowhite((char *)p);
|
s = skiptowhite(p);
|
||||||
kp->from = vim_strnsave(p, (size_t)(s - p));
|
kp->from = xstrnsave(p, (size_t)(s - p));
|
||||||
p = (char_u *)skipwhite((char *)s);
|
p = skipwhite(s);
|
||||||
s = (char_u *)skiptowhite((char *)p);
|
s = skiptowhite(p);
|
||||||
kp->to = vim_strnsave(p, (size_t)(s - p));
|
kp->to = xstrnsave(p, (size_t)(s - p));
|
||||||
|
|
||||||
if ((STRLEN(kp->from) + STRLEN(kp->to) >= KMAP_LLEN)
|
if ((STRLEN(kp->from) + STRLEN(kp->to) >= KMAP_LLEN)
|
||||||
|| (*kp->from == NUL)
|
|| (*kp->from == NUL)
|
||||||
@ -2118,10 +2118,10 @@ void ex_loadkeymap(exarg_T *eap)
|
|||||||
|
|
||||||
// setup ":lmap" to map the keys
|
// setup ":lmap" to map the keys
|
||||||
for (int i = 0; i < curbuf->b_kmap_ga.ga_len; i++) {
|
for (int i = 0; i < curbuf->b_kmap_ga.ga_len; i++) {
|
||||||
vim_snprintf((char *)buf, sizeof(buf), "<buffer> %s %s",
|
vim_snprintf(buf, sizeof(buf), "<buffer> %s %s",
|
||||||
((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].from,
|
((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].from,
|
||||||
((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].to);
|
((kmap_T *)curbuf->b_kmap_ga.ga_data)[i].to);
|
||||||
(void)do_map(MAPTYPE_MAP, buf, MODE_LANGMAP, false);
|
(void)do_map(MAPTYPE_MAP, (char_u *)buf, MODE_LANGMAP, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
p_cpo = save_cpo;
|
p_cpo = save_cpo;
|
||||||
|
@ -190,7 +190,7 @@ static void insert_enter(InsertState *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Insstart_textlen = (colnr_T)linetabsize(get_cursor_line_ptr());
|
Insstart_textlen = (colnr_T)linetabsize((char_u *)get_cursor_line_ptr());
|
||||||
Insstart_blank_vcol = MAXCOL;
|
Insstart_blank_vcol = MAXCOL;
|
||||||
|
|
||||||
if (!did_ai) {
|
if (!did_ai) {
|
||||||
@ -274,7 +274,7 @@ static void insert_enter(InsertState *s)
|
|||||||
update_curswant();
|
update_curswant();
|
||||||
if (((ins_at_eol && curwin->w_cursor.lnum == o_lnum)
|
if (((ins_at_eol && curwin->w_cursor.lnum == o_lnum)
|
||||||
|| curwin->w_curswant > curwin->w_virtcol)
|
|| curwin->w_curswant > curwin->w_virtcol)
|
||||||
&& *(s->ptr = get_cursor_line_ptr() + curwin->w_cursor.col) != NUL) {
|
&& *(s->ptr = (char_u *)get_cursor_line_ptr() + curwin->w_cursor.col) != NUL) {
|
||||||
if (s->ptr[1] == NUL) {
|
if (s->ptr[1] == NUL) {
|
||||||
curwin->w_cursor.col++;
|
curwin->w_cursor.col++;
|
||||||
} else {
|
} else {
|
||||||
@ -1470,7 +1470,7 @@ static void init_prompt(int cmdchar_todo)
|
|||||||
char_u *text;
|
char_u *text;
|
||||||
|
|
||||||
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
||||||
text = get_cursor_line_ptr();
|
text = (char_u *)get_cursor_line_ptr();
|
||||||
if (STRNCMP(text, prompt, STRLEN(prompt)) != 0) {
|
if (STRNCMP(text, prompt, STRLEN(prompt)) != 0) {
|
||||||
// prompt is missing, insert it or append a line with it
|
// prompt is missing, insert it or append a line with it
|
||||||
if (*text == NUL) {
|
if (*text == NUL) {
|
||||||
@ -1544,7 +1544,7 @@ void display_dollar(colnr_T col)
|
|||||||
curwin->w_cursor.col = col;
|
curwin->w_cursor.col = col;
|
||||||
|
|
||||||
// If on the last byte of a multi-byte move to the first byte.
|
// If on the last byte of a multi-byte move to the first byte.
|
||||||
char_u *p = get_cursor_line_ptr();
|
char_u *p = (char_u *)get_cursor_line_ptr();
|
||||||
curwin->w_cursor.col -= utf_head_off((char *)p, (char *)p + col);
|
curwin->w_cursor.col -= utf_head_off((char *)p, (char *)p + col);
|
||||||
curs_columns(curwin, false); // Recompute w_wrow and w_wcol
|
curs_columns(curwin, false); // Recompute w_wrow and w_wcol
|
||||||
if (curwin->w_wcol < curwin->w_grid.cols) {
|
if (curwin->w_wcol < curwin->w_grid.cols) {
|
||||||
@ -1590,7 +1590,7 @@ void change_indent(int type, int amount, int round, int replaced, int call_chang
|
|||||||
|
|
||||||
// MODE_VREPLACE state needs to know what the line was like before changing
|
// MODE_VREPLACE state needs to know what the line was like before changing
|
||||||
if (State & VREPLACE_FLAG) {
|
if (State & VREPLACE_FLAG) {
|
||||||
orig_line = vim_strsave(get_cursor_line_ptr()); // Deal with NULL below
|
orig_line = vim_strsave((char_u *)get_cursor_line_ptr()); // Deal with NULL below
|
||||||
orig_col = curwin->w_cursor.col;
|
orig_col = curwin->w_cursor.col;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1670,7 +1670,7 @@ void change_indent(int type, int amount, int round, int replaced, int call_chang
|
|||||||
|
|
||||||
// Advance the cursor until we reach the right screen column.
|
// Advance the cursor until we reach the right screen column.
|
||||||
last_vcol = 0;
|
last_vcol = 0;
|
||||||
ptr = get_cursor_line_ptr();
|
ptr = (char_u *)get_cursor_line_ptr();
|
||||||
chartabsize_T cts;
|
chartabsize_T cts;
|
||||||
init_chartabsize_arg(&cts, curwin, 0, 0, (char *)ptr, (char *)ptr);
|
init_chartabsize_arg(&cts, curwin, 0, 0, (char *)ptr, (char *)ptr);
|
||||||
while (cts.cts_vcol <= (int)curwin->w_virtcol) {
|
while (cts.cts_vcol <= (int)curwin->w_virtcol) {
|
||||||
@ -1761,7 +1761,7 @@ void change_indent(int type, int amount, int round, int replaced, int call_chang
|
|||||||
// then put it back again the way we wanted it.
|
// then put it back again the way we wanted it.
|
||||||
if (State & VREPLACE_FLAG) {
|
if (State & VREPLACE_FLAG) {
|
||||||
// Save new line
|
// Save new line
|
||||||
new_line = vim_strsave(get_cursor_line_ptr());
|
new_line = vim_strsave((char_u *)get_cursor_line_ptr());
|
||||||
|
|
||||||
// We only put back the new line up to the cursor
|
// We only put back the new line up to the cursor
|
||||||
new_line[curwin->w_cursor.col] = NUL;
|
new_line[curwin->w_cursor.col] = NUL;
|
||||||
@ -2082,7 +2082,7 @@ void insertchar(int c, int flags, int second_indent)
|
|||||||
|
|
||||||
// Need to remove existing (middle) comment leader and insert end
|
// Need to remove existing (middle) comment leader and insert end
|
||||||
// comment leader. First, check what comment leader we can find.
|
// comment leader. First, check what comment leader we can find.
|
||||||
char_u *line = get_cursor_line_ptr();
|
char_u *line = (char_u *)get_cursor_line_ptr();
|
||||||
int i = get_leader_len((char *)line, &p, false, true);
|
int i = get_leader_len((char *)line, &p, false, true);
|
||||||
if (i > 0 && vim_strchr(p, COM_MIDDLE) != NULL) { // Just checking
|
if (i > 0 && vim_strchr(p, COM_MIDDLE) != NULL) { // Just checking
|
||||||
// Skip middle-comment string
|
// Skip middle-comment string
|
||||||
@ -2287,7 +2287,7 @@ int stop_arrow(void)
|
|||||||
// right, except when nothing was inserted yet.
|
// right, except when nothing was inserted yet.
|
||||||
update_Insstart_orig = false;
|
update_Insstart_orig = false;
|
||||||
}
|
}
|
||||||
Insstart_textlen = (colnr_T)linetabsize(get_cursor_line_ptr());
|
Insstart_textlen = (colnr_T)linetabsize((char_u *)get_cursor_line_ptr());
|
||||||
|
|
||||||
if (u_save_cursor() == OK) {
|
if (u_save_cursor() == OK) {
|
||||||
arrow_used = false;
|
arrow_used = false;
|
||||||
@ -2484,7 +2484,7 @@ void beginline(int flags)
|
|||||||
if (flags & (BL_WHITE | BL_SOL)) {
|
if (flags & (BL_WHITE | BL_SOL)) {
|
||||||
char_u *ptr;
|
char_u *ptr;
|
||||||
|
|
||||||
for (ptr = get_cursor_line_ptr(); ascii_iswhite(*ptr)
|
for (ptr = (char_u *)get_cursor_line_ptr(); ascii_iswhite(*ptr)
|
||||||
&& !((flags & BL_FIX) && ptr[1] == NUL); ptr++) {
|
&& !((flags & BL_FIX) && ptr[1] == NUL); ptr++) {
|
||||||
curwin->w_cursor.col++;
|
curwin->w_cursor.col++;
|
||||||
}
|
}
|
||||||
@ -2799,7 +2799,7 @@ static bool echeck_abbr(int c)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return check_abbr(c, get_cursor_line_ptr(), curwin->w_cursor.col,
|
return check_abbr(c, (char_u *)get_cursor_line_ptr(), curwin->w_cursor.col,
|
||||||
curwin->w_cursor.lnum == Insstart.lnum ? Insstart.col : 0);
|
curwin->w_cursor.lnum == Insstart.lnum ? Insstart.col : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3148,7 +3148,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
|
|||||||
// cursor.
|
// cursor.
|
||||||
} else if (*look == 'e') {
|
} else if (*look == 'e') {
|
||||||
if (try_match && keytyped == 'e' && curwin->w_cursor.col >= 4) {
|
if (try_match && keytyped == 'e' && curwin->w_cursor.col >= 4) {
|
||||||
p = get_cursor_line_ptr();
|
p = (char_u *)get_cursor_line_ptr();
|
||||||
if ((char_u *)skipwhite((char *)p) == p + curwin->w_cursor.col - 4
|
if ((char_u *)skipwhite((char *)p) == p + curwin->w_cursor.col - 4
|
||||||
&& STRNCMP(p + curwin->w_cursor.col - 4, "else", 4) == 0) {
|
&& STRNCMP(p + curwin->w_cursor.col - 4, "else", 4) == 0) {
|
||||||
return true;
|
return true;
|
||||||
@ -3161,12 +3161,12 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
|
|||||||
// class::method for C++).
|
// class::method for C++).
|
||||||
} else if (*look == ':') {
|
} else if (*look == ':') {
|
||||||
if (try_match && keytyped == ':') {
|
if (try_match && keytyped == ':') {
|
||||||
p = get_cursor_line_ptr();
|
p = (char_u *)get_cursor_line_ptr();
|
||||||
if (cin_iscase(p, false) || cin_isscopedecl(p) || cin_islabel()) {
|
if (cin_iscase(p, false) || cin_isscopedecl(p) || cin_islabel()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Need to get the line again after cin_islabel().
|
// Need to get the line again after cin_islabel().
|
||||||
p = get_cursor_line_ptr();
|
p = (char_u *)get_cursor_line_ptr();
|
||||||
if (curwin->w_cursor.col > 2
|
if (curwin->w_cursor.col > 2
|
||||||
&& p[curwin->w_cursor.col - 1] == ':'
|
&& p[curwin->w_cursor.col - 1] == ':'
|
||||||
&& p[curwin->w_cursor.col - 2] == ':') {
|
&& p[curwin->w_cursor.col - 2] == ':') {
|
||||||
@ -3174,7 +3174,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
|
|||||||
const bool i = cin_iscase(p, false)
|
const bool i = cin_iscase(p, false)
|
||||||
|| cin_isscopedecl(p)
|
|| cin_isscopedecl(p)
|
||||||
|| cin_islabel();
|
|| cin_islabel();
|
||||||
p = get_cursor_line_ptr();
|
p = (char_u *)get_cursor_line_ptr();
|
||||||
p[curwin->w_cursor.col - 1] = ':';
|
p[curwin->w_cursor.col - 1] = ':';
|
||||||
if (i) {
|
if (i) {
|
||||||
return true;
|
return true;
|
||||||
@ -3226,7 +3226,7 @@ bool in_cinkeys(int keytyped, int when, bool line_is_empty)
|
|||||||
|
|
||||||
/* Just completed a word, check if it starts with "look".
|
/* Just completed a word, check if it starts with "look".
|
||||||
* search back for the start of a word. */
|
* search back for the start of a word. */
|
||||||
line = get_cursor_line_ptr();
|
line = (char_u *)get_cursor_line_ptr();
|
||||||
for (s = line + curwin->w_cursor.col; s > line; s = n) {
|
for (s = line + curwin->w_cursor.col; s > line; s = n) {
|
||||||
n = mb_prevptr(line, s);
|
n = mb_prevptr(line, s);
|
||||||
if (!vim_iswordp(n)) {
|
if (!vim_iswordp(n)) {
|
||||||
@ -3805,7 +3805,7 @@ static void ins_shift(int c, int lastc)
|
|||||||
change_indent(c == Ctrl_D ? INDENT_DEC : INDENT_INC, 0, true, 0, true);
|
change_indent(c == Ctrl_D ? INDENT_DEC : INDENT_INC, 0, true, 0, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (did_ai && *skipwhite((char *)get_cursor_line_ptr()) != NUL) {
|
if (did_ai && *skipwhite(get_cursor_line_ptr()) != NUL) {
|
||||||
did_ai = false;
|
did_ai = false;
|
||||||
}
|
}
|
||||||
did_si = false;
|
did_si = false;
|
||||||
@ -4609,7 +4609,7 @@ static bool ins_tab(void)
|
|||||||
if (State & VREPLACE_FLAG) {
|
if (State & VREPLACE_FLAG) {
|
||||||
pos = curwin->w_cursor;
|
pos = curwin->w_cursor;
|
||||||
cursor = &pos;
|
cursor = &pos;
|
||||||
saved_line = vim_strsave(get_cursor_line_ptr());
|
saved_line = vim_strsave((char_u *)get_cursor_line_ptr());
|
||||||
ptr = saved_line + pos.col;
|
ptr = saved_line + pos.col;
|
||||||
} else {
|
} else {
|
||||||
ptr = get_cursor_pos_ptr();
|
ptr = get_cursor_pos_ptr();
|
||||||
|
@ -2995,7 +2995,7 @@ static int eval7(char **arg, typval_T *rettv, int evaluate, int want_string)
|
|||||||
*arg = bp;
|
*arg = bp;
|
||||||
} else {
|
} else {
|
||||||
// decimal, hex or octal number
|
// decimal, hex or octal number
|
||||||
vim_str2nr((char_u *)(*arg), NULL, &len, STR2NR_ALL, &n, NULL, 0, true);
|
vim_str2nr(*arg, NULL, &len, STR2NR_ALL, &n, NULL, 0, true);
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
semsg(_(e_invexpr2), *arg);
|
semsg(_(e_invexpr2), *arg);
|
||||||
ret = FAIL;
|
ret = FAIL;
|
||||||
@ -6450,7 +6450,7 @@ pos_T *var2fpos(const typval_T *const tv, const bool dollar_lnum, int *const ret
|
|||||||
} else {
|
} else {
|
||||||
pos.lnum = curwin->w_cursor.lnum;
|
pos.lnum = curwin->w_cursor.lnum;
|
||||||
if (charcol) {
|
if (charcol) {
|
||||||
pos.col = (colnr_T)mb_charlen(get_cursor_line_ptr());
|
pos.col = (colnr_T)mb_charlen((char_u *)get_cursor_line_ptr());
|
||||||
} else {
|
} else {
|
||||||
pos.col = (colnr_T)STRLEN(get_cursor_line_ptr());
|
pos.col = (colnr_T)STRLEN(get_cursor_line_ptr());
|
||||||
}
|
}
|
||||||
|
@ -430,7 +430,7 @@ static inline int parse_json_string(const char *const buf, const size_t buf_len,
|
|||||||
const char ubuf[] = { t[1], t[2], t[3], t[4] };
|
const char ubuf[] = { t[1], t[2], t[3], t[4] };
|
||||||
t += 4;
|
t += 4;
|
||||||
uvarnumber_T ch;
|
uvarnumber_T ch;
|
||||||
vim_str2nr((char_u *)ubuf, NULL, NULL,
|
vim_str2nr(ubuf, NULL, NULL,
|
||||||
STR2NR_HEX | STR2NR_FORCE, NULL, &ch, 4, true);
|
STR2NR_HEX | STR2NR_FORCE, NULL, &ch, 4, true);
|
||||||
if (ch == 0) {
|
if (ch == 0) {
|
||||||
hasnul = true;
|
hasnul = true;
|
||||||
@ -600,7 +600,7 @@ parse_json_number_check:
|
|||||||
// Convert integer
|
// Convert integer
|
||||||
varnumber_T nr;
|
varnumber_T nr;
|
||||||
int num_len;
|
int num_len;
|
||||||
vim_str2nr((char_u *)s, NULL, &num_len, 0, &nr, NULL, (int)(p - s), true);
|
vim_str2nr(s, NULL, &num_len, 0, &nr, NULL, (int)(p - s), true);
|
||||||
if ((int)exp_num_len != num_len) {
|
if ((int)exp_num_len != num_len) {
|
||||||
semsg(_("E685: internal error: while converting number \"%.*s\" "
|
semsg(_("E685: internal error: while converting number \"%.*s\" "
|
||||||
"to integer vim_str2nr consumed %i bytes in place of %zu"),
|
"to integer vim_str2nr consumed %i bytes in place of %zu"),
|
||||||
|
@ -5869,9 +5869,9 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
bool binary = false;
|
bool binary = false;
|
||||||
bool blob = false;
|
bool blob = false;
|
||||||
FILE *fd;
|
FILE *fd;
|
||||||
char_u buf[(IOSIZE/256) * 256]; // rounded to avoid odd + 1
|
char buf[(IOSIZE/256) * 256]; // rounded to avoid odd + 1
|
||||||
int io_size = sizeof(buf);
|
int io_size = sizeof(buf);
|
||||||
char_u *prev = NULL; // previously read bytes, if any
|
char *prev = NULL; // previously read bytes, if any
|
||||||
long prevlen = 0; // length of data in prev
|
long prevlen = 0; // length of data in prev
|
||||||
long prevsize = 0; // size of prev buffer
|
long prevsize = 0; // size of prev buffer
|
||||||
long maxline = MAXLNUM;
|
long maxline = MAXLNUM;
|
||||||
@ -5922,13 +5922,13 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
// - an incomplete line gets written
|
// - an incomplete line gets written
|
||||||
// - a "binary" file gets an empty line at the end if it ends in a
|
// - a "binary" file gets an empty line at the end if it ends in a
|
||||||
// newline.
|
// newline.
|
||||||
char_u *p; // Position in buf.
|
char *p; // Position in buf.
|
||||||
char_u *start; // Start of current line.
|
char *start; // Start of current line.
|
||||||
for (p = buf, start = buf;
|
for (p = buf, start = buf;
|
||||||
p < buf + readlen || (readlen <= 0 && (prevlen > 0 || binary));
|
p < buf + readlen || (readlen <= 0 && (prevlen > 0 || binary));
|
||||||
p++) {
|
p++) {
|
||||||
if (*p == '\n' || readlen <= 0) {
|
if (*p == '\n' || readlen <= 0) {
|
||||||
char_u *s = NULL;
|
char *s = NULL;
|
||||||
size_t len = (size_t)(p - start);
|
size_t len = (size_t)(p - start);
|
||||||
|
|
||||||
// Finished a line. Remove CRs before NL.
|
// Finished a line. Remove CRs before NL.
|
||||||
@ -5945,7 +5945,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
}
|
}
|
||||||
if (prevlen == 0) {
|
if (prevlen == 0) {
|
||||||
assert(len < INT_MAX);
|
assert(len < INT_MAX);
|
||||||
s = vim_strnsave(start, len);
|
s = xstrnsave(start, len);
|
||||||
} else {
|
} else {
|
||||||
// Change "prev" buffer to be the right size. This way
|
// Change "prev" buffer to be the right size. This way
|
||||||
// the bytes are only copied once, and very long lines are
|
// the bytes are only copied once, and very long lines are
|
||||||
@ -5960,7 +5960,7 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
tv_list_append_owned_tv(l, (typval_T) {
|
tv_list_append_owned_tv(l, (typval_T) {
|
||||||
.v_type = VAR_STRING,
|
.v_type = VAR_STRING,
|
||||||
.v_lock = VAR_UNLOCKED,
|
.v_lock = VAR_UNLOCKED,
|
||||||
.vval.v_string = (char *)s,
|
.vval.v_string = s,
|
||||||
});
|
});
|
||||||
|
|
||||||
start = p + 1; // Step over newline.
|
start = p + 1; // Step over newline.
|
||||||
@ -5980,18 +5980,18 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
*p = '\n';
|
*p = '\n';
|
||||||
// Check for utf8 "bom"; U+FEFF is encoded as EF BB BF. Do this
|
// Check for utf8 "bom"; U+FEFF is encoded as EF BB BF. Do this
|
||||||
// when finding the BF and check the previous two bytes.
|
// when finding the BF and check the previous two bytes.
|
||||||
} else if (*p == 0xbf && !binary) {
|
} else if ((uint8_t)(*p) == 0xbf && !binary) {
|
||||||
// Find the two bytes before the 0xbf. If p is at buf, or buf + 1,
|
// Find the two bytes before the 0xbf. If p is at buf, or buf + 1,
|
||||||
// these may be in the "prev" string.
|
// these may be in the "prev" string.
|
||||||
char_u back1 = p >= buf + 1 ? p[-1]
|
char back1 = p >= buf + 1 ? p[-1]
|
||||||
: prevlen >= 1 ? prev[prevlen - 1] : NUL;
|
: prevlen >= 1 ? prev[prevlen - 1] : NUL;
|
||||||
char_u back2 = p >= buf + 2 ? p[-2]
|
char back2 = p >= buf + 2 ? p[-2]
|
||||||
: p == buf + 1 && prevlen >= 1 ? prev[prevlen - 1]
|
: p == buf + 1 && prevlen >= 1 ? prev[prevlen - 1]
|
||||||
: prevlen >=
|
: prevlen >=
|
||||||
2 ? prev[prevlen - 2] : NUL;
|
2 ? prev[prevlen - 2] : NUL;
|
||||||
|
|
||||||
if (back2 == 0xef && back1 == 0xbb) {
|
if ((uint8_t)back2 == 0xef && (uint8_t)back1 == 0xbb) {
|
||||||
char_u *dest = p - 2;
|
char *dest = p - 2;
|
||||||
|
|
||||||
// Usually a BOM is at the beginning of a file, and so at
|
// Usually a BOM is at the beginning of a file, and so at
|
||||||
// the beginning of a line; then we can just step over it.
|
// the beginning of a line; then we can just step over it.
|
||||||
@ -8304,7 +8304,7 @@ static void f_str2nr(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
varnumber_T n;
|
varnumber_T n;
|
||||||
vim_str2nr(p, NULL, NULL, what, &n, NULL, 0, false);
|
vim_str2nr((char *)p, NULL, NULL, what, &n, NULL, 0, false);
|
||||||
// Text after the number is silently ignored.
|
// Text after the number is silently ignored.
|
||||||
if (isneg) {
|
if (isneg) {
|
||||||
rettv->vval.v_number = -n;
|
rettv->vval.v_number = -n;
|
||||||
@ -9416,10 +9416,10 @@ static void f_trim(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
{
|
{
|
||||||
char buf1[NUMBUFLEN];
|
char buf1[NUMBUFLEN];
|
||||||
char buf2[NUMBUFLEN];
|
char buf2[NUMBUFLEN];
|
||||||
const char_u *head = (const char_u *)tv_get_string_buf_chk(&argvars[0], buf1);
|
const char *head = tv_get_string_buf_chk(&argvars[0], buf1);
|
||||||
const char_u *mask = NULL;
|
const char *mask = NULL;
|
||||||
const char_u *prev;
|
const char *prev;
|
||||||
const char_u *p;
|
const char *p;
|
||||||
int dir = 0;
|
int dir = 0;
|
||||||
|
|
||||||
rettv->v_type = VAR_STRING;
|
rettv->v_type = VAR_STRING;
|
||||||
@ -9434,7 +9434,7 @@ static void f_trim(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (argvars[1].v_type == VAR_STRING) {
|
if (argvars[1].v_type == VAR_STRING) {
|
||||||
mask = (const char_u *)tv_get_string_buf_chk(&argvars[1], buf2);
|
mask = tv_get_string_buf_chk(&argvars[1], buf2);
|
||||||
if (argvars[2].v_type != VAR_UNKNOWN) {
|
if (argvars[2].v_type != VAR_UNKNOWN) {
|
||||||
bool error = false;
|
bool error = false;
|
||||||
// leading or trailing characters to trim
|
// leading or trailing characters to trim
|
||||||
@ -9472,7 +9472,7 @@ static void f_trim(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char_u *tail = head + STRLEN(head);
|
const char *tail = head + STRLEN(head);
|
||||||
if (dir == 0 || dir == 2) {
|
if (dir == 0 || dir == 2) {
|
||||||
// Trim trailing characters
|
// Trim trailing characters
|
||||||
for (; tail > head; tail = prev) {
|
for (; tail > head; tail = prev) {
|
||||||
@ -9495,7 +9495,7 @@ static void f_trim(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rettv->vval.v_string = (char *)vim_strnsave(head, (size_t)(tail - head));
|
rettv->vval.v_string = xstrnsave(head, (size_t)(tail - head));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// "type(expr)" function
|
/// "type(expr)" function
|
||||||
|
@ -3717,8 +3717,7 @@ varnumber_T tv_get_number_chk(const typval_T *const tv, bool *const ret_error)
|
|||||||
case VAR_STRING: {
|
case VAR_STRING: {
|
||||||
varnumber_T n = 0;
|
varnumber_T n = 0;
|
||||||
if (tv->vval.v_string != NULL) {
|
if (tv->vval.v_string != NULL) {
|
||||||
vim_str2nr((char_u *)tv->vval.v_string, NULL, NULL, STR2NR_ALL, &n, NULL, 0,
|
vim_str2nr(tv->vval.v_string, NULL, NULL, STR2NR_ALL, &n, NULL, 0, false);
|
||||||
false);
|
|
||||||
}
|
}
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
@ -525,22 +525,22 @@ static inline bool eval_fname_sid(const char *const name)
|
|||||||
///
|
///
|
||||||
/// @return transformed name: either `fname_buf` or a pointer to an allocated
|
/// @return transformed name: either `fname_buf` or a pointer to an allocated
|
||||||
/// memory.
|
/// memory.
|
||||||
static char_u *fname_trans_sid(const char_u *const name, char_u *const fname_buf,
|
static char *fname_trans_sid(const char *const name, char *const fname_buf, char **const tofree,
|
||||||
char_u **const tofree, int *const error)
|
int *const error)
|
||||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
|
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_WARN_UNUSED_RESULT
|
||||||
{
|
{
|
||||||
char_u *fname;
|
char *fname;
|
||||||
const int llen = eval_fname_script((const char *)name);
|
const int llen = eval_fname_script(name);
|
||||||
if (llen > 0) {
|
if (llen > 0) {
|
||||||
fname_buf[0] = K_SPECIAL;
|
fname_buf[0] = (char)K_SPECIAL;
|
||||||
fname_buf[1] = KS_EXTRA;
|
fname_buf[1] = (char)KS_EXTRA;
|
||||||
fname_buf[2] = KE_SNR;
|
fname_buf[2] = KE_SNR;
|
||||||
int i = 3;
|
int i = 3;
|
||||||
if (eval_fname_sid((const char *)name)) { // "<SID>" or "s:"
|
if (eval_fname_sid(name)) { // "<SID>" or "s:"
|
||||||
if (current_sctx.sc_sid <= 0) {
|
if (current_sctx.sc_sid <= 0) {
|
||||||
*error = ERROR_SCRIPT;
|
*error = ERROR_SCRIPT;
|
||||||
} else {
|
} else {
|
||||||
snprintf((char *)fname_buf + i, (size_t)(FLEN_FIXED + 1 - i), "%" PRId64 "_",
|
snprintf(fname_buf + i, (size_t)(FLEN_FIXED + 1 - i), "%" PRId64 "_",
|
||||||
(int64_t)current_sctx.sc_sid);
|
(int64_t)current_sctx.sc_sid);
|
||||||
i = (int)STRLEN(fname_buf);
|
i = (int)STRLEN(fname_buf);
|
||||||
}
|
}
|
||||||
@ -555,7 +555,7 @@ static char_u *fname_trans_sid(const char_u *const name, char_u *const fname_buf
|
|||||||
STRCPY(fname + i, name + llen);
|
STRCPY(fname + i, name + llen);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
fname = (char_u *)name;
|
fname = (char *)name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return fname;
|
return fname;
|
||||||
@ -1437,10 +1437,10 @@ int call_func(const char *funcname, int len, typval_T *rettv, int argcount_in, t
|
|||||||
int ret = FAIL;
|
int ret = FAIL;
|
||||||
int error = ERROR_NONE;
|
int error = ERROR_NONE;
|
||||||
ufunc_T *fp = NULL;
|
ufunc_T *fp = NULL;
|
||||||
char_u fname_buf[FLEN_FIXED + 1];
|
char fname_buf[FLEN_FIXED + 1];
|
||||||
char_u *tofree = NULL;
|
char *tofree = NULL;
|
||||||
char_u *fname = NULL;
|
char *fname = NULL;
|
||||||
char_u *name = NULL;
|
char *name = NULL;
|
||||||
int argcount = argcount_in;
|
int argcount = argcount_in;
|
||||||
typval_T *argvars = argvars_in;
|
typval_T *argvars = argvars_in;
|
||||||
dict_T *selfdict = funcexe->selfdict;
|
dict_T *selfdict = funcexe->selfdict;
|
||||||
@ -1463,8 +1463,8 @@ int call_func(const char *funcname, int len, typval_T *rettv, int argcount_in, t
|
|||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
// Make a copy of the name, if it comes from a funcref variable it could
|
// Make a copy of the name, if it comes from a funcref variable it could
|
||||||
// be changed or deleted in the called function.
|
// be changed or deleted in the called function.
|
||||||
name = vim_strnsave((char_u *)funcname, (size_t)len);
|
name = xstrnsave(funcname, (size_t)len);
|
||||||
fname = fname_trans_sid(name, fname_buf, &tofree, &error);
|
fname = fname_trans_sid(name, (char *)fname_buf, &tofree, &error);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (funcexe->doesrange != NULL) {
|
if (funcexe->doesrange != NULL) {
|
||||||
@ -1495,7 +1495,7 @@ int call_func(const char *funcname, int len, typval_T *rettv, int argcount_in, t
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (error == ERROR_NONE && funcexe->evaluate) {
|
if (error == ERROR_NONE && funcexe->evaluate) {
|
||||||
char_u *rfname = fname;
|
char *rfname = fname;
|
||||||
|
|
||||||
// Ignore "g:" before a function name.
|
// Ignore "g:" before a function name.
|
||||||
if (fp == NULL && fname[0] == 'g' && fname[1] == ':') {
|
if (fp == NULL && fname[0] == 'g' && fname[1] == ':') {
|
||||||
@ -1519,21 +1519,21 @@ int call_func(const char *funcname, int len, typval_T *rettv, int argcount_in, t
|
|||||||
} else if (fp != NULL || !builtin_function((const char *)rfname, -1)) {
|
} else if (fp != NULL || !builtin_function((const char *)rfname, -1)) {
|
||||||
// User defined function.
|
// User defined function.
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
fp = find_func(rfname);
|
fp = find_func((char_u *)rfname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Trigger FuncUndefined event, may load the function.
|
// Trigger FuncUndefined event, may load the function.
|
||||||
if (fp == NULL
|
if (fp == NULL
|
||||||
&& apply_autocmds(EVENT_FUNCUNDEFINED, (char *)rfname, (char *)rfname, true, NULL)
|
&& apply_autocmds(EVENT_FUNCUNDEFINED, rfname, rfname, true, NULL)
|
||||||
&& !aborting()) {
|
&& !aborting()) {
|
||||||
// executed an autocommand, search for the function again
|
// executed an autocommand, search for the function again
|
||||||
fp = find_func(rfname);
|
fp = find_func((char_u *)rfname);
|
||||||
}
|
}
|
||||||
// Try loading a package.
|
// Try loading a package.
|
||||||
if (fp == NULL && script_autoload((const char *)rfname, STRLEN(rfname),
|
if (fp == NULL && script_autoload((const char *)rfname, STRLEN(rfname),
|
||||||
true) && !aborting()) {
|
true) && !aborting()) {
|
||||||
// Loaded a package, search for the function again.
|
// Loaded a package, search for the function again.
|
||||||
fp = find_func(rfname);
|
fp = find_func((char_u *)rfname);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fp != NULL && (fp->uf_flags & FC_DELETED)) {
|
if (fp != NULL && (fp->uf_flags & FC_DELETED)) {
|
||||||
@ -1570,11 +1570,11 @@ int call_func(const char *funcname, int len, typval_T *rettv, int argcount_in, t
|
|||||||
} else if (funcexe->basetv != NULL) {
|
} else if (funcexe->basetv != NULL) {
|
||||||
// expr->method(): Find the method name in the table, call its
|
// expr->method(): Find the method name in the table, call its
|
||||||
// implementation with the base as one of the arguments.
|
// implementation with the base as one of the arguments.
|
||||||
error = call_internal_method(fname, argcount, argvars, rettv,
|
error = call_internal_method((char_u *)fname, argcount, argvars, rettv,
|
||||||
funcexe->basetv);
|
funcexe->basetv);
|
||||||
} else {
|
} else {
|
||||||
// Find the function name in the table, call its implementation.
|
// Find the function name in the table, call its implementation.
|
||||||
error = call_internal_func(fname, argcount, argvars, rettv);
|
error = call_internal_func((char_u *)fname, argcount, argvars, rettv);
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
* The function call (or "FuncUndefined" autocommand sequence) might
|
* The function call (or "FuncUndefined" autocommand sequence) might
|
||||||
@ -1596,7 +1596,7 @@ theend:
|
|||||||
// Report an error unless the argument evaluation or function call has been
|
// Report an error unless the argument evaluation or function call has been
|
||||||
// cancelled due to an aborting error, an interrupt, or an exception.
|
// cancelled due to an aborting error, an interrupt, or an exception.
|
||||||
if (!aborting()) {
|
if (!aborting()) {
|
||||||
user_func_error(error, (name != NULL) ? name : (char_u *)funcname);
|
user_func_error(error, (name != NULL) ? (char_u *)name : (char_u *)funcname);
|
||||||
}
|
}
|
||||||
|
|
||||||
// clear the copies made from the partial
|
// clear the copies made from the partial
|
||||||
@ -1890,15 +1890,15 @@ theend:
|
|||||||
/// ":function"
|
/// ":function"
|
||||||
void ex_function(exarg_T *eap)
|
void ex_function(exarg_T *eap)
|
||||||
{
|
{
|
||||||
char_u *theline;
|
char *theline;
|
||||||
char_u *line_to_free = NULL;
|
char *line_to_free = NULL;
|
||||||
char_u c;
|
char c;
|
||||||
int saved_did_emsg;
|
int saved_did_emsg;
|
||||||
bool saved_wait_return = need_wait_return;
|
bool saved_wait_return = need_wait_return;
|
||||||
char_u *name = NULL;
|
char *name = NULL;
|
||||||
char_u *p;
|
char *p;
|
||||||
char_u *arg;
|
char *arg;
|
||||||
char_u *line_arg = NULL;
|
char *line_arg = NULL;
|
||||||
garray_T newargs;
|
garray_T newargs;
|
||||||
garray_T default_args;
|
garray_T default_args;
|
||||||
garray_T newlines;
|
garray_T newlines;
|
||||||
@ -1918,8 +1918,8 @@ void ex_function(exarg_T *eap)
|
|||||||
linenr_T sourcing_lnum_off;
|
linenr_T sourcing_lnum_off;
|
||||||
linenr_T sourcing_lnum_top;
|
linenr_T sourcing_lnum_top;
|
||||||
bool is_heredoc = false;
|
bool is_heredoc = false;
|
||||||
char_u *skip_until = NULL;
|
char *skip_until = NULL;
|
||||||
char_u *heredoc_trimmed = NULL;
|
char *heredoc_trimmed = NULL;
|
||||||
bool show_block = false;
|
bool show_block = false;
|
||||||
bool do_concat = true;
|
bool do_concat = true;
|
||||||
|
|
||||||
@ -1950,7 +1950,7 @@ void ex_function(exarg_T *eap)
|
|||||||
* ":function /pat": list functions matching pattern.
|
* ":function /pat": list functions matching pattern.
|
||||||
*/
|
*/
|
||||||
if (*eap->arg == '/') {
|
if (*eap->arg == '/') {
|
||||||
p = (char_u *)skip_regexp(eap->arg + 1, '/', true, NULL);
|
p = skip_regexp(eap->arg + 1, '/', true, NULL);
|
||||||
if (!eap->skip) {
|
if (!eap->skip) {
|
||||||
regmatch_T regmatch;
|
regmatch_T regmatch;
|
||||||
|
|
||||||
@ -1978,7 +1978,7 @@ void ex_function(exarg_T *eap)
|
|||||||
if (*p == '/') {
|
if (*p == '/') {
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
eap->nextcmd = check_nextcmd((char *)p);
|
eap->nextcmd = check_nextcmd(p);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1996,9 +1996,9 @@ void ex_function(exarg_T *eap)
|
|||||||
// "fudi.fd_di" set, "fudi.fd_newkey" == NULL
|
// "fudi.fd_di" set, "fudi.fd_newkey" == NULL
|
||||||
// s:func script-local function name
|
// s:func script-local function name
|
||||||
// g:func global function name, same as "func"
|
// g:func global function name, same as "func"
|
||||||
p = (char_u *)eap->arg;
|
p = eap->arg;
|
||||||
name = trans_function_name((char **)&p, eap->skip, TFN_NO_AUTOLOAD, &fudi, NULL);
|
name = (char *)trans_function_name(&p, eap->skip, TFN_NO_AUTOLOAD, &fudi, NULL);
|
||||||
paren = (vim_strchr((char *)p, '(') != NULL);
|
paren = (vim_strchr(p, '(') != NULL);
|
||||||
if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip) {
|
if (name == NULL && (fudi.fd_dict == NULL || !paren) && !eap->skip) {
|
||||||
/*
|
/*
|
||||||
* Return on an invalid expression in braces, unless the expression
|
* Return on an invalid expression in braces, unless the expression
|
||||||
@ -2028,16 +2028,16 @@ void ex_function(exarg_T *eap)
|
|||||||
// - exclude line numbers from function body
|
// - exclude line numbers from function body
|
||||||
//
|
//
|
||||||
if (!paren) {
|
if (!paren) {
|
||||||
if (!ends_excmd(*skipwhite((char *)p))) {
|
if (!ends_excmd(*skipwhite(p))) {
|
||||||
semsg(_(e_trailing_arg), p);
|
semsg(_(e_trailing_arg), p);
|
||||||
goto ret_free;
|
goto ret_free;
|
||||||
}
|
}
|
||||||
eap->nextcmd = check_nextcmd((char *)p);
|
eap->nextcmd = check_nextcmd(p);
|
||||||
if (eap->nextcmd != NULL) {
|
if (eap->nextcmd != NULL) {
|
||||||
*p = NUL;
|
*p = NUL;
|
||||||
}
|
}
|
||||||
if (!eap->skip && !got_int) {
|
if (!eap->skip && !got_int) {
|
||||||
fp = find_func(name);
|
fp = find_func((char_u *)name);
|
||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
list_func_head(fp, !eap->forceit, eap->forceit);
|
list_func_head(fp, !eap->forceit, eap->forceit);
|
||||||
for (int j = 0; j < fp->uf_lines.ga_len && !got_int; j++) {
|
for (int j = 0; j < fp->uf_lines.ga_len && !got_int; j++) {
|
||||||
@ -2063,7 +2063,7 @@ void ex_function(exarg_T *eap)
|
|||||||
msg_puts(eap->forceit ? "endfunction" : " endfunction");
|
msg_puts(eap->forceit ? "endfunction" : " endfunction");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
emsg_funcname(N_("E123: Undefined function: %s"), name);
|
emsg_funcname(N_("E123: Undefined function: %s"), (char_u *)name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
goto ret_free;
|
goto ret_free;
|
||||||
@ -2072,18 +2072,18 @@ void ex_function(exarg_T *eap)
|
|||||||
/*
|
/*
|
||||||
* ":function name(arg1, arg2)" Define function.
|
* ":function name(arg1, arg2)" Define function.
|
||||||
*/
|
*/
|
||||||
p = (char_u *)skipwhite((char *)p);
|
p = skipwhite(p);
|
||||||
if (*p != '(') {
|
if (*p != '(') {
|
||||||
if (!eap->skip) {
|
if (!eap->skip) {
|
||||||
semsg(_("E124: Missing '(': %s"), eap->arg);
|
semsg(_("E124: Missing '(': %s"), eap->arg);
|
||||||
goto ret_free;
|
goto ret_free;
|
||||||
}
|
}
|
||||||
// attempt to continue by skipping some text
|
// attempt to continue by skipping some text
|
||||||
if (vim_strchr((char *)p, '(') != NULL) {
|
if (vim_strchr(p, '(') != NULL) {
|
||||||
p = (char_u *)vim_strchr((char *)p, '(');
|
p = vim_strchr(p, '(');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
p = (char_u *)skipwhite((char *)p + 1);
|
p = skipwhite(p + 1);
|
||||||
|
|
||||||
ga_init(&newargs, (int)sizeof(char_u *), 3);
|
ga_init(&newargs, (int)sizeof(char_u *), 3);
|
||||||
ga_init(&newlines, (int)sizeof(char_u *), 3);
|
ga_init(&newlines, (int)sizeof(char_u *), 3);
|
||||||
@ -2094,15 +2094,15 @@ void ex_function(exarg_T *eap)
|
|||||||
if (name != NULL) {
|
if (name != NULL) {
|
||||||
arg = name;
|
arg = name;
|
||||||
} else {
|
} else {
|
||||||
arg = fudi.fd_newkey;
|
arg = (char *)fudi.fd_newkey;
|
||||||
}
|
}
|
||||||
if (arg != NULL && (fudi.fd_di == NULL || !tv_is_func(fudi.fd_di->di_tv))) {
|
if (arg != NULL && (fudi.fd_di == NULL || !tv_is_func(fudi.fd_di->di_tv))) {
|
||||||
int j = (*arg == K_SPECIAL) ? 3 : 0;
|
int j = ((uint8_t)(*arg) == K_SPECIAL) ? 3 : 0;
|
||||||
while (arg[j] != NUL && (j == 0 ? eval_isnamec1(arg[j]) : eval_isnamec(arg[j]))) {
|
while (arg[j] != NUL && (j == 0 ? eval_isnamec1(arg[j]) : eval_isnamec(arg[j]))) {
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
if (arg[j] != NUL) {
|
if (arg[j] != NUL) {
|
||||||
emsg_funcname((char *)e_invarg2, arg);
|
emsg_funcname((char *)e_invarg2, (char_u *)arg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Disallow using the g: dict.
|
// Disallow using the g: dict.
|
||||||
@ -2111,7 +2111,7 @@ void ex_function(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (get_function_args((char **)&p, ')', &newargs, &varargs,
|
if (get_function_args(&p, ')', &newargs, &varargs,
|
||||||
&default_args, eap->skip) == FAIL) {
|
&default_args, eap->skip) == FAIL) {
|
||||||
goto errret_2;
|
goto errret_2;
|
||||||
}
|
}
|
||||||
@ -2123,7 +2123,7 @@ void ex_function(exarg_T *eap)
|
|||||||
|
|
||||||
// find extra arguments "range", "dict", "abort" and "closure"
|
// find extra arguments "range", "dict", "abort" and "closure"
|
||||||
for (;;) {
|
for (;;) {
|
||||||
p = (char_u *)skipwhite((char *)p);
|
p = skipwhite(p);
|
||||||
if (STRNCMP(p, "range", 5) == 0) {
|
if (STRNCMP(p, "range", 5) == 0) {
|
||||||
flags |= FC_RANGE;
|
flags |= FC_RANGE;
|
||||||
p += 5;
|
p += 5;
|
||||||
@ -2137,9 +2137,8 @@ void ex_function(exarg_T *eap)
|
|||||||
flags |= FC_CLOSURE;
|
flags |= FC_CLOSURE;
|
||||||
p += 7;
|
p += 7;
|
||||||
if (current_funccal == NULL) {
|
if (current_funccal == NULL) {
|
||||||
emsg_funcname(N_
|
emsg_funcname(N_("E932: Closure function should not be at top level: %s"),
|
||||||
("E932: Closure function should not be at top level: %s"),
|
name == NULL ? (char_u *)"" : (char_u *)name);
|
||||||
name == NULL ? (char_u *)"" : name);
|
|
||||||
goto erret;
|
goto erret;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2165,8 +2164,8 @@ void ex_function(exarg_T *eap)
|
|||||||
if (!eap->skip && !eap->forceit) {
|
if (!eap->skip && !eap->forceit) {
|
||||||
if (fudi.fd_dict != NULL && fudi.fd_newkey == NULL) {
|
if (fudi.fd_dict != NULL && fudi.fd_newkey == NULL) {
|
||||||
emsg(_(e_funcdict));
|
emsg(_(e_funcdict));
|
||||||
} else if (name != NULL && find_func(name) != NULL) {
|
} else if (name != NULL && find_func((char_u *)name) != NULL) {
|
||||||
emsg_funcname(e_funcexts, name);
|
emsg_funcname(e_funcexts, (char_u *)name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2195,7 +2194,7 @@ void ex_function(exarg_T *eap)
|
|||||||
if (line_arg != NULL) {
|
if (line_arg != NULL) {
|
||||||
// Use eap->arg, split up in parts by line breaks.
|
// Use eap->arg, split up in parts by line breaks.
|
||||||
theline = line_arg;
|
theline = line_arg;
|
||||||
p = (char_u *)vim_strchr((char *)theline, '\n');
|
p = vim_strchr(theline, '\n');
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
line_arg += STRLEN(line_arg);
|
line_arg += STRLEN(line_arg);
|
||||||
} else {
|
} else {
|
||||||
@ -2205,9 +2204,9 @@ void ex_function(exarg_T *eap)
|
|||||||
} else {
|
} else {
|
||||||
xfree(line_to_free);
|
xfree(line_to_free);
|
||||||
if (eap->getline == NULL) {
|
if (eap->getline == NULL) {
|
||||||
theline = getcmdline(':', 0L, indent, do_concat);
|
theline = (char *)getcmdline(':', 0L, indent, do_concat);
|
||||||
} else {
|
} else {
|
||||||
theline = (char_u *)eap->getline(':', eap->cookie, indent, do_concat);
|
theline = eap->getline(':', eap->cookie, indent, do_concat);
|
||||||
}
|
}
|
||||||
line_to_free = theline;
|
line_to_free = theline;
|
||||||
}
|
}
|
||||||
@ -2237,13 +2236,13 @@ void ex_function(exarg_T *eap)
|
|||||||
// * ":python <<EOF" and "EOF"
|
// * ":python <<EOF" and "EOF"
|
||||||
// * ":let {var-name} =<< [trim] {marker}" and "{marker}"
|
// * ":let {var-name} =<< [trim] {marker}" and "{marker}"
|
||||||
if (heredoc_trimmed == NULL
|
if (heredoc_trimmed == NULL
|
||||||
|| (is_heredoc && (char_u *)skipwhite((char *)theline) == theline)
|
|| (is_heredoc && skipwhite(theline) == theline)
|
||||||
|| STRNCMP(theline, heredoc_trimmed,
|
|| STRNCMP(theline, heredoc_trimmed,
|
||||||
STRLEN(heredoc_trimmed)) == 0) {
|
STRLEN(heredoc_trimmed)) == 0) {
|
||||||
if (heredoc_trimmed == NULL) {
|
if (heredoc_trimmed == NULL) {
|
||||||
p = theline;
|
p = theline;
|
||||||
} else if (is_heredoc) {
|
} else if (is_heredoc) {
|
||||||
p = (char_u *)skipwhite((char *)theline) == theline
|
p = skipwhite(theline) == theline
|
||||||
? theline : theline + STRLEN(heredoc_trimmed);
|
? theline : theline + STRLEN(heredoc_trimmed);
|
||||||
} else {
|
} else {
|
||||||
p = theline + STRLEN(heredoc_trimmed);
|
p = theline + STRLEN(heredoc_trimmed);
|
||||||
@ -2260,27 +2259,26 @@ void ex_function(exarg_T *eap)
|
|||||||
for (p = theline; ascii_iswhite(*p) || *p == ':'; p++) {}
|
for (p = theline; ascii_iswhite(*p) || *p == ':'; p++) {}
|
||||||
|
|
||||||
// Check for "endfunction".
|
// Check for "endfunction".
|
||||||
if (checkforcmd((char **)&p, "endfunction", 4) && nesting-- == 0) {
|
if (checkforcmd(&p, "endfunction", 4) && nesting-- == 0) {
|
||||||
if (*p == '!') {
|
if (*p == '!') {
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
char_u *nextcmd = NULL;
|
char *nextcmd = NULL;
|
||||||
if (*p == '|') {
|
if (*p == '|') {
|
||||||
nextcmd = p + 1;
|
nextcmd = p + 1;
|
||||||
} else if (line_arg != NULL && *skipwhite((char *)line_arg) != NUL) {
|
} else if (line_arg != NULL && *skipwhite(line_arg) != NUL) {
|
||||||
nextcmd = line_arg;
|
nextcmd = line_arg;
|
||||||
} else if (*p != NUL && *p != '"' && p_verbose > 0) {
|
} else if (*p != NUL && *p != '"' && p_verbose > 0) {
|
||||||
give_warning2(_("W22: Text found after :endfunction: %s"),
|
give_warning2(_("W22: Text found after :endfunction: %s"), p, true);
|
||||||
(char *)p, true);
|
|
||||||
}
|
}
|
||||||
if (nextcmd != NULL) {
|
if (nextcmd != NULL) {
|
||||||
// Another command follows. If the line came from "eap" we
|
// Another command follows. If the line came from "eap" we
|
||||||
// can simply point into it, otherwise we need to change
|
// can simply point into it, otherwise we need to change
|
||||||
// "eap->cmdlinep".
|
// "eap->cmdlinep".
|
||||||
eap->nextcmd = (char *)nextcmd;
|
eap->nextcmd = nextcmd;
|
||||||
if (line_to_free != NULL) {
|
if (line_to_free != NULL) {
|
||||||
xfree(*eap->cmdlinep);
|
xfree(*eap->cmdlinep);
|
||||||
*eap->cmdlinep = (char *)line_to_free;
|
*eap->cmdlinep = line_to_free;
|
||||||
line_to_free = NULL;
|
line_to_free = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2299,13 +2297,13 @@ void ex_function(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for defining a function inside this function.
|
// Check for defining a function inside this function.
|
||||||
if (checkforcmd((char **)&p, "function", 2)) {
|
if (checkforcmd(&p, "function", 2)) {
|
||||||
if (*p == '!') {
|
if (*p == '!') {
|
||||||
p = (char_u *)skipwhite((char *)p + 1);
|
p = skipwhite(p + 1);
|
||||||
}
|
}
|
||||||
p += eval_fname_script((const char *)p);
|
p += eval_fname_script((const char *)p);
|
||||||
xfree(trans_function_name((char **)&p, true, 0, NULL, NULL));
|
xfree(trans_function_name(&p, true, 0, NULL, NULL));
|
||||||
if (*skipwhite((char *)p) == '(') {
|
if (*skipwhite(p) == '(') {
|
||||||
if (nesting == MAX_FUNC_NESTING - 1) {
|
if (nesting == MAX_FUNC_NESTING - 1) {
|
||||||
emsg(_("E1058: function nesting too deep"));
|
emsg(_("E1058: function nesting too deep"));
|
||||||
} else {
|
} else {
|
||||||
@ -2316,7 +2314,7 @@ void ex_function(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for ":append", ":change", ":insert".
|
// Check for ":append", ":change", ":insert".
|
||||||
p = (char_u *)skip_range((char *)p, NULL);
|
p = skip_range(p, NULL);
|
||||||
if ((p[0] == 'a' && (!ASCII_ISALPHA(p[1]) || p[1] == 'p'))
|
if ((p[0] == 'a' && (!ASCII_ISALPHA(p[1]) || p[1] == 'p'))
|
||||||
|| (p[0] == 'c'
|
|| (p[0] == 'c'
|
||||||
&& (!ASCII_ISALPHA(p[1])
|
&& (!ASCII_ISALPHA(p[1])
|
||||||
@ -2328,11 +2326,11 @@ void ex_function(exarg_T *eap)
|
|||||||
&& (!ASCII_ISALPHA(p[1]) || (p[1] == 'n'
|
&& (!ASCII_ISALPHA(p[1]) || (p[1] == 'n'
|
||||||
&& (!ASCII_ISALPHA(p[2])
|
&& (!ASCII_ISALPHA(p[2])
|
||||||
|| (p[2] == 's')))))) {
|
|| (p[2] == 's')))))) {
|
||||||
skip_until = vim_strsave((char_u *)".");
|
skip_until = xstrdup(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
// heredoc: Check for ":python <<EOF", ":lua <<EOF", etc.
|
// heredoc: Check for ":python <<EOF", ":lua <<EOF", etc.
|
||||||
arg = (char_u *)skipwhite(skiptowhite((char *)p));
|
arg = skipwhite(skiptowhite(p));
|
||||||
if (arg[0] == '<' && arg[1] == '<'
|
if (arg[0] == '<' && arg[1] == '<'
|
||||||
&& ((p[0] == 'p' && p[1] == 'y'
|
&& ((p[0] == 'p' && p[1] == 'y'
|
||||||
&& (!ASCII_ISALNUM(p[2]) || p[2] == 't'
|
&& (!ASCII_ISALNUM(p[2]) || p[2] == 't'
|
||||||
@ -2349,22 +2347,22 @@ void ex_function(exarg_T *eap)
|
|||||||
|| (p[0] == 'm' && p[1] == 'z'
|
|| (p[0] == 'm' && p[1] == 'z'
|
||||||
&& (!ASCII_ISALPHA(p[2]) || p[2] == 's')))) {
|
&& (!ASCII_ISALPHA(p[2]) || p[2] == 's')))) {
|
||||||
// ":python <<" continues until a dot, like ":append"
|
// ":python <<" continues until a dot, like ":append"
|
||||||
p = (char_u *)skipwhite((char *)arg + 2);
|
p = skipwhite(arg + 2);
|
||||||
if (*p == NUL) {
|
if (*p == NUL) {
|
||||||
skip_until = vim_strsave((char_u *)".");
|
skip_until = xstrdup(".");
|
||||||
} else {
|
} else {
|
||||||
skip_until = vim_strsave(p);
|
skip_until = xstrdup(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for ":let v =<< [trim] EOF"
|
// Check for ":let v =<< [trim] EOF"
|
||||||
// and ":let [a, b] =<< [trim] EOF"
|
// and ":let [a, b] =<< [trim] EOF"
|
||||||
arg = (char_u *)skipwhite(skiptowhite((char *)p));
|
arg = skipwhite(skiptowhite(p));
|
||||||
if (*arg == '[') {
|
if (*arg == '[') {
|
||||||
arg = (char_u *)vim_strchr((char *)arg, ']');
|
arg = vim_strchr(arg, ']');
|
||||||
}
|
}
|
||||||
if (arg != NULL) {
|
if (arg != NULL) {
|
||||||
arg = (char_u *)skipwhite(skiptowhite((char *)arg));
|
arg = skipwhite(skiptowhite(arg));
|
||||||
if (arg[0] == '='
|
if (arg[0] == '='
|
||||||
&& arg[1] == '<'
|
&& arg[1] == '<'
|
||||||
&& arg[2] == '<'
|
&& arg[2] == '<'
|
||||||
@ -2372,14 +2370,13 @@ void ex_function(exarg_T *eap)
|
|||||||
&& p[1] == 'e'
|
&& p[1] == 'e'
|
||||||
&& (!ASCII_ISALNUM(p[2])
|
&& (!ASCII_ISALNUM(p[2])
|
||||||
|| (p[2] == 't' && !ASCII_ISALNUM(p[3]))))) {
|
|| (p[2] == 't' && !ASCII_ISALNUM(p[3]))))) {
|
||||||
p = (char_u *)skipwhite((char *)arg + 3);
|
p = skipwhite(arg + 3);
|
||||||
if (STRNCMP(p, "trim", 4) == 0) {
|
if (STRNCMP(p, "trim", 4) == 0) {
|
||||||
// Ignore leading white space.
|
// Ignore leading white space.
|
||||||
p = (char_u *)skipwhite((char *)p + 4);
|
p = skipwhite(p + 4);
|
||||||
heredoc_trimmed =
|
heredoc_trimmed = xstrnsave(theline, (size_t)(skipwhite(theline) - theline));
|
||||||
vim_strnsave(theline, (size_t)((char_u *)skipwhite((char *)theline) - theline));
|
|
||||||
}
|
}
|
||||||
skip_until = vim_strnsave(p, (size_t)((char_u *)skiptowhite((char *)p) - p));
|
skip_until = xstrnsave(p, (size_t)(skiptowhite(p) - p));
|
||||||
do_concat = false;
|
do_concat = false;
|
||||||
is_heredoc = true;
|
is_heredoc = true;
|
||||||
}
|
}
|
||||||
@ -2392,8 +2389,8 @@ void ex_function(exarg_T *eap)
|
|||||||
// Copy the line to newly allocated memory. get_one_sourceline()
|
// Copy the line to newly allocated memory. get_one_sourceline()
|
||||||
// allocates 250 bytes per line, this saves 80% on average. The cost
|
// allocates 250 bytes per line, this saves 80% on average. The cost
|
||||||
// is an extra alloc/free.
|
// is an extra alloc/free.
|
||||||
p = vim_strsave(theline);
|
p = xstrdup(theline);
|
||||||
((char **)(newlines.ga_data))[newlines.ga_len++] = (char *)p;
|
((char **)(newlines.ga_data))[newlines.ga_len++] = p;
|
||||||
|
|
||||||
// Add NULL lines for continuation lines, so that the line count is
|
// Add NULL lines for continuation lines, so that the line count is
|
||||||
// equal to the index in the growarray.
|
// equal to the index in the growarray.
|
||||||
@ -2420,23 +2417,23 @@ void ex_function(exarg_T *eap)
|
|||||||
v = find_var((const char *)name, STRLEN(name), &ht, false);
|
v = find_var((const char *)name, STRLEN(name), &ht, false);
|
||||||
if (v != NULL && v->di_tv.v_type == VAR_FUNC) {
|
if (v != NULL && v->di_tv.v_type == VAR_FUNC) {
|
||||||
emsg_funcname(N_("E707: Function name conflicts with variable: %s"),
|
emsg_funcname(N_("E707: Function name conflicts with variable: %s"),
|
||||||
name);
|
(char_u *)name);
|
||||||
goto erret;
|
goto erret;
|
||||||
}
|
}
|
||||||
|
|
||||||
fp = find_func(name);
|
fp = find_func((char_u *)name);
|
||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
// Function can be replaced with "function!" and when sourcing the
|
// Function can be replaced with "function!" and when sourcing the
|
||||||
// same script again, but only once.
|
// same script again, but only once.
|
||||||
if (!eap->forceit
|
if (!eap->forceit
|
||||||
&& (fp->uf_script_ctx.sc_sid != current_sctx.sc_sid
|
&& (fp->uf_script_ctx.sc_sid != current_sctx.sc_sid
|
||||||
|| fp->uf_script_ctx.sc_seq == current_sctx.sc_seq)) {
|
|| fp->uf_script_ctx.sc_seq == current_sctx.sc_seq)) {
|
||||||
emsg_funcname(e_funcexts, name);
|
emsg_funcname(e_funcexts, (char_u *)name);
|
||||||
goto erret;
|
goto erret;
|
||||||
}
|
}
|
||||||
if (fp->uf_calls > 0) {
|
if (fp->uf_calls > 0) {
|
||||||
emsg_funcname(N_("E127: Cannot redefine function %s: It is in use"),
|
emsg_funcname(N_("E127: Cannot redefine function %s: It is in use"),
|
||||||
name);
|
(char_u *)name);
|
||||||
goto erret;
|
goto erret;
|
||||||
}
|
}
|
||||||
if (fp->uf_refcount > 1) {
|
if (fp->uf_refcount > 1) {
|
||||||
@ -2480,12 +2477,12 @@ void ex_function(exarg_T *eap)
|
|||||||
// Give the function a sequential number. Can only be used with a
|
// Give the function a sequential number. Can only be used with a
|
||||||
// Funcref!
|
// Funcref!
|
||||||
xfree(name);
|
xfree(name);
|
||||||
sprintf(numbuf, "%d", ++func_nr);
|
sprintf(numbuf, "%d", ++func_nr); // NOLINT(runtime/printf)
|
||||||
name = vim_strsave((char_u *)numbuf);
|
name = xstrdup(numbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fp == NULL) {
|
if (fp == NULL) {
|
||||||
if (fudi.fd_dict == NULL && vim_strchr((char *)name, AUTOLOAD_CHAR) != NULL) {
|
if (fudi.fd_dict == NULL && vim_strchr(name, AUTOLOAD_CHAR) != NULL) {
|
||||||
int slen, plen;
|
int slen, plen;
|
||||||
char_u *scriptname;
|
char_u *scriptname;
|
||||||
|
|
||||||
@ -2493,7 +2490,7 @@ void ex_function(exarg_T *eap)
|
|||||||
int j = FAIL;
|
int j = FAIL;
|
||||||
if (SOURCING_NAME != NULL) {
|
if (SOURCING_NAME != NULL) {
|
||||||
scriptname = (char_u *)autoload_name((const char *)name, STRLEN(name));
|
scriptname = (char_u *)autoload_name((const char *)name, STRLEN(name));
|
||||||
p = (char_u *)vim_strchr((char *)scriptname, '/');
|
p = vim_strchr((char *)scriptname, '/');
|
||||||
plen = (int)STRLEN(p);
|
plen = (int)STRLEN(p);
|
||||||
slen = (int)STRLEN(SOURCING_NAME);
|
slen = (int)STRLEN(SOURCING_NAME);
|
||||||
if (slen > plen && FNAMECMP(p, SOURCING_NAME + slen - plen) == 0) {
|
if (slen > plen && FNAMECMP(p, SOURCING_NAME + slen - plen) == 0) {
|
||||||
@ -2524,16 +2521,16 @@ void ex_function(exarg_T *eap)
|
|||||||
tv_clear(&fudi.fd_di->di_tv);
|
tv_clear(&fudi.fd_di->di_tv);
|
||||||
}
|
}
|
||||||
fudi.fd_di->di_tv.v_type = VAR_FUNC;
|
fudi.fd_di->di_tv.v_type = VAR_FUNC;
|
||||||
fudi.fd_di->di_tv.vval.v_string = (char *)vim_strsave(name);
|
fudi.fd_di->di_tv.vval.v_string = xstrdup(name);
|
||||||
|
|
||||||
// behave like "dict" was used
|
// behave like "dict" was used
|
||||||
flags |= FC_DICT;
|
flags |= FC_DICT;
|
||||||
}
|
}
|
||||||
|
|
||||||
// insert the new function in the function list
|
// insert the new function in the function list
|
||||||
set_ufunc_name(fp, name);
|
set_ufunc_name(fp, (char_u *)name);
|
||||||
if (overwrite) {
|
if (overwrite) {
|
||||||
hi = hash_find(&func_hashtab, (char *)name);
|
hi = hash_find(&func_hashtab, name);
|
||||||
hi->hi_key = UF2HIKEY(fp);
|
hi->hi_key = UF2HIKEY(fp);
|
||||||
} else if (hash_add(&func_hashtab, UF2HIKEY(fp)) == FAIL) {
|
} else if (hash_add(&func_hashtab, UF2HIKEY(fp)) == FAIL) {
|
||||||
xfree(fp);
|
xfree(fp);
|
||||||
@ -3213,7 +3210,7 @@ void make_partial(dict_T *const selfdict, typval_T *const rettv)
|
|||||||
? (char_u *)rettv->vval.v_string
|
? (char_u *)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.
|
||||||
fname = fname_trans_sid(fname, fname_buf, &tofree, &error);
|
fname = (char_u *)fname_trans_sid((char *)fname, (char *)fname_buf, (char **)&tofree, &error);
|
||||||
fp = find_func(fname);
|
fp = find_func(fname);
|
||||||
xfree(tofree);
|
xfree(tofree);
|
||||||
}
|
}
|
||||||
@ -3559,7 +3556,7 @@ bool set_ref_in_func(char_u *name, ufunc_T *fp_in, int copyID)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (fp_in == NULL) {
|
if (fp_in == NULL) {
|
||||||
fname = fname_trans_sid(name, fname_buf, &tofree, &error);
|
fname = (char_u *)fname_trans_sid((char *)name, (char *)fname_buf, (char **)&tofree, &error);
|
||||||
fp = find_func(fname);
|
fp = find_func(fname);
|
||||||
}
|
}
|
||||||
if (fp != NULL) {
|
if (fp != NULL) {
|
||||||
|
@ -330,7 +330,7 @@ static int linelen(int *has_tab)
|
|||||||
|
|
||||||
// Get the line. If it's empty bail out early (could be the empty string
|
// Get the line. If it's empty bail out early (could be the empty string
|
||||||
// for an unloaded buffer).
|
// for an unloaded buffer).
|
||||||
line = (char *)get_cursor_line_ptr();
|
line = get_cursor_line_ptr();
|
||||||
if (*line == NUL) {
|
if (*line == NUL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -601,7 +601,7 @@ void ex_sort(exarg_T *eap)
|
|||||||
nrs[lnum - eap->line1].st_u.num.value = 0;
|
nrs[lnum - eap->line1].st_u.num.value = 0;
|
||||||
} else {
|
} else {
|
||||||
nrs[lnum - eap->line1].st_u.num.is_number = true;
|
nrs[lnum - eap->line1].st_u.num.is_number = true;
|
||||||
vim_str2nr((char_u *)s, NULL, NULL, sort_what,
|
vim_str2nr(s, NULL, NULL, sort_what,
|
||||||
&nrs[lnum - eap->line1].st_u.num.value, NULL, 0, false);
|
&nrs[lnum - eap->line1].st_u.num.value, NULL, 0, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2808,7 +2808,7 @@ int do_ecmd(int fnum, char *ffname, char *sfname, exarg_T *eap, linenr_T newlnum
|
|||||||
// keep it. Also when it moves within a line. But not when it moves
|
// keep it. Also when it moves within a line. But not when it moves
|
||||||
// to the first non-blank.
|
// to the first non-blank.
|
||||||
if (!equalpos(curwin->w_cursor, orig_pos)) {
|
if (!equalpos(curwin->w_cursor, orig_pos)) {
|
||||||
const char *text = (char *)get_cursor_line_ptr();
|
const char *text = get_cursor_line_ptr();
|
||||||
|
|
||||||
if (curwin->w_cursor.lnum != orig_pos.lnum
|
if (curwin->w_cursor.lnum != orig_pos.lnum
|
||||||
|| curwin->w_cursor.col != (int)(skipwhite(text) - text)) {
|
|| curwin->w_cursor.col != (int)(skipwhite(text) - text)) {
|
||||||
@ -3354,7 +3354,7 @@ static bool sub_joining_lines(exarg_T *eap, char *pat, char *sub, char *cmd, boo
|
|||||||
save_re_pat(RE_SUBST, (char_u *)pat, p_magic);
|
save_re_pat(RE_SUBST, (char_u *)pat, p_magic);
|
||||||
}
|
}
|
||||||
// put pattern in history
|
// put pattern in history
|
||||||
add_to_history(HIST_SEARCH, (char_u *)pat, true, NUL);
|
add_to_history(HIST_SEARCH, pat, true, NUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -3694,7 +3694,7 @@ int expand_filename(exarg_T *eap, char **cmdlinep, char **errormsgp)
|
|||||||
// Decide to expand wildcards *before* replacing '%', '#', etc. If
|
// Decide to expand wildcards *before* replacing '%', '#', etc. If
|
||||||
// the file name contains a wildcard it should not cause expanding.
|
// the file name contains a wildcard it should not cause expanding.
|
||||||
// (it will be expanded anyway if there is a wildcard before replacing).
|
// (it will be expanded anyway if there is a wildcard before replacing).
|
||||||
int has_wildcards = path_has_wildcard((char_u *)p);
|
int has_wildcards = path_has_wildcard(p);
|
||||||
while (*p != NUL) {
|
while (*p != NUL) {
|
||||||
// Skip over `=expr`, wildcards in it are not expanded.
|
// Skip over `=expr`, wildcards in it are not expanded.
|
||||||
if (p[0] == '`' && p[1] == '=') {
|
if (p[0] == '`' && p[1] == '=') {
|
||||||
@ -3799,7 +3799,7 @@ int expand_filename(exarg_T *eap, char **cmdlinep, char **errormsgp)
|
|||||||
if (vim_strchr(eap->arg, '$') != NULL
|
if (vim_strchr(eap->arg, '$') != NULL
|
||||||
|| vim_strchr(eap->arg, '~') != NULL) {
|
|| vim_strchr(eap->arg, '~') != NULL) {
|
||||||
expand_env_esc((char_u *)eap->arg, (char_u *)NameBuff, MAXPATHL, true, true, NULL);
|
expand_env_esc((char_u *)eap->arg, (char_u *)NameBuff, MAXPATHL, true, true, NULL);
|
||||||
has_wildcards = path_has_wildcard((char_u *)NameBuff);
|
has_wildcards = path_has_wildcard(NameBuff);
|
||||||
p = (char *)NameBuff;
|
p = (char *)NameBuff;
|
||||||
} else {
|
} else {
|
||||||
p = NULL;
|
p = NULL;
|
||||||
|
@ -255,7 +255,7 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
|
|||||||
exarg_T ea = {
|
exarg_T ea = {
|
||||||
.line1 = 1,
|
.line1 = 1,
|
||||||
.line2 = 1,
|
.line2 = 1,
|
||||||
.cmd = (char *)ccline.cmdbuff,
|
.cmd = ccline.cmdbuff,
|
||||||
.addr_type = ADDR_LINES,
|
.addr_type = ADDR_LINES,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ static bool do_incsearch_highlighting(int firstc, int *search_delim, incsearch_s
|
|||||||
}
|
}
|
||||||
|
|
||||||
// found a non-empty pattern or //
|
// found a non-empty pattern or //
|
||||||
*skiplen = (int)((char_u *)p - ccline.cmdbuff);
|
*skiplen = (int)(p - ccline.cmdbuff);
|
||||||
*patlen = (int)(end - p);
|
*patlen = (int)(end - p);
|
||||||
|
|
||||||
// parse the address range
|
// parse the address range
|
||||||
@ -409,7 +409,7 @@ static void may_do_incsearch_highlighting(int firstc, long count, incsearch_stat
|
|||||||
int found; // do_search() result
|
int found; // do_search() result
|
||||||
|
|
||||||
// Use the previous pattern for ":s//".
|
// Use the previous pattern for ":s//".
|
||||||
next_char = ccline.cmdbuff[skiplen + patlen];
|
next_char = (char_u)ccline.cmdbuff[skiplen + patlen];
|
||||||
use_last_pat = patlen == 0 && skiplen > 0
|
use_last_pat = patlen == 0 && skiplen > 0
|
||||||
&& ccline.cmdbuff[skiplen - 1] == next_char;
|
&& ccline.cmdbuff[skiplen - 1] == next_char;
|
||||||
|
|
||||||
@ -436,9 +436,9 @@ static void may_do_incsearch_highlighting(int firstc, long count, incsearch_stat
|
|||||||
.sa_tm = &tm,
|
.sa_tm = &tm,
|
||||||
};
|
};
|
||||||
found = do_search(NULL, firstc == ':' ? '/' : firstc, search_delim,
|
found = do_search(NULL, firstc == ':' ? '/' : firstc, search_delim,
|
||||||
ccline.cmdbuff + skiplen, count,
|
(char_u *)ccline.cmdbuff + skiplen, count,
|
||||||
search_flags, &sia);
|
search_flags, &sia);
|
||||||
ccline.cmdbuff[skiplen + patlen] = next_char;
|
ccline.cmdbuff[skiplen + patlen] = (char)next_char;
|
||||||
emsg_off--;
|
emsg_off--;
|
||||||
if (curwin->w_cursor.lnum < search_first_line
|
if (curwin->w_cursor.lnum < search_first_line
|
||||||
|| curwin->w_cursor.lnum > search_last_line) {
|
|| curwin->w_cursor.lnum > search_last_line) {
|
||||||
@ -487,13 +487,13 @@ static void may_do_incsearch_highlighting(int firstc, long count, incsearch_stat
|
|||||||
// Disable 'hlsearch' highlighting if the pattern matches
|
// Disable 'hlsearch' highlighting if the pattern matches
|
||||||
// everything. Avoids a flash when typing "foo\|".
|
// everything. Avoids a flash when typing "foo\|".
|
||||||
if (!use_last_pat) {
|
if (!use_last_pat) {
|
||||||
next_char = ccline.cmdbuff[skiplen + patlen];
|
next_char = (char_u)ccline.cmdbuff[skiplen + patlen];
|
||||||
ccline.cmdbuff[skiplen + patlen] = NUL;
|
ccline.cmdbuff[skiplen + patlen] = NUL;
|
||||||
if (empty_pattern((char *)ccline.cmdbuff) && !no_hlsearch) {
|
if (empty_pattern(ccline.cmdbuff) && !no_hlsearch) {
|
||||||
redraw_all_later(UPD_SOME_VALID);
|
redraw_all_later(UPD_SOME_VALID);
|
||||||
set_no_hlsearch(true);
|
set_no_hlsearch(true);
|
||||||
}
|
}
|
||||||
ccline.cmdbuff[skiplen + patlen] = next_char;
|
ccline.cmdbuff[skiplen + patlen] = (char)next_char;
|
||||||
}
|
}
|
||||||
|
|
||||||
validate_cursor();
|
validate_cursor();
|
||||||
@ -548,7 +548,7 @@ static int may_add_char_to_search(int firstc, int *c, incsearch_state_T *s)
|
|||||||
// command line has no uppercase characters, convert
|
// command line has no uppercase characters, convert
|
||||||
// the character to lowercase
|
// the character to lowercase
|
||||||
if (p_ic && p_scs
|
if (p_ic && p_scs
|
||||||
&& !pat_has_uppercase(ccline.cmdbuff + skiplen)) {
|
&& !pat_has_uppercase((char_u *)ccline.cmdbuff + skiplen)) {
|
||||||
*c = mb_tolower(*c);
|
*c = mb_tolower(*c);
|
||||||
}
|
}
|
||||||
if (*c == search_delim
|
if (*c == search_delim
|
||||||
@ -724,7 +724,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent, bool init
|
|||||||
|
|
||||||
if (ccline.input_fn) {
|
if (ccline.input_fn) {
|
||||||
s->xpc.xp_context = ccline.xp_context;
|
s->xpc.xp_context = ccline.xp_context;
|
||||||
s->xpc.xp_pattern = (char *)ccline.cmdbuff;
|
s->xpc.xp_pattern = ccline.cmdbuff;
|
||||||
s->xpc.xp_arg = (char *)ccline.xp_arg;
|
s->xpc.xp_arg = (char *)ccline.xp_arg;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -854,7 +854,7 @@ static uint8_t *command_line_enter(int firstc, long count, int indent, bool init
|
|||||||
s->histype == HIST_SEARCH ? s->firstc : NUL);
|
s->histype == HIST_SEARCH ? s->firstc : NUL);
|
||||||
if (s->firstc == ':') {
|
if (s->firstc == ':') {
|
||||||
xfree(new_last_cmdline);
|
xfree(new_last_cmdline);
|
||||||
new_last_cmdline = (char *)vim_strsave(ccline.cmdbuff);
|
new_last_cmdline = xstrdup(ccline.cmdbuff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -897,7 +897,7 @@ theend:
|
|||||||
xfree(ccline.last_colors.cmdbuff);
|
xfree(ccline.last_colors.cmdbuff);
|
||||||
kv_destroy(ccline.last_colors.colors);
|
kv_destroy(ccline.last_colors.colors);
|
||||||
|
|
||||||
char_u *p = ccline.cmdbuff;
|
char_u *p = (char_u *)ccline.cmdbuff;
|
||||||
|
|
||||||
if (ui_has(kUICmdline)) {
|
if (ui_has(kUICmdline)) {
|
||||||
ui_call_cmdline_hide(ccline.level);
|
ui_call_cmdline_hide(ccline.level);
|
||||||
@ -1339,7 +1339,7 @@ static int may_do_command_line_next_incsearch(int firstc, long count, incsearch_
|
|||||||
skiplen = 0;
|
skiplen = 0;
|
||||||
patlen = (int)STRLEN(pat);
|
patlen = (int)STRLEN(pat);
|
||||||
} else {
|
} else {
|
||||||
pat = ccline.cmdbuff + skiplen;
|
pat = (char_u *)ccline.cmdbuff + skiplen;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (next_match) {
|
if (next_match) {
|
||||||
@ -1483,24 +1483,24 @@ static int command_line_handle_key(CommandLineState *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (s->c == K_DEL) {
|
if (s->c == K_DEL) {
|
||||||
ccline.cmdpos += mb_off_next(ccline.cmdbuff,
|
ccline.cmdpos += mb_off_next((char_u *)ccline.cmdbuff,
|
||||||
ccline.cmdbuff + ccline.cmdpos);
|
(char_u *)ccline.cmdbuff + ccline.cmdpos);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ccline.cmdpos > 0) {
|
if (ccline.cmdpos > 0) {
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
int j = ccline.cmdpos;
|
int j = ccline.cmdpos;
|
||||||
p = mb_prevptr(ccline.cmdbuff, ccline.cmdbuff + j);
|
p = mb_prevptr((char_u *)ccline.cmdbuff, (char_u *)ccline.cmdbuff + j);
|
||||||
|
|
||||||
if (s->c == Ctrl_W) {
|
if (s->c == Ctrl_W) {
|
||||||
while (p > ccline.cmdbuff && ascii_isspace(*p)) {
|
while (p > (char_u *)ccline.cmdbuff && ascii_isspace(*p)) {
|
||||||
p = mb_prevptr(ccline.cmdbuff, p);
|
p = mb_prevptr((char_u *)ccline.cmdbuff, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = mb_get_class(p);
|
int i = mb_get_class(p);
|
||||||
while (p > ccline.cmdbuff && mb_get_class(p) == i) {
|
while (p > (char_u *)ccline.cmdbuff && mb_get_class(p) == i) {
|
||||||
p = mb_prevptr(ccline.cmdbuff, p);
|
p = mb_prevptr((char_u *)ccline.cmdbuff, p);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mb_get_class(p) != i) {
|
if (mb_get_class(p) != i) {
|
||||||
@ -1508,7 +1508,7 @@ static int command_line_handle_key(CommandLineState *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ccline.cmdpos = (int)(p - ccline.cmdbuff);
|
ccline.cmdpos = (int)(p - (char_u *)ccline.cmdbuff);
|
||||||
ccline.cmdlen -= j - ccline.cmdpos;
|
ccline.cmdlen -= j - ccline.cmdpos;
|
||||||
int i = ccline.cmdpos;
|
int i = ccline.cmdpos;
|
||||||
|
|
||||||
@ -1688,7 +1688,7 @@ static int command_line_handle_key(CommandLineState *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ccline.cmdspos += cells;
|
ccline.cmdspos += cells;
|
||||||
ccline.cmdpos += utfc_ptr2len((char *)ccline.cmdbuff + ccline.cmdpos);
|
ccline.cmdpos += utfc_ptr2len(ccline.cmdbuff + ccline.cmdpos);
|
||||||
} while ((s->c == K_S_RIGHT || s->c == K_C_RIGHT
|
} while ((s->c == K_S_RIGHT || s->c == K_C_RIGHT
|
||||||
|| (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)))
|
|| (mod_mask & (MOD_MASK_SHIFT|MOD_MASK_CTRL)))
|
||||||
&& ccline.cmdbuff[ccline.cmdpos] != ' ');
|
&& ccline.cmdbuff[ccline.cmdpos] != ' ');
|
||||||
@ -1704,8 +1704,8 @@ static int command_line_handle_key(CommandLineState *s)
|
|||||||
do {
|
do {
|
||||||
ccline.cmdpos--;
|
ccline.cmdpos--;
|
||||||
// Move to first byte of possibly multibyte char.
|
// Move to first byte of possibly multibyte char.
|
||||||
ccline.cmdpos -= utf_head_off((char *)ccline.cmdbuff,
|
ccline.cmdpos -= utf_head_off(ccline.cmdbuff,
|
||||||
(char *)ccline.cmdbuff + ccline.cmdpos);
|
ccline.cmdbuff + ccline.cmdpos);
|
||||||
ccline.cmdspos -= cmdline_charsize(ccline.cmdpos);
|
ccline.cmdspos -= cmdline_charsize(ccline.cmdpos);
|
||||||
} while (ccline.cmdpos > 0
|
} while (ccline.cmdpos > 0
|
||||||
&& (s->c == K_S_LEFT || s->c == K_C_LEFT
|
&& (s->c == K_S_LEFT || s->c == K_C_LEFT
|
||||||
@ -1761,7 +1761,7 @@ static int command_line_handle_key(CommandLineState *s)
|
|||||||
|
|
||||||
// Count ">" for double-wide char that doesn't fit.
|
// Count ">" for double-wide char that doesn't fit.
|
||||||
correct_screencol(ccline.cmdpos, cells, &ccline.cmdspos);
|
correct_screencol(ccline.cmdpos, cells, &ccline.cmdspos);
|
||||||
ccline.cmdpos += utfc_ptr2len((char *)ccline.cmdbuff + ccline.cmdpos) - 1;
|
ccline.cmdpos += utfc_ptr2len(ccline.cmdbuff + ccline.cmdpos) - 1;
|
||||||
ccline.cmdspos += cells;
|
ccline.cmdspos += cells;
|
||||||
}
|
}
|
||||||
return command_line_not_changed(s);
|
return command_line_not_changed(s);
|
||||||
@ -1855,7 +1855,7 @@ static int command_line_handle_key(CommandLineState *s)
|
|||||||
|
|
||||||
// save current command string so it can be restored later
|
// save current command string so it can be restored later
|
||||||
if (s->lookfor == NULL) {
|
if (s->lookfor == NULL) {
|
||||||
s->lookfor = vim_strsave(ccline.cmdbuff);
|
s->lookfor = vim_strsave((char_u *)ccline.cmdbuff);
|
||||||
s->lookfor[ccline.cmdpos] = NUL;
|
s->lookfor[ccline.cmdpos] = NUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1874,7 +1874,7 @@ static int command_line_handle_key(CommandLineState *s)
|
|||||||
if (s->hiscnt == get_hislen()) {
|
if (s->hiscnt == get_hislen()) {
|
||||||
p = s->lookfor; // back to the old one
|
p = s->lookfor; // back to the old one
|
||||||
} else {
|
} else {
|
||||||
p = get_histentry(s->histype)[s->hiscnt].hisstr;
|
p = (char_u *)get_histentry(s->histype)[s->hiscnt].hisstr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (s->histype == HIST_SEARCH
|
if (s->histype == HIST_SEARCH
|
||||||
@ -1892,7 +1892,7 @@ static int command_line_handle_key(CommandLineState *s)
|
|||||||
if (p[j] == old_firstc
|
if (p[j] == old_firstc
|
||||||
&& (j == 0 || p[j - 1] != '\\')) {
|
&& (j == 0 || p[j - 1] != '\\')) {
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
ccline.cmdbuff[len] = (char_u)s->firstc;
|
ccline.cmdbuff[len] = (char)s->firstc;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Escape new sep, unless it is already
|
// Escape new sep, unless it is already
|
||||||
@ -1906,7 +1906,7 @@ static int command_line_handle_key(CommandLineState *s)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
ccline.cmdbuff[len] = p[j];
|
ccline.cmdbuff[len] = (char)p[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
len++;
|
len++;
|
||||||
@ -2281,7 +2281,7 @@ static bool cmdpreview_may_show(CommandLineState *s)
|
|||||||
CmdParseInfo cmdinfo;
|
CmdParseInfo cmdinfo;
|
||||||
// Copy the command line so we can modify it.
|
// Copy the command line so we can modify it.
|
||||||
int cmdpreview_type = 0;
|
int cmdpreview_type = 0;
|
||||||
char *cmdline = xstrdup((char *)ccline.cmdbuff);
|
char *cmdline = xstrdup(ccline.cmdbuff);
|
||||||
char *errormsg = NULL;
|
char *errormsg = NULL;
|
||||||
emsg_off++; // Block errors when parsing the command line, and don't update v:errmsg
|
emsg_off++; // Block errors when parsing the command line, and don't update v:errmsg
|
||||||
if (!parse_cmdline(cmdline, &ea, &cmdinfo, &errormsg)) {
|
if (!parse_cmdline(cmdline, &ea, &cmdinfo, &errormsg)) {
|
||||||
@ -2659,7 +2659,7 @@ static int cmdline_charsize(int idx)
|
|||||||
if (cmdline_star > 0) { // showing '*', always 1 position
|
if (cmdline_star > 0) { // showing '*', always 1 position
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return ptr2cells((char *)ccline.cmdbuff + idx);
|
return ptr2cells(ccline.cmdbuff + idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Compute the offset of the cursor on the command line for the prompt and
|
/// Compute the offset of the cursor on the command line for the prompt and
|
||||||
@ -2685,7 +2685,7 @@ int cmd_screencol(int bytepos)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < ccline.cmdlen && i < bytepos;
|
for (int i = 0; i < ccline.cmdlen && i < bytepos;
|
||||||
i += utfc_ptr2len((char *)ccline.cmdbuff + i)) {
|
i += utfc_ptr2len(ccline.cmdbuff + i)) {
|
||||||
int c = cmdline_charsize(i);
|
int c = cmdline_charsize(i);
|
||||||
// Count ">" for double-wide multi-byte char that doesn't fit.
|
// Count ">" for double-wide multi-byte char that doesn't fit.
|
||||||
correct_screencol(i, c, &col);
|
correct_screencol(i, c, &col);
|
||||||
@ -2704,8 +2704,8 @@ int cmd_screencol(int bytepos)
|
|||||||
/// character that doesn't fit, so that a ">" must be displayed.
|
/// character that doesn't fit, so that a ">" must be displayed.
|
||||||
static void correct_screencol(int idx, int cells, int *col)
|
static void correct_screencol(int idx, int cells, int *col)
|
||||||
{
|
{
|
||||||
if (utfc_ptr2len((char *)ccline.cmdbuff + idx) > 1
|
if (utfc_ptr2len(ccline.cmdbuff + idx) > 1
|
||||||
&& utf_ptr2cells((char *)ccline.cmdbuff + idx) > 1
|
&& utf_ptr2cells(ccline.cmdbuff + idx) > 1
|
||||||
&& (*col) % Columns + cells > Columns) {
|
&& (*col) % Columns + cells > Columns) {
|
||||||
(*col)++;
|
(*col)++;
|
||||||
}
|
}
|
||||||
@ -2764,7 +2764,7 @@ void realloc_cmdbuff(int len)
|
|||||||
return; // no need to resize
|
return; // no need to resize
|
||||||
}
|
}
|
||||||
|
|
||||||
char_u *p = ccline.cmdbuff;
|
char_u *p = (char_u *)ccline.cmdbuff;
|
||||||
alloc_cmdbuff(len); // will get some more
|
alloc_cmdbuff(len); // will get some more
|
||||||
// There isn't always a NUL after the command, but it may need to be
|
// There isn't always a NUL after the command, but it may need to be
|
||||||
// there, thus copy up to the NUL and add a NUL.
|
// there, thus copy up to the NUL and add a NUL.
|
||||||
@ -2781,7 +2781,7 @@ void realloc_cmdbuff(int len)
|
|||||||
// If xp_pattern points inside the old cmdbuff it needs to be adjusted
|
// If xp_pattern points inside the old cmdbuff it needs to be adjusted
|
||||||
// to point into the newly allocated memory.
|
// to point into the newly allocated memory.
|
||||||
if (i >= 0 && i <= ccline.cmdlen) {
|
if (i >= 0 && i <= ccline.cmdlen) {
|
||||||
ccline.xpc->xp_pattern = (char *)ccline.cmdbuff + i;
|
ccline.xpc->xp_pattern = ccline.cmdbuff + i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2904,7 +2904,7 @@ static bool color_cmdline(CmdlineInfo *colored_ccline)
|
|||||||
bool arg_allocated = false;
|
bool arg_allocated = false;
|
||||||
typval_T arg = {
|
typval_T arg = {
|
||||||
.v_type = VAR_STRING,
|
.v_type = VAR_STRING,
|
||||||
.vval.v_string = (char *)colored_ccline->cmdbuff,
|
.vval.v_string = colored_ccline->cmdbuff,
|
||||||
};
|
};
|
||||||
typval_T tv = { .v_type = VAR_UNKNOWN };
|
typval_T tv = { .v_type = VAR_UNKNOWN };
|
||||||
|
|
||||||
@ -3107,16 +3107,16 @@ static void draw_cmdline(int start, int len)
|
|||||||
if (cmdline_star > 0) {
|
if (cmdline_star > 0) {
|
||||||
for (int i = 0; i < len; i++) {
|
for (int i = 0; i < len; i++) {
|
||||||
msg_putchar('*');
|
msg_putchar('*');
|
||||||
i += utfc_ptr2len((char *)ccline.cmdbuff + start + i) - 1;
|
i += utfc_ptr2len(ccline.cmdbuff + start + i) - 1;
|
||||||
}
|
}
|
||||||
} else if (p_arshape && !p_tbidi && len > 0) {
|
} else if (p_arshape && !p_tbidi && len > 0) {
|
||||||
bool do_arabicshape = false;
|
bool do_arabicshape = false;
|
||||||
int mb_l;
|
int mb_l;
|
||||||
for (int i = start; i < start + len; i += mb_l) {
|
for (int i = start; i < start + len; i += mb_l) {
|
||||||
char_u *p = ccline.cmdbuff + i;
|
char_u *p = (char_u *)ccline.cmdbuff + i;
|
||||||
int u8cc[MAX_MCO];
|
int u8cc[MAX_MCO];
|
||||||
int u8c = utfc_ptr2char_len(p, u8cc, start + len - i);
|
int u8c = utfc_ptr2char_len(p, u8cc, start + len - i);
|
||||||
mb_l = utfc_ptr2len_len(p, start + len - i);
|
mb_l = utfc_ptr2len_len((char *)p, start + len - i);
|
||||||
if (ARABIC_CHAR(u8c)) {
|
if (ARABIC_CHAR(u8c)) {
|
||||||
do_arabicshape = true;
|
do_arabicshape = true;
|
||||||
break;
|
break;
|
||||||
@ -3140,7 +3140,7 @@ static void draw_cmdline(int start, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int newlen = 0;
|
int newlen = 0;
|
||||||
if (utf_iscomposing(utf_ptr2char((char *)ccline.cmdbuff + start))) {
|
if (utf_iscomposing(utf_ptr2char(ccline.cmdbuff + start))) {
|
||||||
// Prepend a space to draw the leading composing char on.
|
// Prepend a space to draw the leading composing char on.
|
||||||
arshape_buf[0] = ' ';
|
arshape_buf[0] = ' ';
|
||||||
newlen = 1;
|
newlen = 1;
|
||||||
@ -3149,10 +3149,10 @@ static void draw_cmdline(int start, int len)
|
|||||||
int prev_c = 0;
|
int prev_c = 0;
|
||||||
int prev_c1 = 0;
|
int prev_c1 = 0;
|
||||||
for (int i = start; i < start + len; i += mb_l) {
|
for (int i = start; i < start + len; i += mb_l) {
|
||||||
char_u *p = ccline.cmdbuff + i;
|
char_u *p = (char_u *)ccline.cmdbuff + i;
|
||||||
int u8cc[MAX_MCO];
|
int u8cc[MAX_MCO];
|
||||||
int u8c = utfc_ptr2char_len(p, u8cc, start + len - i);
|
int u8c = utfc_ptr2char_len(p, u8cc, start + len - i);
|
||||||
mb_l = utfc_ptr2len_len(p, start + len - i);
|
mb_l = utfc_ptr2len_len((char *)p, start + len - i);
|
||||||
if (ARABIC_CHAR(u8c)) {
|
if (ARABIC_CHAR(u8c)) {
|
||||||
int pc;
|
int pc;
|
||||||
int pc1 = 0;
|
int pc1 = 0;
|
||||||
@ -3208,12 +3208,12 @@ draw_cmdline_no_arabicshape:
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const int chunk_start = MAX(chunk.start, start);
|
const int chunk_start = MAX(chunk.start, start);
|
||||||
msg_outtrans_len_attr((char *)ccline.cmdbuff + chunk_start,
|
msg_outtrans_len_attr(ccline.cmdbuff + chunk_start,
|
||||||
chunk.end - chunk_start,
|
chunk.end - chunk_start,
|
||||||
chunk.attr);
|
chunk.attr);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
msg_outtrans_len((char *)ccline.cmdbuff + start, len);
|
msg_outtrans_len(ccline.cmdbuff + start, len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3225,7 +3225,7 @@ static void ui_ext_cmdline_show(CmdlineInfo *line)
|
|||||||
if (cmdline_star) {
|
if (cmdline_star) {
|
||||||
content = arena_array(&arena, 1);
|
content = arena_array(&arena, 1);
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
for (char_u *p = ccline.cmdbuff; *p; MB_PTR_ADV(p)) {
|
for (char_u *p = (char_u *)ccline.cmdbuff; *p; MB_PTR_ADV(p)) {
|
||||||
len++;
|
len++;
|
||||||
}
|
}
|
||||||
char *buf = arena_alloc(&arena, len, false);
|
char *buf = arena_alloc(&arena, len, false);
|
||||||
@ -3380,7 +3380,7 @@ void unputcmdline(void)
|
|||||||
if (ccline.cmdlen == ccline.cmdpos && !ui_has(kUICmdline)) {
|
if (ccline.cmdlen == ccline.cmdpos && !ui_has(kUICmdline)) {
|
||||||
msg_putchar(' ');
|
msg_putchar(' ');
|
||||||
} else {
|
} else {
|
||||||
draw_cmdline(ccline.cmdpos, utfc_ptr2len((char *)ccline.cmdbuff + ccline.cmdpos));
|
draw_cmdline(ccline.cmdpos, utfc_ptr2len(ccline.cmdbuff + ccline.cmdpos));
|
||||||
}
|
}
|
||||||
msg_no_more = false;
|
msg_no_more = false;
|
||||||
cursorcmd();
|
cursorcmd();
|
||||||
@ -3422,7 +3422,7 @@ void put_on_cmdline(char_u *str, int len, int redraw)
|
|||||||
// Count nr of bytes in cmdline that are overwritten by these
|
// Count nr of bytes in cmdline that are overwritten by these
|
||||||
// characters.
|
// characters.
|
||||||
for (i = ccline.cmdpos; i < ccline.cmdlen && m > 0;
|
for (i = ccline.cmdpos; i < ccline.cmdlen && m > 0;
|
||||||
i += utfc_ptr2len((char *)ccline.cmdbuff + i)) {
|
i += utfc_ptr2len(ccline.cmdbuff + i)) {
|
||||||
m--;
|
m--;
|
||||||
}
|
}
|
||||||
if (i < ccline.cmdlen) {
|
if (i < ccline.cmdlen) {
|
||||||
@ -3440,17 +3440,17 @@ void put_on_cmdline(char_u *str, int len, int redraw)
|
|||||||
// When the inserted text starts with a composing character,
|
// When the inserted text starts with a composing character,
|
||||||
// backup to the character before it. There could be two of them.
|
// backup to the character before it. There could be two of them.
|
||||||
i = 0;
|
i = 0;
|
||||||
c = utf_ptr2char((char *)ccline.cmdbuff + ccline.cmdpos);
|
c = utf_ptr2char(ccline.cmdbuff + ccline.cmdpos);
|
||||||
while (ccline.cmdpos > 0 && utf_iscomposing(c)) {
|
while (ccline.cmdpos > 0 && utf_iscomposing(c)) {
|
||||||
i = utf_head_off((char *)ccline.cmdbuff, (char *)ccline.cmdbuff + ccline.cmdpos - 1) + 1;
|
i = utf_head_off(ccline.cmdbuff, ccline.cmdbuff + ccline.cmdpos - 1) + 1;
|
||||||
ccline.cmdpos -= i;
|
ccline.cmdpos -= i;
|
||||||
len += i;
|
len += i;
|
||||||
c = utf_ptr2char((char *)ccline.cmdbuff + ccline.cmdpos);
|
c = utf_ptr2char(ccline.cmdbuff + ccline.cmdpos);
|
||||||
}
|
}
|
||||||
if (i == 0 && ccline.cmdpos > 0 && arabic_maycombine(c)) {
|
if (i == 0 && ccline.cmdpos > 0 && arabic_maycombine(c)) {
|
||||||
// Check the previous character for Arabic combining pair.
|
// Check the previous character for Arabic combining pair.
|
||||||
i = utf_head_off((char *)ccline.cmdbuff, (char *)ccline.cmdbuff + ccline.cmdpos - 1) + 1;
|
i = utf_head_off(ccline.cmdbuff, ccline.cmdbuff + ccline.cmdpos - 1) + 1;
|
||||||
if (arabic_combine(utf_ptr2char((char *)ccline.cmdbuff + ccline.cmdpos - i), c)) {
|
if (arabic_combine(utf_ptr2char(ccline.cmdbuff + ccline.cmdpos - i), c)) {
|
||||||
ccline.cmdpos -= i;
|
ccline.cmdpos -= i;
|
||||||
len += i;
|
len += i;
|
||||||
} else {
|
} else {
|
||||||
@ -3459,7 +3459,7 @@ void put_on_cmdline(char_u *str, int len, int redraw)
|
|||||||
}
|
}
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
// Also backup the cursor position.
|
// Also backup the cursor position.
|
||||||
i = ptr2cells((char *)ccline.cmdbuff + ccline.cmdpos);
|
i = ptr2cells(ccline.cmdbuff + ccline.cmdpos);
|
||||||
ccline.cmdspos -= i;
|
ccline.cmdspos -= i;
|
||||||
msg_col -= i;
|
msg_col -= i;
|
||||||
if (msg_col < 0) {
|
if (msg_col < 0) {
|
||||||
@ -3498,7 +3498,7 @@ void put_on_cmdline(char_u *str, int len, int redraw)
|
|||||||
if (ccline.cmdspos + c < m) {
|
if (ccline.cmdspos + c < m) {
|
||||||
ccline.cmdspos += c;
|
ccline.cmdspos += c;
|
||||||
}
|
}
|
||||||
c = utfc_ptr2len((char *)ccline.cmdbuff + ccline.cmdpos) - 1;
|
c = utfc_ptr2len(ccline.cmdbuff + ccline.cmdpos) - 1;
|
||||||
if (c > len - i - 1) {
|
if (c > len - i - 1) {
|
||||||
c = len - i - 1;
|
c = len - i - 1;
|
||||||
}
|
}
|
||||||
@ -3580,14 +3580,14 @@ static bool cmdline_paste(int regname, bool literally, bool remcr)
|
|||||||
int len;
|
int len;
|
||||||
|
|
||||||
// Locate start of last word in the cmd buffer.
|
// Locate start of last word in the cmd buffer.
|
||||||
for (w = ccline.cmdbuff + ccline.cmdpos; w > ccline.cmdbuff;) {
|
for (w = (char_u *)ccline.cmdbuff + ccline.cmdpos; w > (char_u *)ccline.cmdbuff;) {
|
||||||
len = utf_head_off((char *)ccline.cmdbuff, (char *)w - 1) + 1;
|
len = utf_head_off(ccline.cmdbuff, (char *)w - 1) + 1;
|
||||||
if (!vim_iswordc(utf_ptr2char((char *)w - len))) {
|
if (!vim_iswordc(utf_ptr2char((char *)w - len))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
w -= len;
|
w -= len;
|
||||||
}
|
}
|
||||||
len = (int)((ccline.cmdbuff + ccline.cmdpos) - w);
|
len = (int)(((char_u *)ccline.cmdbuff + ccline.cmdpos) - w);
|
||||||
if (p_ic ? STRNICMP(w, arg, len) == 0 : STRNCMP(w, arg, len) == 0) {
|
if (p_ic ? STRNICMP(w, arg, len) == 0 : STRNCMP(w, arg, len) == 0) {
|
||||||
p += len;
|
p += len;
|
||||||
}
|
}
|
||||||
@ -3823,7 +3823,7 @@ static int ccheck_abbr(int c)
|
|||||||
spos = 0;
|
spos = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return check_abbr(c, ccline.cmdbuff, ccline.cmdpos, spos);
|
return check_abbr(c, (char_u *)ccline.cmdbuff, ccline.cmdpos, spos);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Escape special characters in "fname", depending on "what":
|
/// Escape special characters in "fname", depending on "what":
|
||||||
@ -3964,7 +3964,7 @@ static char *get_cmdline_str(void)
|
|||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return (char *)vim_strnsave(p->cmdbuff, (size_t)p->cmdlen);
|
return xstrnsave(p->cmdbuff, (size_t)p->cmdlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the current command-line completion type.
|
/// Get the current command-line completion type.
|
||||||
@ -4126,7 +4126,7 @@ int get_list_range(char **str, int *num1, int *num2)
|
|||||||
|
|
||||||
*str = skipwhite((*str));
|
*str = skipwhite((*str));
|
||||||
if (**str == '-' || ascii_isdigit(**str)) { // parse "from" part of range
|
if (**str == '-' || ascii_isdigit(**str)) { // parse "from" part of range
|
||||||
vim_str2nr((char_u *)(*str), NULL, &len, 0, &num, NULL, 0, false);
|
vim_str2nr(*str, NULL, &len, 0, &num, NULL, 0, false);
|
||||||
*str += len;
|
*str += len;
|
||||||
*num1 = (int)num;
|
*num1 = (int)num;
|
||||||
first = true;
|
first = true;
|
||||||
@ -4134,7 +4134,7 @@ int get_list_range(char **str, int *num1, int *num2)
|
|||||||
*str = skipwhite((*str));
|
*str = skipwhite((*str));
|
||||||
if (**str == ',') { // parse "to" part of range
|
if (**str == ',') { // parse "to" part of range
|
||||||
*str = skipwhite((*str) + 1);
|
*str = skipwhite((*str) + 1);
|
||||||
vim_str2nr((char_u *)(*str), NULL, &len, 0, &num, NULL, 0, false);
|
vim_str2nr(*str, NULL, &len, 0, &num, NULL, 0, false);
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
*num2 = (int)num;
|
*num2 = (int)num;
|
||||||
*str = skipwhite((*str) + len);
|
*str = skipwhite((*str) + len);
|
||||||
@ -4270,7 +4270,7 @@ static int open_cmdwin(void)
|
|||||||
i = 0;
|
i = 0;
|
||||||
}
|
}
|
||||||
if (get_histentry(histtype)[i].hisstr != NULL) {
|
if (get_histentry(histtype)[i].hisstr != NULL) {
|
||||||
ml_append(lnum++, (char *)get_histentry(histtype)[i].hisstr, (colnr_T)0, false);
|
ml_append(lnum++, get_histentry(histtype)[i].hisstr, (colnr_T)0, false);
|
||||||
}
|
}
|
||||||
} while (i != *get_hisidx(histtype));
|
} while (i != *get_hisidx(histtype));
|
||||||
}
|
}
|
||||||
@ -4278,7 +4278,7 @@ static int open_cmdwin(void)
|
|||||||
|
|
||||||
// Replace the empty last line with the current command-line and put the
|
// Replace the empty last line with the current command-line and put the
|
||||||
// cursor there.
|
// cursor there.
|
||||||
ml_replace(curbuf->b_ml.ml_line_count, (char *)ccline.cmdbuff, true);
|
ml_replace(curbuf->b_ml.ml_line_count, ccline.cmdbuff, true);
|
||||||
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
curwin->w_cursor.lnum = curbuf->b_ml.ml_line_count;
|
||||||
curwin->w_cursor.col = ccline.cmdpos;
|
curwin->w_cursor.col = ccline.cmdpos;
|
||||||
changed_line_abv_curs();
|
changed_line_abv_curs();
|
||||||
@ -4348,7 +4348,7 @@ static int open_cmdwin(void)
|
|||||||
|
|
||||||
if (histtype == HIST_CMD) {
|
if (histtype == HIST_CMD) {
|
||||||
// Execute the command directly.
|
// Execute the command directly.
|
||||||
ccline.cmdbuff = (char_u *)xstrdup(p);
|
ccline.cmdbuff = xstrdup(p);
|
||||||
cmdwin_result = CAR;
|
cmdwin_result = CAR;
|
||||||
} else {
|
} else {
|
||||||
// First need to cancel what we were doing.
|
// First need to cancel what we were doing.
|
||||||
@ -4362,10 +4362,10 @@ static int open_cmdwin(void)
|
|||||||
// and don't modify the cmd window.
|
// and don't modify the cmd window.
|
||||||
ccline.cmdbuff = NULL;
|
ccline.cmdbuff = NULL;
|
||||||
} else {
|
} else {
|
||||||
ccline.cmdbuff = vim_strsave(get_cursor_line_ptr());
|
ccline.cmdbuff = xstrdup(get_cursor_line_ptr());
|
||||||
}
|
}
|
||||||
if (ccline.cmdbuff == NULL) {
|
if (ccline.cmdbuff == NULL) {
|
||||||
ccline.cmdbuff = vim_strsave((char_u *)"");
|
ccline.cmdbuff = xstrdup("");
|
||||||
ccline.cmdlen = 0;
|
ccline.cmdlen = 0;
|
||||||
ccline.cmdbufflen = 1;
|
ccline.cmdbufflen = 1;
|
||||||
ccline.cmdpos = 0;
|
ccline.cmdpos = 0;
|
||||||
|
@ -41,7 +41,7 @@ typedef enum {
|
|||||||
/// structure.
|
/// structure.
|
||||||
typedef struct cmdline_info CmdlineInfo;
|
typedef struct cmdline_info CmdlineInfo;
|
||||||
struct cmdline_info {
|
struct cmdline_info {
|
||||||
char_u *cmdbuff; ///< pointer to command line buffer
|
char *cmdbuff; ///< pointer to command line buffer
|
||||||
int cmdbufflen; ///< length of cmdbuff
|
int cmdbufflen; ///< length of cmdbuff
|
||||||
int cmdlen; ///< number of chars in command line
|
int cmdlen; ///< number of chars in command line
|
||||||
int cmdpos; ///< current cursor position
|
int cmdpos; ///< current cursor position
|
||||||
|
@ -174,12 +174,12 @@ typedef struct ff_search_ctx_T {
|
|||||||
ff_visited_list_hdr_T *ffsc_dir_visited_list;
|
ff_visited_list_hdr_T *ffsc_dir_visited_list;
|
||||||
ff_visited_list_hdr_T *ffsc_visited_lists_list;
|
ff_visited_list_hdr_T *ffsc_visited_lists_list;
|
||||||
ff_visited_list_hdr_T *ffsc_dir_visited_lists_list;
|
ff_visited_list_hdr_T *ffsc_dir_visited_lists_list;
|
||||||
char_u *ffsc_file_to_search;
|
char *ffsc_file_to_search;
|
||||||
char_u *ffsc_start_dir;
|
char *ffsc_start_dir;
|
||||||
char_u *ffsc_fix_path;
|
char *ffsc_fix_path;
|
||||||
char_u *ffsc_wc_path;
|
char *ffsc_wc_path;
|
||||||
int ffsc_level;
|
int ffsc_level;
|
||||||
char_u **ffsc_stopdirs_v;
|
char **ffsc_stopdirs_v;
|
||||||
int ffsc_find_what;
|
int ffsc_find_what;
|
||||||
int ffsc_tagfile;
|
int ffsc_tagfile;
|
||||||
} ff_search_ctx_T;
|
} ff_search_ctx_T;
|
||||||
@ -245,11 +245,10 @@ static char_u e_pathtoolong[] = N_("E854: path too long for completion");
|
|||||||
///
|
///
|
||||||
/// @param tagfile expanding names of tags files
|
/// @param tagfile expanding names of tags files
|
||||||
/// @param rel_fname file name to use for "."
|
/// @param rel_fname file name to use for "."
|
||||||
void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int level,
|
void *vim_findfile_init(char *path, char *filename, char *stopdirs, int level, int free_visited,
|
||||||
int free_visited, int find_what, void *search_ctx_arg, int tagfile,
|
int find_what, void *search_ctx_arg, int tagfile, char *rel_fname)
|
||||||
char_u *rel_fname)
|
|
||||||
{
|
{
|
||||||
char_u *wc_part;
|
char *wc_part;
|
||||||
ff_stack_T *sptr;
|
ff_stack_T *sptr;
|
||||||
ff_search_ctx_T *search_ctx;
|
ff_search_ctx_T *search_ctx;
|
||||||
|
|
||||||
@ -274,12 +273,12 @@ void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int le
|
|||||||
/* Reuse old visited lists. Get the visited list for the given
|
/* Reuse old visited lists. Get the visited list for the given
|
||||||
* filename. If no list for the current filename exists, creates a new
|
* filename. If no list for the current filename exists, creates a new
|
||||||
* one. */
|
* one. */
|
||||||
search_ctx->ffsc_visited_list = ff_get_visited_list(filename,
|
search_ctx->ffsc_visited_list = ff_get_visited_list((char_u *)filename,
|
||||||
&search_ctx->ffsc_visited_lists_list);
|
&search_ctx->ffsc_visited_lists_list);
|
||||||
if (search_ctx->ffsc_visited_list == NULL) {
|
if (search_ctx->ffsc_visited_list == NULL) {
|
||||||
goto error_return;
|
goto error_return;
|
||||||
}
|
}
|
||||||
search_ctx->ffsc_dir_visited_list = ff_get_visited_list(filename,
|
search_ctx->ffsc_dir_visited_list = ff_get_visited_list((char_u *)filename,
|
||||||
&search_ctx->ffsc_dir_visited_lists_list);
|
&search_ctx->ffsc_dir_visited_lists_list);
|
||||||
if (search_ctx->ffsc_dir_visited_list == NULL) {
|
if (search_ctx->ffsc_dir_visited_list == NULL) {
|
||||||
goto error_return;
|
goto error_return;
|
||||||
@ -296,19 +295,19 @@ void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int le
|
|||||||
&& (vim_ispathsep(path[1]) || path[1] == NUL)
|
&& (vim_ispathsep(path[1]) || path[1] == NUL)
|
||||||
&& (!tagfile || vim_strchr(p_cpo, CPO_DOTTAG) == NULL)
|
&& (!tagfile || vim_strchr(p_cpo, CPO_DOTTAG) == NULL)
|
||||||
&& rel_fname != NULL) {
|
&& rel_fname != NULL) {
|
||||||
size_t len = (size_t)((char_u *)path_tail((char *)rel_fname) - rel_fname);
|
size_t len = (size_t)(path_tail(rel_fname) - rel_fname);
|
||||||
|
|
||||||
if (!vim_isAbsName(rel_fname) && len + 1 < MAXPATHL) {
|
if (!vim_isAbsName((char_u *)rel_fname) && len + 1 < MAXPATHL) {
|
||||||
// Make the start dir an absolute path name.
|
// Make the start dir an absolute path name.
|
||||||
STRLCPY(ff_expand_buffer, rel_fname, len + 1);
|
STRLCPY(ff_expand_buffer, rel_fname, len + 1);
|
||||||
search_ctx->ffsc_start_dir = (char_u *)FullName_save((char *)ff_expand_buffer, false);
|
search_ctx->ffsc_start_dir = FullName_save((char *)ff_expand_buffer, false);
|
||||||
} else {
|
} else {
|
||||||
search_ctx->ffsc_start_dir = vim_strnsave(rel_fname, len);
|
search_ctx->ffsc_start_dir = xstrnsave(rel_fname, len);
|
||||||
}
|
}
|
||||||
if (*++path != NUL) {
|
if (*++path != NUL) {
|
||||||
path++;
|
path++;
|
||||||
}
|
}
|
||||||
} else if (*path == NUL || !vim_isAbsName(path)) {
|
} else if (*path == NUL || !vim_isAbsName((char_u *)path)) {
|
||||||
#ifdef BACKSLASH_IN_FILENAME
|
#ifdef BACKSLASH_IN_FILENAME
|
||||||
// "c:dir" needs "c:" to be expanded, otherwise use current dir
|
// "c:dir" needs "c:" to be expanded, otherwise use current dir
|
||||||
if (*path != NUL && path[1] == ':') {
|
if (*path != NUL && path[1] == ':') {
|
||||||
@ -329,7 +328,7 @@ void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int le
|
|||||||
goto error_return;
|
goto error_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
search_ctx->ffsc_start_dir = vim_strsave(ff_expand_buffer);
|
search_ctx->ffsc_start_dir = (char *)vim_strsave(ff_expand_buffer);
|
||||||
|
|
||||||
#ifdef BACKSLASH_IN_FILENAME
|
#ifdef BACKSLASH_IN_FILENAME
|
||||||
/* A path that starts with "/dir" is relative to the drive, not to the
|
/* A path that starts with "/dir" is relative to the drive, not to the
|
||||||
@ -352,7 +351,7 @@ void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int le
|
|||||||
* ff_path_in_stoplist() for details.
|
* ff_path_in_stoplist() for details.
|
||||||
*/
|
*/
|
||||||
if (stopdirs != NULL) {
|
if (stopdirs != NULL) {
|
||||||
char_u *walker = stopdirs;
|
char *walker = stopdirs;
|
||||||
|
|
||||||
while (*walker == ';') {
|
while (*walker == ';') {
|
||||||
walker++;
|
walker++;
|
||||||
@ -362,25 +361,23 @@ void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int le
|
|||||||
search_ctx->ffsc_stopdirs_v = xmalloc(sizeof(char_u *));
|
search_ctx->ffsc_stopdirs_v = xmalloc(sizeof(char_u *));
|
||||||
|
|
||||||
do {
|
do {
|
||||||
char_u *helper;
|
char *helper;
|
||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
helper = walker;
|
helper = walker;
|
||||||
ptr = xrealloc(search_ctx->ffsc_stopdirs_v,
|
ptr = xrealloc(search_ctx->ffsc_stopdirs_v,
|
||||||
(dircount + 1) * sizeof(char_u *));
|
(dircount + 1) * sizeof(char_u *));
|
||||||
search_ctx->ffsc_stopdirs_v = ptr;
|
search_ctx->ffsc_stopdirs_v = ptr;
|
||||||
walker = (char_u *)vim_strchr((char *)walker, ';');
|
walker = vim_strchr(walker, ';');
|
||||||
if (walker) {
|
if (walker) {
|
||||||
assert(walker - helper >= 0);
|
assert(walker - helper >= 0);
|
||||||
search_ctx->ffsc_stopdirs_v[dircount - 1] =
|
search_ctx->ffsc_stopdirs_v[dircount - 1] = xstrnsave(helper, (size_t)(walker - helper));
|
||||||
vim_strnsave(helper, (size_t)(walker - helper));
|
|
||||||
walker++;
|
walker++;
|
||||||
} else {
|
} else {
|
||||||
/* this might be "", which means ascent till top
|
/* this might be "", which means ascent till top
|
||||||
* of directory tree.
|
* of directory tree.
|
||||||
*/
|
*/
|
||||||
search_ctx->ffsc_stopdirs_v[dircount - 1] =
|
search_ctx->ffsc_stopdirs_v[dircount - 1] = xstrdup(helper);
|
||||||
vim_strsave(helper);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dircount++;
|
dircount++;
|
||||||
@ -394,7 +391,7 @@ void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int le
|
|||||||
* -fix path
|
* -fix path
|
||||||
* -wildcard_stuff (might be NULL)
|
* -wildcard_stuff (might be NULL)
|
||||||
*/
|
*/
|
||||||
wc_part = (char_u *)vim_strchr((char *)path, '*');
|
wc_part = vim_strchr(path, '*');
|
||||||
if (wc_part != NULL) {
|
if (wc_part != NULL) {
|
||||||
int64_t llevel;
|
int64_t llevel;
|
||||||
int len;
|
int len;
|
||||||
@ -402,7 +399,7 @@ void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int le
|
|||||||
|
|
||||||
// save the fix part of the path
|
// save the fix part of the path
|
||||||
assert(wc_part - path >= 0);
|
assert(wc_part - path >= 0);
|
||||||
search_ctx->ffsc_fix_path = vim_strnsave(path, (size_t)(wc_part - path));
|
search_ctx->ffsc_fix_path = xstrnsave(path, (size_t)(wc_part - path));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* copy wc_path and add restricts to the '**' wildcard.
|
* copy wc_path and add restricts to the '**' wildcard.
|
||||||
@ -420,19 +417,19 @@ void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int le
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (STRNCMP(wc_part, "**", 2) == 0) {
|
if (STRNCMP(wc_part, "**", 2) == 0) {
|
||||||
ff_expand_buffer[len++] = *wc_part++;
|
ff_expand_buffer[len++] = (char_u)(*wc_part++);
|
||||||
ff_expand_buffer[len++] = *wc_part++;
|
ff_expand_buffer[len++] = (char_u)(*wc_part++);
|
||||||
|
|
||||||
llevel = strtol((char *)wc_part, &errpt, 10);
|
llevel = strtol(wc_part, &errpt, 10);
|
||||||
if ((char_u *)errpt != wc_part && llevel > 0 && llevel < 255) {
|
if (errpt != wc_part && llevel > 0 && llevel < 255) {
|
||||||
ff_expand_buffer[len++] = (char_u)llevel;
|
ff_expand_buffer[len++] = (char_u)llevel;
|
||||||
} else if ((char_u *)errpt != wc_part && llevel == 0) {
|
} else if (errpt != wc_part && llevel == 0) {
|
||||||
// restrict is 0 -> remove already added '**'
|
// restrict is 0 -> remove already added '**'
|
||||||
len -= 2;
|
len -= 2;
|
||||||
} else {
|
} else {
|
||||||
ff_expand_buffer[len++] = FF_MAX_STAR_STAR_EXPAND;
|
ff_expand_buffer[len++] = FF_MAX_STAR_STAR_EXPAND;
|
||||||
}
|
}
|
||||||
wc_part = (char_u *)errpt;
|
wc_part = errpt;
|
||||||
if (*wc_part != NUL && !vim_ispathsep(*wc_part)) {
|
if (*wc_part != NUL && !vim_ispathsep(*wc_part)) {
|
||||||
semsg(_(
|
semsg(_(
|
||||||
"E343: Invalid path: '**[number]' must be at the end of the path or be followed by '%s'."),
|
"E343: Invalid path: '**[number]' must be at the end of the path or be followed by '%s'."),
|
||||||
@ -440,20 +437,20 @@ void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int le
|
|||||||
goto error_return;
|
goto error_return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ff_expand_buffer[len++] = *wc_part++;
|
ff_expand_buffer[len++] = (char_u)(*wc_part++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ff_expand_buffer[len] = NUL;
|
ff_expand_buffer[len] = NUL;
|
||||||
search_ctx->ffsc_wc_path = vim_strsave(ff_expand_buffer);
|
search_ctx->ffsc_wc_path = (char *)vim_strsave(ff_expand_buffer);
|
||||||
} else {
|
} else {
|
||||||
search_ctx->ffsc_fix_path = vim_strsave(path);
|
search_ctx->ffsc_fix_path = xstrdup(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (search_ctx->ffsc_start_dir == NULL) {
|
if (search_ctx->ffsc_start_dir == NULL) {
|
||||||
/* store the fix part as startdir.
|
/* store the fix part as startdir.
|
||||||
* This is needed if the parameter path is fully qualified.
|
* This is needed if the parameter path is fully qualified.
|
||||||
*/
|
*/
|
||||||
search_ctx->ffsc_start_dir = vim_strsave(search_ctx->ffsc_fix_path);
|
search_ctx->ffsc_start_dir = xstrdup(search_ctx->ffsc_fix_path);
|
||||||
search_ctx->ffsc_fix_path[0] = NUL;
|
search_ctx->ffsc_fix_path[0] = NUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -475,9 +472,9 @@ void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int le
|
|||||||
STRCAT(ff_expand_buffer, search_ctx->ffsc_fix_path);
|
STRCAT(ff_expand_buffer, search_ctx->ffsc_fix_path);
|
||||||
add_pathsep((char *)ff_expand_buffer);
|
add_pathsep((char *)ff_expand_buffer);
|
||||||
} else {
|
} else {
|
||||||
char_u *p = (char_u *)path_tail((char *)search_ctx->ffsc_fix_path);
|
char *p = path_tail(search_ctx->ffsc_fix_path);
|
||||||
char_u *wc_path = NULL;
|
char *wc_path = NULL;
|
||||||
char_u *temp = NULL;
|
char *temp = NULL;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
|
|
||||||
if (p > search_ctx->ffsc_fix_path) {
|
if (p > search_ctx->ffsc_fix_path) {
|
||||||
@ -495,7 +492,7 @@ void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int le
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (search_ctx->ffsc_wc_path != NULL) {
|
if (search_ctx->ffsc_wc_path != NULL) {
|
||||||
wc_path = vim_strsave(search_ctx->ffsc_wc_path);
|
wc_path = xstrdup(search_ctx->ffsc_wc_path);
|
||||||
temp = xmalloc(STRLEN(search_ctx->ffsc_wc_path)
|
temp = xmalloc(STRLEN(search_ctx->ffsc_wc_path)
|
||||||
+ STRLEN(search_ctx->ffsc_fix_path + len)
|
+ STRLEN(search_ctx->ffsc_fix_path + len)
|
||||||
+ 1);
|
+ 1);
|
||||||
@ -509,10 +506,10 @@ void *vim_findfile_init(char_u *path, char_u *filename, char_u *stopdirs, int le
|
|||||||
xfree(buf);
|
xfree(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
sptr = ff_create_stack_element(ff_expand_buffer, search_ctx->ffsc_wc_path, level, 0);
|
sptr = ff_create_stack_element(ff_expand_buffer, (char_u *)search_ctx->ffsc_wc_path, level, 0);
|
||||||
|
|
||||||
ff_push(search_ctx, sptr);
|
ff_push(search_ctx, sptr);
|
||||||
search_ctx->ffsc_file_to_search = vim_strsave(filename);
|
search_ctx->ffsc_file_to_search = xstrdup(filename);
|
||||||
return search_ctx;
|
return search_ctx;
|
||||||
|
|
||||||
error_return:
|
error_return:
|
||||||
@ -598,8 +595,7 @@ char_u *vim_findfile(void *search_ctx_arg)
|
|||||||
|
|
||||||
// store the end of the start dir -- needed for upward search
|
// store the end of the start dir -- needed for upward search
|
||||||
if (search_ctx->ffsc_start_dir != NULL) {
|
if (search_ctx->ffsc_start_dir != NULL) {
|
||||||
path_end = &search_ctx->ffsc_start_dir[
|
path_end = (char_u *)&search_ctx->ffsc_start_dir[STRLEN(search_ctx->ffsc_start_dir)];
|
||||||
STRLEN(search_ctx->ffsc_start_dir)];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// upward search loop
|
// upward search loop
|
||||||
@ -930,19 +926,17 @@ char_u *vim_findfile(void *search_ctx_arg)
|
|||||||
ff_stack_T *sptr;
|
ff_stack_T *sptr;
|
||||||
|
|
||||||
// is the last starting directory in the stop list?
|
// is the last starting directory in the stop list?
|
||||||
if (ff_path_in_stoplist(search_ctx->ffsc_start_dir,
|
if (ff_path_in_stoplist((char_u *)search_ctx->ffsc_start_dir,
|
||||||
(int)(path_end - search_ctx->ffsc_start_dir),
|
(int)(path_end - (char_u *)search_ctx->ffsc_start_dir),
|
||||||
search_ctx->ffsc_stopdirs_v) == true) {
|
(char_u **)search_ctx->ffsc_stopdirs_v) == true) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// cut of last dir
|
// cut of last dir
|
||||||
while (path_end > search_ctx->ffsc_start_dir
|
while (path_end > (char_u *)search_ctx->ffsc_start_dir && vim_ispathsep(*path_end)) {
|
||||||
&& vim_ispathsep(*path_end)) {
|
|
||||||
path_end--;
|
path_end--;
|
||||||
}
|
}
|
||||||
while (path_end > search_ctx->ffsc_start_dir
|
while (path_end > (char_u *)search_ctx->ffsc_start_dir && !vim_ispathsep(path_end[-1])) {
|
||||||
&& !vim_ispathsep(path_end[-1])) {
|
|
||||||
path_end--;
|
path_end--;
|
||||||
}
|
}
|
||||||
*path_end = 0;
|
*path_end = 0;
|
||||||
@ -964,7 +958,7 @@ char_u *vim_findfile(void *search_ctx_arg)
|
|||||||
|
|
||||||
// create a new stack entry
|
// create a new stack entry
|
||||||
sptr = ff_create_stack_element(file_path,
|
sptr = ff_create_stack_element(file_path,
|
||||||
search_ctx->ffsc_wc_path, search_ctx->ffsc_level, 0);
|
(char_u *)search_ctx->ffsc_wc_path, search_ctx->ffsc_level, 0);
|
||||||
ff_push(search_ctx, sptr);
|
ff_push(search_ctx, sptr);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
@ -1528,9 +1522,9 @@ char_u *find_file_in_path_option(char_u *ptr, size_t len, int options, int first
|
|||||||
|
|
||||||
// get the stopdir string
|
// get the stopdir string
|
||||||
r_ptr = vim_findfile_stopdir((char_u *)buf);
|
r_ptr = vim_findfile_stopdir((char_u *)buf);
|
||||||
fdip_search_ctx = vim_findfile_init((char_u *)buf, ff_file_to_find,
|
fdip_search_ctx = vim_findfile_init(buf, (char *)ff_file_to_find,
|
||||||
r_ptr, 100, false, find_what,
|
(char *)r_ptr, 100, false, find_what,
|
||||||
fdip_search_ctx, false, rel_fname);
|
fdip_search_ctx, false, (char *)rel_fname);
|
||||||
if (fdip_search_ctx != NULL) {
|
if (fdip_search_ctx != NULL) {
|
||||||
did_findfile_init = true;
|
did_findfile_init = true;
|
||||||
}
|
}
|
||||||
|
@ -719,7 +719,7 @@ int readfile(char *fname, char *sfname, linenr_T from, linenr_T lines_to_skip,
|
|||||||
fenc_alloced = false;
|
fenc_alloced = false;
|
||||||
} else {
|
} else {
|
||||||
fenc_next = p_fencs; // try items in 'fileencodings'
|
fenc_next = p_fencs; // try items in 'fileencodings'
|
||||||
fenc = (char *)next_fenc(&fenc_next, &fenc_alloced);
|
fenc = next_fenc(&fenc_next, &fenc_alloced);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -813,7 +813,7 @@ retry:
|
|||||||
xfree(fenc);
|
xfree(fenc);
|
||||||
}
|
}
|
||||||
if (fenc_next != NULL) {
|
if (fenc_next != NULL) {
|
||||||
fenc = (char *)next_fenc(&fenc_next, &fenc_alloced);
|
fenc = next_fenc(&fenc_next, &fenc_alloced);
|
||||||
} else {
|
} else {
|
||||||
fenc = "";
|
fenc = "";
|
||||||
fenc_alloced = false;
|
fenc_alloced = false;
|
||||||
@ -2068,25 +2068,25 @@ void set_forced_fenc(exarg_T *eap)
|
|||||||
/// NULL.
|
/// NULL.
|
||||||
/// When *pp is not set to NULL, the result is in allocated memory and "alloced"
|
/// When *pp is not set to NULL, the result is in allocated memory and "alloced"
|
||||||
/// is set to true.
|
/// is set to true.
|
||||||
static char_u *next_fenc(char **pp, bool *alloced)
|
static char *next_fenc(char **pp, bool *alloced)
|
||||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
|
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_NONNULL_RET
|
||||||
{
|
{
|
||||||
char_u *p;
|
char *p;
|
||||||
char_u *r;
|
char *r;
|
||||||
|
|
||||||
*alloced = false;
|
*alloced = false;
|
||||||
if (**pp == NUL) {
|
if (**pp == NUL) {
|
||||||
*pp = NULL;
|
*pp = NULL;
|
||||||
return (char_u *)"";
|
return "";
|
||||||
}
|
}
|
||||||
p = (char_u *)vim_strchr((*pp), ',');
|
p = vim_strchr((*pp), ',');
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
r = (char_u *)enc_canonize(*pp);
|
r = enc_canonize(*pp);
|
||||||
*pp += STRLEN(*pp);
|
*pp += STRLEN(*pp);
|
||||||
} else {
|
} else {
|
||||||
r = vim_strnsave((char_u *)(*pp), (size_t)(p - (char_u *)(*pp)));
|
r = xstrnsave(*pp, (size_t)(p - *pp));
|
||||||
*pp = (char *)p + 1;
|
*pp = p + 1;
|
||||||
p = (char_u *)enc_canonize((char *)r);
|
p = enc_canonize(r);
|
||||||
xfree(r);
|
xfree(r);
|
||||||
r = p;
|
r = p;
|
||||||
}
|
}
|
||||||
|
@ -2566,7 +2566,7 @@ static int vgetorpeek(bool advance)
|
|||||||
// white-space, so find the last non-white
|
// white-space, so find the last non-white
|
||||||
// character -- webb
|
// character -- webb
|
||||||
curwin->w_wcol = 0;
|
curwin->w_wcol = 0;
|
||||||
ptr = get_cursor_line_ptr();
|
ptr = (char_u *)get_cursor_line_ptr();
|
||||||
chartabsize_T cts;
|
chartabsize_T cts;
|
||||||
init_chartabsize_arg(&cts, curwin,
|
init_chartabsize_arg(&cts, curwin,
|
||||||
curwin->w_cursor.lnum, 0, (char *)ptr, (char *)ptr);
|
curwin->w_cursor.lnum, 0, (char *)ptr, (char *)ptr);
|
||||||
@ -2596,7 +2596,7 @@ static int vgetorpeek(bool advance)
|
|||||||
if (col > 0 && curwin->w_wcol > 0) {
|
if (col > 0 && curwin->w_wcol > 0) {
|
||||||
// Correct when the cursor is on the right halve
|
// Correct when the cursor is on the right halve
|
||||||
// of a double-wide character.
|
// of a double-wide character.
|
||||||
ptr = get_cursor_line_ptr();
|
ptr = (char_u *)get_cursor_line_ptr();
|
||||||
col -= utf_head_off((char *)ptr, (char *)ptr + col);
|
col -= utf_head_off((char *)ptr, (char *)ptr + col);
|
||||||
if (utf_ptr2cells((char *)ptr + col) > 1) {
|
if (utf_ptr2cells((char *)ptr + col) > 1) {
|
||||||
curwin->w_wcol--;
|
curwin->w_wcol--;
|
||||||
|
@ -240,7 +240,7 @@ void grid_puts_len(ScreenGrid *grid, char *text, int textlen, int row, int col,
|
|||||||
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
|
mbyte_blen = len > 0
|
||||||
? utfc_ptr2len_len((char_u *)ptr, (int)((text + len) - ptr))
|
? utfc_ptr2len_len(ptr, (int)((text + len) - ptr))
|
||||||
: utfc_ptr2len(ptr);
|
: utfc_ptr2len(ptr);
|
||||||
u8c = len >= 0
|
u8c = len >= 0
|
||||||
? utfc_ptr2char_len((char_u *)ptr, u8cc, (int)((text + len) - ptr))
|
? utfc_ptr2char_len((char_u *)ptr, u8cc, (int)((text + len) - ptr))
|
||||||
|
@ -343,7 +343,7 @@ int get_sts_value(void)
|
|||||||
// Count the size (in window cells) of the indent in the current line.
|
// Count the size (in window cells) of the indent in the current line.
|
||||||
int get_indent(void)
|
int get_indent(void)
|
||||||
{
|
{
|
||||||
return get_indent_str_vtab((char *)get_cursor_line_ptr(),
|
return get_indent_str_vtab(get_cursor_line_ptr(),
|
||||||
curbuf->b_p_ts,
|
curbuf->b_p_ts,
|
||||||
curbuf->b_p_vts_array,
|
curbuf->b_p_vts_array,
|
||||||
false);
|
false);
|
||||||
@ -454,7 +454,7 @@ int set_indent(int size, int flags)
|
|||||||
// characters needed for the indent.
|
// characters needed for the indent.
|
||||||
todo = size;
|
todo = size;
|
||||||
ind_len = 0;
|
ind_len = 0;
|
||||||
p = oldline = get_cursor_line_ptr();
|
p = oldline = (char_u *)get_cursor_line_ptr();
|
||||||
|
|
||||||
// Calculate the buffer size for the new indent, and check to see if it
|
// Calculate the buffer size for the new indent, and check to see if it
|
||||||
// isn't already set.
|
// isn't already set.
|
||||||
@ -857,7 +857,7 @@ int inindent(int extra)
|
|||||||
char_u *ptr;
|
char_u *ptr;
|
||||||
colnr_T col;
|
colnr_T col;
|
||||||
|
|
||||||
for (col = 0, ptr = get_cursor_line_ptr(); ascii_iswhite(*ptr); col++) {
|
for (col = 0, ptr = (char_u *)get_cursor_line_ptr(); ascii_iswhite(*ptr); col++) {
|
||||||
ptr++;
|
ptr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -979,7 +979,7 @@ int get_lisp_indent(void)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (that = get_cursor_line_ptr(); *that != NUL; that++) {
|
for (that = (char_u *)get_cursor_line_ptr(); *that != NUL; that++) {
|
||||||
if (*that == ';') {
|
if (*that == ';') {
|
||||||
while (*(that + 1) != NUL) {
|
while (*(that + 1) != NUL) {
|
||||||
that++;
|
that++;
|
||||||
@ -1029,7 +1029,7 @@ int get_lisp_indent(void)
|
|||||||
curwin->w_cursor.col = pos->col;
|
curwin->w_cursor.col = pos->col;
|
||||||
col = pos->col;
|
col = pos->col;
|
||||||
|
|
||||||
that = get_cursor_line_ptr();
|
that = (char_u *)get_cursor_line_ptr();
|
||||||
|
|
||||||
if (vi_lisp && (get_indent() == 0)) {
|
if (vi_lisp && (get_indent() == 0)) {
|
||||||
amount = 2;
|
amount = 2;
|
||||||
|
@ -355,7 +355,7 @@ static bool cin_islabel_skip(const char_u **s)
|
|||||||
// Note: curwin->w_cursor must be where we are looking for the label.
|
// Note: curwin->w_cursor must be where we are looking for the label.
|
||||||
bool cin_islabel(void) // XXX
|
bool cin_islabel(void) // XXX
|
||||||
{
|
{
|
||||||
const char_u *s = cin_skipcomment(get_cursor_line_ptr());
|
const char_u *s = cin_skipcomment((char_u *)get_cursor_line_ptr());
|
||||||
|
|
||||||
// Exclude "default" from labels, since it should be indented
|
// Exclude "default" from labels, since it should be indented
|
||||||
// like a switch label. Same for C++ scope declarations.
|
// like a switch label. Same for C++ scope declarations.
|
||||||
@ -390,7 +390,7 @@ bool cin_islabel(void) // XXX
|
|||||||
curwin->w_cursor = *trypos;
|
curwin->w_cursor = *trypos;
|
||||||
}
|
}
|
||||||
|
|
||||||
line = get_cursor_line_ptr();
|
line = (char_u *)get_cursor_line_ptr();
|
||||||
if (cin_ispreproc(line)) { // ignore #defines, #if, etc.
|
if (cin_ispreproc(line)) { // ignore #defines, #if, etc.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -421,7 +421,7 @@ static int cin_isinit(void)
|
|||||||
const char_u *s;
|
const char_u *s;
|
||||||
static char *skip[] = { "static", "public", "protected", "private" };
|
static char *skip[] = { "static", "public", "protected", "private" };
|
||||||
|
|
||||||
s = cin_skipcomment(get_cursor_line_ptr());
|
s = cin_skipcomment((char_u *)get_cursor_line_ptr());
|
||||||
|
|
||||||
if (cin_starts_with(s, "typedef")) {
|
if (cin_starts_with(s, "typedef")) {
|
||||||
s = cin_skipcomment(s + 7);
|
s = cin_skipcomment(s + 7);
|
||||||
@ -642,17 +642,17 @@ static int skip_label(linenr_T lnum, const char_u **pp)
|
|||||||
|
|
||||||
cursor_save = curwin->w_cursor;
|
cursor_save = curwin->w_cursor;
|
||||||
curwin->w_cursor.lnum = lnum;
|
curwin->w_cursor.lnum = lnum;
|
||||||
l = get_cursor_line_ptr();
|
l = (char_u *)get_cursor_line_ptr();
|
||||||
// XXX
|
// XXX
|
||||||
if (cin_iscase(l, false) || cin_isscopedecl(l) || cin_islabel()) {
|
if (cin_iscase(l, false) || cin_isscopedecl(l) || cin_islabel()) {
|
||||||
amount = get_indent_nolabel(lnum);
|
amount = get_indent_nolabel(lnum);
|
||||||
l = after_label(get_cursor_line_ptr());
|
l = after_label((char_u *)get_cursor_line_ptr());
|
||||||
if (l == NULL) { // just in case
|
if (l == NULL) { // just in case
|
||||||
l = get_cursor_line_ptr();
|
l = (char_u *)get_cursor_line_ptr();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
amount = get_indent();
|
amount = get_indent();
|
||||||
l = get_cursor_line_ptr();
|
l = (char_u *)get_cursor_line_ptr();
|
||||||
}
|
}
|
||||||
*pp = l;
|
*pp = l;
|
||||||
|
|
||||||
@ -674,7 +674,7 @@ static int cin_first_id_amount(void)
|
|||||||
pos_T fp;
|
pos_T fp;
|
||||||
colnr_T col;
|
colnr_T col;
|
||||||
|
|
||||||
line = get_cursor_line_ptr();
|
line = (char_u *)get_cursor_line_ptr();
|
||||||
p = (char_u *)skipwhite((char *)line);
|
p = (char_u *)skipwhite((char *)line);
|
||||||
len = (int)((char_u *)skiptowhite((char *)p) - p);
|
len = (int)((char_u *)skiptowhite((char *)p) - p);
|
||||||
if (len == 6 && STRNCMP(p, "static", 6) == 0) {
|
if (len == 6 && STRNCMP(p, "static", 6) == 0) {
|
||||||
@ -1033,7 +1033,7 @@ static int cin_iswhileofdo(const char_u *p, linenr_T lnum) // XXX
|
|||||||
cursor_save = curwin->w_cursor;
|
cursor_save = curwin->w_cursor;
|
||||||
curwin->w_cursor.lnum = lnum;
|
curwin->w_cursor.lnum = lnum;
|
||||||
curwin->w_cursor.col = 0;
|
curwin->w_cursor.col = 0;
|
||||||
p = get_cursor_line_ptr();
|
p = (char_u *)get_cursor_line_ptr();
|
||||||
while (*p && *p != 'w') { // skip any '}', until the 'w' of the "while"
|
while (*p && *p != 'w') { // skip any '}', until the 'w' of the "while"
|
||||||
p++;
|
p++;
|
||||||
curwin->w_cursor.col++;
|
curwin->w_cursor.col++;
|
||||||
@ -1110,7 +1110,7 @@ static int cin_iswhileofdo_end(int terminated)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = line = get_cursor_line_ptr();
|
p = line = (char_u *)get_cursor_line_ptr();
|
||||||
while (*p != NUL) {
|
while (*p != NUL) {
|
||||||
p = cin_skipcomment(p);
|
p = cin_skipcomment(p);
|
||||||
if (*p == ')') {
|
if (*p == ')') {
|
||||||
@ -1133,7 +1133,7 @@ static int cin_iswhileofdo_end(int terminated)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Searching may have made "line" invalid, get it again.
|
// Searching may have made "line" invalid, get it again.
|
||||||
line = get_cursor_line_ptr();
|
line = (char_u *)get_cursor_line_ptr();
|
||||||
p = line + i;
|
p = line + i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1168,7 +1168,7 @@ static int cin_is_cpp_baseclass(cpp_baseclass_cache_T *cached)
|
|||||||
const char_u *s;
|
const char_u *s;
|
||||||
int class_or_struct, lookfor_ctor_init, cpp_base_class;
|
int class_or_struct, lookfor_ctor_init, cpp_base_class;
|
||||||
linenr_T lnum = curwin->w_cursor.lnum;
|
linenr_T lnum = curwin->w_cursor.lnum;
|
||||||
const char_u *line = get_cursor_line_ptr();
|
const char_u *line = (char_u *)get_cursor_line_ptr();
|
||||||
|
|
||||||
if (pos->lnum <= lnum) {
|
if (pos->lnum <= lnum) {
|
||||||
return cached->found; // Use the cached result
|
return cached->found; // Use the cached result
|
||||||
@ -1322,11 +1322,11 @@ static int get_baseclass_amount(int col)
|
|||||||
|
|
||||||
if (col == 0) {
|
if (col == 0) {
|
||||||
amount = get_indent();
|
amount = get_indent();
|
||||||
if (find_last_paren(get_cursor_line_ptr(), '(', ')')
|
if (find_last_paren((char_u *)get_cursor_line_ptr(), '(', ')')
|
||||||
&& (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) {
|
&& (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) {
|
||||||
amount = get_indent_lnum(trypos->lnum); // XXX
|
amount = get_indent_lnum(trypos->lnum); // XXX
|
||||||
}
|
}
|
||||||
if (!cin_ends_in(get_cursor_line_ptr(), (char_u *)",", NULL)) {
|
if (!cin_ends_in((char_u *)get_cursor_line_ptr(), (char_u *)",", NULL)) {
|
||||||
amount += curbuf->b_ind_cpp_baseclass;
|
amount += curbuf->b_ind_cpp_baseclass;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2287,7 +2287,7 @@ int get_c_indent(void)
|
|||||||
/* Ignore a '(' in front of the line that has a match before
|
/* Ignore a '(' in front of the line that has a match before
|
||||||
* our matching '('. */
|
* our matching '('. */
|
||||||
curwin->w_cursor.lnum = our_paren_pos.lnum;
|
curwin->w_cursor.lnum = our_paren_pos.lnum;
|
||||||
line = get_cursor_line_ptr();
|
line = (char_u *)get_cursor_line_ptr();
|
||||||
look_col = (int)(look - line);
|
look_col = (int)(look - line);
|
||||||
curwin->w_cursor.col = look_col + 1;
|
curwin->w_cursor.col = look_col + 1;
|
||||||
if ((trypos = findmatchlimit(NULL, ')', 0,
|
if ((trypos = findmatchlimit(NULL, ')', 0,
|
||||||
@ -2472,7 +2472,7 @@ int get_c_indent(void)
|
|||||||
// ldfd) {
|
// ldfd) {
|
||||||
// }
|
// }
|
||||||
if ((curbuf->b_ind_js || curbuf->b_ind_keep_case_label)
|
if ((curbuf->b_ind_js || curbuf->b_ind_keep_case_label)
|
||||||
&& cin_iscase((char_u *)skipwhite((char *)get_cursor_line_ptr()), false)) {
|
&& cin_iscase((char_u *)skipwhite(get_cursor_line_ptr()), false)) {
|
||||||
amount = get_indent();
|
amount = get_indent();
|
||||||
} else if (curbuf->b_ind_js) {
|
} else if (curbuf->b_ind_js) {
|
||||||
amount = get_indent_lnum(lnum);
|
amount = get_indent_lnum(lnum);
|
||||||
@ -2539,7 +2539,7 @@ int get_c_indent(void)
|
|||||||
if (start_brace == BRACE_AT_END) { // '{' is at end of line
|
if (start_brace == BRACE_AT_END) { // '{' is at end of line
|
||||||
amount += curbuf->b_ind_open_imag;
|
amount += curbuf->b_ind_open_imag;
|
||||||
|
|
||||||
l = (char_u *)skipwhite((char *)get_cursor_line_ptr());
|
l = (char_u *)skipwhite(get_cursor_line_ptr());
|
||||||
if (cin_is_cpp_namespace(l)) {
|
if (cin_is_cpp_namespace(l)) {
|
||||||
amount += curbuf->b_ind_cpp_namespace;
|
amount += curbuf->b_ind_cpp_namespace;
|
||||||
} else if (cin_is_cpp_extern_c(l)) {
|
} else if (cin_is_cpp_extern_c(l)) {
|
||||||
@ -2614,7 +2614,7 @@ int get_c_indent(void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
l = get_cursor_line_ptr();
|
l = (char_u *)get_cursor_line_ptr();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we're in a comment or raw string now, skip to
|
* If we're in a comment or raw string now, skip to
|
||||||
@ -2734,7 +2734,7 @@ int get_c_indent(void)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
l = get_cursor_line_ptr();
|
l = (char_u *)get_cursor_line_ptr();
|
||||||
|
|
||||||
/* If we're in a comment or raw string now, skip
|
/* If we're in a comment or raw string now, skip
|
||||||
* to the start of it. */
|
* to the start of it. */
|
||||||
@ -2777,7 +2777,7 @@ int get_c_indent(void)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
l = get_cursor_line_ptr();
|
l = (char_u *)get_cursor_line_ptr();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If this is a switch() label, may line up relative to that.
|
* If this is a switch() label, may line up relative to that.
|
||||||
@ -2853,7 +2853,7 @@ int get_c_indent(void)
|
|||||||
// -> y = y + 1;
|
// -> y = y + 1;
|
||||||
if (n) {
|
if (n) {
|
||||||
amount = n;
|
amount = n;
|
||||||
l = after_label(get_cursor_line_ptr());
|
l = after_label((char_u *)get_cursor_line_ptr());
|
||||||
if (l != NULL && cin_is_cinword((char *)l)) {
|
if (l != NULL && cin_is_cinword((char *)l)) {
|
||||||
if (theline[0] == '{') {
|
if (theline[0] == '{') {
|
||||||
amount += curbuf->b_ind_open_extra;
|
amount += curbuf->b_ind_open_extra;
|
||||||
@ -2898,7 +2898,7 @@ int get_c_indent(void)
|
|||||||
* Ignore jump labels with nothing after them.
|
* Ignore jump labels with nothing after them.
|
||||||
*/
|
*/
|
||||||
if (!curbuf->b_ind_js && cin_islabel()) {
|
if (!curbuf->b_ind_js && cin_islabel()) {
|
||||||
l = after_label(get_cursor_line_ptr());
|
l = after_label((char_u *)get_cursor_line_ptr());
|
||||||
if (l == NULL || cin_nocode(l)) {
|
if (l == NULL || cin_nocode(l)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -2910,7 +2910,7 @@ int get_c_indent(void)
|
|||||||
* (need to get the line again, cin_islabel() may have
|
* (need to get the line again, cin_islabel() may have
|
||||||
* unlocked it)
|
* unlocked it)
|
||||||
*/
|
*/
|
||||||
l = get_cursor_line_ptr();
|
l = (char_u *)get_cursor_line_ptr();
|
||||||
if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount)
|
if (cin_ispreproc_cont(&l, &curwin->w_cursor.lnum, &amount)
|
||||||
|| cin_nocode(l)) {
|
|| cin_nocode(l)) {
|
||||||
continue;
|
continue;
|
||||||
@ -2922,7 +2922,7 @@ int get_c_indent(void)
|
|||||||
n = 0;
|
n = 0;
|
||||||
if (lookfor != LOOKFOR_TERM && curbuf->b_ind_cpp_baseclass > 0) {
|
if (lookfor != LOOKFOR_TERM && curbuf->b_ind_cpp_baseclass > 0) {
|
||||||
n = cin_is_cpp_baseclass(&cache_cpp_baseclass);
|
n = cin_is_cpp_baseclass(&cache_cpp_baseclass);
|
||||||
l = get_cursor_line_ptr();
|
l = (char_u *)get_cursor_line_ptr();
|
||||||
}
|
}
|
||||||
if (n) {
|
if (n) {
|
||||||
if (lookfor == LOOKFOR_UNTERM) {
|
if (lookfor == LOOKFOR_UNTERM) {
|
||||||
@ -3039,7 +3039,7 @@ int get_c_indent(void)
|
|||||||
* asdf)
|
* asdf)
|
||||||
*/
|
*/
|
||||||
curwin->w_cursor = *trypos;
|
curwin->w_cursor = *trypos;
|
||||||
l = get_cursor_line_ptr();
|
l = (char_u *)get_cursor_line_ptr();
|
||||||
if (cin_iscase(l, false) || cin_isscopedecl(l)) {
|
if (cin_iscase(l, false) || cin_isscopedecl(l)) {
|
||||||
curwin->w_cursor.lnum++;
|
curwin->w_cursor.lnum++;
|
||||||
curwin->w_cursor.col = 0;
|
curwin->w_cursor.col = 0;
|
||||||
@ -3154,7 +3154,7 @@ int get_c_indent(void)
|
|||||||
* x = 1;
|
* x = 1;
|
||||||
* -> here
|
* -> here
|
||||||
*/
|
*/
|
||||||
l = (char_u *)skipwhite((char *)get_cursor_line_ptr());
|
l = (char_u *)skipwhite(get_cursor_line_ptr());
|
||||||
if (cin_isdo(l)) {
|
if (cin_isdo(l)) {
|
||||||
if (whilelevel == 0) {
|
if (whilelevel == 0) {
|
||||||
break;
|
break;
|
||||||
@ -3174,7 +3174,7 @@ int get_c_indent(void)
|
|||||||
* not the one from "if () {". */
|
* not the one from "if () {". */
|
||||||
if (*l == '}') {
|
if (*l == '}') {
|
||||||
curwin->w_cursor.col =
|
curwin->w_cursor.col =
|
||||||
(colnr_T)(l - get_cursor_line_ptr()) + 1;
|
(colnr_T)(l - (char_u *)get_cursor_line_ptr()) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((trypos = find_start_brace()) == NULL
|
if ((trypos = find_start_brace()) == NULL
|
||||||
@ -3231,7 +3231,7 @@ int get_c_indent(void)
|
|||||||
// line up with this line, remember its indent
|
// line up with this line, remember its indent
|
||||||
// 100 + // NOLINT(whitespace/tab)
|
// 100 + // NOLINT(whitespace/tab)
|
||||||
// -> here; // NOLINT(whitespace/tab)
|
// -> here; // NOLINT(whitespace/tab)
|
||||||
l = get_cursor_line_ptr();
|
l = (char_u *)get_cursor_line_ptr();
|
||||||
amount = cur_amount;
|
amount = cur_amount;
|
||||||
|
|
||||||
n = (int)STRLEN(l);
|
n = (int)STRLEN(l);
|
||||||
@ -3341,7 +3341,7 @@ int get_c_indent(void)
|
|||||||
* may be lined up with the case label.
|
* may be lined up with the case label.
|
||||||
*/
|
*/
|
||||||
if (lookfor == LOOKFOR_NOBREAK
|
if (lookfor == LOOKFOR_NOBREAK
|
||||||
&& cin_isbreak((char_u *)skipwhite((char *)get_cursor_line_ptr()))) {
|
&& cin_isbreak((char_u *)skipwhite(get_cursor_line_ptr()))) {
|
||||||
lookfor = LOOKFOR_ANY;
|
lookfor = LOOKFOR_ANY;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -3350,7 +3350,7 @@ int get_c_indent(void)
|
|||||||
* Handle "do {" line.
|
* Handle "do {" line.
|
||||||
*/
|
*/
|
||||||
if (whilelevel > 0) {
|
if (whilelevel > 0) {
|
||||||
l = cin_skipcomment(get_cursor_line_ptr());
|
l = cin_skipcomment((char_u *)get_cursor_line_ptr());
|
||||||
if (cin_isdo(l)) {
|
if (cin_isdo(l)) {
|
||||||
amount = get_indent(); // XXX
|
amount = get_indent(); // XXX
|
||||||
whilelevel--;
|
whilelevel--;
|
||||||
@ -3408,7 +3408,7 @@ int get_c_indent(void)
|
|||||||
* here;
|
* here;
|
||||||
*/
|
*/
|
||||||
term_again:
|
term_again:
|
||||||
l = get_cursor_line_ptr();
|
l = (char_u *)get_cursor_line_ptr();
|
||||||
if (find_last_paren(l, '(', ')')
|
if (find_last_paren(l, '(', ')')
|
||||||
&& (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) {
|
&& (trypos = find_match_paren(curbuf->b_ind_maxparen)) != NULL) {
|
||||||
// Check if we are on a case label now. This is
|
// Check if we are on a case label now. This is
|
||||||
@ -3416,7 +3416,7 @@ term_again:
|
|||||||
// case xx: if ( asdf &&
|
// case xx: if ( asdf &&
|
||||||
// asdf)
|
// asdf)
|
||||||
curwin->w_cursor = *trypos;
|
curwin->w_cursor = *trypos;
|
||||||
l = get_cursor_line_ptr();
|
l = (char_u *)get_cursor_line_ptr();
|
||||||
if (cin_iscase(l, false) || cin_isscopedecl(l)) {
|
if (cin_iscase(l, false) || cin_isscopedecl(l)) {
|
||||||
curwin->w_cursor.lnum++;
|
curwin->w_cursor.lnum++;
|
||||||
curwin->w_cursor.col = 0;
|
curwin->w_cursor.col = 0;
|
||||||
@ -3475,13 +3475,13 @@ term_again:
|
|||||||
* If we're at the end of a block, skip to the start of
|
* If we're at the end of a block, skip to the start of
|
||||||
* that block.
|
* that block.
|
||||||
*/
|
*/
|
||||||
l = get_cursor_line_ptr();
|
l = (char_u *)get_cursor_line_ptr();
|
||||||
if (find_last_paren(l, '{', '}') // XXX
|
if (find_last_paren(l, '{', '}') // XXX
|
||||||
&& (trypos = find_start_brace()) != NULL) {
|
&& (trypos = find_start_brace()) != NULL) {
|
||||||
curwin->w_cursor = *trypos;
|
curwin->w_cursor = *trypos;
|
||||||
// if not "else {" check for terminated again
|
// if not "else {" check for terminated again
|
||||||
// but skip block for "} else {"
|
// but skip block for "} else {"
|
||||||
l = cin_skipcomment(get_cursor_line_ptr());
|
l = cin_skipcomment((char_u *)get_cursor_line_ptr());
|
||||||
if (*l == '}' || !cin_iselse(l)) {
|
if (*l == '}' || !cin_iselse(l)) {
|
||||||
goto term_again;
|
goto term_again;
|
||||||
}
|
}
|
||||||
@ -3547,7 +3547,7 @@ term_again:
|
|||||||
curwin->w_cursor.lnum--;
|
curwin->w_cursor.lnum--;
|
||||||
curwin->w_cursor.col = 0;
|
curwin->w_cursor.col = 0;
|
||||||
|
|
||||||
l = get_cursor_line_ptr();
|
l = (char_u *)get_cursor_line_ptr();
|
||||||
|
|
||||||
// If we're in a comment or raw string now, skip to the start
|
// If we're in a comment or raw string now, skip to the start
|
||||||
// of it.
|
// of it.
|
||||||
@ -3563,7 +3563,7 @@ term_again:
|
|||||||
n = 0;
|
n = 0;
|
||||||
if (curbuf->b_ind_cpp_baseclass != 0) {
|
if (curbuf->b_ind_cpp_baseclass != 0) {
|
||||||
n = cin_is_cpp_baseclass(&cache_cpp_baseclass);
|
n = cin_is_cpp_baseclass(&cache_cpp_baseclass);
|
||||||
l = get_cursor_line_ptr();
|
l = (char_u *)get_cursor_line_ptr();
|
||||||
}
|
}
|
||||||
if (n) {
|
if (n) {
|
||||||
// XXX
|
// XXX
|
||||||
@ -3635,7 +3635,7 @@ term_again:
|
|||||||
if (cin_isfuncdecl(NULL, cur_curpos.lnum, 0)) { // XXX
|
if (cin_isfuncdecl(NULL, cur_curpos.lnum, 0)) { // XXX
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
l = get_cursor_line_ptr();
|
l = (char_u *)get_cursor_line_ptr();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Finding the closing '}' of a previous function. Put
|
* Finding the closing '}' of a previous function. Put
|
||||||
@ -3709,7 +3709,7 @@ term_again:
|
|||||||
|| (*l != NUL && l[STRLEN(l) - 1] == '\\')) {
|
|| (*l != NUL && l[STRLEN(l) - 1] == '\\')) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
l = get_cursor_line_ptr();
|
l = (char_u *)get_cursor_line_ptr();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3786,7 +3786,7 @@ static int find_match(int lookfor, linenr_T ourscope)
|
|||||||
curwin->w_cursor.lnum--;
|
curwin->w_cursor.lnum--;
|
||||||
curwin->w_cursor.col = 0;
|
curwin->w_cursor.col = 0;
|
||||||
|
|
||||||
look = cin_skipcomment(get_cursor_line_ptr());
|
look = cin_skipcomment((char_u *)get_cursor_line_ptr());
|
||||||
if (!cin_iselse(look)
|
if (!cin_iselse(look)
|
||||||
&& !cin_isif(look)
|
&& !cin_isif(look)
|
||||||
&& !cin_isdo(look) // XXX
|
&& !cin_isdo(look) // XXX
|
||||||
@ -3826,7 +3826,7 @@ static int find_match(int lookfor, linenr_T ourscope)
|
|||||||
* then we need to go back to another if, so
|
* then we need to go back to another if, so
|
||||||
* increment elselevel
|
* increment elselevel
|
||||||
*/
|
*/
|
||||||
look = cin_skipcomment(get_cursor_line_ptr());
|
look = cin_skipcomment((char_u *)get_cursor_line_ptr());
|
||||||
if (cin_iselse(look)) {
|
if (cin_iselse(look)) {
|
||||||
mightbeif = cin_skipcomment(look + 4);
|
mightbeif = cin_skipcomment(look + 4);
|
||||||
if (!cin_isif(mightbeif)) {
|
if (!cin_isif(mightbeif)) {
|
||||||
@ -3845,7 +3845,7 @@ static int find_match(int lookfor, linenr_T ourscope)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If it's an "if" decrement elselevel
|
// If it's an "if" decrement elselevel
|
||||||
look = cin_skipcomment(get_cursor_line_ptr());
|
look = cin_skipcomment((char_u *)get_cursor_line_ptr());
|
||||||
if (cin_isif(look)) {
|
if (cin_isif(look)) {
|
||||||
elselevel--;
|
elselevel--;
|
||||||
/*
|
/*
|
||||||
|
@ -231,7 +231,7 @@ static pos_T compl_startpos;
|
|||||||
static int compl_length = 0;
|
static int compl_length = 0;
|
||||||
static colnr_T compl_col = 0; ///< column where the text starts
|
static colnr_T compl_col = 0; ///< column where the text starts
|
||||||
///< that is being completed
|
///< that is being completed
|
||||||
static char_u *compl_orig_text = NULL; ///< text as it was before
|
static char *compl_orig_text = NULL; ///< text as it was before
|
||||||
///< completion started
|
///< completion started
|
||||||
static int compl_cont_mode = 0;
|
static int compl_cont_mode = 0;
|
||||||
static expand_T compl_xp;
|
static expand_T compl_xp;
|
||||||
@ -587,7 +587,7 @@ static char_u *ins_compl_infercase_gettext(char_u *str, int char_len, int compl_
|
|||||||
|
|
||||||
// Rule 1: Were any chars converted to lower?
|
// Rule 1: Were any chars converted to lower?
|
||||||
{
|
{
|
||||||
const char_u *p = compl_orig_text;
|
const char_u *p = (char_u *)compl_orig_text;
|
||||||
for (int i = 0; i < min_len; i++) {
|
for (int i = 0; i < min_len; i++) {
|
||||||
const int c = mb_ptr2char_adv(&p);
|
const int c = mb_ptr2char_adv(&p);
|
||||||
if (mb_islower(c)) {
|
if (mb_islower(c)) {
|
||||||
@ -606,7 +606,7 @@ static char_u *ins_compl_infercase_gettext(char_u *str, int char_len, int compl_
|
|||||||
// Rule 2: No lower case, 2nd consecutive letter converted to
|
// Rule 2: No lower case, 2nd consecutive letter converted to
|
||||||
// upper case.
|
// upper case.
|
||||||
if (!has_lower) {
|
if (!has_lower) {
|
||||||
const char_u *p = compl_orig_text;
|
const char_u *p = (char_u *)compl_orig_text;
|
||||||
for (int i = 0; i < min_len; i++) {
|
for (int i = 0; i < min_len; i++) {
|
||||||
const int c = mb_ptr2char_adv(&p);
|
const int c = mb_ptr2char_adv(&p);
|
||||||
if (was_letter && mb_isupper(c) && mb_islower(wca[i])) {
|
if (was_letter && mb_isupper(c) && mb_islower(wca[i])) {
|
||||||
@ -622,7 +622,7 @@ static char_u *ins_compl_infercase_gettext(char_u *str, int char_len, int compl_
|
|||||||
|
|
||||||
// Copy the original case of the part we typed.
|
// Copy the original case of the part we typed.
|
||||||
{
|
{
|
||||||
const char_u *p = compl_orig_text;
|
const char_u *p = (char_u *)compl_orig_text;
|
||||||
for (int i = 0; i < min_len; i++) {
|
for (int i = 0; i < min_len; i++) {
|
||||||
const int c = mb_ptr2char_adv(&p);
|
const int c = mb_ptr2char_adv(&p);
|
||||||
if (mb_islower(c)) {
|
if (mb_islower(c)) {
|
||||||
@ -699,7 +699,7 @@ int ins_compl_add_infercase(char_u *str_arg, int len, bool icase, char_u *fname,
|
|||||||
|
|
||||||
// Find actual length of original text.
|
// Find actual length of original text.
|
||||||
{
|
{
|
||||||
const char_u *p = compl_orig_text;
|
const char_u *p = (char_u *)compl_orig_text;
|
||||||
compl_char_len = 0;
|
compl_char_len = 0;
|
||||||
while (*p != NUL) {
|
while (*p != NUL) {
|
||||||
MB_PTR_ADV(p);
|
MB_PTR_ADV(p);
|
||||||
@ -720,7 +720,7 @@ int ins_compl_add_infercase(char_u *str_arg, int len, bool icase, char_u *fname,
|
|||||||
flags |= CP_ICASE;
|
flags |= CP_ICASE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int res = ins_compl_add(str, len, fname, NULL, false, NULL, dir, flags, false);
|
int res = ins_compl_add((char *)str, len, (char *)fname, NULL, false, NULL, dir, flags, false);
|
||||||
xfree(tofree);
|
xfree(tofree);
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@ -748,9 +748,9 @@ int ins_compl_add_infercase(char_u *str_arg, int len, bool icase, char_u *fname,
|
|||||||
/// @return NOTDONE if the given string is already in the list of completions,
|
/// @return NOTDONE if the given string is already in the list of completions,
|
||||||
/// otherwise it is added to the list and OK is returned. FAIL will be
|
/// otherwise it is added to the list and OK is returned. FAIL will be
|
||||||
/// returned in case of error.
|
/// returned in case of error.
|
||||||
static int ins_compl_add(char_u *const str, int len, char_u *const fname,
|
static int ins_compl_add(char *const str, int len, char *const fname, char *const *const cptext,
|
||||||
char_u *const *const cptext, const bool cptext_allocated,
|
const bool cptext_allocated, typval_T *user_data, const Direction cdir,
|
||||||
typval_T *user_data, const Direction cdir, int flags_arg, const bool adup)
|
int flags_arg, const bool adup)
|
||||||
FUNC_ATTR_NONNULL_ARG(1)
|
FUNC_ATTR_NONNULL_ARG(1)
|
||||||
{
|
{
|
||||||
compl_T *match;
|
compl_T *match;
|
||||||
@ -802,7 +802,7 @@ static int ins_compl_add(char_u *const str, int len, char_u *const fname,
|
|||||||
if (flags & CP_ORIGINAL_TEXT) {
|
if (flags & CP_ORIGINAL_TEXT) {
|
||||||
match->cp_number = 0;
|
match->cp_number = 0;
|
||||||
}
|
}
|
||||||
match->cp_str = vim_strnsave(str, (size_t)len);
|
match->cp_str = (char_u *)xstrnsave(str, (size_t)len);
|
||||||
|
|
||||||
// match-fname is:
|
// match-fname is:
|
||||||
// - compl_curr_match->cp_fname if it is a string equal to fname.
|
// - compl_curr_match->cp_fname if it is a string equal to fname.
|
||||||
@ -814,7 +814,7 @@ static int ins_compl_add(char_u *const str, int len, char_u *const fname,
|
|||||||
&& STRCMP(fname, compl_curr_match->cp_fname) == 0) {
|
&& STRCMP(fname, compl_curr_match->cp_fname) == 0) {
|
||||||
match->cp_fname = compl_curr_match->cp_fname;
|
match->cp_fname = compl_curr_match->cp_fname;
|
||||||
} else if (fname != NULL) {
|
} else if (fname != NULL) {
|
||||||
match->cp_fname = vim_strsave(fname);
|
match->cp_fname = vim_strsave((char_u *)fname);
|
||||||
flags |= CP_FREE_FNAME;
|
flags |= CP_FREE_FNAME;
|
||||||
} else {
|
} else {
|
||||||
match->cp_fname = NULL;
|
match->cp_fname = NULL;
|
||||||
@ -830,8 +830,8 @@ static int ins_compl_add(char_u *const str, int len, char_u *const fname,
|
|||||||
}
|
}
|
||||||
if (*cptext[i] != NUL) {
|
if (*cptext[i] != NUL) {
|
||||||
match->cp_text[i] = (cptext_allocated
|
match->cp_text[i] = (cptext_allocated
|
||||||
? cptext[i]
|
? (char_u *)cptext[i]
|
||||||
: (char_u *)xstrdup((char *)cptext[i]));
|
: (char_u *)xstrdup(cptext[i]));
|
||||||
} else if (cptext_allocated) {
|
} else if (cptext_allocated) {
|
||||||
xfree(cptext[i]);
|
xfree(cptext[i]);
|
||||||
}
|
}
|
||||||
@ -957,7 +957,7 @@ static void ins_compl_add_matches(int num_matches, char **matches, int icase)
|
|||||||
Direction dir = compl_direction;
|
Direction dir = compl_direction;
|
||||||
|
|
||||||
for (int i = 0; i < num_matches && add_r != FAIL; i++) {
|
for (int i = 0; i < num_matches && add_r != FAIL; i++) {
|
||||||
if ((add_r = ins_compl_add((char_u *)matches[i], -1, NULL, NULL, false, NULL, dir,
|
if ((add_r = ins_compl_add(matches[i], -1, NULL, NULL, false, NULL, dir,
|
||||||
CP_FAST | (icase ? CP_ICASE : 0),
|
CP_FAST | (icase ? CP_ICASE : 0),
|
||||||
false)) == OK) {
|
false)) == OK) {
|
||||||
// If dir was BACKWARD then honor it just once.
|
// If dir was BACKWARD then honor it just once.
|
||||||
@ -1621,8 +1621,8 @@ int ins_compl_len(void)
|
|||||||
/// to be got from the user.
|
/// to be got from the user.
|
||||||
int ins_compl_bs(void)
|
int ins_compl_bs(void)
|
||||||
{
|
{
|
||||||
char_u *line = get_cursor_line_ptr();
|
char *line = get_cursor_line_ptr();
|
||||||
char_u *p = line + curwin->w_cursor.col;
|
char *p = line + curwin->w_cursor.col;
|
||||||
MB_PTR_BACK(line, p);
|
MB_PTR_BACK(line, p);
|
||||||
ptrdiff_t p_off = p - line;
|
ptrdiff_t p_off = p - line;
|
||||||
|
|
||||||
@ -1649,7 +1649,7 @@ int ins_compl_bs(void)
|
|||||||
line = get_cursor_line_ptr();
|
line = get_cursor_line_ptr();
|
||||||
|
|
||||||
xfree(compl_leader);
|
xfree(compl_leader);
|
||||||
compl_leader = vim_strnsave(line + compl_col, (size_t)(p_off - (ptrdiff_t)compl_col));
|
compl_leader = (char_u *)xstrnsave(line + compl_col, (size_t)(p_off - (ptrdiff_t)compl_col));
|
||||||
|
|
||||||
ins_compl_new_leader();
|
ins_compl_new_leader();
|
||||||
if (compl_shown_match != NULL) {
|
if (compl_shown_match != NULL) {
|
||||||
@ -1743,8 +1743,8 @@ void ins_compl_addleader(int c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
xfree(compl_leader);
|
xfree(compl_leader);
|
||||||
compl_leader = vim_strnsave(get_cursor_line_ptr() + compl_col,
|
compl_leader = (char_u *)xstrnsave(get_cursor_line_ptr() + compl_col,
|
||||||
(size_t)(curwin->w_cursor.col - compl_col));
|
(size_t)(curwin->w_cursor.col - compl_col));
|
||||||
ins_compl_new_leader();
|
ins_compl_new_leader();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2008,7 +2008,7 @@ static bool ins_compl_stop(const int c, const int prev_mode, bool retval)
|
|||||||
if (compl_leader != NULL) {
|
if (compl_leader != NULL) {
|
||||||
p = compl_leader;
|
p = compl_leader;
|
||||||
} else if (compl_first_match != NULL) {
|
} else if (compl_first_match != NULL) {
|
||||||
p = compl_orig_text;
|
p = (char_u *)compl_orig_text;
|
||||||
}
|
}
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
const int compl_len = get_compl_len();
|
const int compl_len = get_compl_len();
|
||||||
@ -2174,7 +2174,7 @@ static void ins_compl_fixRedoBufForLeader(char_u *ptr_arg)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (compl_orig_text != NULL) {
|
if (compl_orig_text != NULL) {
|
||||||
p = compl_orig_text;
|
p = (char_u *)compl_orig_text;
|
||||||
for (len = 0; p[len] != NUL && p[len] == ptr[len]; len++) {}
|
for (len = 0; p[len] != NUL && p[len] == ptr[len]; len++) {}
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
len -= utf_head_off((char *)p, (char *)p + len);
|
len -= utf_head_off((char *)p, (char *)p + len);
|
||||||
@ -2360,7 +2360,7 @@ static int ins_compl_add_tv(typval_T *const tv, const Direction dir, bool fast)
|
|||||||
tv_clear(&user_data);
|
tv_clear(&user_data);
|
||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
int status = ins_compl_add((char_u *)word, -1, NULL, (char_u **)cptext, true,
|
int status = ins_compl_add((char *)word, -1, NULL, cptext, true,
|
||||||
&user_data, dir, flags, dup);
|
&user_data, dir, flags, dup);
|
||||||
if (status != OK) {
|
if (status != OK) {
|
||||||
tv_clear(&user_data);
|
tv_clear(&user_data);
|
||||||
@ -2430,8 +2430,8 @@ static void set_completion(colnr_T startcol, list_T *list)
|
|||||||
compl_col = startcol;
|
compl_col = startcol;
|
||||||
compl_length = (int)curwin->w_cursor.col - (int)startcol;
|
compl_length = (int)curwin->w_cursor.col - (int)startcol;
|
||||||
// compl_pattern doesn't need to be set
|
// compl_pattern doesn't need to be set
|
||||||
compl_orig_text = vim_strnsave(get_cursor_line_ptr() + compl_col,
|
compl_orig_text = xstrnsave(get_cursor_line_ptr() + compl_col,
|
||||||
(size_t)compl_length);
|
(size_t)compl_length);
|
||||||
if (p_ic) {
|
if (p_ic) {
|
||||||
flags |= CP_ICASE;
|
flags |= CP_ICASE;
|
||||||
}
|
}
|
||||||
@ -3513,7 +3513,7 @@ static int ins_compl_next(bool allow_get_expansion, int count, bool insert_match
|
|||||||
|
|
||||||
// Insert the text of the new completion, or the compl_leader.
|
// Insert the text of the new completion, or the compl_leader.
|
||||||
if (compl_no_insert && !started) {
|
if (compl_no_insert && !started) {
|
||||||
ins_bytes((char *)compl_orig_text + get_compl_len());
|
ins_bytes(compl_orig_text + get_compl_len());
|
||||||
compl_used_match = false;
|
compl_used_match = false;
|
||||||
} else if (insert_match) {
|
} else if (insert_match) {
|
||||||
if (!compl_get_longest || compl_used_match) {
|
if (!compl_get_longest || compl_used_match) {
|
||||||
@ -3697,7 +3697,7 @@ static bool ins_compl_use_match(int c)
|
|||||||
/// completion)
|
/// completion)
|
||||||
/// Sets the global variables: compl_col, compl_length and compl_pattern.
|
/// Sets the global variables: compl_col, compl_length and compl_pattern.
|
||||||
/// Uses the global variables: compl_cont_status and ctrl_x_mode
|
/// Uses the global variables: compl_cont_status and ctrl_x_mode
|
||||||
static int get_normal_compl_info(char_u *line, int startcol, colnr_T curs_col)
|
static int get_normal_compl_info(char *line, int startcol, colnr_T curs_col)
|
||||||
{
|
{
|
||||||
if ((compl_cont_status & CONT_SOL) || ctrl_x_mode_path_defines()) {
|
if ((compl_cont_status & CONT_SOL) || ctrl_x_mode_path_defines()) {
|
||||||
if (!compl_status_adding()) {
|
if (!compl_status_adding()) {
|
||||||
@ -3706,25 +3706,25 @@ static int get_normal_compl_info(char_u *line, int startcol, colnr_T curs_col)
|
|||||||
compl_length = curs_col - startcol;
|
compl_length = curs_col - startcol;
|
||||||
}
|
}
|
||||||
if (p_ic) {
|
if (p_ic) {
|
||||||
compl_pattern = (char *)str_foldcase(line + compl_col, compl_length, NULL, 0);
|
compl_pattern = (char *)str_foldcase((char_u *)line + compl_col, compl_length, NULL, 0);
|
||||||
} else {
|
} else {
|
||||||
compl_pattern = (char *)vim_strnsave(line + compl_col, (size_t)compl_length);
|
compl_pattern = xstrnsave(line + compl_col, (size_t)compl_length);
|
||||||
}
|
}
|
||||||
} else if (compl_status_adding()) {
|
} else if (compl_status_adding()) {
|
||||||
char_u *prefix = (char_u *)"\\<";
|
char_u *prefix = (char_u *)"\\<";
|
||||||
|
|
||||||
// we need up to 2 extra chars for the prefix
|
// we need up to 2 extra chars for the prefix
|
||||||
compl_pattern = xmalloc(quote_meta(NULL, line + compl_col,
|
compl_pattern = xmalloc(quote_meta(NULL, (char_u *)line + compl_col, compl_length) + 2);
|
||||||
compl_length) + 2);
|
if (!vim_iswordp((char_u *)line + compl_col)
|
||||||
if (!vim_iswordp(line + compl_col)
|
|| (compl_col > 0
|
||||||
|| (compl_col > 0 && (vim_iswordp(mb_prevptr(line, line + compl_col))))) {
|
&& (vim_iswordp(mb_prevptr((char_u *)line, (char_u *)line + compl_col))))) {
|
||||||
prefix = (char_u *)"";
|
prefix = (char_u *)"";
|
||||||
}
|
}
|
||||||
STRCPY(compl_pattern, prefix);
|
STRCPY(compl_pattern, prefix);
|
||||||
(void)quote_meta((char_u *)compl_pattern + STRLEN(prefix),
|
(void)quote_meta((char_u *)compl_pattern + STRLEN(prefix),
|
||||||
line + compl_col, compl_length);
|
(char_u *)line + compl_col, compl_length);
|
||||||
} else if (--startcol < 0
|
} else if (--startcol < 0
|
||||||
|| !vim_iswordp(mb_prevptr(line, line + startcol + 1))) {
|
|| !vim_iswordp(mb_prevptr((char_u *)line, (char_u *)line + startcol + 1))) {
|
||||||
// Match any word of at least two chars
|
// Match any word of at least two chars
|
||||||
compl_pattern = xstrdup("\\<\\k\\k");
|
compl_pattern = xstrdup("\\<\\k\\k");
|
||||||
compl_col += curs_col;
|
compl_col += curs_col;
|
||||||
@ -3732,11 +3732,11 @@ static int get_normal_compl_info(char_u *line, int startcol, colnr_T curs_col)
|
|||||||
} else {
|
} else {
|
||||||
// Search the point of change class of multibyte character
|
// Search the point of change class of multibyte character
|
||||||
// or not a word single byte character backward.
|
// or not a word single byte character backward.
|
||||||
startcol -= utf_head_off((char *)line, (char *)line + startcol);
|
startcol -= utf_head_off(line, line + startcol);
|
||||||
int base_class = mb_get_class(line + startcol);
|
int base_class = mb_get_class((char_u *)line + startcol);
|
||||||
while (--startcol >= 0) {
|
while (--startcol >= 0) {
|
||||||
int head_off = utf_head_off((char *)line, (char *)line + startcol);
|
int head_off = utf_head_off(line, line + startcol);
|
||||||
if (base_class != mb_get_class(line + startcol - head_off)) {
|
if (base_class != mb_get_class((char_u *)line + startcol - head_off)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
startcol -= head_off;
|
startcol -= head_off;
|
||||||
@ -3749,13 +3749,13 @@ static int get_normal_compl_info(char_u *line, int startcol, colnr_T curs_col)
|
|||||||
// xmalloc(7) is enough -- Acevedo
|
// xmalloc(7) is enough -- Acevedo
|
||||||
compl_pattern = xmalloc(7);
|
compl_pattern = xmalloc(7);
|
||||||
STRCPY(compl_pattern, "\\<");
|
STRCPY(compl_pattern, "\\<");
|
||||||
(void)quote_meta((char_u *)compl_pattern + 2, line + compl_col, 1);
|
(void)quote_meta((char_u *)compl_pattern + 2, (char_u *)line + compl_col, 1);
|
||||||
STRCAT(compl_pattern, "\\k");
|
STRCAT(compl_pattern, "\\k");
|
||||||
} else {
|
} else {
|
||||||
compl_pattern = xmalloc(quote_meta(NULL, line + compl_col,
|
compl_pattern = xmalloc(quote_meta(NULL, (char_u *)line + compl_col,
|
||||||
compl_length) + 2);
|
compl_length) + 2);
|
||||||
STRCPY(compl_pattern, "\\<");
|
STRCPY(compl_pattern, "\\<");
|
||||||
(void)quote_meta((char_u *)compl_pattern + 2, line + compl_col, compl_length);
|
(void)quote_meta((char_u *)compl_pattern + 2, (char_u *)line + compl_col, compl_length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3765,17 +3765,17 @@ static int get_normal_compl_info(char_u *line, int startcol, colnr_T curs_col)
|
|||||||
/// Get the pattern, column and length for whole line completion or for the
|
/// Get the pattern, column and length for whole line completion or for the
|
||||||
/// complete() function.
|
/// complete() function.
|
||||||
/// Sets the global variables: compl_col, compl_length and compl_pattern.
|
/// Sets the global variables: compl_col, compl_length and compl_pattern.
|
||||||
static int get_wholeline_compl_info(char_u *line, colnr_T curs_col)
|
static int get_wholeline_compl_info(char *line, colnr_T curs_col)
|
||||||
{
|
{
|
||||||
compl_col = (colnr_T)getwhitecols((char *)line);
|
compl_col = (colnr_T)getwhitecols(line);
|
||||||
compl_length = (int)curs_col - (int)compl_col;
|
compl_length = (int)curs_col - (int)compl_col;
|
||||||
if (compl_length < 0) { // cursor in indent: empty pattern
|
if (compl_length < 0) { // cursor in indent: empty pattern
|
||||||
compl_length = 0;
|
compl_length = 0;
|
||||||
}
|
}
|
||||||
if (p_ic) {
|
if (p_ic) {
|
||||||
compl_pattern = (char *)str_foldcase(line + compl_col, compl_length, NULL, 0);
|
compl_pattern = (char *)str_foldcase((char_u *)line + compl_col, compl_length, NULL, 0);
|
||||||
} else {
|
} else {
|
||||||
compl_pattern = (char *)vim_strnsave(line + compl_col, (size_t)compl_length);
|
compl_pattern = xstrnsave(line + compl_col, (size_t)compl_length);
|
||||||
}
|
}
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
@ -3802,16 +3802,16 @@ static int get_filename_compl_info(char_u *line, int startcol, colnr_T curs_col)
|
|||||||
|
|
||||||
compl_col += startcol;
|
compl_col += startcol;
|
||||||
compl_length = (int)curs_col - startcol;
|
compl_length = (int)curs_col - startcol;
|
||||||
compl_pattern = (char *)addstar(line + compl_col, (size_t)compl_length, EXPAND_FILES);
|
compl_pattern = addstar((char *)line + compl_col, (size_t)compl_length, EXPAND_FILES);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the pattern, column and length for command-line completion.
|
/// Get the pattern, column and length for command-line completion.
|
||||||
/// Sets the global variables: compl_col, compl_length and compl_pattern.
|
/// Sets the global variables: compl_col, compl_length and compl_pattern.
|
||||||
static int get_cmdline_compl_info(char_u *line, colnr_T curs_col)
|
static int get_cmdline_compl_info(char *line, colnr_T curs_col)
|
||||||
{
|
{
|
||||||
compl_pattern = (char *)vim_strnsave(line, (size_t)curs_col);
|
compl_pattern = xstrnsave(line, (size_t)curs_col);
|
||||||
set_cmd_context(&compl_xp, (char_u *)compl_pattern, (int)STRLEN(compl_pattern), curs_col, false);
|
set_cmd_context(&compl_xp, (char_u *)compl_pattern, (int)STRLEN(compl_pattern), curs_col, false);
|
||||||
if (compl_xp.xp_context == EXPAND_UNSUCCESSFUL
|
if (compl_xp.xp_context == EXPAND_UNSUCCESSFUL
|
||||||
|| compl_xp.xp_context == EXPAND_NOTHING) {
|
|| compl_xp.xp_context == EXPAND_NOTHING) {
|
||||||
@ -3893,9 +3893,9 @@ static int get_userdefined_compl_info(colnr_T curs_col)
|
|||||||
|
|
||||||
// Setup variables for completion. Need to obtain "line" again,
|
// Setup variables for completion. Need to obtain "line" again,
|
||||||
// it may have become invalid.
|
// it may have become invalid.
|
||||||
char_u *line = (char_u *)ml_get(curwin->w_cursor.lnum);
|
char *line = ml_get(curwin->w_cursor.lnum);
|
||||||
compl_length = curs_col - compl_col;
|
compl_length = curs_col - compl_col;
|
||||||
compl_pattern = (char *)vim_strnsave(line + compl_col, (size_t)compl_length);
|
compl_pattern = xstrnsave(line + compl_col, (size_t)compl_length);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@ -3919,8 +3919,8 @@ static int get_spell_compl_info(int startcol, colnr_T curs_col)
|
|||||||
compl_length = (int)curs_col - compl_col;
|
compl_length = (int)curs_col - compl_col;
|
||||||
}
|
}
|
||||||
// Need to obtain "line" again, it may have become invalid.
|
// Need to obtain "line" again, it may have become invalid.
|
||||||
char_u *line = (char_u *)ml_get(curwin->w_cursor.lnum);
|
char *line = ml_get(curwin->w_cursor.lnum);
|
||||||
compl_pattern = (char *)vim_strnsave(line + compl_col, (size_t)compl_length);
|
compl_pattern = xstrnsave(line + compl_col, (size_t)compl_length);
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@ -3939,13 +3939,13 @@ static int compl_get_info(char_u *line, int startcol, colnr_T curs_col, bool *li
|
|||||||
if (ctrl_x_mode_normal()
|
if (ctrl_x_mode_normal()
|
||||||
|| ((ctrl_x_mode & CTRL_X_WANT_IDENT)
|
|| ((ctrl_x_mode & CTRL_X_WANT_IDENT)
|
||||||
&& !thesaurus_func_complete(ctrl_x_mode))) {
|
&& !thesaurus_func_complete(ctrl_x_mode))) {
|
||||||
return get_normal_compl_info(line, startcol, curs_col);
|
return get_normal_compl_info((char *)line, startcol, curs_col);
|
||||||
} else if (ctrl_x_mode_line_or_eval()) {
|
} else if (ctrl_x_mode_line_or_eval()) {
|
||||||
return get_wholeline_compl_info(line, curs_col);
|
return get_wholeline_compl_info((char *)line, curs_col);
|
||||||
} else if (ctrl_x_mode_files()) {
|
} else if (ctrl_x_mode_files()) {
|
||||||
return get_filename_compl_info(line, startcol, curs_col);
|
return get_filename_compl_info(line, startcol, curs_col);
|
||||||
} else if (ctrl_x_mode == CTRL_X_CMDLINE) {
|
} else if (ctrl_x_mode == CTRL_X_CMDLINE) {
|
||||||
return get_cmdline_compl_info(line, curs_col);
|
return get_cmdline_compl_info((char *)line, curs_col);
|
||||||
} else if (ctrl_x_mode_function() || ctrl_x_mode_omni()
|
} else if (ctrl_x_mode_function() || ctrl_x_mode_omni()
|
||||||
|| thesaurus_func_complete(ctrl_x_mode)) {
|
|| thesaurus_func_complete(ctrl_x_mode)) {
|
||||||
if (get_userdefined_compl_info(curs_col) == FAIL) {
|
if (get_userdefined_compl_info(curs_col) == FAIL) {
|
||||||
@ -4036,7 +4036,7 @@ static int ins_compl_start(void)
|
|||||||
return FAIL;
|
return FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
char_u *line = (char_u *)ml_get(curwin->w_cursor.lnum);
|
char *line = ml_get(curwin->w_cursor.lnum);
|
||||||
colnr_T curs_col = curwin->w_cursor.col;
|
colnr_T curs_col = curwin->w_cursor.col;
|
||||||
compl_pending = 0;
|
compl_pending = 0;
|
||||||
|
|
||||||
@ -4044,7 +4044,7 @@ static int ins_compl_start(void)
|
|||||||
&& compl_cont_mode == ctrl_x_mode) {
|
&& compl_cont_mode == ctrl_x_mode) {
|
||||||
// this same ctrl-x_mode was interrupted previously. Continue the
|
// this same ctrl-x_mode was interrupted previously. Continue the
|
||||||
// completion.
|
// completion.
|
||||||
ins_compl_continue_search(line);
|
ins_compl_continue_search((char_u *)line);
|
||||||
} else {
|
} else {
|
||||||
compl_cont_status &= CONT_LOCAL;
|
compl_cont_status &= CONT_LOCAL;
|
||||||
}
|
}
|
||||||
@ -4064,7 +4064,7 @@ static int ins_compl_start(void)
|
|||||||
|
|
||||||
// Work out completion pattern and original text -- webb
|
// Work out completion pattern and original text -- webb
|
||||||
bool line_invalid = false;
|
bool line_invalid = false;
|
||||||
if (compl_get_info(line, startcol, curs_col, &line_invalid) == FAIL) {
|
if (compl_get_info((char_u *)line, startcol, curs_col, &line_invalid) == FAIL) {
|
||||||
if (ctrl_x_mode_function() || ctrl_x_mode_omni()
|
if (ctrl_x_mode_function() || ctrl_x_mode_omni()
|
||||||
|| thesaurus_func_complete(ctrl_x_mode)) {
|
|| thesaurus_func_complete(ctrl_x_mode)) {
|
||||||
// restore did_ai, so that adding comment leader works
|
// restore did_ai, so that adding comment leader works
|
||||||
@ -4074,7 +4074,7 @@ static int ins_compl_start(void)
|
|||||||
}
|
}
|
||||||
// If "line" was changed while getting completion info get it again.
|
// If "line" was changed while getting completion info get it again.
|
||||||
if (line_invalid) {
|
if (line_invalid) {
|
||||||
line = (char_u *)ml_get(curwin->w_cursor.lnum);
|
line = ml_get(curwin->w_cursor.lnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compl_status_adding()) {
|
if (compl_status_adding()) {
|
||||||
@ -4108,7 +4108,7 @@ static int ins_compl_start(void)
|
|||||||
|
|
||||||
// Always add completion for the original text.
|
// Always add completion for the original text.
|
||||||
xfree(compl_orig_text);
|
xfree(compl_orig_text);
|
||||||
compl_orig_text = vim_strnsave(line + compl_col, (size_t)compl_length);
|
compl_orig_text = xstrnsave(line + compl_col, (size_t)compl_length);
|
||||||
int flags = CP_ORIGINAL_TEXT;
|
int flags = CP_ORIGINAL_TEXT;
|
||||||
if (p_ic) {
|
if (p_ic) {
|
||||||
flags |= CP_ICASE;
|
flags |= CP_ICASE;
|
||||||
|
@ -650,7 +650,7 @@ int find_special_key(const char_u **const srcp, const size_t src_len, int *const
|
|||||||
if (*bp == '-') {
|
if (*bp == '-') {
|
||||||
last_dash = bp;
|
last_dash = bp;
|
||||||
if (bp + 1 <= end) {
|
if (bp + 1 <= end) {
|
||||||
l = utfc_ptr2len_len(bp + 1, (int)(end - bp) + 1);
|
l = utfc_ptr2len_len((char *)bp + 1, (int)(end - bp) + 1);
|
||||||
// Anything accepted, like <C-?>.
|
// Anything accepted, like <C-?>.
|
||||||
// <C-"> or <M-"> are not special in strings as " is
|
// <C-"> or <M-"> are not special in strings as " is
|
||||||
// the string delimiter. With a backslash it works: <M-\">
|
// the string delimiter. With a backslash it works: <M-\">
|
||||||
@ -665,7 +665,7 @@ int find_special_key(const char_u **const srcp, const size_t src_len, int *const
|
|||||||
if (end - bp > 3 && bp[0] == 't' && bp[1] == '_') {
|
if (end - bp > 3 && bp[0] == 't' && bp[1] == '_') {
|
||||||
bp += 3; // skip t_xx, xx may be '-' or '>'
|
bp += 3; // skip t_xx, xx may be '-' or '>'
|
||||||
} else if (end - bp > 4 && STRNICMP(bp, "char-", 5) == 0) {
|
} else if (end - bp > 4 && STRNICMP(bp, "char-", 5) == 0) {
|
||||||
vim_str2nr(bp + 5, NULL, &l, STR2NR_ALL, NULL, NULL, 0, true);
|
vim_str2nr((char *)bp + 5, NULL, &l, STR2NR_ALL, NULL, NULL, 0, true);
|
||||||
if (l == 0) {
|
if (l == 0) {
|
||||||
emsg(_(e_invarg));
|
emsg(_(e_invarg));
|
||||||
return 0;
|
return 0;
|
||||||
@ -695,7 +695,7 @@ int find_special_key(const char_u **const srcp, const size_t src_len, int *const
|
|||||||
if (STRNICMP(last_dash + 1, "char-", 5) == 0
|
if (STRNICMP(last_dash + 1, "char-", 5) == 0
|
||||||
&& ascii_isdigit(last_dash[6])) {
|
&& ascii_isdigit(last_dash[6])) {
|
||||||
// <Char-123> or <Char-033> or <Char-0x33>
|
// <Char-123> or <Char-033> or <Char-0x33>
|
||||||
vim_str2nr(last_dash + 6, NULL, &l, STR2NR_ALL, NULL, &n, 0, true);
|
vim_str2nr((char *)last_dash + 6, NULL, &l, STR2NR_ALL, NULL, &n, 0, true);
|
||||||
if (l == 0) {
|
if (l == 0) {
|
||||||
emsg(_(e_invarg));
|
emsg(_(e_invarg));
|
||||||
return 0;
|
return 0;
|
||||||
@ -993,7 +993,7 @@ char *replace_termcodes(const char *const from, const size_t from_len, char **co
|
|||||||
}
|
}
|
||||||
|
|
||||||
// skip multibyte char correctly
|
// skip multibyte char correctly
|
||||||
for (i = utfc_ptr2len_len(src, (int)(end - src) + 1); i > 0; i--) {
|
for (i = utfc_ptr2len_len((char *)src, (int)(end - src) + 1); i > 0; i--) {
|
||||||
// If the character is K_SPECIAL, replace it with K_SPECIAL
|
// If the character is K_SPECIAL, replace it with K_SPECIAL
|
||||||
// KS_SPECIAL KE_FILLER.
|
// KS_SPECIAL KE_FILLER.
|
||||||
if (*src == K_SPECIAL) {
|
if (*src == K_SPECIAL) {
|
||||||
|
@ -800,31 +800,29 @@ void clrallmarks(buf_T *const buf)
|
|||||||
char_u *fm_getname(fmark_T *fmark, int lead_len)
|
char_u *fm_getname(fmark_T *fmark, int lead_len)
|
||||||
{
|
{
|
||||||
if (fmark->fnum == curbuf->b_fnum) { // current buffer
|
if (fmark->fnum == curbuf->b_fnum) { // current buffer
|
||||||
return mark_line(&(fmark->mark), lead_len);
|
return (char_u *)mark_line(&(fmark->mark), lead_len);
|
||||||
}
|
}
|
||||||
return (char_u *)buflist_nr2name(fmark->fnum, false, true);
|
return (char_u *)buflist_nr2name(fmark->fnum, false, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Return the line at mark "mp". Truncate to fit in window.
|
||||||
* Return the line at mark "mp". Truncate to fit in window.
|
/// The returned string has been allocated.
|
||||||
* The returned string has been allocated.
|
static char *mark_line(pos_T *mp, int lead_len)
|
||||||
*/
|
|
||||||
static char_u *mark_line(pos_T *mp, int lead_len)
|
|
||||||
{
|
{
|
||||||
char_u *s, *p;
|
char *s, *p;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if (mp->lnum == 0 || mp->lnum > curbuf->b_ml.ml_line_count) {
|
if (mp->lnum == 0 || mp->lnum > curbuf->b_ml.ml_line_count) {
|
||||||
return vim_strsave((char_u *)"-invalid-");
|
return xstrdup("-invalid-");
|
||||||
}
|
}
|
||||||
assert(Columns >= 0);
|
assert(Columns >= 0);
|
||||||
// Allow for up to 5 bytes per character.
|
// Allow for up to 5 bytes per character.
|
||||||
s = vim_strnsave((char_u *)skipwhite(ml_get(mp->lnum)), (size_t)Columns * 5);
|
s = xstrnsave(skipwhite(ml_get(mp->lnum)), (size_t)Columns * 5);
|
||||||
|
|
||||||
// Truncate the line to fit it in the window
|
// Truncate the line to fit it in the window
|
||||||
len = 0;
|
len = 0;
|
||||||
for (p = s; *p != NUL; MB_PTR_ADV(p)) {
|
for (p = s; *p != NUL; MB_PTR_ADV(p)) {
|
||||||
len += ptr2cells((char *)p);
|
len += ptr2cells(p);
|
||||||
if (len >= Columns - lead_len) {
|
if (len >= Columns - lead_len) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -908,7 +906,7 @@ static void show_one_mark(int c, char_u *arg, pos_T *p, char_u *name_arg, int cu
|
|||||||
&& p->lnum != 0) {
|
&& p->lnum != 0) {
|
||||||
// don't output anything if 'q' typed at --more-- prompt
|
// don't output anything if 'q' typed at --more-- prompt
|
||||||
if (name == NULL && current) {
|
if (name == NULL && current) {
|
||||||
name = mark_line(p, 15);
|
name = (char_u *)mark_line(p, 15);
|
||||||
mustfree = true;
|
mustfree = true;
|
||||||
}
|
}
|
||||||
if (!message_filtered((char *)name)) {
|
if (!message_filtered((char *)name)) {
|
||||||
@ -1094,7 +1092,7 @@ void ex_changes(exarg_T *eap)
|
|||||||
(long)curbuf->b_changelist[i].mark.lnum,
|
(long)curbuf->b_changelist[i].mark.lnum,
|
||||||
curbuf->b_changelist[i].mark.col);
|
curbuf->b_changelist[i].mark.col);
|
||||||
msg_outtrans((char *)IObuff);
|
msg_outtrans((char *)IObuff);
|
||||||
name = mark_line(&curbuf->b_changelist[i].mark, 17);
|
name = (char_u *)mark_line(&curbuf->b_changelist[i].mark, 17);
|
||||||
msg_outtrans_attr((char *)name, HL_ATTR(HLF_D));
|
msg_outtrans_attr((char *)name, HL_ATTR(HLF_D));
|
||||||
xfree(name);
|
xfree(name);
|
||||||
os_breakcheck();
|
os_breakcheck();
|
||||||
|
@ -1159,9 +1159,9 @@ void f_matchdelete(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
|
|||||||
/// skipping commands to find the next command.
|
/// skipping commands to find the next command.
|
||||||
void ex_match(exarg_T *eap)
|
void ex_match(exarg_T *eap)
|
||||||
{
|
{
|
||||||
char_u *p;
|
char *p;
|
||||||
char_u *g = NULL;
|
char *g = NULL;
|
||||||
char_u *end;
|
char *end;
|
||||||
int c;
|
int c;
|
||||||
int id;
|
int id;
|
||||||
|
|
||||||
@ -1178,25 +1178,25 @@ void ex_match(exarg_T *eap)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ends_excmd(*eap->arg)) {
|
if (ends_excmd(*eap->arg)) {
|
||||||
end = (char_u *)eap->arg;
|
end = eap->arg;
|
||||||
} else if ((STRNICMP(eap->arg, "none", 4) == 0
|
} else if ((STRNICMP(eap->arg, "none", 4) == 0
|
||||||
&& (ascii_iswhite(eap->arg[4]) || ends_excmd(eap->arg[4])))) {
|
&& (ascii_iswhite(eap->arg[4]) || ends_excmd(eap->arg[4])))) {
|
||||||
end = (char_u *)eap->arg + 4;
|
end = eap->arg + 4;
|
||||||
} else {
|
} else {
|
||||||
p = (char_u *)skiptowhite(eap->arg);
|
p = skiptowhite(eap->arg);
|
||||||
if (!eap->skip) {
|
if (!eap->skip) {
|
||||||
g = vim_strnsave((char_u *)eap->arg, (size_t)(p - (char_u *)eap->arg));
|
g = xstrnsave(eap->arg, (size_t)(p - eap->arg));
|
||||||
}
|
}
|
||||||
p = (char_u *)skipwhite((char *)p);
|
p = skipwhite(p);
|
||||||
if (*p == NUL) {
|
if (*p == NUL) {
|
||||||
// There must be two arguments.
|
// There must be two arguments.
|
||||||
xfree(g);
|
xfree(g);
|
||||||
semsg(_(e_invarg2), eap->arg);
|
semsg(_(e_invarg2), eap->arg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
end = (char_u *)skip_regexp((char *)p + 1, *p, true, NULL);
|
end = skip_regexp(p + 1, *p, true, NULL);
|
||||||
if (!eap->skip) {
|
if (!eap->skip) {
|
||||||
if (*end != NUL && !ends_excmd(*skipwhite((char *)end + 1))) {
|
if (*end != NUL && !ends_excmd(*skipwhite(end + 1))) {
|
||||||
xfree(g);
|
xfree(g);
|
||||||
eap->errmsg = ex_errmsg(e_trailing_arg, (const char *)end);
|
eap->errmsg = ex_errmsg(e_trailing_arg, (const char *)end);
|
||||||
return;
|
return;
|
||||||
@ -1207,13 +1207,13 @@ void ex_match(exarg_T *eap)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
c = *end;
|
c = (uint8_t)(*end);
|
||||||
*end = NUL;
|
*end = NUL;
|
||||||
match_add(curwin, (const char *)g, (const char *)p + 1, 10, id,
|
match_add(curwin, (const char *)g, (const char *)p + 1, 10, id,
|
||||||
NULL, NULL);
|
NULL, NULL);
|
||||||
xfree(g);
|
xfree(g);
|
||||||
*end = (char_u)c;
|
*end = (char)c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
eap->nextcmd = find_nextcmd((char *)end);
|
eap->nextcmd = find_nextcmd(end);
|
||||||
}
|
}
|
||||||
|
@ -587,7 +587,7 @@ size_t mb_string2cells_len(const char *str, size_t size)
|
|||||||
size_t clen = 0;
|
size_t clen = 0;
|
||||||
|
|
||||||
for (const char_u *p = (char_u *)str; *p != NUL && p < (char_u *)str + size;
|
for (const char_u *p = (char_u *)str; *p != NUL && p < (char_u *)str + size;
|
||||||
p += utfc_ptr2len_len(p, (int)size + (int)(p - (char_u *)str))) {
|
p += utfc_ptr2len_len((char *)p, (int)size + (int)(p - (char_u *)str))) {
|
||||||
clen += (size_t)utf_ptr2cells((char *)p);
|
clen += (size_t)utf_ptr2cells((char *)p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -727,12 +727,10 @@ int mb_cptr2char_adv(const char_u **pp)
|
|||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Check if the character pointed to by "p2" is a composing character when it
|
||||||
* Check if the character pointed to by "p2" is a composing character when it
|
/// comes after "p1". For Arabic sometimes "ab" is replaced with "c", which
|
||||||
* comes after "p1". For Arabic sometimes "ab" is replaced with "c", which
|
/// behaves like a composing character.
|
||||||
* behaves like a composing character.
|
bool utf_composinglike(const char *p1, const char *p2)
|
||||||
*/
|
|
||||||
bool utf_composinglike(const char_u *p1, const char_u *p2)
|
|
||||||
{
|
{
|
||||||
int c2;
|
int c2;
|
||||||
|
|
||||||
@ -765,7 +763,7 @@ int utfc_ptr2char(const char *p_in, int *pcc)
|
|||||||
// Only accept a composing char when the first char isn't illegal.
|
// Only accept a composing char when the first char isn't illegal.
|
||||||
if ((len > 1 || *p < 0x80)
|
if ((len > 1 || *p < 0x80)
|
||||||
&& p[len] >= 0x80
|
&& p[len] >= 0x80
|
||||||
&& utf_composinglike(p, p + len)) {
|
&& utf_composinglike((char *)p, (char *)p + len)) {
|
||||||
int cc = utf_ptr2char((char *)p + len);
|
int cc = utf_ptr2char((char *)p + len);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
pcc[i++] = cc;
|
pcc[i++] = cc;
|
||||||
@ -809,7 +807,7 @@ int utfc_ptr2char_len(const char_u *p, int *pcc, int maxlen)
|
|||||||
int len_cc = utf_ptr2len_len(p + len, maxlen - len);
|
int len_cc = utf_ptr2len_len(p + len, maxlen - len);
|
||||||
safe = len_cc > 1 && len_cc <= maxlen - len;
|
safe = len_cc > 1 && len_cc <= maxlen - len;
|
||||||
if (!safe || (pcc[i] = utf_ptr2char((char *)p + len)) < 0x80
|
if (!safe || (pcc[i] = utf_ptr2char((char *)p + len)) < 0x80
|
||||||
|| !(i == 0 ? utf_composinglike(p, p + len) : utf_iscomposing(pcc[i]))) {
|
|| !(i == 0 ? utf_composinglike((char *)p, (char *)p + len) : utf_iscomposing(pcc[i]))) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
len += len_cc;
|
len += len_cc;
|
||||||
@ -916,7 +914,7 @@ int utfc_ptr2len(const char *const p_in)
|
|||||||
// skip all of them (otherwise the cursor would get stuck).
|
// skip all of them (otherwise the cursor would get stuck).
|
||||||
int prevlen = 0;
|
int prevlen = 0;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (p[len] < 0x80 || !utf_composinglike(p + prevlen, p + len)) {
|
if (p[len] < 0x80 || !utf_composinglike((char *)p + prevlen, (char *)p + len)) {
|
||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -926,13 +924,11 @@ int utfc_ptr2len(const char *const p_in)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Return the number of bytes the UTF-8 encoding of the character at "p[size]"
|
||||||
* Return the number of bytes the UTF-8 encoding of the character at "p[size]"
|
/// takes. This includes following composing characters.
|
||||||
* takes. This includes following composing characters.
|
/// Returns 0 for an empty string.
|
||||||
* Returns 0 for an empty string.
|
/// Returns 1 for an illegal char or an incomplete byte sequence.
|
||||||
* Returns 1 for an illegal char or an incomplete byte sequence.
|
int utfc_ptr2len_len(const char *p, int size)
|
||||||
*/
|
|
||||||
int utfc_ptr2len_len(const char_u *p, int size)
|
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
int prevlen;
|
int prevlen;
|
||||||
@ -940,15 +936,15 @@ int utfc_ptr2len_len(const char_u *p, int size)
|
|||||||
if (size < 1 || *p == NUL) {
|
if (size < 1 || *p == NUL) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (p[0] < 0x80 && (size == 1 || p[1] < 0x80)) { // be quick for ASCII
|
if ((uint8_t)p[0] < 0x80 && (size == 1 || (uint8_t)p[1] < 0x80)) { // be quick for ASCII
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip over first UTF-8 char, stopping at a NUL byte.
|
// Skip over first UTF-8 char, stopping at a NUL byte.
|
||||||
len = utf_ptr2len_len(p, size);
|
len = utf_ptr2len_len((char_u *)p, size);
|
||||||
|
|
||||||
// Check for illegal byte and incomplete byte sequence.
|
// Check for illegal byte and incomplete byte sequence.
|
||||||
if ((len == 1 && p[0] >= 0x80) || len > size) {
|
if ((len == 1 && (uint8_t)p[0] >= 0x80) || len > size) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -960,7 +956,7 @@ int utfc_ptr2len_len(const char_u *p, int size)
|
|||||||
while (len < size) {
|
while (len < size) {
|
||||||
int len_next_char;
|
int len_next_char;
|
||||||
|
|
||||||
if (p[len] < 0x80) {
|
if ((uint8_t)p[len] < 0x80) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -968,7 +964,7 @@ int utfc_ptr2len_len(const char_u *p, int size)
|
|||||||
* Next character length should not go beyond size to ensure that
|
* Next character length should not go beyond size to ensure that
|
||||||
* utf_composinglike(...) does not read beyond size.
|
* utf_composinglike(...) does not read beyond size.
|
||||||
*/
|
*/
|
||||||
len_next_char = utf_ptr2len_len(p + len, size - len);
|
len_next_char = utf_ptr2len_len((char_u *)p + len, size - len);
|
||||||
if (len_next_char > size - len) {
|
if (len_next_char > size - len) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2420,7 +2416,7 @@ static char_u *iconv_string(const vimconv_T *const vcp, char_u *str, size_t slen
|
|||||||
if (utf_ptr2cells(from) > 1) {
|
if (utf_ptr2cells(from) > 1) {
|
||||||
*to++ = '?';
|
*to++ = '?';
|
||||||
}
|
}
|
||||||
l = utfc_ptr2len_len((const char_u *)from, (int)fromlen);
|
l = utfc_ptr2len_len(from, (int)fromlen);
|
||||||
from += l;
|
from += l;
|
||||||
fromlen -= (size_t)l;
|
fromlen -= (size_t)l;
|
||||||
} else if (ICONV_ERRNO != ICONV_E2BIG) {
|
} else if (ICONV_ERRNO != ICONV_E2BIG) {
|
||||||
|
@ -735,12 +735,12 @@ void ml_recover(bool checkext)
|
|||||||
{
|
{
|
||||||
buf_T *buf = NULL;
|
buf_T *buf = NULL;
|
||||||
memfile_T *mfp = NULL;
|
memfile_T *mfp = NULL;
|
||||||
char_u *fname;
|
char *fname;
|
||||||
char_u *fname_used = NULL;
|
char *fname_used = NULL;
|
||||||
bhdr_T *hp = NULL;
|
bhdr_T *hp = NULL;
|
||||||
ZERO_BL *b0p;
|
ZERO_BL *b0p;
|
||||||
int b0_ff;
|
int b0_ff;
|
||||||
char_u *b0_fenc = NULL;
|
char *b0_fenc = NULL;
|
||||||
PTR_BL *pp;
|
PTR_BL *pp;
|
||||||
DATA_BL *dp;
|
DATA_BL *dp;
|
||||||
infoptr_T *ip;
|
infoptr_T *ip;
|
||||||
@ -748,7 +748,7 @@ void ml_recover(bool checkext)
|
|||||||
int len;
|
int len;
|
||||||
bool directly;
|
bool directly;
|
||||||
linenr_T lnum;
|
linenr_T lnum;
|
||||||
char_u *p;
|
char *p;
|
||||||
int i;
|
int i;
|
||||||
long error;
|
long error;
|
||||||
bool cannot_open;
|
bool cannot_open;
|
||||||
@ -770,9 +770,9 @@ void ml_recover(bool checkext)
|
|||||||
|
|
||||||
// If the file name ends in ".s[a-w][a-z]" we assume this is the swap file.
|
// If the file name ends in ".s[a-w][a-z]" we assume this is the swap file.
|
||||||
// Otherwise a search is done to find the swap file(s).
|
// Otherwise a search is done to find the swap file(s).
|
||||||
fname = (char_u *)curbuf->b_fname;
|
fname = curbuf->b_fname;
|
||||||
if (fname == NULL) { // When there is no file name
|
if (fname == NULL) { // When there is no file name
|
||||||
fname = (char_u *)"";
|
fname = "";
|
||||||
}
|
}
|
||||||
len = (int)STRLEN(fname);
|
len = (int)STRLEN(fname);
|
||||||
if (checkext && len >= 4
|
if (checkext && len >= 4
|
||||||
@ -780,12 +780,12 @@ void ml_recover(bool checkext)
|
|||||||
&& vim_strchr("abcdefghijklmnopqrstuvw", TOLOWER_ASC(fname[len - 2])) != NULL
|
&& vim_strchr("abcdefghijklmnopqrstuvw", TOLOWER_ASC(fname[len - 2])) != NULL
|
||||||
&& ASCII_ISALPHA(fname[len - 1])) {
|
&& ASCII_ISALPHA(fname[len - 1])) {
|
||||||
directly = true;
|
directly = true;
|
||||||
fname_used = vim_strsave(fname); // make a copy for mf_open()
|
fname_used = xstrdup(fname); // make a copy for mf_open()
|
||||||
} else {
|
} else {
|
||||||
directly = false;
|
directly = false;
|
||||||
|
|
||||||
// count the number of matching swap files
|
// count the number of matching swap files
|
||||||
len = recover_names(fname, false, 0, NULL);
|
len = recover_names((char_u *)fname, false, 0, NULL);
|
||||||
if (len == 0) { // no swap files found
|
if (len == 0) { // no swap files found
|
||||||
semsg(_("E305: No swap file found for %s"), fname);
|
semsg(_("E305: No swap file found for %s"), fname);
|
||||||
goto theend;
|
goto theend;
|
||||||
@ -794,7 +794,7 @@ void ml_recover(bool checkext)
|
|||||||
i = 1;
|
i = 1;
|
||||||
} else { // several swap files found, choose
|
} else { // several swap files found, choose
|
||||||
// list the names of the swap files
|
// list the names of the swap files
|
||||||
(void)recover_names(fname, true, 0, NULL);
|
(void)recover_names((char_u *)fname, true, 0, NULL);
|
||||||
msg_putchar('\n');
|
msg_putchar('\n');
|
||||||
msg_puts(_("Enter number of swap file to use (0 to quit): "));
|
msg_puts(_("Enter number of swap file to use (0 to quit): "));
|
||||||
i = get_number(false, NULL);
|
i = get_number(false, NULL);
|
||||||
@ -803,7 +803,7 @@ void ml_recover(bool checkext)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// get the swap file name that will be used
|
// get the swap file name that will be used
|
||||||
(void)recover_names(fname, false, i, &fname_used);
|
(void)recover_names((char_u *)fname, false, i, (char_u **)&fname_used);
|
||||||
}
|
}
|
||||||
if (fname_used == NULL) {
|
if (fname_used == NULL) {
|
||||||
goto theend; // user chose invalid number.
|
goto theend; // user chose invalid number.
|
||||||
@ -833,9 +833,9 @@ void ml_recover(bool checkext)
|
|||||||
/*
|
/*
|
||||||
* open the memfile from the old swap file
|
* open the memfile from the old swap file
|
||||||
*/
|
*/
|
||||||
p = vim_strsave(fname_used); // save "fname_used" for the message:
|
p = xstrdup(fname_used); // save "fname_used" for the message:
|
||||||
// mf_open() will consume "fname_used"!
|
// mf_open() will consume "fname_used"!
|
||||||
mfp = mf_open((char *)fname_used, O_RDONLY);
|
mfp = mf_open(fname_used, O_RDONLY);
|
||||||
fname_used = p;
|
fname_used = p;
|
||||||
if (mfp == NULL || mfp->mf_fd < 0) {
|
if (mfp == NULL || mfp->mf_fd < 0) {
|
||||||
semsg(_("E306: Cannot open %s"), fname_used);
|
semsg(_("E306: Cannot open %s"), fname_used);
|
||||||
@ -962,8 +962,8 @@ void ml_recover(bool checkext)
|
|||||||
if (b0p->b0_flags & B0_HAS_FENC) {
|
if (b0p->b0_flags & B0_HAS_FENC) {
|
||||||
int fnsize = B0_FNAME_SIZE_NOCRYPT;
|
int fnsize = B0_FNAME_SIZE_NOCRYPT;
|
||||||
|
|
||||||
for (p = b0p->b0_fname + fnsize; p > b0p->b0_fname && p[-1] != NUL; p--) {}
|
for (p = (char *)b0p->b0_fname + fnsize; (char_u *)p > b0p->b0_fname && p[-1] != NUL; p--) {}
|
||||||
b0_fenc = vim_strnsave(p, (size_t)(b0p->b0_fname + fnsize - p));
|
b0_fenc = xstrnsave(p, (size_t)(b0p->b0_fname + fnsize - (char_u *)p));
|
||||||
}
|
}
|
||||||
|
|
||||||
mf_put(mfp, hp, false, false); // release block 0
|
mf_put(mfp, hp, false, false); // release block 0
|
||||||
@ -991,7 +991,7 @@ void ml_recover(bool checkext)
|
|||||||
set_fileformat(b0_ff - 1, OPT_LOCAL);
|
set_fileformat(b0_ff - 1, OPT_LOCAL);
|
||||||
}
|
}
|
||||||
if (b0_fenc != NULL) {
|
if (b0_fenc != NULL) {
|
||||||
set_option_value_give_err("fenc", 0L, (char *)b0_fenc, OPT_LOCAL);
|
set_option_value_give_err("fenc", 0L, b0_fenc, OPT_LOCAL);
|
||||||
xfree(b0_fenc);
|
xfree(b0_fenc);
|
||||||
}
|
}
|
||||||
unchanged(curbuf, true, true);
|
unchanged(curbuf, true, true);
|
||||||
@ -1133,12 +1133,12 @@ void ml_recover(bool checkext)
|
|||||||
txt_start = (dp->db_index[i] & DB_INDEX_MASK);
|
txt_start = (dp->db_index[i] & DB_INDEX_MASK);
|
||||||
if (txt_start <= (int)HEADER_SIZE
|
if (txt_start <= (int)HEADER_SIZE
|
||||||
|| txt_start >= (int)dp->db_txt_end) {
|
|| txt_start >= (int)dp->db_txt_end) {
|
||||||
p = (char_u *)"???";
|
p = "???";
|
||||||
error++;
|
error++;
|
||||||
} else {
|
} else {
|
||||||
p = (char_u *)dp + txt_start;
|
p = (char *)dp + txt_start;
|
||||||
}
|
}
|
||||||
ml_append(lnum++, (char *)p, (colnr_T)0, true);
|
ml_append(lnum++, p, (colnr_T)0, true);
|
||||||
}
|
}
|
||||||
if (has_error) {
|
if (has_error) {
|
||||||
ml_append(lnum++, _("???END"), (colnr_T)0, true);
|
ml_append(lnum++, _("???END"), (colnr_T)0, true);
|
||||||
@ -1177,7 +1177,7 @@ void ml_recover(bool checkext)
|
|||||||
} else {
|
} else {
|
||||||
for (idx = 1; idx <= lnum; idx++) {
|
for (idx = 1; idx <= lnum; idx++) {
|
||||||
// Need to copy one line, fetching the other one may flush it.
|
// Need to copy one line, fetching the other one may flush it.
|
||||||
p = vim_strsave((char_u *)ml_get(idx));
|
p = xstrdup(ml_get(idx));
|
||||||
i = STRCMP(p, ml_get(idx + lnum));
|
i = STRCMP(p, ml_get(idx + lnum));
|
||||||
xfree(p);
|
xfree(p);
|
||||||
if (i != 0) {
|
if (i != 0) {
|
||||||
|
@ -1581,7 +1581,7 @@ int msg_outtrans_len_attr(const char *msgstr, int len, int attr)
|
|||||||
*/
|
*/
|
||||||
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((char_u *)str, len + 1);
|
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)) {
|
||||||
@ -2219,7 +2219,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse)
|
|||||||
if (has_last_char) {
|
if (has_last_char) {
|
||||||
if (maxlen >= 0) {
|
if (maxlen >= 0) {
|
||||||
// Avoid including composing chars after the end.
|
// Avoid including composing chars after the end.
|
||||||
l = utfc_ptr2len_len((char_u *)s, (int)((str + maxlen) - s));
|
l = utfc_ptr2len_len(s, (int)((str + maxlen) - s));
|
||||||
} else {
|
} else {
|
||||||
l = utfc_ptr2len(s);
|
l = utfc_ptr2len(s);
|
||||||
}
|
}
|
||||||
@ -2316,7 +2316,7 @@ static void msg_puts_display(const char *str, int maxlen, int attr, int recurse)
|
|||||||
cw = utf_ptr2cells(s);
|
cw = utf_ptr2cells(s);
|
||||||
if (maxlen >= 0) {
|
if (maxlen >= 0) {
|
||||||
// avoid including composing chars after the end
|
// avoid including composing chars after the end
|
||||||
l = utfc_ptr2len_len((char_u *)s, (int)((str + maxlen) - s));
|
l = utfc_ptr2len_len(s, (int)((str + maxlen) - s));
|
||||||
} else {
|
} else {
|
||||||
l = utfc_ptr2len(s);
|
l = utfc_ptr2len(s);
|
||||||
}
|
}
|
||||||
|
@ -3134,7 +3134,7 @@ bool find_decl(char_u *ptr, size_t len, bool locally, bool thisblock, int flags_
|
|||||||
} else {
|
} else {
|
||||||
par_pos = curwin->w_cursor;
|
par_pos = curwin->w_cursor;
|
||||||
while (curwin->w_cursor.lnum > 1
|
while (curwin->w_cursor.lnum > 1
|
||||||
&& *skipwhite((char *)get_cursor_line_ptr()) != NUL) {
|
&& *skipwhite(get_cursor_line_ptr()) != NUL) {
|
||||||
curwin->w_cursor.lnum--;
|
curwin->w_cursor.lnum--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3171,13 +3171,13 @@ bool find_decl(char_u *ptr, size_t len, bool locally, bool thisblock, int flags_
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (get_leader_len((char *)get_cursor_line_ptr(), NULL, false, true) > 0) {
|
if (get_leader_len(get_cursor_line_ptr(), NULL, false, true) > 0) {
|
||||||
// Ignore this line, continue at start of next line.
|
// Ignore this line, continue at start of next line.
|
||||||
curwin->w_cursor.lnum++;
|
curwin->w_cursor.lnum++;
|
||||||
curwin->w_cursor.col = 0;
|
curwin->w_cursor.col = 0;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
bool valid = is_ident(get_cursor_line_ptr(), curwin->w_cursor.col);
|
bool valid = is_ident((char_u *)get_cursor_line_ptr(), curwin->w_cursor.col);
|
||||||
|
|
||||||
// If the current position is not a valid identifier and a previous match is
|
// If the current position is not a valid identifier and a previous match is
|
||||||
// present, favor that one instead.
|
// present, favor that one instead.
|
||||||
@ -3232,7 +3232,7 @@ bool find_decl(char_u *ptr, size_t len, bool locally, bool thisblock, int flags_
|
|||||||
/// @return true if able to move cursor, false otherwise.
|
/// @return true if able to move cursor, false otherwise.
|
||||||
static bool nv_screengo(oparg_T *oap, int dir, long dist)
|
static bool nv_screengo(oparg_T *oap, int dir, long dist)
|
||||||
{
|
{
|
||||||
int linelen = linetabsize(get_cursor_line_ptr());
|
int linelen = linetabsize((char_u *)get_cursor_line_ptr());
|
||||||
bool retval = true;
|
bool retval = true;
|
||||||
bool atend = false;
|
bool atend = false;
|
||||||
int n;
|
int n;
|
||||||
@ -3303,7 +3303,7 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist)
|
|||||||
}
|
}
|
||||||
curwin->w_cursor.lnum--;
|
curwin->w_cursor.lnum--;
|
||||||
|
|
||||||
linelen = linetabsize(get_cursor_line_ptr());
|
linelen = linetabsize((char_u *)get_cursor_line_ptr());
|
||||||
if (linelen > width1) {
|
if (linelen > width1) {
|
||||||
int w = (((linelen - width1 - 1) / width2) + 1) * width2;
|
int w = (((linelen - width1 - 1) / width2) + 1) * width2;
|
||||||
assert(curwin->w_curswant <= INT_MAX - w);
|
assert(curwin->w_curswant <= INT_MAX - w);
|
||||||
@ -3339,7 +3339,7 @@ static bool nv_screengo(oparg_T *oap, int dir, long dist)
|
|||||||
if (curwin->w_curswant >= width1) {
|
if (curwin->w_curswant >= width1) {
|
||||||
curwin->w_curswant -= width2;
|
curwin->w_curswant -= width2;
|
||||||
}
|
}
|
||||||
linelen = linetabsize(get_cursor_line_ptr());
|
linelen = linetabsize((char_u *)get_cursor_line_ptr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4294,7 +4294,7 @@ static void nv_ident(cmdarg_T *cap)
|
|||||||
// Call setpcmark() first, so "*``" puts the cursor back where
|
// Call setpcmark() first, so "*``" puts the cursor back where
|
||||||
// it was.
|
// it was.
|
||||||
setpcmark();
|
setpcmark();
|
||||||
curwin->w_cursor.col = (colnr_T)(ptr - (char *)get_cursor_line_ptr());
|
curwin->w_cursor.col = (colnr_T)(ptr - get_cursor_line_ptr());
|
||||||
|
|
||||||
if (!g_cmd && vim_iswordp((char_u *)ptr)) {
|
if (!g_cmd && vim_iswordp((char_u *)ptr)) {
|
||||||
STRCPY(buf, "\\<");
|
STRCPY(buf, "\\<");
|
||||||
@ -4382,13 +4382,13 @@ static void nv_ident(cmdarg_T *cap)
|
|||||||
// Execute the command.
|
// Execute the command.
|
||||||
if (cmdchar == '*' || cmdchar == '#') {
|
if (cmdchar == '*' || cmdchar == '#') {
|
||||||
if (!g_cmd
|
if (!g_cmd
|
||||||
&& vim_iswordp(mb_prevptr(get_cursor_line_ptr(), (char_u *)ptr))) {
|
&& vim_iswordp(mb_prevptr((char_u *)get_cursor_line_ptr(), (char_u *)ptr))) {
|
||||||
STRCAT(buf, "\\>");
|
STRCAT(buf, "\\>");
|
||||||
}
|
}
|
||||||
|
|
||||||
// put pattern in search history
|
// put pattern in search history
|
||||||
init_history();
|
init_history();
|
||||||
add_to_history(HIST_SEARCH, (char_u *)buf, true, NUL);
|
add_to_history(HIST_SEARCH, buf, true, NUL);
|
||||||
|
|
||||||
(void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0, NULL);
|
(void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0, NULL);
|
||||||
} else {
|
} else {
|
||||||
@ -4425,7 +4425,7 @@ bool get_visual_text(cmdarg_T *cap, char **pp, size_t *lenp)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (VIsual_mode == 'V') {
|
if (VIsual_mode == 'V') {
|
||||||
*pp = (char *)get_cursor_line_ptr();
|
*pp = get_cursor_line_ptr();
|
||||||
*lenp = STRLEN(*pp);
|
*lenp = STRLEN(*pp);
|
||||||
} else {
|
} else {
|
||||||
if (lt(curwin->w_cursor, VIsual)) {
|
if (lt(curwin->w_cursor, VIsual)) {
|
||||||
@ -6068,7 +6068,7 @@ static void nv_g_underscore_cmd(cmdarg_T *cap)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
char_u *ptr = get_cursor_line_ptr();
|
char_u *ptr = (char_u *)get_cursor_line_ptr();
|
||||||
|
|
||||||
// In Visual mode we may end up after the line.
|
// In Visual mode we may end up after the line.
|
||||||
if (curwin->w_cursor.col > 0 && ptr[curwin->w_cursor.col] == NUL) {
|
if (curwin->w_cursor.col > 0 && ptr[curwin->w_cursor.col] == NUL) {
|
||||||
@ -6279,7 +6279,7 @@ static void nv_g_cmd(cmdarg_T *cap)
|
|||||||
case 'M':
|
case 'M':
|
||||||
oap->motion_type = kMTCharWise;
|
oap->motion_type = kMTCharWise;
|
||||||
oap->inclusive = false;
|
oap->inclusive = false;
|
||||||
i = linetabsize(get_cursor_line_ptr());
|
i = linetabsize((char_u *)get_cursor_line_ptr());
|
||||||
if (cap->count0 > 0 && cap->count0 <= 100) {
|
if (cap->count0 > 0 && cap->count0 <= 100) {
|
||||||
coladvance((colnr_T)(i * cap->count0 / 100));
|
coladvance((colnr_T)(i * cap->count0 / 100));
|
||||||
} else {
|
} else {
|
||||||
|
@ -225,7 +225,7 @@ void op_shift(oparg_T *oap, int curs_top, int amount)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (i = oap->line_count - 1; i >= 0; i--) {
|
for (i = oap->line_count - 1; i >= 0; i--) {
|
||||||
first_char = *get_cursor_line_ptr();
|
first_char = (uint8_t)(*get_cursor_line_ptr());
|
||||||
if (first_char == NUL) { // empty line
|
if (first_char == NUL) { // empty line
|
||||||
curwin->w_cursor.col = 0;
|
curwin->w_cursor.col = 0;
|
||||||
} else if (oap->motion_type == kMTBlockWise) {
|
} else if (oap->motion_type == kMTBlockWise) {
|
||||||
@ -356,7 +356,7 @@ static void shift_block(oparg_T *oap, int amount)
|
|||||||
return; // multiplication overflow
|
return; // multiplication overflow
|
||||||
}
|
}
|
||||||
|
|
||||||
char_u *const oldp = get_cursor_line_ptr();
|
char_u *const oldp = (char_u *)get_cursor_line_ptr();
|
||||||
|
|
||||||
int startcol, oldlen, newlen;
|
int startcol, oldlen, newlen;
|
||||||
|
|
||||||
@ -668,7 +668,7 @@ void op_reindent(oparg_T *oap, Indenter how)
|
|||||||
// indented, unless there is only one line.
|
// indented, unless there is only one line.
|
||||||
if (i != oap->line_count - 1 || oap->line_count == 1
|
if (i != oap->line_count - 1 || oap->line_count == 1
|
||||||
|| how != get_lisp_indent) {
|
|| how != get_lisp_indent) {
|
||||||
l = (char_u *)skipwhite((char *)get_cursor_line_ptr());
|
l = (char_u *)skipwhite(get_cursor_line_ptr());
|
||||||
if (*l == NUL) { // empty or blank line
|
if (*l == NUL) { // empty or blank line
|
||||||
amount = 0;
|
amount = 0;
|
||||||
} else {
|
} else {
|
||||||
@ -1735,7 +1735,7 @@ int op_delete(oparg_T *oap)
|
|||||||
if (virtual_op) {
|
if (virtual_op) {
|
||||||
// fix up things for virtualedit-delete:
|
// fix up things for virtualedit-delete:
|
||||||
// break the tabs which are going to get in our way
|
// break the tabs which are going to get in our way
|
||||||
char_u *curline = get_cursor_line_ptr();
|
char_u *curline = (char_u *)get_cursor_line_ptr();
|
||||||
int len = (int)STRLEN(curline);
|
int len = (int)STRLEN(curline);
|
||||||
|
|
||||||
if (oap->end.coladd != 0
|
if (oap->end.coladd != 0
|
||||||
@ -1926,7 +1926,7 @@ static int op_replace(oparg_T *oap, int c)
|
|||||||
num_chars = numc;
|
num_chars = numc;
|
||||||
numc *= utf_char2len(c);
|
numc *= utf_char2len(c);
|
||||||
|
|
||||||
oldp = get_cursor_line_ptr();
|
oldp = (char_u *)get_cursor_line_ptr();
|
||||||
oldlen = (int)STRLEN(oldp);
|
oldlen = (int)STRLEN(oldp);
|
||||||
|
|
||||||
size_t newp_size = (size_t)bd.textcol + (size_t)bd.startspaces;
|
size_t newp_size = (size_t)bd.textcol + (size_t)bd.startspaces;
|
||||||
@ -2240,7 +2240,7 @@ bool swapchar(int op_type, pos_T *pos)
|
|||||||
void op_insert(oparg_T *oap, long count1)
|
void op_insert(oparg_T *oap, long count1)
|
||||||
{
|
{
|
||||||
long ins_len, pre_textlen = 0;
|
long ins_len, pre_textlen = 0;
|
||||||
char_u *firstline, *ins_text;
|
char *firstline, *ins_text;
|
||||||
colnr_T ind_pre_col = 0, ind_post_col;
|
colnr_T ind_pre_col = 0, ind_post_col;
|
||||||
int ind_pre_vcol = 0, ind_post_vcol = 0;
|
int ind_pre_vcol = 0, ind_post_vcol = 0;
|
||||||
struct block_def bd;
|
struct block_def bd;
|
||||||
@ -2281,7 +2281,7 @@ void op_insert(oparg_T *oap, long count1)
|
|||||||
// Get indent information
|
// Get indent information
|
||||||
ind_pre_col = (colnr_T)getwhitecols_curline();
|
ind_pre_col = (colnr_T)getwhitecols_curline();
|
||||||
ind_pre_vcol = get_indent();
|
ind_pre_vcol = get_indent();
|
||||||
firstline = (char_u *)ml_get(oap->start.lnum) + bd.textcol;
|
firstline = ml_get(oap->start.lnum) + bd.textcol;
|
||||||
|
|
||||||
if (oap->op_type == OP_APPEND) {
|
if (oap->op_type == OP_APPEND) {
|
||||||
firstline += bd.textlen;
|
firstline += bd.textlen;
|
||||||
@ -2413,7 +2413,7 @@ void op_insert(oparg_T *oap, long count1)
|
|||||||
* Subsequent calls to ml_get() flush the firstline data - take a
|
* Subsequent calls to ml_get() flush the firstline data - take a
|
||||||
* copy of the required string.
|
* copy of the required string.
|
||||||
*/
|
*/
|
||||||
firstline = (char_u *)ml_get(oap->start.lnum);
|
firstline = ml_get(oap->start.lnum);
|
||||||
const size_t len = STRLEN(firstline);
|
const size_t len = STRLEN(firstline);
|
||||||
colnr_T add = bd.textcol;
|
colnr_T add = bd.textcol;
|
||||||
colnr_T offset = 0; // offset when cursor was moved in insert mode
|
colnr_T offset = 0; // offset when cursor was moved in insert mode
|
||||||
@ -2438,10 +2438,10 @@ void op_insert(oparg_T *oap, long count1)
|
|||||||
}
|
}
|
||||||
ins_len = (long)STRLEN(firstline) - pre_textlen - offset;
|
ins_len = (long)STRLEN(firstline) - pre_textlen - offset;
|
||||||
if (pre_textlen >= 0 && ins_len > 0) {
|
if (pre_textlen >= 0 && ins_len > 0) {
|
||||||
ins_text = vim_strnsave(firstline, (size_t)ins_len);
|
ins_text = xstrnsave(firstline, (size_t)ins_len);
|
||||||
// block handled here
|
// block handled here
|
||||||
if (u_save(oap->start.lnum, (linenr_T)(oap->end.lnum + 1)) == OK) {
|
if (u_save(oap->start.lnum, (linenr_T)(oap->end.lnum + 1)) == OK) {
|
||||||
block_insert(oap, ins_text, (oap->op_type == OP_INSERT), &bd);
|
block_insert(oap, (char_u *)ins_text, (oap->op_type == OP_INSERT), &bd);
|
||||||
}
|
}
|
||||||
|
|
||||||
curwin->w_cursor.col = oap->start.col;
|
curwin->w_cursor.col = oap->start.col;
|
||||||
@ -2934,9 +2934,9 @@ static void do_autocmd_textyankpost(oparg_T *oap, yankreg_T *reg)
|
|||||||
/// @param dir BACKWARD for 'P', FORWARD for 'p'
|
/// @param dir BACKWARD for 'P', FORWARD for 'p'
|
||||||
void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
||||||
{
|
{
|
||||||
char_u *ptr;
|
char *ptr;
|
||||||
char_u *newp;
|
char *newp;
|
||||||
char_u *oldp;
|
char *oldp;
|
||||||
int yanklen;
|
int yanklen;
|
||||||
size_t totlen = 0; // init for gcc
|
size_t totlen = 0; // init for gcc
|
||||||
linenr_T lnum = 0;
|
linenr_T lnum = 0;
|
||||||
@ -3082,13 +3082,13 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
* Loop twice: count the number of lines and save them. */
|
* Loop twice: count the number of lines and save them. */
|
||||||
for (;;) {
|
for (;;) {
|
||||||
y_size = 0;
|
y_size = 0;
|
||||||
ptr = (char_u *)insert_string;
|
ptr = insert_string;
|
||||||
while (ptr != NULL) {
|
while (ptr != NULL) {
|
||||||
if (y_array != NULL) {
|
if (y_array != NULL) {
|
||||||
y_array[y_size] = (char *)ptr;
|
y_array[y_size] = ptr;
|
||||||
}
|
}
|
||||||
y_size++;
|
y_size++;
|
||||||
ptr = (char_u *)vim_strchr((char *)ptr, '\n');
|
ptr = vim_strchr(ptr, '\n');
|
||||||
if (ptr != NULL) {
|
if (ptr != NULL) {
|
||||||
if (y_array != NULL) {
|
if (y_array != NULL) {
|
||||||
*ptr = NUL;
|
*ptr = NUL;
|
||||||
@ -3136,12 +3136,12 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
if (u_save_cursor() == FAIL) {
|
if (u_save_cursor() == FAIL) {
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
char_u *p = get_cursor_pos_ptr();
|
char *p = (char *)get_cursor_pos_ptr();
|
||||||
if (dir == FORWARD && *p != NUL) {
|
if (dir == FORWARD && *p != NUL) {
|
||||||
MB_PTR_ADV(p);
|
MB_PTR_ADV(p);
|
||||||
}
|
}
|
||||||
ptr = vim_strsave(p);
|
ptr = xstrdup(p);
|
||||||
ml_append(curwin->w_cursor.lnum, (char *)ptr, (colnr_T)0, false);
|
ml_append(curwin->w_cursor.lnum, ptr, (colnr_T)0, false);
|
||||||
xfree(ptr);
|
xfree(ptr);
|
||||||
|
|
||||||
oldp = get_cursor_line_ptr();
|
oldp = get_cursor_line_ptr();
|
||||||
@ -3149,8 +3149,8 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
if (dir == FORWARD && *p != NUL) {
|
if (dir == FORWARD && *p != NUL) {
|
||||||
MB_PTR_ADV(p);
|
MB_PTR_ADV(p);
|
||||||
}
|
}
|
||||||
ptr = vim_strnsave(oldp, (size_t)(p - oldp));
|
ptr = xstrnsave(oldp, (size_t)(p - oldp));
|
||||||
ml_replace(curwin->w_cursor.lnum, (char *)ptr, false);
|
ml_replace(curwin->w_cursor.lnum, ptr, false);
|
||||||
nr_lines++;
|
nr_lines++;
|
||||||
dir = FORWARD;
|
dir = FORWARD;
|
||||||
}
|
}
|
||||||
@ -3298,8 +3298,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
oldp = get_cursor_line_ptr();
|
oldp = get_cursor_line_ptr();
|
||||||
oldlen = STRLEN(oldp);
|
oldlen = STRLEN(oldp);
|
||||||
chartabsize_T cts;
|
chartabsize_T cts;
|
||||||
init_chartabsize_arg(&cts, curwin, curwin->w_cursor.lnum, 0,
|
init_chartabsize_arg(&cts, curwin, curwin->w_cursor.lnum, 0, oldp, oldp);
|
||||||
(char *)oldp, (char *)oldp);
|
|
||||||
|
|
||||||
while (cts.cts_vcol < col && *cts.cts_ptr != NUL) {
|
while (cts.cts_vcol < col && *cts.cts_ptr != NUL) {
|
||||||
// Count a tab for what it's worth (if list mode not on)
|
// Count a tab for what it's worth (if list mode not on)
|
||||||
@ -3307,7 +3306,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
cts.cts_vcol += incr;
|
cts.cts_vcol += incr;
|
||||||
}
|
}
|
||||||
vcol = cts.cts_vcol;
|
vcol = cts.cts_vcol;
|
||||||
ptr = (char_u *)cts.cts_ptr;
|
ptr = cts.cts_ptr;
|
||||||
bd.textcol = (colnr_T)(ptr - oldp);
|
bd.textcol = (colnr_T)(ptr - oldp);
|
||||||
clear_chartabsize_arg(&cts);
|
clear_chartabsize_arg(&cts);
|
||||||
|
|
||||||
@ -3320,7 +3319,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
bd.startspaces = incr - bd.endspaces;
|
bd.startspaces = incr - bd.endspaces;
|
||||||
bd.textcol--;
|
bd.textcol--;
|
||||||
delcount = 1;
|
delcount = 1;
|
||||||
bd.textcol -= utf_head_off((char *)oldp, (char *)oldp + bd.textcol);
|
bd.textcol -= utf_head_off(oldp, oldp + bd.textcol);
|
||||||
if (oldp[bd.textcol] != TAB) {
|
if (oldp[bd.textcol] != TAB) {
|
||||||
/* Only a Tab can be split into spaces. Other
|
/* Only a Tab can be split into spaces. Other
|
||||||
* characters will have to be moved to after the
|
* characters will have to be moved to after the
|
||||||
@ -3356,9 +3355,8 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
totlen = (size_t)(count * (yanklen + spaces)
|
totlen = (size_t)(count * (yanklen + spaces) + bd.startspaces + bd.endspaces);
|
||||||
+ bd.startspaces + bd.endspaces);
|
newp = xmalloc(totlen + oldlen + 1);
|
||||||
newp = (char_u *)xmalloc(totlen + oldlen + 1);
|
|
||||||
|
|
||||||
// copy part up to cursor to new line
|
// copy part up to cursor to new line
|
||||||
ptr = newp;
|
ptr = newp;
|
||||||
@ -3391,7 +3389,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
int columns = (int)oldlen - bd.textcol - delcount + 1;
|
int columns = (int)oldlen - bd.textcol - delcount + 1;
|
||||||
assert(columns >= 0);
|
assert(columns >= 0);
|
||||||
memmove(ptr, oldp + bd.textcol + delcount, (size_t)columns);
|
memmove(ptr, oldp + bd.textcol + delcount, (size_t)columns);
|
||||||
ml_replace(curwin->w_cursor.lnum, (char *)newp, false);
|
ml_replace(curwin->w_cursor.lnum, newp, false);
|
||||||
extmark_splice_cols(curbuf, (int)curwin->w_cursor.lnum - 1, bd.textcol,
|
extmark_splice_cols(curbuf, (int)curwin->w_cursor.lnum - 1, bd.textcol,
|
||||||
delcount, (int)totlen + lines_appended, kExtmarkUndo);
|
delcount, (int)totlen + lines_appended, kExtmarkUndo);
|
||||||
|
|
||||||
@ -3482,7 +3480,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
} else {
|
} else {
|
||||||
totlen = (size_t)(count * yanklen);
|
totlen = (size_t)(count * yanklen);
|
||||||
do {
|
do {
|
||||||
oldp = (char_u *)ml_get(lnum);
|
oldp = ml_get(lnum);
|
||||||
oldlen = STRLEN(oldp);
|
oldlen = STRLEN(oldp);
|
||||||
if (lnum > start_lnum) {
|
if (lnum > start_lnum) {
|
||||||
pos_T pos = {
|
pos_T pos = {
|
||||||
@ -3498,7 +3496,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
lnum++;
|
lnum++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
newp = (char_u *)xmalloc(totlen + oldlen + 1);
|
newp = xmalloc(totlen + oldlen + 1);
|
||||||
memmove(newp, oldp, (size_t)col);
|
memmove(newp, oldp, (size_t)col);
|
||||||
ptr = newp + col;
|
ptr = newp + col;
|
||||||
for (i = 0; i < (size_t)count; i++) {
|
for (i = 0; i < (size_t)count; i++) {
|
||||||
@ -3506,10 +3504,10 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
ptr += yanklen;
|
ptr += yanklen;
|
||||||
}
|
}
|
||||||
STRMOVE(ptr, oldp + col);
|
STRMOVE(ptr, oldp + col);
|
||||||
ml_replace(lnum, (char *)newp, false);
|
ml_replace(lnum, newp, false);
|
||||||
|
|
||||||
// compute the byte offset for the last character
|
// compute the byte offset for the last character
|
||||||
first_byte_off = utf_head_off((char *)newp, (char *)ptr - 1);
|
first_byte_off = utf_head_off(newp, ptr - 1);
|
||||||
|
|
||||||
// Place cursor on last putted char.
|
// Place cursor on last putted char.
|
||||||
if (lnum == curwin->w_cursor.lnum) {
|
if (lnum == curwin->w_cursor.lnum) {
|
||||||
@ -3553,23 +3551,23 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
// First insert y_array[size - 1] in front of second line.
|
// First insert y_array[size - 1] in front of second line.
|
||||||
// Then append y_array[0] to first line.
|
// Then append y_array[0] to first line.
|
||||||
lnum = new_cursor.lnum;
|
lnum = new_cursor.lnum;
|
||||||
ptr = (char_u *)ml_get(lnum) + col;
|
ptr = ml_get(lnum) + col;
|
||||||
totlen = STRLEN(y_array[y_size - 1]);
|
totlen = STRLEN(y_array[y_size - 1]);
|
||||||
newp = (char_u *)xmalloc((size_t)(STRLEN(ptr) + totlen + 1));
|
newp = xmalloc((size_t)(STRLEN(ptr) + totlen + 1));
|
||||||
STRCPY(newp, y_array[y_size - 1]);
|
STRCPY(newp, y_array[y_size - 1]);
|
||||||
STRCAT(newp, ptr);
|
STRCAT(newp, ptr);
|
||||||
// insert second line
|
// insert second line
|
||||||
ml_append(lnum, (char *)newp, (colnr_T)0, false);
|
ml_append(lnum, newp, (colnr_T)0, false);
|
||||||
new_lnum++;
|
new_lnum++;
|
||||||
xfree(newp);
|
xfree(newp);
|
||||||
|
|
||||||
oldp = (char_u *)ml_get(lnum);
|
oldp = ml_get(lnum);
|
||||||
newp = (char_u *)xmalloc((size_t)col + (size_t)yanklen + 1);
|
newp = xmalloc((size_t)col + (size_t)yanklen + 1);
|
||||||
// copy first part of line
|
// copy first part of line
|
||||||
memmove(newp, oldp, (size_t)col);
|
memmove(newp, oldp, (size_t)col);
|
||||||
// append to first line
|
// append to first line
|
||||||
memmove(newp + col, y_array[0], (size_t)yanklen + 1);
|
memmove(newp + col, y_array[0], (size_t)yanklen + 1);
|
||||||
ml_replace(lnum, (char *)newp, false);
|
ml_replace(lnum, newp, false);
|
||||||
|
|
||||||
curwin->w_cursor.lnum = lnum;
|
curwin->w_cursor.lnum = lnum;
|
||||||
i = 1;
|
i = 1;
|
||||||
@ -3587,7 +3585,7 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags)
|
|||||||
if (flags & PUT_FIXINDENT) {
|
if (flags & PUT_FIXINDENT) {
|
||||||
old_pos = curwin->w_cursor;
|
old_pos = curwin->w_cursor;
|
||||||
curwin->w_cursor.lnum = lnum;
|
curwin->w_cursor.lnum = lnum;
|
||||||
ptr = (char_u *)ml_get(lnum);
|
ptr = ml_get(lnum);
|
||||||
if (cnt == count && i == y_size - 1) {
|
if (cnt == count && i == y_size - 1) {
|
||||||
lendiff = (int)STRLEN(ptr);
|
lendiff = (int)STRLEN(ptr);
|
||||||
}
|
}
|
||||||
@ -4656,7 +4654,7 @@ int do_addsub(int op_type, pos_T *pos, int length, linenr_T Prenum1)
|
|||||||
: length);
|
: length);
|
||||||
}
|
}
|
||||||
|
|
||||||
vim_str2nr(ptr + col, &pre, &length,
|
vim_str2nr((char *)ptr + col, &pre, &length,
|
||||||
0 + (do_bin ? STR2NR_BIN : 0)
|
0 + (do_bin ? STR2NR_BIN : 0)
|
||||||
+ (do_oct ? STR2NR_OCT : 0)
|
+ (do_oct ? STR2NR_OCT : 0)
|
||||||
+ (do_hex ? STR2NR_HEX : 0),
|
+ (do_hex ? STR2NR_HEX : 0),
|
||||||
@ -5504,7 +5502,7 @@ void cursor_pos_info(dict_T *dict)
|
|||||||
(int64_t)byte_count_cursor, (int64_t)byte_count);
|
(int64_t)byte_count_cursor, (int64_t)byte_count);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
p = get_cursor_line_ptr();
|
p = (char_u *)get_cursor_line_ptr();
|
||||||
validate_virtcol();
|
validate_virtcol();
|
||||||
col_print((char *)buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1,
|
col_print((char *)buf1, sizeof(buf1), (int)curwin->w_cursor.col + 1,
|
||||||
(int)curwin->w_virtcol + 1);
|
(int)curwin->w_virtcol + 1);
|
||||||
|
@ -664,8 +664,8 @@ void set_init_3(void)
|
|||||||
: !(options[idx_sp].flags & P_WAS_SET);
|
: !(options[idx_sp].flags & P_WAS_SET);
|
||||||
|
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
char_u *p = (char_u *)invocation_path_tail(p_sh, &len);
|
char *p = (char *)invocation_path_tail(p_sh, &len);
|
||||||
p = vim_strnsave(p, len);
|
p = xstrnsave(p, len);
|
||||||
|
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@ -1131,7 +1131,7 @@ int do_set(char *arg, int opt_flags)
|
|||||||
}
|
}
|
||||||
} else if (*arg == '-' || ascii_isdigit(*arg)) {
|
} else if (*arg == '-' || ascii_isdigit(*arg)) {
|
||||||
// Allow negative, octal and hex numbers.
|
// Allow negative, octal and hex numbers.
|
||||||
vim_str2nr((char_u *)arg, NULL, &i, STR2NR_ALL, &value, NULL, 0, true);
|
vim_str2nr(arg, NULL, &i, STR2NR_ALL, &value, NULL, 0, true);
|
||||||
if (i == 0 || (arg[i] != NUL && !ascii_iswhite(arg[i]))) {
|
if (i == 0 || (arg[i] != NUL && !ascii_iswhite(arg[i]))) {
|
||||||
errmsg = e_number_required_after_equal;
|
errmsg = e_number_required_after_equal;
|
||||||
goto skip;
|
goto skip;
|
||||||
|
@ -64,7 +64,7 @@ static void save_patterns(int num_pat, char **pat, int *num_file, char ***file)
|
|||||||
static bool have_wildcard(int num, char **file)
|
static bool have_wildcard(int num, char **file)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < num; i++) {
|
for (int i = 0; i < num; i++) {
|
||||||
if (path_has_wildcard((char_u *)file[i])) {
|
if (path_has_wildcard(file[i])) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1106,7 +1106,7 @@ static void out_data_append_to_screen(char *output, size_t *count, bool eof)
|
|||||||
// incomplete UTF-8 sequence that could be composing with the last
|
// incomplete UTF-8 sequence that could be composing with the last
|
||||||
// complete sequence.
|
// complete sequence.
|
||||||
// This will be corrected when we switch to vterm based implementation
|
// This will be corrected when we switch to vterm based implementation
|
||||||
int i = *p ? utfc_ptr2len_len((char_u *)p, (int)(end - p)) : 1;
|
int i = *p ? utfc_ptr2len_len(p, (int)(end - p)) : 1;
|
||||||
if (!eof && i == 1 && utf8len_tab_zero[*(uint8_t *)p] > (end - p)) {
|
if (!eof && i == 1 && utf8len_tab_zero[*(uint8_t *)p] > (end - p)) {
|
||||||
*count = (size_t)(p - output);
|
*count = (size_t)(p - output);
|
||||||
goto end;
|
goto end;
|
||||||
|
@ -509,7 +509,7 @@ char *save_abs_path(const char *name)
|
|||||||
/// @param p The path to expand.
|
/// @param p The path to expand.
|
||||||
/// @returns Unix: True if it contains one of "?[{`'$".
|
/// @returns Unix: True if it contains one of "?[{`'$".
|
||||||
/// @returns Windows: True if it contains one of "*?$[".
|
/// @returns Windows: True if it contains one of "*?$[".
|
||||||
bool path_has_wildcard(const char_u *p)
|
bool path_has_wildcard(const char *p)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
for (; *p; MB_PTR_ADV(p)) {
|
for (; *p; MB_PTR_ADV(p)) {
|
||||||
@ -1252,7 +1252,7 @@ int gen_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, i
|
|||||||
p = (char_u *)pat[i];
|
p = (char_u *)pat[i];
|
||||||
|
|
||||||
if (vim_backtick(p)) {
|
if (vim_backtick(p)) {
|
||||||
add_pat = expand_backtick(&ga, p, flags);
|
add_pat = expand_backtick(&ga, (char *)p, flags);
|
||||||
if (add_pat == -1) {
|
if (add_pat == -1) {
|
||||||
recursive = false;
|
recursive = false;
|
||||||
FreeWild(ga.ga_len, ga.ga_data);
|
FreeWild(ga.ga_len, ga.ga_data);
|
||||||
@ -1367,14 +1367,14 @@ static int vim_backtick(char_u *p)
|
|||||||
/// Returns number of file names found, -1 if an error is encountered.
|
/// Returns number of file names found, -1 if an error is encountered.
|
||||||
///
|
///
|
||||||
/// @param flags EW_* flags
|
/// @param flags EW_* flags
|
||||||
static int expand_backtick(garray_T *gap, char_u *pat, int flags)
|
static int expand_backtick(garray_T *gap, char *pat, int flags)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
char *buffer;
|
char *buffer;
|
||||||
int cnt = 0;
|
int cnt = 0;
|
||||||
|
|
||||||
// Create the command: lop off the backticks.
|
// Create the command: lop off the backticks.
|
||||||
char *cmd = (char *)vim_strnsave(pat + 1, STRLEN(pat) - 2);
|
char *cmd = xstrnsave(pat + 1, STRLEN(pat) - 2);
|
||||||
|
|
||||||
if (*cmd == '=') { // `={expr}`: Expand expression
|
if (*cmd == '=') { // `={expr}`: Expand expression
|
||||||
buffer = eval_to_string(cmd + 1, &p, true);
|
buffer = eval_to_string(cmd + 1, &p, true);
|
||||||
@ -1683,17 +1683,17 @@ static char *eval_includeexpr(const char *const ptr, const size_t len)
|
|||||||
/// Otherwise like file_name_at_cursor().
|
/// Otherwise like file_name_at_cursor().
|
||||||
///
|
///
|
||||||
/// @param rel_fname file we are searching relative to
|
/// @param rel_fname file we are searching relative to
|
||||||
char_u *find_file_name_in_path(char_u *ptr, size_t len, int options, long count, char_u *rel_fname)
|
char *find_file_name_in_path(char *ptr, size_t len, int options, long count, char *rel_fname)
|
||||||
{
|
{
|
||||||
char_u *file_name;
|
char *file_name;
|
||||||
char_u *tofree = NULL;
|
char *tofree = NULL;
|
||||||
|
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((options & FNAME_INCL) && *curbuf->b_p_inex != NUL) {
|
if ((options & FNAME_INCL) && *curbuf->b_p_inex != NUL) {
|
||||||
tofree = (char_u *)eval_includeexpr((char *)ptr, len);
|
tofree = eval_includeexpr(ptr, len);
|
||||||
if (tofree != NULL) {
|
if (tofree != NULL) {
|
||||||
ptr = tofree;
|
ptr = tofree;
|
||||||
len = STRLEN(ptr);
|
len = STRLEN(ptr);
|
||||||
@ -1701,8 +1701,8 @@ char_u *find_file_name_in_path(char_u *ptr, size_t len, int options, long count,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (options & FNAME_EXP) {
|
if (options & FNAME_EXP) {
|
||||||
file_name = find_file_in_path(ptr, len, options & ~FNAME_MESS, true,
|
file_name = (char *)find_file_in_path((char_u *)ptr, len, options & ~FNAME_MESS, true,
|
||||||
rel_fname);
|
(char_u *)rel_fname);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the file could not be found in a normal way, try applying
|
* If the file could not be found in a normal way, try applying
|
||||||
@ -1710,16 +1710,16 @@ char_u *find_file_name_in_path(char_u *ptr, size_t len, int options, long count,
|
|||||||
*/
|
*/
|
||||||
if (file_name == NULL
|
if (file_name == NULL
|
||||||
&& !(options & FNAME_INCL) && *curbuf->b_p_inex != NUL) {
|
&& !(options & FNAME_INCL) && *curbuf->b_p_inex != NUL) {
|
||||||
tofree = (char_u *)eval_includeexpr((char *)ptr, len);
|
tofree = eval_includeexpr(ptr, len);
|
||||||
if (tofree != NULL) {
|
if (tofree != NULL) {
|
||||||
ptr = tofree;
|
ptr = tofree;
|
||||||
len = STRLEN(ptr);
|
len = STRLEN(ptr);
|
||||||
file_name = find_file_in_path(ptr, len, options & ~FNAME_MESS,
|
file_name = (char *)find_file_in_path((char_u *)ptr, len, options & ~FNAME_MESS,
|
||||||
true, rel_fname);
|
true, (char_u *)rel_fname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (file_name == NULL && (options & FNAME_MESS)) {
|
if (file_name == NULL && (options & FNAME_MESS)) {
|
||||||
char_u c = ptr[len];
|
char c = ptr[len];
|
||||||
ptr[len] = NUL;
|
ptr[len] = NUL;
|
||||||
semsg(_("E447: Can't find file \"%s\" in path"), ptr);
|
semsg(_("E447: Can't find file \"%s\" in path"), ptr);
|
||||||
ptr[len] = c;
|
ptr[len] = c;
|
||||||
@ -1729,10 +1729,11 @@ char_u *find_file_name_in_path(char_u *ptr, size_t len, int options, long count,
|
|||||||
* appears several times in the path. */
|
* appears several times in the path. */
|
||||||
while (file_name != NULL && --count > 0) {
|
while (file_name != NULL && --count > 0) {
|
||||||
xfree(file_name);
|
xfree(file_name);
|
||||||
file_name = find_file_in_path(ptr, len, options, false, rel_fname);
|
file_name =
|
||||||
|
(char *)find_file_in_path((char_u *)ptr, len, options, false, (char_u *)rel_fname);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
file_name = vim_strnsave(ptr, len);
|
file_name = xstrnsave(ptr, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
xfree(tofree);
|
xfree(tofree);
|
||||||
|
@ -1623,14 +1623,14 @@ static int fill_submatch_list(int argc FUNC_ATTR_UNUSED, typval_T *argv, int arg
|
|||||||
// There are always 10 list items in staticList10_T.
|
// There are always 10 list items in staticList10_T.
|
||||||
listitem_T *li = tv_list_first(listarg->vval.v_list);
|
listitem_T *li = tv_list_first(listarg->vval.v_list);
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
char_u *s = rsm.sm_match->startp[i];
|
char *s = (char *)rsm.sm_match->startp[i];
|
||||||
if (s == NULL || rsm.sm_match->endp[i] == NULL) {
|
if (s == NULL || rsm.sm_match->endp[i] == NULL) {
|
||||||
s = NULL;
|
s = NULL;
|
||||||
} else {
|
} else {
|
||||||
s = vim_strnsave(s, (size_t)(rsm.sm_match->endp[i] - s));
|
s = xstrnsave(s, (size_t)(rsm.sm_match->endp[i] - (char_u *)s));
|
||||||
}
|
}
|
||||||
TV_LIST_ITEM_TV(li)->v_type = VAR_STRING;
|
TV_LIST_ITEM_TV(li)->v_type = VAR_STRING;
|
||||||
TV_LIST_ITEM_TV(li)->vval.v_string = (char *)s;
|
TV_LIST_ITEM_TV(li)->vval.v_string = s;
|
||||||
li = TV_LIST_ITEM_NEXT(argv->vval.v_list, li);
|
li = TV_LIST_ITEM_NEXT(argv->vval.v_list, li);
|
||||||
}
|
}
|
||||||
return argskip + 1;
|
return argskip + 1;
|
||||||
|
@ -2469,7 +2469,7 @@ do_multibyte:
|
|||||||
// Need to get composing character too.
|
// Need to get composing character too.
|
||||||
for (;;) {
|
for (;;) {
|
||||||
l = utf_ptr2len((char *)regparse);
|
l = utf_ptr2len((char *)regparse);
|
||||||
if (!utf_composinglike((char_u *)regparse, (char_u *)regparse + l)) {
|
if (!utf_composinglike(regparse, regparse + l)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
regmbc(utf_ptr2char((char *)regparse));
|
regmbc(utf_ptr2char((char *)regparse));
|
||||||
@ -3192,7 +3192,7 @@ static int regrepeat(char_u *p, long maxcount)
|
|||||||
case SKWORD:
|
case SKWORD:
|
||||||
case SKWORD + ADD_NL:
|
case SKWORD + ADD_NL:
|
||||||
while (count < maxcount) {
|
while (count < maxcount) {
|
||||||
if (vim_iswordp_buf(scan, rex.reg_buf)
|
if (vim_iswordp_buf((char *)scan, rex.reg_buf)
|
||||||
&& (testval || !ascii_isdigit(*scan))) {
|
&& (testval || !ascii_isdigit(*scan))) {
|
||||||
MB_PTR_ADV(scan);
|
MB_PTR_ADV(scan);
|
||||||
} else if (*scan == NUL) {
|
} else if (*scan == NUL) {
|
||||||
@ -3829,7 +3829,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case KWORD:
|
case KWORD:
|
||||||
if (!vim_iswordp_buf(rex.input, rex.reg_buf)) {
|
if (!vim_iswordp_buf((char *)rex.input, rex.reg_buf)) {
|
||||||
status = RA_NOMATCH;
|
status = RA_NOMATCH;
|
||||||
} else {
|
} else {
|
||||||
ADVANCE_REGINPUT();
|
ADVANCE_REGINPUT();
|
||||||
@ -3838,7 +3838,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out)
|
|||||||
|
|
||||||
case SKWORD:
|
case SKWORD:
|
||||||
if (ascii_isdigit(*rex.input)
|
if (ascii_isdigit(*rex.input)
|
||||||
|| !vim_iswordp_buf(rex.input, rex.reg_buf)) {
|
|| !vim_iswordp_buf((char *)rex.input, rex.reg_buf)) {
|
||||||
status = RA_NOMATCH;
|
status = RA_NOMATCH;
|
||||||
} else {
|
} else {
|
||||||
ADVANCE_REGINPUT();
|
ADVANCE_REGINPUT();
|
||||||
@ -4046,7 +4046,7 @@ static bool regmatch(char_u *scan, proftime_T *tm, int *timed_out)
|
|||||||
// Check for following composing character, unless %C
|
// Check for following composing character, unless %C
|
||||||
// follows (skips over all composing chars).
|
// follows (skips over all composing chars).
|
||||||
if (status != RA_NOMATCH
|
if (status != RA_NOMATCH
|
||||||
&& utf_composinglike(rex.input, rex.input + len)
|
&& utf_composinglike((char *)rex.input, (char *)rex.input + len)
|
||||||
&& !rex.reg_icombine
|
&& !rex.reg_icombine
|
||||||
&& OP(next) != RE_COMPOSING) {
|
&& OP(next) != RE_COMPOSING) {
|
||||||
// raaron: This code makes a composing character get
|
// raaron: This code makes a composing character get
|
||||||
@ -4975,13 +4975,13 @@ static long regtry(bt_regprog_T *prog, colnr_T col, proftime_T *tm, int *timed_o
|
|||||||
&& reg_endzpos[i].lnum == reg_startzpos[i].lnum
|
&& reg_endzpos[i].lnum == reg_startzpos[i].lnum
|
||||||
&& reg_endzpos[i].col >= reg_startzpos[i].col) {
|
&& reg_endzpos[i].col >= reg_startzpos[i].col) {
|
||||||
re_extmatch_out->matches[i] =
|
re_extmatch_out->matches[i] =
|
||||||
vim_strnsave(reg_getline(reg_startzpos[i].lnum) + reg_startzpos[i].col,
|
(char_u *)xstrnsave((char *)reg_getline(reg_startzpos[i].lnum) + reg_startzpos[i].col,
|
||||||
(size_t)(reg_endzpos[i].col - reg_startzpos[i].col));
|
(size_t)(reg_endzpos[i].col - reg_startzpos[i].col));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (reg_startzp[i] != NULL && reg_endzp[i] != NULL) {
|
if (reg_startzp[i] != NULL && reg_endzp[i] != NULL) {
|
||||||
re_extmatch_out->matches[i] =
|
re_extmatch_out->matches[i] =
|
||||||
vim_strnsave(reg_startzp[i], (size_t)(reg_endzp[i] - reg_startzp[i]));
|
(char_u *)xstrnsave((char *)reg_startzp[i], (size_t)(reg_endzp[i] - reg_startzp[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6643,13 +6643,13 @@ static int nfa_regmatch(nfa_regprog_T *prog, nfa_state_T *start, regsubs_T *subm
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case NFA_KWORD: // \k
|
case NFA_KWORD: // \k
|
||||||
result = vim_iswordp_buf(rex.input, rex.reg_buf);
|
result = vim_iswordp_buf((char *)rex.input, rex.reg_buf);
|
||||||
ADD_STATE_IF_MATCH(t->state);
|
ADD_STATE_IF_MATCH(t->state);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NFA_SKWORD: // \K
|
case NFA_SKWORD: // \K
|
||||||
result = !ascii_isdigit(curc)
|
result = !ascii_isdigit(curc)
|
||||||
&& vim_iswordp_buf(rex.input, rex.reg_buf);
|
&& vim_iswordp_buf((char *)rex.input, rex.reg_buf);
|
||||||
ADD_STATE_IF_MATCH(t->state);
|
ADD_STATE_IF_MATCH(t->state);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -7362,15 +7362,15 @@ static long nfa_regtry(nfa_regprog_T *prog, colnr_T col, proftime_T *tm, int *ti
|
|||||||
&& mpos->start_lnum == mpos->end_lnum
|
&& mpos->start_lnum == mpos->end_lnum
|
||||||
&& mpos->end_col >= mpos->start_col) {
|
&& mpos->end_col >= mpos->start_col) {
|
||||||
re_extmatch_out->matches[i] =
|
re_extmatch_out->matches[i] =
|
||||||
vim_strnsave(reg_getline(mpos->start_lnum) + mpos->start_col,
|
(char_u *)xstrnsave((char *)reg_getline(mpos->start_lnum) + mpos->start_col,
|
||||||
(size_t)(mpos->end_col - mpos->start_col));
|
(size_t)(mpos->end_col - mpos->start_col));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
struct linepos *lpos = &subs.synt.list.line[i];
|
struct linepos *lpos = &subs.synt.list.line[i];
|
||||||
|
|
||||||
if (lpos->start != NULL && lpos->end != NULL) {
|
if (lpos->start != NULL && lpos->end != NULL) {
|
||||||
re_extmatch_out->matches[i] =
|
re_extmatch_out->matches[i] =
|
||||||
vim_strnsave(lpos->start, (size_t)(lpos->end - lpos->start));
|
(char_u *)xstrnsave((char *)lpos->start, (size_t)(lpos->end - lpos->start));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ int search_regcomp(char_u *pat, int pat_save, int pat_use, int options, regmmatc
|
|||||||
magic = spats[i].magic;
|
magic = spats[i].magic;
|
||||||
no_smartcase = spats[i].no_scs;
|
no_smartcase = spats[i].no_scs;
|
||||||
} else if (options & SEARCH_HIS) { // put new pattern in history
|
} else if (options & SEARCH_HIS) { // put new pattern in history
|
||||||
add_to_history(HIST_SEARCH, pat, true, NUL);
|
add_to_history(HIST_SEARCH, (char *)pat, true, NUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mr_pattern_alloced) {
|
if (mr_pattern_alloced) {
|
||||||
@ -1574,7 +1574,7 @@ int searchc(cmdarg_T *cap, int t_cmd)
|
|||||||
cap->oap->inclusive = true;
|
cap->oap->inclusive = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = get_cursor_line_ptr();
|
p = (char_u *)get_cursor_line_ptr();
|
||||||
col = curwin->w_cursor.col;
|
col = curwin->w_cursor.col;
|
||||||
len = (int)STRLEN(p);
|
len = (int)STRLEN(p);
|
||||||
|
|
||||||
@ -1649,22 +1649,21 @@ static bool check_prevcol(char_u *linep, int col, int ch, int *prevcol)
|
|||||||
return col >= 0 && linep[col] == ch;
|
return col >= 0 && linep[col] == ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Raw string start is found at linep[startpos.col - 1].
|
||||||
* Raw string start is found at linep[startpos.col - 1].
|
///
|
||||||
* Return true if the matching end can be found between startpos and endpos.
|
/// @return true if the matching end can be found between startpos and endpos.
|
||||||
*/
|
static bool find_rawstring_end(char *linep, pos_T *startpos, pos_T *endpos)
|
||||||
static bool find_rawstring_end(char_u *linep, pos_T *startpos, pos_T *endpos)
|
|
||||||
{
|
{
|
||||||
char_u *p;
|
char *p;
|
||||||
linenr_T lnum;
|
linenr_T lnum;
|
||||||
|
|
||||||
for (p = linep + startpos->col + 1; *p && *p != '('; p++) {}
|
for (p = linep + startpos->col + 1; *p && *p != '('; p++) {}
|
||||||
|
|
||||||
size_t delim_len = (size_t)((p - linep) - startpos->col - 1);
|
size_t delim_len = (size_t)((p - linep) - startpos->col - 1);
|
||||||
char_u *delim_copy = vim_strnsave(linep + startpos->col + 1, delim_len);
|
char *delim_copy = xstrnsave(linep + startpos->col + 1, delim_len);
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (lnum = startpos->lnum; lnum <= endpos->lnum; lnum++) {
|
for (lnum = startpos->lnum; lnum <= endpos->lnum; lnum++) {
|
||||||
char_u *line = (char_u *)ml_get(lnum);
|
char *line = ml_get(lnum);
|
||||||
|
|
||||||
for (p = line + (lnum == startpos->lnum ? startpos->col + 1 : 0); *p; p++) {
|
for (p = line + (lnum == startpos->lnum ? startpos->col + 1 : 0); *p; p++) {
|
||||||
if (lnum == endpos->lnum && (colnr_T)(p - line) >= endpos->col) {
|
if (lnum == endpos->lnum && (colnr_T)(p - line) >= endpos->col) {
|
||||||
@ -2082,7 +2081,7 @@ pos_T *findmatchlimit(oparg_T *oap, int initc, int flags, int64_t maxtravel)
|
|||||||
// delimiter we can check if it ends before where we
|
// delimiter we can check if it ends before where we
|
||||||
// started searching, or before the previously found
|
// started searching, or before the previously found
|
||||||
// raw string start.
|
// raw string start.
|
||||||
if (!find_rawstring_end(linep, &pos,
|
if (!find_rawstring_end((char *)linep, &pos,
|
||||||
count > 0 ? &match_pos : &curwin->w_cursor)) {
|
count > 0 ? &match_pos : &curwin->w_cursor)) {
|
||||||
count++;
|
count++;
|
||||||
match_pos = pos;
|
match_pos = pos;
|
||||||
@ -3598,11 +3597,11 @@ void find_pattern_in_path(char_u *ptr, Direction dir, size_t len, bool whole, bo
|
|||||||
|
|
||||||
if (inc_opt != NULL && strstr(inc_opt, "\\zs") != NULL) {
|
if (inc_opt != NULL && strstr(inc_opt, "\\zs") != NULL) {
|
||||||
// Use text from '\zs' to '\ze' (or end) of 'include'.
|
// Use text from '\zs' to '\ze' (or end) of 'include'.
|
||||||
new_fname = find_file_name_in_path(incl_regmatch.startp[0],
|
new_fname = (char_u *)find_file_name_in_path((char *)incl_regmatch.startp[0],
|
||||||
(size_t)(incl_regmatch.endp[0]
|
(size_t)(incl_regmatch.endp[0]
|
||||||
- incl_regmatch.startp[0]),
|
- incl_regmatch.startp[0]),
|
||||||
FNAME_EXP|FNAME_INCL|FNAME_REL,
|
FNAME_EXP|FNAME_INCL|FNAME_REL,
|
||||||
1L, p_fname);
|
1L, (char *)p_fname);
|
||||||
} else {
|
} else {
|
||||||
// Use text after match with 'include'.
|
// Use text after match with 'include'.
|
||||||
new_fname = file_name_in_line(incl_regmatch.endp[0], 0,
|
new_fname = file_name_in_line(incl_regmatch.endp[0], 0,
|
||||||
|
@ -882,10 +882,10 @@ static const void *shada_hist_iter(const void *const iter, const uint8_t history
|
|||||||
.data = {
|
.data = {
|
||||||
.history_item = {
|
.history_item = {
|
||||||
.histtype = history_type,
|
.histtype = history_type,
|
||||||
.string = (char *)hist_he.hisstr,
|
.string = hist_he.hisstr,
|
||||||
.sep = (char)(history_type == HIST_SEARCH
|
.sep = (char)(history_type == HIST_SEARCH
|
||||||
? (char)hist_he.hisstr[STRLEN(hist_he.hisstr) + 1]
|
? hist_he.hisstr[STRLEN(hist_he.hisstr) + 1]
|
||||||
: 0),
|
: 0),
|
||||||
.additional_elements = hist_he.additional_elements,
|
.additional_elements = hist_he.additional_elements,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1008,7 +1008,7 @@ static inline void hms_to_he_array(const HistoryMergerState *const hms_p,
|
|||||||
HMLL_FORALL(&hms_p->hmll, cur_entry, {
|
HMLL_FORALL(&hms_p->hmll, cur_entry, {
|
||||||
hist->timestamp = cur_entry->data.timestamp;
|
hist->timestamp = cur_entry->data.timestamp;
|
||||||
hist->hisnum = (int)(hist - hist_array) + 1;
|
hist->hisnum = (int)(hist - hist_array) + 1;
|
||||||
hist->hisstr = (char_u *)cur_entry->data.data.history_item.string;
|
hist->hisstr = cur_entry->data.data.history_item.string;
|
||||||
hist->additional_elements =
|
hist->additional_elements =
|
||||||
cur_entry->data.data.history_item.additional_elements;
|
cur_entry->data.data.history_item.additional_elements;
|
||||||
hist++;
|
hist++;
|
||||||
|
@ -2104,8 +2104,8 @@ static void clear_midword(win_T *wp)
|
|||||||
XFREE_CLEAR(wp->w_s->b_spell_ismw_mb);
|
XFREE_CLEAR(wp->w_s->b_spell_ismw_mb);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use the "sl_midword" field of language "lp" for buffer "buf".
|
/// Use the "sl_midword" field of language "lp" for buffer "buf".
|
||||||
// They add up to any currently used midword characters.
|
/// They add up to any currently used midword characters.
|
||||||
static void use_midword(slang_T *lp, win_T *wp)
|
static void use_midword(slang_T *lp, win_T *wp)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
@ -2113,20 +2113,20 @@ static void use_midword(slang_T *lp, win_T *wp)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (char_u *p = lp->sl_midword; *p != NUL;) {
|
for (char *p = (char *)lp->sl_midword; *p != NUL;) {
|
||||||
const int c = utf_ptr2char((char *)p);
|
const int c = utf_ptr2char(p);
|
||||||
const int l = utfc_ptr2len((char *)p);
|
const int l = utfc_ptr2len(p);
|
||||||
if (c < 256 && l <= 2) {
|
if (c < 256 && l <= 2) {
|
||||||
wp->w_s->b_spell_ismw[c] = true;
|
wp->w_s->b_spell_ismw[c] = true;
|
||||||
} else if (wp->w_s->b_spell_ismw_mb == NULL) {
|
} else if (wp->w_s->b_spell_ismw_mb == NULL) {
|
||||||
// First multi-byte char in "b_spell_ismw_mb".
|
// First multi-byte char in "b_spell_ismw_mb".
|
||||||
wp->w_s->b_spell_ismw_mb = (char *)vim_strnsave(p, (size_t)l);
|
wp->w_s->b_spell_ismw_mb = xstrnsave(p, (size_t)l);
|
||||||
} else {
|
} else {
|
||||||
// Append multi-byte chars to "b_spell_ismw_mb".
|
// Append multi-byte chars to "b_spell_ismw_mb".
|
||||||
const int n = (int)STRLEN(wp->w_s->b_spell_ismw_mb);
|
const int n = (int)STRLEN(wp->w_s->b_spell_ismw_mb);
|
||||||
char_u *bp = vim_strnsave((char_u *)wp->w_s->b_spell_ismw_mb, (size_t)n + (size_t)l);
|
char *bp = xstrnsave(wp->w_s->b_spell_ismw_mb, (size_t)n + (size_t)l);
|
||||||
xfree(wp->w_s->b_spell_ismw_mb);
|
xfree(wp->w_s->b_spell_ismw_mb);
|
||||||
wp->w_s->b_spell_ismw_mb = (char *)bp;
|
wp->w_s->b_spell_ismw_mb = bp;
|
||||||
STRLCPY(bp + n, p, l + 1);
|
STRLCPY(bp + n, p, l + 1);
|
||||||
}
|
}
|
||||||
p += l;
|
p += l;
|
||||||
@ -2470,7 +2470,7 @@ bool check_need_cap(linenr_T lnum, colnr_T col)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char_u *line = get_cursor_line_ptr();
|
char_u *line = (char_u *)get_cursor_line_ptr();
|
||||||
char_u *line_copy = NULL;
|
char_u *line_copy = NULL;
|
||||||
colnr_T endcol = 0;
|
colnr_T endcol = 0;
|
||||||
if (getwhitecols((char *)line) >= (int)col) {
|
if (getwhitecols((char *)line) >= (int)col) {
|
||||||
@ -2548,7 +2548,7 @@ void ex_spellrepall(exarg_T *eap)
|
|||||||
|
|
||||||
// Only replace when the right word isn't there yet. This happens
|
// Only replace when the right word isn't there yet. This happens
|
||||||
// when changing "etc" to "etc.".
|
// when changing "etc" to "etc.".
|
||||||
char_u *line = get_cursor_line_ptr();
|
char_u *line = (char_u *)get_cursor_line_ptr();
|
||||||
if (addlen <= 0 || STRNCMP(line + curwin->w_cursor.col,
|
if (addlen <= 0 || STRNCMP(line + curwin->w_cursor.col,
|
||||||
repl_to, STRLEN(repl_to)) != 0) {
|
repl_to, STRLEN(repl_to)) != 0) {
|
||||||
char_u *p = xmalloc(STRLEN(line) + (size_t)addlen + 1);
|
char_u *p = xmalloc(STRLEN(line) + (size_t)addlen + 1);
|
||||||
@ -3497,7 +3497,7 @@ int spell_word_start(int startcol)
|
|||||||
return startcol;
|
return startcol;
|
||||||
}
|
}
|
||||||
|
|
||||||
char_u *line = get_cursor_line_ptr();
|
char_u *line = (char_u *)get_cursor_line_ptr();
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
// Find a word character before "startcol".
|
// Find a word character before "startcol".
|
||||||
|
@ -65,7 +65,7 @@ typedef struct suginfo_S {
|
|||||||
|
|
||||||
/// One word suggestion. Used in "si_ga".
|
/// One word suggestion. Used in "si_ga".
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char_u *st_word; ///< suggested word, allocated string
|
char *st_word; ///< suggested word, allocated string
|
||||||
int st_wordlen; ///< STRLEN(st_word)
|
int st_wordlen; ///< STRLEN(st_word)
|
||||||
int st_orglen; ///< length of replaced text
|
int st_orglen; ///< length of replaced text
|
||||||
int st_score; ///< lower is better
|
int st_score; ///< lower is better
|
||||||
@ -453,7 +453,7 @@ void spell_suggest(int count)
|
|||||||
// No bad word or it starts after the cursor: use the word under the
|
// No bad word or it starts after the cursor: use the word under the
|
||||||
// cursor.
|
// cursor.
|
||||||
curwin->w_cursor = prev_cursor;
|
curwin->w_cursor = prev_cursor;
|
||||||
line = get_cursor_line_ptr();
|
line = (char_u *)get_cursor_line_ptr();
|
||||||
p = line + curwin->w_cursor.col;
|
p = line + curwin->w_cursor.col;
|
||||||
// Backup to before start of word.
|
// Backup to before start of word.
|
||||||
while (p > line && spell_iswordp_nmw(p, curwin)) {
|
while (p > line && spell_iswordp_nmw(p, curwin)) {
|
||||||
@ -477,7 +477,7 @@ void spell_suggest(int count)
|
|||||||
need_cap = check_need_cap(curwin->w_cursor.lnum, curwin->w_cursor.col);
|
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 = vim_strsave(get_cursor_line_ptr());
|
line = vim_strsave((char_u *)get_cursor_line_ptr());
|
||||||
spell_suggest_timeout = 5000;
|
spell_suggest_timeout = 5000;
|
||||||
|
|
||||||
// Get the list of suggestions. Limit to 'lines' - 2 or the number in
|
// Get the list of suggestions. Limit to 'lines' - 2 or the number in
|
||||||
@ -593,15 +593,15 @@ void spell_suggest(int count)
|
|||||||
if (sug.su_badlen > stp->st_orglen) {
|
if (sug.su_badlen > stp->st_orglen) {
|
||||||
// Replacing less than "su_badlen", append the remainder to
|
// Replacing less than "su_badlen", append the remainder to
|
||||||
// repl_to.
|
// repl_to.
|
||||||
repl_from = vim_strnsave(sug.su_badptr, (size_t)sug.su_badlen);
|
repl_from = (char_u *)xstrnsave((char *)sug.su_badptr, (size_t)sug.su_badlen);
|
||||||
vim_snprintf((char *)IObuff, IOSIZE, "%s%.*s", stp->st_word,
|
vim_snprintf((char *)IObuff, IOSIZE, "%s%.*s", stp->st_word,
|
||||||
sug.su_badlen - stp->st_orglen,
|
sug.su_badlen - stp->st_orglen,
|
||||||
sug.su_badptr + stp->st_orglen);
|
sug.su_badptr + stp->st_orglen);
|
||||||
repl_to = vim_strsave(IObuff);
|
repl_to = vim_strsave(IObuff);
|
||||||
} else {
|
} else {
|
||||||
// Replacing su_badlen or more, use the whole word.
|
// Replacing su_badlen or more, use the whole word.
|
||||||
repl_from = vim_strnsave(sug.su_badptr, (size_t)stp->st_orglen);
|
repl_from = (char_u *)xstrnsave((char *)sug.su_badptr, (size_t)stp->st_orglen);
|
||||||
repl_to = vim_strsave(stp->st_word);
|
repl_to = vim_strsave((char_u *)stp->st_word);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Replace the word.
|
// Replace the word.
|
||||||
@ -748,7 +748,7 @@ static void spell_find_suggest(char_u *badptr, int badlen, suginfo_T *su, int ma
|
|||||||
c = utf_ptr2char((char *)su->su_badptr);
|
c = utf_ptr2char((char *)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, (char *)buf, su->su_badlen, SCORE_ICASE,
|
||||||
0, true, su->su_sallang, false);
|
0, true, su->su_sallang, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -814,7 +814,7 @@ static void spell_suggest_expr(suginfo_T *su, char_u *expr)
|
|||||||
// 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);
|
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, (const char_u *)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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -864,7 +864,7 @@ static void spell_suggest_file(suginfo_T *su, char_u *fname)
|
|||||||
p = cword;
|
p = cword;
|
||||||
}
|
}
|
||||||
|
|
||||||
add_suggestion(su, &su->su_ga, p, su->su_badlen,
|
add_suggestion(su, &su->su_ga, (char *)p, su->su_badlen,
|
||||||
SCORE_FILE, 0, true, su->su_sallang, false);
|
SCORE_FILE, 0, true, su->su_sallang, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -985,7 +985,7 @@ static void suggest_try_special(suginfo_T *su)
|
|||||||
|
|
||||||
// Give a soundalike score of 0, compute the score as if deleting one
|
// Give a soundalike score of 0, compute the score as if deleting one
|
||||||
// character.
|
// character.
|
||||||
add_suggestion(su, &su->su_ga, word, su->su_badlen,
|
add_suggestion(su, &su->su_ga, (char *)word, su->su_badlen,
|
||||||
RESCORE(SCORE_REP, 0), 0, true, su->su_sallang, false);
|
RESCORE(SCORE_REP, 0), 0, true, su->su_sallang, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1330,7 +1330,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
sp->ts_prewordlen > 0);
|
sp->ts_prewordlen > 0);
|
||||||
// Add the suggestion if the score isn't too bad.
|
// Add the suggestion if the score isn't too bad.
|
||||||
if (newscore <= su->su_maxscore) {
|
if (newscore <= su->su_maxscore) {
|
||||||
add_suggestion(su, &su->su_ga, preword,
|
add_suggestion(su, &su->su_ga, (char *)preword,
|
||||||
sp->ts_splitfidx - repextra,
|
sp->ts_splitfidx - repextra,
|
||||||
newscore, 0, false,
|
newscore, 0, false,
|
||||||
lp->lp_sallang, false);
|
lp->lp_sallang, false);
|
||||||
@ -1492,7 +1492,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
|
|
||||||
// Add the suggestion if the score isn't too bad.
|
// Add the suggestion if the score isn't too bad.
|
||||||
if (score <= su->su_maxscore) {
|
if (score <= su->su_maxscore) {
|
||||||
add_suggestion(su, &su->su_ga, preword,
|
add_suggestion(su, &su->su_ga, (char *)preword,
|
||||||
sp->ts_fidx - repextra,
|
sp->ts_fidx - repextra,
|
||||||
score, 0, false, lp->lp_sallang, false);
|
score, 0, false, lp->lp_sallang, false);
|
||||||
|
|
||||||
@ -1505,7 +1505,7 @@ static void suggest_trie_walk(suginfo_T *su, langp_T *lp, char_u *fword, bool so
|
|||||||
preword + sp->ts_prewordlen,
|
preword + sp->ts_prewordlen,
|
||||||
c == 0 ? WF_ALLCAP : 0);
|
c == 0 ? WF_ALLCAP : 0);
|
||||||
|
|
||||||
add_suggestion(su, &su->su_ga, preword,
|
add_suggestion(su, &su->su_ga, (char *)preword,
|
||||||
sp->ts_fidx - repextra,
|
sp->ts_fidx - repextra,
|
||||||
score + SCORE_ICASE, 0, false,
|
score + SCORE_ICASE, 0, false,
|
||||||
lp->lp_sallang, false);
|
lp->lp_sallang, false);
|
||||||
@ -2494,7 +2494,7 @@ static void score_comp_sal(suginfo_T *su)
|
|||||||
if (score < SCORE_MAXMAX) {
|
if (score < SCORE_MAXMAX) {
|
||||||
// Add the suggestion.
|
// Add the suggestion.
|
||||||
sstp = &SUG(su->su_sga, su->su_sga.ga_len);
|
sstp = &SUG(su->su_sga, su->su_sga.ga_len);
|
||||||
sstp->st_word = vim_strsave(stp->st_word);
|
sstp->st_word = xstrdup(stp->st_word);
|
||||||
sstp->st_wordlen = stp->st_wordlen;
|
sstp->st_wordlen = stp->st_wordlen;
|
||||||
sstp->st_score = score;
|
sstp->st_score = score;
|
||||||
sstp->st_altscore = 0;
|
sstp->st_altscore = 0;
|
||||||
@ -2551,8 +2551,7 @@ static void score_combine(suginfo_T *su)
|
|||||||
// Add the alternate score to su_sga.
|
// Add the alternate score to su_sga.
|
||||||
for (int i = 0; i < su->su_sga.ga_len; i++) {
|
for (int i = 0; i < su->su_sga.ga_len; i++) {
|
||||||
stp = &SUG(su->su_sga, i);
|
stp = &SUG(su->su_sga, i);
|
||||||
stp->st_altscore = spell_edit_score(slang,
|
stp->st_altscore = spell_edit_score(slang, su->su_badword, (char_u *)stp->st_word);
|
||||||
su->su_badword, stp->st_word);
|
|
||||||
if (stp->st_score == SCORE_MAXMAX) {
|
if (stp->st_score == SCORE_MAXMAX) {
|
||||||
stp->st_score = (SCORE_BIG * 7 + stp->st_altscore) / 8;
|
stp->st_score = (SCORE_BIG * 7 + stp->st_altscore) / 8;
|
||||||
} else {
|
} else {
|
||||||
@ -2579,7 +2578,7 @@ static void score_combine(suginfo_T *su)
|
|||||||
gap = round == 1 ? &su->su_ga : &su->su_sga;
|
gap = round == 1 ? &su->su_ga : &su->su_sga;
|
||||||
if (i < gap->ga_len) {
|
if (i < gap->ga_len) {
|
||||||
// Don't add a word if it's already there.
|
// Don't add a word if it's already there.
|
||||||
p = SUG(*gap, i).st_word;
|
p = (char_u *)SUG(*gap, i).st_word;
|
||||||
int j;
|
int j;
|
||||||
for (j = 0; j < ga.ga_len; j++) {
|
for (j = 0; j < ga.ga_len; j++) {
|
||||||
if (STRCMP(stp[j].st_word, p) == 0) {
|
if (STRCMP(stp[j].st_word, p) == 0) {
|
||||||
@ -2636,7 +2635,7 @@ static int stp_sal_score(suggest_T *stp, suginfo_T *su, slang_T *slang, char_u *
|
|||||||
// removing the space. Don't do it when the good word also contains a
|
// removing the space. Don't do it when the good word also contains a
|
||||||
// space.
|
// space.
|
||||||
if (ascii_iswhite(su->su_badptr[su->su_badlen])
|
if (ascii_iswhite(su->su_badptr[su->su_badlen])
|
||||||
&& *skiptowhite((char *)stp->st_word) == NUL) {
|
&& *skiptowhite(stp->st_word) == NUL) {
|
||||||
for (p = fword; *(p = (char_u *)skiptowhite((char *)p)) != NUL;) {
|
for (p = fword; *(p = (char_u *)skiptowhite((char *)p)) != NUL;) {
|
||||||
STRMOVE(p, p + 1);
|
STRMOVE(p, p + 1);
|
||||||
}
|
}
|
||||||
@ -2654,7 +2653,7 @@ static int stp_sal_score(suggest_T *stp, suginfo_T *su, slang_T *slang, char_u *
|
|||||||
su->su_badptr + su->su_badlen - lendiff, lendiff + 1);
|
su->su_badptr + su->su_badlen - lendiff, lendiff + 1);
|
||||||
pgood = goodword;
|
pgood = goodword;
|
||||||
} else {
|
} else {
|
||||||
pgood = stp->st_word;
|
pgood = (char_u *)stp->st_word;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sound-fold the word and compute the score for the difference.
|
// Sound-fold the word and compute the score for the difference.
|
||||||
@ -2883,7 +2882,7 @@ badword:
|
|||||||
if (sps_flags & SPS_DOUBLE) {
|
if (sps_flags & SPS_DOUBLE) {
|
||||||
// Add the suggestion if the score isn't too bad.
|
// Add the suggestion if the score isn't too bad.
|
||||||
if (score <= su->su_maxscore) {
|
if (score <= su->su_maxscore) {
|
||||||
add_suggestion(su, &su->su_sga, p, su->su_badlen,
|
add_suggestion(su, &su->su_sga, (char *)p, su->su_badlen,
|
||||||
score, 0, false, slang, false);
|
score, 0, false, slang, false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -2931,7 +2930,7 @@ badword:
|
|||||||
// Add the suggestion if the score isn't too bad.
|
// Add the suggestion if the score isn't too bad.
|
||||||
goodscore = RESCORE(goodscore, score);
|
goodscore = RESCORE(goodscore, score);
|
||||||
if (goodscore <= su->su_sfmaxscore) {
|
if (goodscore <= su->su_sfmaxscore) {
|
||||||
add_suggestion(su, &su->su_ga, p, su->su_badlen,
|
add_suggestion(su, &su->su_ga, (char *)p, su->su_badlen,
|
||||||
goodscore, score, true, slang, true);
|
goodscore, score, true, slang, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3061,7 +3060,7 @@ static bool similar_chars(slang_T *slang, int c1, int c2)
|
|||||||
/// @param had_bonus value for st_had_bonus
|
/// @param had_bonus value for st_had_bonus
|
||||||
/// @param slang language for sound folding
|
/// @param slang language for sound folding
|
||||||
/// @param maxsf su_maxscore applies to soundfold score, su_sfmaxscore to the total score.
|
/// @param maxsf su_maxscore applies to soundfold score, su_sfmaxscore to the total score.
|
||||||
static void add_suggestion(suginfo_T *su, garray_T *gap, const char_u *goodword, int badlenarg,
|
static void add_suggestion(suginfo_T *su, garray_T *gap, const char *goodword, int badlenarg,
|
||||||
int score, int altscore, bool had_bonus, slang_T *slang, bool maxsf)
|
int score, int altscore, bool had_bonus, slang_T *slang, bool maxsf)
|
||||||
{
|
{
|
||||||
int goodlen; // len of goodword changed
|
int goodlen; // len of goodword changed
|
||||||
@ -3071,7 +3070,7 @@ static void add_suggestion(suginfo_T *su, garray_T *gap, const char_u *goodword,
|
|||||||
|
|
||||||
// Minimize "badlen" for consistency. Avoids that changing "the the" to
|
// Minimize "badlen" for consistency. Avoids that changing "the the" to
|
||||||
// "thee the" is added next to changing the first "the" the "thee".
|
// "thee the" is added next to changing the first "the" the "thee".
|
||||||
const char_u *pgood = goodword + STRLEN(goodword);
|
const char *pgood = goodword + STRLEN(goodword);
|
||||||
char_u *pbad = su->su_badptr + badlenarg;
|
char_u *pbad = su->su_badptr + badlenarg;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
goodlen = (int)(pgood - goodword);
|
goodlen = (int)(pgood - goodword);
|
||||||
@ -3144,7 +3143,7 @@ static void add_suggestion(suginfo_T *su, garray_T *gap, const char_u *goodword,
|
|||||||
if (i < 0) {
|
if (i < 0) {
|
||||||
// Add a suggestion.
|
// Add a suggestion.
|
||||||
stp = GA_APPEND_VIA_PTR(suggest_T, gap);
|
stp = GA_APPEND_VIA_PTR(suggest_T, gap);
|
||||||
stp->st_word = vim_strnsave(goodword, (size_t)goodlen);
|
stp->st_word = xstrnsave(goodword, (size_t)goodlen);
|
||||||
stp->st_wordlen = goodlen;
|
stp->st_wordlen = goodlen;
|
||||||
stp->st_score = score;
|
stp->st_score = score;
|
||||||
stp->st_altscore = altscore;
|
stp->st_altscore = altscore;
|
||||||
|
@ -59,15 +59,6 @@ char_u *vim_strsave(const char_u *string)
|
|||||||
/// Copy up to `len` bytes of `string` into newly allocated memory and
|
/// Copy up to `len` bytes of `string` into newly allocated memory and
|
||||||
/// terminate with a NUL. The allocated memory always has size `len + 1`, even
|
/// terminate with a NUL. The allocated memory always has size `len + 1`, even
|
||||||
/// when `string` is shorter.
|
/// when `string` is shorter.
|
||||||
char_u *vim_strnsave(const char_u *string, size_t len)
|
|
||||||
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
|
|
||||||
{
|
|
||||||
// strncpy is intentional: some parts of Vim use `string` shorter than `len`
|
|
||||||
// and expect the remainder to be zeroed out.
|
|
||||||
return (char_u *)strncpy(xmallocz(len), (char *)string, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// A clone of vim_strnsave() that uses char* instead of char_u*
|
|
||||||
char *xstrnsave(const char *string, size_t len)
|
char *xstrnsave(const char *string, size_t len)
|
||||||
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
@ -318,15 +309,13 @@ char_u *vim_strsave_up(const char_u *string)
|
|||||||
return p1;
|
return p1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/// Like xstrnsave(), but make all characters uppercase.
|
||||||
* Like vim_strnsave(), but make all characters uppercase.
|
/// This uses ASCII lower-to-upper case translation, language independent.
|
||||||
* This uses ASCII lower-to-upper case translation, language independent.
|
char *vim_strnsave_up(const char *string, size_t len)
|
||||||
*/
|
|
||||||
char_u *vim_strnsave_up(const char_u *string, size_t len)
|
|
||||||
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_RET FUNC_ATTR_MALLOC FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
char_u *p1 = vim_strnsave(string, len);
|
char *p1 = xstrnsave(string, len);
|
||||||
vim_strup(p1);
|
vim_strup((char_u *)p1);
|
||||||
return p1;
|
return p1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ typedef struct syn_pattern {
|
|||||||
int16_t *sp_cont_list; // cont. group IDs, if non-zero
|
int16_t *sp_cont_list; // cont. group IDs, if non-zero
|
||||||
int16_t *sp_next_list; // next group IDs, if non-zero
|
int16_t *sp_next_list; // next group IDs, if non-zero
|
||||||
struct sp_syn sp_syn; // struct passed to in_id_list()
|
struct sp_syn sp_syn; // struct passed to in_id_list()
|
||||||
char_u *sp_pattern; // regexp to match, pattern
|
char *sp_pattern; // regexp to match, pattern
|
||||||
regprog_T *sp_prog; // regexp to match, program
|
regprog_T *sp_prog; // regexp to match, program
|
||||||
syn_time_T sp_time;
|
syn_time_T sp_time;
|
||||||
} synpat_T;
|
} synpat_T;
|
||||||
@ -1709,9 +1709,10 @@ static int syn_current_attr(const bool syncing, const bool displaying, bool *con
|
|||||||
if (do_keywords) {
|
if (do_keywords) {
|
||||||
line = (char_u *)syn_getcurline();
|
line = (char_u *)syn_getcurline();
|
||||||
const char_u *cur_pos = line + current_col;
|
const char_u *cur_pos = line + current_col;
|
||||||
if (vim_iswordp_buf(cur_pos, syn_buf)
|
if (vim_iswordp_buf((char *)cur_pos, syn_buf)
|
||||||
&& (current_col == 0
|
&& (current_col == 0
|
||||||
|| !vim_iswordp_buf(cur_pos - 1 - utf_head_off((char *)line, (char *)cur_pos - 1),
|
|| !vim_iswordp_buf((char *)cur_pos - 1 -
|
||||||
|
utf_head_off((char *)line, (char *)cur_pos - 1),
|
||||||
syn_buf))) {
|
syn_buf))) {
|
||||||
syn_id = check_keyword_id((char *)line, (int)current_col, &endcol, &flags,
|
syn_id = check_keyword_id((char *)line, (int)current_col, &endcol, &flags,
|
||||||
&next_list, cur_si, &cchar);
|
&next_list, cur_si, &cchar);
|
||||||
@ -2942,7 +2943,7 @@ static int check_keyword_id(char *const line, const int startcol, int *const end
|
|||||||
int kwlen = 0;
|
int kwlen = 0;
|
||||||
do {
|
do {
|
||||||
kwlen += utfc_ptr2len(kwp + kwlen);
|
kwlen += utfc_ptr2len(kwp + kwlen);
|
||||||
} while (vim_iswordp_buf((char_u *)kwp + kwlen, syn_buf));
|
} while (vim_iswordp_buf(kwp + kwlen, syn_buf));
|
||||||
|
|
||||||
if (kwlen > MAXKEYWLEN) {
|
if (kwlen > MAXKEYWLEN) {
|
||||||
return 0;
|
return 0;
|
||||||
@ -3772,14 +3773,14 @@ static void put_pattern(const char *const s, const int c, const synpat_T *const
|
|||||||
msg_putchar(c);
|
msg_putchar(c);
|
||||||
|
|
||||||
// output the pattern, in between a char that is not in the pattern
|
// output the pattern, in between a char that is not in the pattern
|
||||||
for (i = 0; vim_strchr((char *)spp->sp_pattern, sepchars[i]) != NULL;) {
|
for (i = 0; vim_strchr(spp->sp_pattern, sepchars[i]) != NULL;) {
|
||||||
if (sepchars[++i] == NUL) {
|
if (sepchars[++i] == NUL) {
|
||||||
i = 0; // no good char found, just use the first one
|
i = 0; // no good char found, just use the first one
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
msg_putchar(sepchars[i]);
|
msg_putchar(sepchars[i]);
|
||||||
msg_outtrans((char *)spp->sp_pattern);
|
msg_outtrans(spp->sp_pattern);
|
||||||
msg_putchar(sepchars[i]);
|
msg_putchar(sepchars[i]);
|
||||||
|
|
||||||
// output any pattern options
|
// output any pattern options
|
||||||
@ -4048,7 +4049,7 @@ static char *get_group_name(char *arg, char **name_end)
|
|||||||
/// Return NULL for any error;
|
/// Return NULL for any error;
|
||||||
static char *get_syn_options(char *arg, syn_opt_arg_T *opt, int *conceal_char, int skip)
|
static char *get_syn_options(char *arg, syn_opt_arg_T *opt, int *conceal_char, int skip)
|
||||||
{
|
{
|
||||||
char_u *gname_start, *gname;
|
char *gname_start, *gname;
|
||||||
int syn_id;
|
int syn_id;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
char *p;
|
char *p;
|
||||||
@ -4157,16 +4158,16 @@ static char *get_syn_options(char *arg, syn_opt_arg_T *opt, int *conceal_char, i
|
|||||||
emsg(_("E393: group[t]here not accepted here"));
|
emsg(_("E393: group[t]here not accepted here"));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
gname_start = (char_u *)arg;
|
gname_start = arg;
|
||||||
arg = skiptowhite(arg);
|
arg = skiptowhite(arg);
|
||||||
if (gname_start == (char_u *)arg) {
|
if (gname_start == arg) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
gname = vim_strnsave(gname_start, (size_t)((char_u *)arg - gname_start));
|
gname = xstrnsave(gname_start, (size_t)(arg - gname_start));
|
||||||
if (STRCMP(gname, "NONE") == 0) {
|
if (STRCMP(gname, "NONE") == 0) {
|
||||||
*opt->sync_idx = NONE_IDX;
|
*opt->sync_idx = NONE_IDX;
|
||||||
} else {
|
} else {
|
||||||
syn_id = syn_name2id((char *)gname);
|
syn_id = syn_name2id(gname);
|
||||||
int i;
|
int i;
|
||||||
for (i = curwin->w_s->b_syn_patterns.ga_len; --i >= 0;) {
|
for (i = curwin->w_s->b_syn_patterns.ga_len; --i >= 0;) {
|
||||||
if (SYN_ITEMS(curwin->w_s)[i].sp_syn.id == syn_id
|
if (SYN_ITEMS(curwin->w_s)[i].sp_syn.id == syn_id
|
||||||
@ -4566,7 +4567,7 @@ static void syn_cmd_region(exarg_T *eap, int syncing)
|
|||||||
key_end++;
|
key_end++;
|
||||||
}
|
}
|
||||||
xfree(key);
|
xfree(key);
|
||||||
key = (char *)vim_strnsave_up((char_u *)rest, (size_t)(key_end - rest));
|
key = vim_strnsave_up(rest, (size_t)(key_end - rest));
|
||||||
if (STRCMP(key, "MATCHGROUP") == 0) {
|
if (STRCMP(key, "MATCHGROUP") == 0) {
|
||||||
item = ITEM_MATCHGROUP;
|
item = ITEM_MATCHGROUP;
|
||||||
} else if (STRCMP(key, "START") == 0) {
|
} else if (STRCMP(key, "START") == 0) {
|
||||||
@ -5043,12 +5044,12 @@ static char *get_syn_pattern(char *arg, synpat_T *ci)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
// store the pattern and compiled regexp program
|
// store the pattern and compiled regexp program
|
||||||
ci->sp_pattern = vim_strnsave((char_u *)arg + 1, (size_t)(end - arg) - 1);
|
ci->sp_pattern = xstrnsave(arg + 1, (size_t)(end - arg) - 1);
|
||||||
|
|
||||||
// Make 'cpoptions' empty, to avoid the 'l' flag
|
// Make 'cpoptions' empty, to avoid the 'l' flag
|
||||||
cpo_save = p_cpo;
|
cpo_save = p_cpo;
|
||||||
p_cpo = empty_option;
|
p_cpo = empty_option;
|
||||||
ci->sp_prog = vim_regcomp((char *)ci->sp_pattern, RE_MAGIC);
|
ci->sp_prog = vim_regcomp(ci->sp_pattern, RE_MAGIC);
|
||||||
p_cpo = cpo_save;
|
p_cpo = cpo_save;
|
||||||
|
|
||||||
if (ci->sp_prog == NULL) {
|
if (ci->sp_prog == NULL) {
|
||||||
@ -5137,7 +5138,7 @@ static void syn_cmd_sync(exarg_T *eap, int syncing)
|
|||||||
arg_end = skiptowhite(arg_start);
|
arg_end = skiptowhite(arg_start);
|
||||||
next_arg = skipwhite(arg_end);
|
next_arg = skipwhite(arg_end);
|
||||||
xfree(key);
|
xfree(key);
|
||||||
key = (char *)vim_strnsave_up((char_u *)arg_start, (size_t)(arg_end - arg_start));
|
key = vim_strnsave_up(arg_start, (size_t)(arg_end - arg_start));
|
||||||
if (STRCMP(key, "CCOMMENT") == 0) {
|
if (STRCMP(key, "CCOMMENT") == 0) {
|
||||||
if (!eap->skip) {
|
if (!eap->skip) {
|
||||||
curwin->w_s->b_syn_sync_flags |= SF_CCOMMENT;
|
curwin->w_s->b_syn_sync_flags |= SF_CCOMMENT;
|
||||||
@ -5975,7 +5976,7 @@ static void syntime_report(void)
|
|||||||
proftime_T tm = profile_divide(spp->sp_time.total, (int)spp->sp_time.count);
|
proftime_T tm = profile_divide(spp->sp_time.total, (int)spp->sp_time.count);
|
||||||
p->average = tm;
|
p->average = tm;
|
||||||
p->id = spp->sp_syn.id;
|
p->id = spp->sp_syn.id;
|
||||||
p->pattern = spp->sp_pattern;
|
p->pattern = (char_u *)spp->sp_pattern;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,11 +66,11 @@ typedef struct tag_pointers {
|
|||||||
char_u *command_end; // first char after command
|
char_u *command_end; // first char after command
|
||||||
char_u *tag_fname; // file name of the tags file. This is used
|
char_u *tag_fname; // file name of the tags file. This is used
|
||||||
// when 'tr' is set.
|
// when 'tr' is set.
|
||||||
char_u *tagkind; // "kind:" value
|
char_u *tagkind; // "kind:" value
|
||||||
char_u *tagkind_end; // end of tagkind
|
char_u *tagkind_end; // end of tagkind
|
||||||
char_u *user_data; // user_data string
|
char *user_data; // user_data string
|
||||||
char_u *user_data_end; // end of user_data
|
char_u *user_data_end; // end of user_data
|
||||||
linenr_T tagline; // "line:" value
|
linenr_T tagline; // "line:" value
|
||||||
} tagptrs_T;
|
} tagptrs_T;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -588,9 +588,8 @@ bool do_tag(char_u *tag, int type, int count, int forceit, int verbose)
|
|||||||
if (use_tfu && parse_match(matches[cur_match], &tagp2) == OK
|
if (use_tfu && parse_match(matches[cur_match], &tagp2) == OK
|
||||||
&& tagp2.user_data) {
|
&& tagp2.user_data) {
|
||||||
XFREE_CLEAR(tagstack[tagstackidx].user_data);
|
XFREE_CLEAR(tagstack[tagstackidx].user_data);
|
||||||
tagstack[tagstackidx].user_data = (char *)vim_strnsave(tagp2.user_data,
|
tagstack[tagstackidx].user_data =
|
||||||
(size_t)(tagp2.user_data_end -
|
xstrnsave(tagp2.user_data, (size_t)(tagp2.user_data_end - (char_u *)tagp2.user_data));
|
||||||
tagp2.user_data));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tagstackidx++;
|
tagstackidx++;
|
||||||
@ -1425,7 +1424,7 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc
|
|||||||
int help_pri = 0;
|
int help_pri = 0;
|
||||||
char_u *help_lang_find = NULL; // lang to be found
|
char_u *help_lang_find = NULL; // lang to be found
|
||||||
char_u help_lang[3]; // lang of current tags file
|
char_u help_lang[3]; // lang of current tags file
|
||||||
char_u *saved_pat = NULL; // copy of pat[]
|
char *saved_pat = NULL; // copy of pat[]
|
||||||
bool is_txt = false;
|
bool is_txt = false;
|
||||||
|
|
||||||
pat_T orgpat; // holds unconverted pattern info
|
pat_T orgpat; // holds unconverted pattern info
|
||||||
@ -1503,9 +1502,9 @@ int find_tags(char *pat, int *num_matches, char ***matchesp, int flags, int minc
|
|||||||
if (orgpat.len > 3 && pat[orgpat.len - 3] == '@'
|
if (orgpat.len > 3 && pat[orgpat.len - 3] == '@'
|
||||||
&& ASCII_ISALPHA(pat[orgpat.len - 2])
|
&& ASCII_ISALPHA(pat[orgpat.len - 2])
|
||||||
&& ASCII_ISALPHA(pat[orgpat.len - 1])) {
|
&& ASCII_ISALPHA(pat[orgpat.len - 1])) {
|
||||||
saved_pat = vim_strnsave((char_u *)pat, (size_t)orgpat.len - 3);
|
saved_pat = xstrnsave(pat, (size_t)orgpat.len - 3);
|
||||||
help_lang_find = (char_u *)&pat[orgpat.len - 2];
|
help_lang_find = (char_u *)&pat[orgpat.len - 2];
|
||||||
orgpat.pat = saved_pat;
|
orgpat.pat = (char_u *)saved_pat;
|
||||||
orgpat.len -= 3;
|
orgpat.len -= 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2430,11 +2429,11 @@ int get_tagfname(tagname_T *tnp, int first, char *buf)
|
|||||||
STRMOVE(filename + 1, filename);
|
STRMOVE(filename + 1, filename);
|
||||||
*filename++ = NUL;
|
*filename++ = NUL;
|
||||||
|
|
||||||
tnp->tn_search_ctx = vim_findfile_init((char_u *)buf, filename,
|
tnp->tn_search_ctx = vim_findfile_init(buf, (char *)filename,
|
||||||
(char_u *)r_ptr, 100,
|
r_ptr, 100,
|
||||||
false, // don't free visited list
|
false, // don't free visited list
|
||||||
FINDFILE_FILE, // we search for a file
|
FINDFILE_FILE, // we search for a file
|
||||||
tnp->tn_search_ctx, true, (char_u *)curbuf->b_ffname);
|
tnp->tn_search_ctx, true, curbuf->b_ffname);
|
||||||
if (tnp->tn_search_ctx != NULL) {
|
if (tnp->tn_search_ctx != NULL) {
|
||||||
tnp->tn_did_filefind_init = true;
|
tnp->tn_did_filefind_init = true;
|
||||||
}
|
}
|
||||||
@ -2584,7 +2583,7 @@ static int parse_match(char *lbuf, tagptrs_T *tagp)
|
|||||||
if (STRNCMP(p, "kind:", 5) == 0) {
|
if (STRNCMP(p, "kind:", 5) == 0) {
|
||||||
tagp->tagkind = (char_u *)p + 5;
|
tagp->tagkind = (char_u *)p + 5;
|
||||||
} else if (STRNCMP(p, "user_data:", 10) == 0) {
|
} else if (STRNCMP(p, "user_data:", 10) == 0) {
|
||||||
tagp->user_data = (char_u *)p + 10;
|
tagp->user_data = p + 10;
|
||||||
} else if (STRNCMP(p, "line:", 5) == 0) {
|
} else if (STRNCMP(p, "line:", 5) == 0) {
|
||||||
tagp->tagline = atoi(p + 5);
|
tagp->tagline = atoi(p + 5);
|
||||||
}
|
}
|
||||||
@ -2612,7 +2611,7 @@ static int parse_match(char *lbuf, tagptrs_T *tagp)
|
|||||||
tagp->tagkind_end = (char_u *)p;
|
tagp->tagkind_end = (char_u *)p;
|
||||||
}
|
}
|
||||||
if (tagp->user_data != NULL) {
|
if (tagp->user_data != NULL) {
|
||||||
for (p = (char *)tagp->user_data;
|
for (p = tagp->user_data;
|
||||||
*p && *p != '\t' && *p != '\r' && *p != '\n';
|
*p && *p != '\t' && *p != '\r' && *p != '\n';
|
||||||
MB_PTR_ADV(p)) {}
|
MB_PTR_ADV(p)) {}
|
||||||
tagp->user_data_end = (char_u *)p;
|
tagp->user_data_end = (char_u *)p;
|
||||||
@ -2980,7 +2979,7 @@ static char_u *expand_tag_fname(char_u *fname, char_u *const tag_fname, const bo
|
|||||||
/*
|
/*
|
||||||
* Expand file name (for environment variables) when needed.
|
* Expand file name (for environment variables) when needed.
|
||||||
*/
|
*/
|
||||||
if (expand && path_has_wildcard(fname)) {
|
if (expand && path_has_wildcard((char *)fname)) {
|
||||||
ExpandInit(&xpc);
|
ExpandInit(&xpc);
|
||||||
xpc.xp_context = EXPAND_FILES;
|
xpc.xp_context = EXPAND_FILES;
|
||||||
expanded_fname = ExpandOne(&xpc, fname, NULL,
|
expanded_fname = ExpandOne(&xpc, fname, NULL,
|
||||||
|
@ -117,7 +117,7 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on
|
|||||||
|
|
||||||
// Don't break until after the comment leader
|
// Don't break until after the comment leader
|
||||||
if (do_comments) {
|
if (do_comments) {
|
||||||
char_u *line = get_cursor_line_ptr();
|
char_u *line = (char_u *)get_cursor_line_ptr();
|
||||||
leader_len = get_leader_len((char *)line, NULL, false, true);
|
leader_len = get_leader_len((char *)line, NULL, false, true);
|
||||||
if (leader_len == 0 && curbuf->b_p_cin) {
|
if (leader_len == 0 && curbuf->b_p_cin) {
|
||||||
// Check for a line comment after code.
|
// Check for a line comment after code.
|
||||||
@ -624,8 +624,8 @@ void auto_format(bool trailblank, bool prev_line)
|
|||||||
{
|
{
|
||||||
pos_T pos;
|
pos_T pos;
|
||||||
colnr_T len;
|
colnr_T len;
|
||||||
char_u *old;
|
char *old;
|
||||||
char_u *new, *pnew;
|
char *new, *pnew;
|
||||||
int wasatend;
|
int wasatend;
|
||||||
int cc;
|
int cc;
|
||||||
|
|
||||||
@ -663,7 +663,7 @@ void auto_format(bool trailblank, bool prev_line)
|
|||||||
// With the 'c' flag in 'formatoptions' and 't' missing: only format
|
// With the 'c' flag in 'formatoptions' and 't' missing: only format
|
||||||
// comments.
|
// comments.
|
||||||
if (has_format_option(FO_WRAP_COMS) && !has_format_option(FO_WRAP)
|
if (has_format_option(FO_WRAP_COMS) && !has_format_option(FO_WRAP)
|
||||||
&& get_leader_len((char *)old, NULL, false, true) == 0) {
|
&& get_leader_len(old, NULL, false, true) == 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -700,10 +700,10 @@ void auto_format(bool trailblank, bool prev_line)
|
|||||||
new = get_cursor_line_ptr();
|
new = get_cursor_line_ptr();
|
||||||
len = (colnr_T)STRLEN(new);
|
len = (colnr_T)STRLEN(new);
|
||||||
if (curwin->w_cursor.col == len) {
|
if (curwin->w_cursor.col == len) {
|
||||||
pnew = vim_strnsave(new, (size_t)len + 2);
|
pnew = xstrnsave(new, (size_t)len + 2);
|
||||||
pnew[len] = ' ';
|
pnew[len] = ' ';
|
||||||
pnew[len + 1] = NUL;
|
pnew[len + 1] = NUL;
|
||||||
ml_replace(curwin->w_cursor.lnum, (char *)pnew, false);
|
ml_replace(curwin->w_cursor.lnum, pnew, false);
|
||||||
// remove the space later
|
// remove the space later
|
||||||
did_add_space = true;
|
did_add_space = true;
|
||||||
} else {
|
} else {
|
||||||
@ -1026,7 +1026,7 @@ void format_lines(linenr_T line_count, bool avoid_fex)
|
|||||||
// paragraph doesn't really end.
|
// paragraph doesn't really end.
|
||||||
if (next_leader_flags == NULL
|
if (next_leader_flags == NULL
|
||||||
|| STRNCMP(next_leader_flags, "://", 3) != 0
|
|| STRNCMP(next_leader_flags, "://", 3) != 0
|
||||||
|| check_linecomment((char *)get_cursor_line_ptr()) == MAXCOL) {
|
|| check_linecomment(get_cursor_line_ptr()) == MAXCOL) {
|
||||||
is_end_par = true;
|
is_end_par = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1032,7 +1032,7 @@ int current_block(oparg_T *oap, long count, bool include, int what, int other)
|
|||||||
/// @return true if the cursor is on a "<aaa>" tag. Ignore "<aaa/>".
|
/// @return true if the cursor is on a "<aaa>" tag. Ignore "<aaa/>".
|
||||||
static bool in_html_tag(bool end_tag)
|
static bool in_html_tag(bool end_tag)
|
||||||
{
|
{
|
||||||
char_u *line = get_cursor_line_ptr();
|
char_u *line = (char_u *)get_cursor_line_ptr();
|
||||||
char_u *p;
|
char_u *p;
|
||||||
int c;
|
int c;
|
||||||
int lc = NUL;
|
int lc = NUL;
|
||||||
@ -1493,7 +1493,7 @@ static int find_prev_quote(char_u *line, int col_start, int quotechar, char_u *e
|
|||||||
bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
|
bool current_quote(oparg_T *oap, long count, bool include, int quotechar)
|
||||||
FUNC_ATTR_NONNULL_ALL
|
FUNC_ATTR_NONNULL_ALL
|
||||||
{
|
{
|
||||||
char_u *line = get_cursor_line_ptr();
|
char_u *line = (char_u *)get_cursor_line_ptr();
|
||||||
int col_end;
|
int col_end;
|
||||||
int col_start = curwin->w_cursor.col;
|
int col_start = curwin->w_cursor.col;
|
||||||
bool inclusive = false;
|
bool inclusive = false;
|
||||||
|
@ -66,8 +66,6 @@
|
|||||||
#include "nvim/viml/parser/expressions.h"
|
#include "nvim/viml/parser/expressions.h"
|
||||||
#include "nvim/viml/parser/parser.h"
|
#include "nvim/viml/parser/parser.h"
|
||||||
|
|
||||||
#define VIM_STR2NR(s, ...) vim_str2nr((const char_u *)(s), __VA_ARGS__)
|
|
||||||
|
|
||||||
typedef kvec_withinit_t(ExprASTNode **, 16) ExprASTStack;
|
typedef kvec_withinit_t(ExprASTNode **, 16) ExprASTStack;
|
||||||
|
|
||||||
/// Which nodes may be wanted
|
/// Which nodes may be wanted
|
||||||
@ -371,7 +369,7 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags)
|
|||||||
significand_part = significand_part * 10 + (pline.data[i] - '0');
|
significand_part = significand_part * 10 + (pline.data[i] - '0');
|
||||||
}
|
}
|
||||||
if (exp_start) {
|
if (exp_start) {
|
||||||
VIM_STR2NR(pline.data + exp_start, NULL, NULL, 0, NULL, &exp_part,
|
vim_str2nr(pline.data + exp_start, NULL, NULL, 0, NULL, &exp_part,
|
||||||
(int)(ret.len - exp_start), false);
|
(int)(ret.len - exp_start), false);
|
||||||
}
|
}
|
||||||
if (exp_negative) {
|
if (exp_negative) {
|
||||||
@ -389,7 +387,7 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags)
|
|||||||
} else {
|
} else {
|
||||||
int len;
|
int len;
|
||||||
int prep;
|
int prep;
|
||||||
VIM_STR2NR(pline.data, &prep, &len, STR2NR_ALL, NULL,
|
vim_str2nr(pline.data, &prep, &len, STR2NR_ALL, NULL,
|
||||||
&ret.data.num.val.integer, (int)pline.size, false);
|
&ret.data.num.val.integer, (int)pline.size, false);
|
||||||
ret.len = (size_t)len;
|
ret.len = (size_t)len;
|
||||||
const uint8_t bases[] = {
|
const uint8_t bases[] = {
|
||||||
@ -696,8 +694,7 @@ LexExprToken viml_pexpr_next_token(ParserState *const pstate, const int flags)
|
|||||||
|
|
||||||
// Everything else is not valid.
|
// Everything else is not valid.
|
||||||
default:
|
default:
|
||||||
ret.len = (size_t)utfc_ptr2len_len((const char_u *)pline.data,
|
ret.len = (size_t)utfc_ptr2len_len(pline.data, (int)pline.size);
|
||||||
(int)pline.size);
|
|
||||||
ret.type = kExprLexInvalid;
|
ret.type = kExprLexInvalid;
|
||||||
ret.data.err.type = kExprLexPlainIdentifier;
|
ret.data.err.type = kExprLexPlainIdentifier;
|
||||||
ret.data.err.msg = _("E15: Unidentified character: %.*s");
|
ret.data.err.msg = _("E15: Unidentified character: %.*s");
|
||||||
|
@ -6524,7 +6524,7 @@ char_u *grab_file_name(long count, linenr_T *file_lnum)
|
|||||||
|
|
||||||
*file_lnum = (linenr_T)getdigits_long(&p, false, 0);
|
*file_lnum = (linenr_T)getdigits_long(&p, false, 0);
|
||||||
}
|
}
|
||||||
return find_file_name_in_path((char_u *)ptr, len, options, count, (char_u *)curbuf->b_ffname);
|
return (char_u *)find_file_name_in_path(ptr, len, options, count, curbuf->b_ffname);
|
||||||
}
|
}
|
||||||
return file_name_at_cursor(options | FNAME_HYP, count, file_lnum);
|
return file_name_at_cursor(options | FNAME_HYP, count, file_lnum);
|
||||||
}
|
}
|
||||||
@ -6544,7 +6544,7 @@ char_u *grab_file_name(long count, linenr_T *file_lnum)
|
|||||||
*/
|
*/
|
||||||
char_u *file_name_at_cursor(int options, long count, linenr_T *file_lnum)
|
char_u *file_name_at_cursor(int options, long count, linenr_T *file_lnum)
|
||||||
{
|
{
|
||||||
return file_name_in_line(get_cursor_line_ptr(),
|
return file_name_in_line((char_u *)get_cursor_line_ptr(),
|
||||||
curwin->w_cursor.col, options, count, (char_u *)curbuf->b_ffname,
|
curwin->w_cursor.col, options, count, (char_u *)curbuf->b_ffname,
|
||||||
file_lnum);
|
file_lnum);
|
||||||
}
|
}
|
||||||
@ -6651,7 +6651,7 @@ char_u *file_name_in_line(char_u *line, int col, int options, long count, char_u
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return find_file_name_in_path((char_u *)ptr, len, options, count, rel_fname);
|
return (char_u *)find_file_name_in_path(ptr, len, options, count, (char *)rel_fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add or remove a status line from window(s), according to the
|
/// Add or remove a status line from window(s), according to the
|
||||||
|
Loading…
Reference in New Issue
Block a user