mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
parent
6aefae8c4e
commit
22311457ab
@ -6398,8 +6398,10 @@ stuff_inserted (
|
|||||||
/* may want to stuff the command character, to start Insert mode */
|
/* may want to stuff the command character, to start Insert mode */
|
||||||
if (c != NUL)
|
if (c != NUL)
|
||||||
stuffcharReadbuff(c);
|
stuffcharReadbuff(c);
|
||||||
if ((esc_ptr = (char_u *)vim_strrchr(ptr, ESC)) != NULL)
|
if ((esc_ptr = STRRCHR(ptr, ESC)) != NULL) {
|
||||||
*esc_ptr = NUL; /* remove the ESC */
|
// remove the ESC.
|
||||||
|
*esc_ptr = NUL;
|
||||||
|
}
|
||||||
|
|
||||||
/* when the last char is either "0" or "^" it will be quoted if no ESC
|
/* when the last char is either "0" or "^" it will be quoted if no ESC
|
||||||
* comes after it OR if it will inserted more than once and "ptr"
|
* comes after it OR if it will inserted more than once and "ptr"
|
||||||
|
@ -307,9 +307,12 @@ static int linelen(int *has_tab)
|
|||||||
;
|
;
|
||||||
save = *last;
|
save = *last;
|
||||||
*last = NUL;
|
*last = NUL;
|
||||||
len = linetabsize(line); /* get line length */
|
// Get line length.
|
||||||
if (has_tab != NULL) /* check for embedded TAB */
|
len = linetabsize(line);
|
||||||
*has_tab = (vim_strrchr(first, TAB) != NULL);
|
// Check for embedded TAB.
|
||||||
|
if (has_tab != NULL) {
|
||||||
|
*has_tab = STRRCHR(first, TAB) != NULL;
|
||||||
|
}
|
||||||
*last = save;
|
*last = save;
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
@ -5016,8 +5019,8 @@ void fix_help_buffer(void)
|
|||||||
if (fnamencmp(f1, f2, t1 - f1) != 0) {
|
if (fnamencmp(f1, f2, t1 - f1) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const char_u *const e1 = vim_strrchr(t1, '.');
|
const char_u *const e1 = STRRCHR(t1, '.');
|
||||||
const char_u *const e2 = vim_strrchr(path_tail(f2), '.');
|
const char_u *const e2 = STRRCHR(path_tail(f2), '.');
|
||||||
if (e1 == NULL || e2 == NULL) {
|
if (e1 == NULL || e2 == NULL) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -8607,11 +8607,14 @@ eval_vars (
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
resultlen = STRLEN(result); /* length of new string */
|
// Length of new string.
|
||||||
if (src[*usedlen] == '<') { /* remove the file name extension */
|
resultlen = STRLEN(result);
|
||||||
++*usedlen;
|
// Remove the file name extension.
|
||||||
if ((s = vim_strrchr(result, '.')) != NULL && s >= path_tail(result))
|
if (src[*usedlen] == '<') {
|
||||||
|
(*usedlen)++;
|
||||||
|
if ((s = STRRCHR(result, '.')) != NULL && s >= path_tail(result)) {
|
||||||
resultlen = (size_t)(s - result);
|
resultlen = (size_t)(s - result);
|
||||||
|
}
|
||||||
} else if (!skip_mod) {
|
} else if (!skip_mod) {
|
||||||
valid |= modify_fname(src, usedlen, &result, &resultbuf, &resultlen);
|
valid |= modify_fname(src, usedlen, &result, &resultbuf, &resultlen);
|
||||||
if (result == NULL) {
|
if (result == NULL) {
|
||||||
|
@ -1770,7 +1770,7 @@ void path_fix_case(char_u *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Open the directory where the file is located.
|
// Open the directory where the file is located.
|
||||||
char_u *slash = vim_strrchr(name, '/');
|
char_u *slash = STRRCHR(name, '/');
|
||||||
char_u *tail;
|
char_u *tail;
|
||||||
Directory dir;
|
Directory dir;
|
||||||
bool ok;
|
bool ok;
|
||||||
@ -2213,10 +2213,10 @@ static int path_to_absolute(const char_u *fname, char_u *buf, size_t len,
|
|||||||
|
|
||||||
// expand it if forced or not an absolute path
|
// expand it if forced or not an absolute path
|
||||||
if (force || !path_is_absolute(fname)) {
|
if (force || !path_is_absolute(fname)) {
|
||||||
p = vim_strrchr(fname, '/');
|
p = STRRCHR(fname, '/');
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
p = vim_strrchr(fname, '\\');
|
p = STRRCHR(fname, '\\');
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
|
@ -880,9 +880,10 @@ void suggest_load_files(void)
|
|||||||
// don't try again and again.
|
// don't try again and again.
|
||||||
slang->sl_sugloaded = true;
|
slang->sl_sugloaded = true;
|
||||||
|
|
||||||
dotp = vim_strrchr(slang->sl_fname, '.');
|
dotp = STRRCHR(slang->sl_fname, '.');
|
||||||
if (dotp == NULL || fnamecmp(dotp, ".spl") != 0)
|
if (dotp == NULL || fnamecmp(dotp, ".spl") != 0) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
STRCPY(dotp, ".sug");
|
STRCPY(dotp, ".sug");
|
||||||
fd = mch_fopen((char *)slang->sl_fname, "r");
|
fd = mch_fopen((char *)slang->sl_fname, "r");
|
||||||
if (fd == NULL)
|
if (fd == NULL)
|
||||||
|
@ -455,25 +455,6 @@ char_u *vim_strchr(const char_u *const string, const int c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Search for last occurrence of "c" in "string".
|
|
||||||
* Return NULL if not found.
|
|
||||||
* Does not handle multi-byte char for "c"!
|
|
||||||
*/
|
|
||||||
char_u *vim_strrchr(const char_u *string, int c)
|
|
||||||
FUNC_ATTR_NONNULL_ALL FUNC_ATTR_PURE
|
|
||||||
{
|
|
||||||
const char_u *retval = NULL;
|
|
||||||
const char_u *p = string;
|
|
||||||
|
|
||||||
while (*p) {
|
|
||||||
if (*p == c)
|
|
||||||
retval = p;
|
|
||||||
MB_PTR_ADV(p);
|
|
||||||
}
|
|
||||||
return (char_u *) retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sort an array of strings.
|
* Sort an array of strings.
|
||||||
*/
|
*/
|
||||||
|
@ -207,7 +207,7 @@ enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext()
|
|||||||
|
|
||||||
|
|
||||||
// defines to avoid typecasts from (char_u *) to (char *) and back
|
// defines to avoid typecasts from (char_u *) to (char *) and back
|
||||||
// (vim_strchr() and vim_strrchr() are now in alloc.c)
|
// (vim_strchr() is now in strings.c)
|
||||||
|
|
||||||
#define STRLEN(s) strlen((char *)(s))
|
#define STRLEN(s) strlen((char *)(s))
|
||||||
#define STRCPY(d, s) strcpy((char *)(d), (char *)(s))
|
#define STRCPY(d, s) strcpy((char *)(d), (char *)(s))
|
||||||
@ -238,6 +238,8 @@ enum { FOLD_TEXT_LEN = 51 }; //!< buffer size for get_foldtext()
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define STRRCHR(s, c) (char_u *)strrchr((const char *)(s), (c))
|
||||||
|
|
||||||
#define STRCAT(d, s) strcat((char *)(d), (char *)(s))
|
#define STRCAT(d, s) strcat((char *)(d), (char *)(s))
|
||||||
#define STRNCAT(d, s, n) strncat((char *)(d), (char *)(s), (size_t)(n))
|
#define STRNCAT(d, s, n) strncat((char *)(d), (char *)(s), (size_t)(n))
|
||||||
#define STRLCAT(d, s, n) xstrlcat((char *)(d), (char *)(s), (size_t)(n))
|
#define STRLCAT(d, s, n) xstrlcat((char *)(d), (char *)(s), (size_t)(n))
|
||||||
|
Loading…
Reference in New Issue
Block a user