mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #2418: Remove char_u (4)
Reviewed-by: Scott Prager <splinterofchaos@gmail.com> Reviewed-by: Michael Reed <m.reed@mykolab.com> Reviewed-by: Eliseo Martínez <eliseomarmol@gmail.com>
This commit is contained in:
commit
7086d435e0
@ -808,7 +808,7 @@ static void diff_file(char_u *tmp_orig, char_u *tmp_new, char_u *tmp_diff)
|
|||||||
|
|
||||||
/* We don't want $DIFF_OPTIONS to get in the way. */
|
/* We don't want $DIFF_OPTIONS to get in the way. */
|
||||||
if (os_getenv("DIFF_OPTIONS")) {
|
if (os_getenv("DIFF_OPTIONS")) {
|
||||||
vim_setenv((char_u *)"DIFF_OPTIONS", (char_u *)"");
|
vim_setenv("DIFF_OPTIONS", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Build the diff command and execute it. Always use -a, binary
|
/* Build the diff command and execute it. Always use -a, binary
|
||||||
|
@ -1751,17 +1751,15 @@ ex_let_one (
|
|||||||
name[len] = NUL;
|
name[len] = NUL;
|
||||||
p = get_tv_string_chk(tv);
|
p = get_tv_string_chk(tv);
|
||||||
if (p != NULL && op != NULL && *op == '.') {
|
if (p != NULL && op != NULL && *op == '.') {
|
||||||
bool mustfree = false;
|
char *s = vim_getenv((char *)name);
|
||||||
char_u *s = vim_getenv(name, &mustfree);
|
|
||||||
|
|
||||||
if (s != NULL) {
|
if (s != NULL) {
|
||||||
p = tofree = concat_str(s, p);
|
p = tofree = concat_str((char_u *)s, p);
|
||||||
if (mustfree)
|
|
||||||
xfree(s);
|
xfree(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
vim_setenv(name, p);
|
vim_setenv((char *)name, (char *)p);
|
||||||
if (STRICMP(name, "HOME") == 0)
|
if (STRICMP(name, "HOME") == 0)
|
||||||
init_homedir();
|
init_homedir();
|
||||||
else if (didset_vim && STRICMP(name, "VIM") == 0)
|
else if (didset_vim && STRICMP(name, "VIM") == 0)
|
||||||
@ -6357,7 +6355,6 @@ static int get_env_tv(char_u **arg, typval_T *rettv, int evaluate)
|
|||||||
{
|
{
|
||||||
char_u *name;
|
char_u *name;
|
||||||
char_u *string = NULL;
|
char_u *string = NULL;
|
||||||
bool mustfree = false;
|
|
||||||
int len;
|
int len;
|
||||||
int cc;
|
int cc;
|
||||||
|
|
||||||
@ -6372,15 +6369,9 @@ static int get_env_tv(char_u **arg, typval_T *rettv, int evaluate)
|
|||||||
cc = name[len];
|
cc = name[len];
|
||||||
name[len] = NUL;
|
name[len] = NUL;
|
||||||
// First try vim_getenv(), fast for normal environment vars.
|
// First try vim_getenv(), fast for normal environment vars.
|
||||||
string = vim_getenv(name, &mustfree);
|
string = (char_u *)vim_getenv((char *)name);
|
||||||
if (string != NULL && *string != NUL) {
|
if (string == NULL || *string == NUL) {
|
||||||
if (!mustfree) {
|
|
||||||
string = vim_strsave(string);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (mustfree) {
|
|
||||||
xfree(string);
|
xfree(string);
|
||||||
}
|
|
||||||
|
|
||||||
// Next try expanding things like $VIM and ${HOME}.
|
// Next try expanding things like $VIM and ${HOME}.
|
||||||
string = expand_env_save(name - 1);
|
string = expand_env_save(name - 1);
|
||||||
@ -12417,7 +12408,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv)
|
|||||||
is_relative_to_current = TRUE;
|
is_relative_to_current = TRUE;
|
||||||
|
|
||||||
len = STRLEN(p);
|
len = STRLEN(p);
|
||||||
if (len > 0 && after_pathsep(p, p + len)) {
|
if (len > 0 && after_pathsep((char *)p, (char *)p + len)) {
|
||||||
has_trailing_pathsep = TRUE;
|
has_trailing_pathsep = TRUE;
|
||||||
p[len - 1] = NUL; /* the trailing slash breaks readlink() */
|
p[len - 1] = NUL; /* the trailing slash breaks readlink() */
|
||||||
}
|
}
|
||||||
@ -12531,7 +12522,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv)
|
|||||||
* if the argument had none. But keep "/" or "//". */
|
* if the argument had none. But keep "/" or "//". */
|
||||||
if (!has_trailing_pathsep) {
|
if (!has_trailing_pathsep) {
|
||||||
q = p + STRLEN(p);
|
q = p + STRLEN(p);
|
||||||
if (after_pathsep(p, q))
|
if (after_pathsep((char *)p, (char *)q))
|
||||||
*path_tail_with_sep(p) = NUL;
|
*path_tail_with_sep(p) = NUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -19929,7 +19920,7 @@ repeat:
|
|||||||
valid |= VALID_HEAD;
|
valid |= VALID_HEAD;
|
||||||
*usedlen += 2;
|
*usedlen += 2;
|
||||||
s = get_past_head(*fnamep);
|
s = get_past_head(*fnamep);
|
||||||
while (tail > s && after_pathsep(s, tail))
|
while (tail > s && after_pathsep((char *)s, (char *)tail))
|
||||||
mb_ptr_back(*fnamep, tail);
|
mb_ptr_back(*fnamep, tail);
|
||||||
*fnamelen = (int)(tail - *fnamep);
|
*fnamelen = (int)(tail - *fnamep);
|
||||||
if (*fnamelen == 0) {
|
if (*fnamelen == 0) {
|
||||||
@ -19938,7 +19929,7 @@ repeat:
|
|||||||
*bufp = *fnamep = tail = vim_strsave((char_u *)".");
|
*bufp = *fnamep = tail = vim_strsave((char_u *)".");
|
||||||
*fnamelen = 1;
|
*fnamelen = 1;
|
||||||
} else {
|
} else {
|
||||||
while (tail > s && !after_pathsep(s, tail))
|
while (tail > s && !after_pathsep((char *)s, (char *)tail))
|
||||||
mb_ptr_back(*fnamep, tail);
|
mb_ptr_back(*fnamep, tail);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5061,7 +5061,6 @@ void fix_help_buffer(void)
|
|||||||
char_u *fname;
|
char_u *fname;
|
||||||
char_u *p;
|
char_u *p;
|
||||||
char_u *rt;
|
char_u *rt;
|
||||||
bool mustfree;
|
|
||||||
|
|
||||||
/* set filetype to "help". */
|
/* set filetype to "help". */
|
||||||
set_option_value((char_u *)"ft", 0L, (char_u *)"help", OPT_LOCAL);
|
set_option_value((char_u *)"ft", 0L, (char_u *)"help", OPT_LOCAL);
|
||||||
@ -5116,8 +5115,7 @@ void fix_help_buffer(void)
|
|||||||
p = p_rtp;
|
p = p_rtp;
|
||||||
while (*p != NUL) {
|
while (*p != NUL) {
|
||||||
copy_option_part(&p, NameBuff, MAXPATHL, ",");
|
copy_option_part(&p, NameBuff, MAXPATHL, ",");
|
||||||
mustfree = FALSE;
|
rt = (char_u *)vim_getenv("VIMRUNTIME");
|
||||||
rt = vim_getenv((char_u *)"VIMRUNTIME", &mustfree);
|
|
||||||
if (path_full_compare(rt, NameBuff, FALSE) != kEqualFiles) {
|
if (path_full_compare(rt, NameBuff, FALSE) != kEqualFiles) {
|
||||||
int fcount;
|
int fcount;
|
||||||
char_u **fnames;
|
char_u **fnames;
|
||||||
@ -5242,7 +5240,6 @@ void fix_help_buffer(void)
|
|||||||
FreeWild(fcount, fnames);
|
FreeWild(fcount, fnames);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mustfree)
|
|
||||||
xfree(rt);
|
xfree(rt);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2970,26 +2970,26 @@ static char *get_locale_val(int what)
|
|||||||
* Obtain the current messages language. Used to set the default for
|
* Obtain the current messages language. Used to set the default for
|
||||||
* 'helplang'. May return NULL or an empty string.
|
* 'helplang'. May return NULL or an empty string.
|
||||||
*/
|
*/
|
||||||
char_u *get_mess_lang(void)
|
char *get_mess_lang(void)
|
||||||
{
|
{
|
||||||
char_u *p;
|
char *p;
|
||||||
|
|
||||||
# ifdef HAVE_GET_LOCALE_VAL
|
# ifdef HAVE_GET_LOCALE_VAL
|
||||||
# if defined(LC_MESSAGES)
|
# if defined(LC_MESSAGES)
|
||||||
p = (char_u *)get_locale_val(LC_MESSAGES);
|
p = get_locale_val(LC_MESSAGES);
|
||||||
# else
|
# else
|
||||||
/* This is necessary for Win32, where LC_MESSAGES is not defined and $LANG
|
/* This is necessary for Win32, where LC_MESSAGES is not defined and $LANG
|
||||||
* may be set to the LCID number. LC_COLLATE is the best guess, LC_TIME
|
* may be set to the LCID number. LC_COLLATE is the best guess, LC_TIME
|
||||||
* and LC_MONETARY may be set differently for a Japanese working in the
|
* and LC_MONETARY may be set differently for a Japanese working in the
|
||||||
* US. */
|
* US. */
|
||||||
p = (char_u *)get_locale_val(LC_COLLATE);
|
p = get_locale_val(LC_COLLATE);
|
||||||
# endif
|
# endif
|
||||||
# else
|
# else
|
||||||
p = os_getenv((char_u *)"LC_ALL");
|
p = os_getenv("LC_ALL");
|
||||||
if (p == NULL || *p == NUL) {
|
if (p == NULL || *p == NUL) {
|
||||||
p = os_getenv((char_u *)"LC_MESSAGES");
|
p = os_getenv("LC_MESSAGES");
|
||||||
if (p == NULL || *p == NUL)
|
if (p == NULL || *p == NUL)
|
||||||
p = os_getenv((char_u *)"LANG");
|
p = os_getenv("LANG");
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
return p;
|
return p;
|
||||||
@ -3127,22 +3127,20 @@ void ex_language(exarg_T *eap)
|
|||||||
++_nl_msg_cat_cntr;
|
++_nl_msg_cat_cntr;
|
||||||
#endif
|
#endif
|
||||||
/* Reset $LC_ALL, otherwise it would overrule everything. */
|
/* Reset $LC_ALL, otherwise it would overrule everything. */
|
||||||
vim_setenv((char_u *)"LC_ALL", (char_u *)"");
|
vim_setenv("LC_ALL", "");
|
||||||
|
|
||||||
if (what != LC_TIME) {
|
if (what != LC_TIME) {
|
||||||
/* Tell gettext() what to translate to. It apparently doesn't
|
/* Tell gettext() what to translate to. It apparently doesn't
|
||||||
* use the currently effective locale. */
|
* use the currently effective locale. */
|
||||||
if (what == LC_ALL) {
|
if (what == LC_ALL) {
|
||||||
vim_setenv((char_u *)"LANG", name);
|
vim_setenv("LANG", (char *)name);
|
||||||
|
|
||||||
/* Clear $LANGUAGE because GNU gettext uses it. */
|
/* Clear $LANGUAGE because GNU gettext uses it. */
|
||||||
vim_setenv((char_u *)"LANGUAGE", (char_u *)"");
|
vim_setenv("LANGUAGE", "");
|
||||||
}
|
}
|
||||||
if (what != LC_CTYPE) {
|
if (what != LC_CTYPE) {
|
||||||
char_u *mname;
|
vim_setenv("LC_MESSAGES", (char *)name);
|
||||||
mname = name;
|
set_helplang_default((char *)name);
|
||||||
vim_setenv((char_u *)"LC_MESSAGES", mname);
|
|
||||||
set_helplang_default(mname);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3825,7 +3825,6 @@ static void expand_shellcmd(char_u *filepat, int *num_file, char_u ***file,
|
|||||||
char_u *pat;
|
char_u *pat;
|
||||||
int i;
|
int i;
|
||||||
char_u *path;
|
char_u *path;
|
||||||
bool mustfree = false;
|
|
||||||
garray_T ga;
|
garray_T ga;
|
||||||
char_u *buf = xmalloc(MAXPATHL);
|
char_u *buf = xmalloc(MAXPATHL);
|
||||||
size_t l;
|
size_t l;
|
||||||
@ -3849,7 +3848,7 @@ static void expand_shellcmd(char_u *filepat, int *num_file, char_u ***file,
|
|||||||
|| (pat[1] == '.' && vim_ispathsep(pat[2])))))
|
|| (pat[1] == '.' && vim_ispathsep(pat[2])))))
|
||||||
path = (char_u *)".";
|
path = (char_u *)".";
|
||||||
else {
|
else {
|
||||||
path = vim_getenv((char_u *)"PATH", &mustfree);
|
path = (char_u *)vim_getenv("PATH");
|
||||||
if (path == NULL)
|
if (path == NULL)
|
||||||
path = (char_u *)"";
|
path = (char_u *)"";
|
||||||
}
|
}
|
||||||
@ -3900,7 +3899,6 @@ static void expand_shellcmd(char_u *filepat, int *num_file, char_u ***file,
|
|||||||
|
|
||||||
xfree(buf);
|
xfree(buf);
|
||||||
xfree(pat);
|
xfree(pat);
|
||||||
if (mustfree)
|
|
||||||
xfree(path);
|
xfree(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -422,7 +422,7 @@ readfile (
|
|||||||
*/
|
*/
|
||||||
if (fname != NULL && *fname != NUL) {
|
if (fname != NULL && *fname != NUL) {
|
||||||
p = fname + STRLEN(fname);
|
p = fname + STRLEN(fname);
|
||||||
if (after_pathsep(fname, p) || STRLEN(fname) >= MAXPATHL) {
|
if (after_pathsep((char *)fname, (char *)p) || STRLEN(fname) >= MAXPATHL) {
|
||||||
filemess(curbuf, fname, (char_u *)_("Illegal file name"), 0);
|
filemess(curbuf, fname, (char_u *)_("Illegal file name"), 0);
|
||||||
msg_end();
|
msg_end();
|
||||||
msg_scroll = msg_save;
|
msg_scroll = msg_save;
|
||||||
@ -4369,7 +4369,7 @@ modname (
|
|||||||
xfree(retval);
|
xfree(retval);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (!after_pathsep(retval, retval + fnamelen)) {
|
if (!after_pathsep((char *)retval, (char *)retval + fnamelen)) {
|
||||||
retval[fnamelen++] = PATHSEP;
|
retval[fnamelen++] = PATHSEP;
|
||||||
retval[fnamelen] = NUL;
|
retval[fnamelen] = NUL;
|
||||||
}
|
}
|
||||||
|
@ -829,17 +829,15 @@ static void init_locale(void)
|
|||||||
# endif
|
# endif
|
||||||
|
|
||||||
{
|
{
|
||||||
bool mustfree = false;
|
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
/* expand_env() doesn't work yet, because chartab[] is not initialized
|
/* expand_env() doesn't work yet, because chartab[] is not initialized
|
||||||
* yet, call vim_getenv() directly */
|
* yet, call vim_getenv() directly */
|
||||||
p = vim_getenv((char_u *)"VIMRUNTIME", &mustfree);
|
p = (char_u *)vim_getenv("VIMRUNTIME");
|
||||||
if (p != NULL && *p != NUL) {
|
if (p != NULL && *p != NUL) {
|
||||||
vim_snprintf((char *)NameBuff, MAXPATHL, "%s/lang", p);
|
vim_snprintf((char *)NameBuff, MAXPATHL, "%s/lang", p);
|
||||||
bindtextdomain(VIMPACKAGE, (char *)NameBuff);
|
bindtextdomain(VIMPACKAGE, (char *)NameBuff);
|
||||||
}
|
}
|
||||||
if (mustfree)
|
|
||||||
xfree(p);
|
xfree(p);
|
||||||
textdomain(VIMPACKAGE);
|
textdomain(VIMPACKAGE);
|
||||||
}
|
}
|
||||||
|
@ -1340,7 +1340,7 @@ recover_names (
|
|||||||
num_names = 3;
|
num_names = 3;
|
||||||
} else {
|
} else {
|
||||||
p = dir_name + STRLEN(dir_name);
|
p = dir_name + STRLEN(dir_name);
|
||||||
if (after_pathsep(dir_name, p) && p[-1] == p[-2]) {
|
if (after_pathsep((char *)dir_name, (char *)p) && p[-1] == p[-2]) {
|
||||||
/* Ends with '//', Use Full path for swap name */
|
/* Ends with '//', Use Full path for swap name */
|
||||||
tail = make_percent_swname(dir_name, fname_res);
|
tail = make_percent_swname(dir_name, fname_res);
|
||||||
} else {
|
} else {
|
||||||
@ -3066,7 +3066,7 @@ char_u *makeswapname(char_u *fname, char_u *ffname, buf_T *buf, char_u *dir_name
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
s = dir_name + STRLEN(dir_name);
|
s = dir_name + STRLEN(dir_name);
|
||||||
if (after_pathsep(dir_name, s) && s[-1] == s[-2]) { /* Ends with '//', Use Full path */
|
if (after_pathsep((char *)dir_name, (char *)s) && s[-1] == s[-2]) { /* Ends with '//', Use Full path */
|
||||||
r = NULL;
|
r = NULL;
|
||||||
if ((s = make_percent_swname(dir_name, fname)) != NULL) {
|
if ((s = make_percent_swname(dir_name, fname)) != NULL) {
|
||||||
r = modname(s, (char_u *)".swp", FALSE);
|
r = modname(s, (char_u *)".swp", FALSE);
|
||||||
|
@ -1804,19 +1804,20 @@ void set_init_1(void)
|
|||||||
# endif
|
# endif
|
||||||
int len;
|
int len;
|
||||||
garray_T ga;
|
garray_T ga;
|
||||||
bool mustfree;
|
|
||||||
|
|
||||||
ga_init(&ga, 1, 100);
|
ga_init(&ga, 1, 100);
|
||||||
for (size_t n = 0; n < ARRAY_SIZE(names); ++n) {
|
for (size_t n = 0; n < ARRAY_SIZE(names); ++n) {
|
||||||
mustfree = FALSE;
|
bool mustfree = true;
|
||||||
# ifdef UNIX
|
# ifdef UNIX
|
||||||
if (*names[n] == NUL)
|
if (*names[n] == NUL) {
|
||||||
p = (char_u *)"/tmp";
|
p = (char_u *)"/tmp";
|
||||||
|
mustfree = false;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
# endif
|
# endif
|
||||||
p = vim_getenv((char_u *)names[n], &mustfree);
|
p = (char_u *)vim_getenv(names[n]);
|
||||||
if (p != NULL && *p != NUL) {
|
if (p != NULL && *p != NUL) {
|
||||||
/* First time count the NUL, otherwise count the ','. */
|
// First time count the NUL, otherwise count the ','.
|
||||||
len = (int)STRLEN(p) + 3;
|
len = (int)STRLEN(p) + 3;
|
||||||
ga_grow(&ga, len);
|
ga_grow(&ga, len);
|
||||||
if (!GA_EMPTY(&ga))
|
if (!GA_EMPTY(&ga))
|
||||||
@ -1826,9 +1827,10 @@ void set_init_1(void)
|
|||||||
STRCAT(ga.ga_data, "*");
|
STRCAT(ga.ga_data, "*");
|
||||||
ga.ga_len += len;
|
ga.ga_len += len;
|
||||||
}
|
}
|
||||||
if (mustfree)
|
if(mustfree) {
|
||||||
xfree(p);
|
xfree(p);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (ga.ga_data != NULL) {
|
if (ga.ga_data != NULL) {
|
||||||
set_string_default("bsk", ga.ga_data);
|
set_string_default("bsk", ga.ga_data);
|
||||||
xfree(ga.ga_data);
|
xfree(ga.ga_data);
|
||||||
@ -1861,10 +1863,9 @@ void set_init_1(void)
|
|||||||
char_u *buf;
|
char_u *buf;
|
||||||
int i;
|
int i;
|
||||||
int j;
|
int j;
|
||||||
bool mustfree = false;
|
|
||||||
|
|
||||||
/* Initialize the 'cdpath' option's default value. */
|
/* Initialize the 'cdpath' option's default value. */
|
||||||
cdpath = vim_getenv((char_u *)"CDPATH", &mustfree);
|
cdpath = (char_u *)vim_getenv("CDPATH");
|
||||||
if (cdpath != NULL) {
|
if (cdpath != NULL) {
|
||||||
buf = xmalloc(2 * STRLEN(cdpath) + 2);
|
buf = xmalloc(2 * STRLEN(cdpath) + 2);
|
||||||
{
|
{
|
||||||
@ -1887,7 +1888,6 @@ void set_init_1(void)
|
|||||||
} else
|
} else
|
||||||
xfree(buf); /* cannot happen */
|
xfree(buf); /* cannot happen */
|
||||||
}
|
}
|
||||||
if (mustfree)
|
|
||||||
xfree(cdpath);
|
xfree(cdpath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2288,7 +2288,7 @@ void set_init_3(void)
|
|||||||
* When 'helplang' is still at its default value, set it to "lang".
|
* When 'helplang' is still at its default value, set it to "lang".
|
||||||
* Only the first two characters of "lang" are used.
|
* Only the first two characters of "lang" are used.
|
||||||
*/
|
*/
|
||||||
void set_helplang_default(char_u *lang)
|
void set_helplang_default(const char *lang)
|
||||||
{
|
{
|
||||||
int idx;
|
int idx;
|
||||||
|
|
||||||
@ -2298,7 +2298,7 @@ void set_helplang_default(char_u *lang)
|
|||||||
if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) {
|
if (idx >= 0 && !(options[idx].flags & P_WAS_SET)) {
|
||||||
if (options[idx].flags & P_ALLOCED)
|
if (options[idx].flags & P_ALLOCED)
|
||||||
free_string_option(p_hlg);
|
free_string_option(p_hlg);
|
||||||
p_hlg = vim_strsave(lang);
|
p_hlg = (char_u *)xstrdup(lang);
|
||||||
/* zh_CN becomes "cn", zh_TW becomes "tw". */
|
/* zh_CN becomes "cn", zh_TW becomes "tw". */
|
||||||
if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) {
|
if (STRNICMP(p_hlg, "zh_", 3) == 0 && STRLEN(p_hlg) >= 5) {
|
||||||
p_hlg[0] = (char_u)TOLOWER_ASC(p_hlg[3]);
|
p_hlg[0] = (char_u)TOLOWER_ASC(p_hlg[3]);
|
||||||
@ -3644,11 +3644,11 @@ did_set_string_option (
|
|||||||
else if (varp == &p_hf) {
|
else if (varp == &p_hf) {
|
||||||
/* May compute new values for $VIM and $VIMRUNTIME */
|
/* May compute new values for $VIM and $VIMRUNTIME */
|
||||||
if (didset_vim) {
|
if (didset_vim) {
|
||||||
vim_setenv((char_u *)"VIM", (char_u *)"");
|
vim_setenv("VIM", "");
|
||||||
didset_vim = FALSE;
|
didset_vim = FALSE;
|
||||||
}
|
}
|
||||||
if (didset_vimruntime) {
|
if (didset_vimruntime) {
|
||||||
vim_setenv((char_u *)"VIMRUNTIME", (char_u *)"");
|
vim_setenv("VIMRUNTIME", "");
|
||||||
didset_vimruntime = FALSE;
|
didset_vimruntime = FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -7428,22 +7428,22 @@ static void paste_option_changed(void)
|
|||||||
/// When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
|
/// When "fname" is not NULL, use it to set $"envname" when it wasn't set yet.
|
||||||
void vimrc_found(char_u *fname, char_u *envname)
|
void vimrc_found(char_u *fname, char_u *envname)
|
||||||
{
|
{
|
||||||
bool dofree = false;
|
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
if (fname != NULL) {
|
if (fname != NULL) {
|
||||||
p = vim_getenv(envname, &dofree);
|
p = (char_u *)vim_getenv((char *)envname);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
/* Set $MYVIMRC to the first vimrc file found. */
|
/* Set $MYVIMRC to the first vimrc file found. */
|
||||||
p = FullName_save(fname, FALSE);
|
p = FullName_save(fname, FALSE);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
vim_setenv(envname, p);
|
vim_setenv((char *)envname, (char *)p);
|
||||||
xfree(p);
|
xfree(p);
|
||||||
}
|
}
|
||||||
} else if (dofree)
|
} else {
|
||||||
xfree(p);
|
xfree(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return TRUE when option "name" has been set.
|
* Return TRUE when option "name" has been set.
|
||||||
|
@ -215,31 +215,29 @@ void expand_env_esc(char_u *srcp, char_u *dst, int dstlen, bool esc, bool one,
|
|||||||
int c;
|
int c;
|
||||||
char_u *var;
|
char_u *var;
|
||||||
bool copy_char;
|
bool copy_char;
|
||||||
bool mustfree; /* var was allocated, need to free it later */
|
bool mustfree; // var was allocated, need to free it later
|
||||||
bool at_start = true; /* at start of a name */
|
bool at_start = true; // at start of a name
|
||||||
int startstr_len = 0;
|
int startstr_len = 0;
|
||||||
|
|
||||||
if (startstr != NULL)
|
if (startstr != NULL)
|
||||||
startstr_len = (int)STRLEN(startstr);
|
startstr_len = (int)STRLEN(startstr);
|
||||||
|
|
||||||
src = skipwhite(srcp);
|
src = skipwhite(srcp);
|
||||||
--dstlen; /* leave one char space for "\," */
|
--dstlen; // leave one char space for "\,"
|
||||||
while (*src && dstlen > 0) {
|
while (*src && dstlen > 0) {
|
||||||
copy_char = true;
|
copy_char = true;
|
||||||
if ((*src == '$') || (*src == '~' && at_start)) {
|
if ((*src == '$') || (*src == '~' && at_start)) {
|
||||||
mustfree = false;
|
mustfree = false;
|
||||||
|
|
||||||
/*
|
// The variable name is copied into dst temporarily, because it may
|
||||||
* The variable name is copied into dst temporarily, because it may
|
// be a string in read-only memory and a NUL needs to be appended.
|
||||||
* be a string in read-only memory and a NUL needs to be appended.
|
if (*src != '~') { // environment var
|
||||||
*/
|
|
||||||
if (*src != '~') { /* environment var */
|
|
||||||
tail = src + 1;
|
tail = src + 1;
|
||||||
var = dst;
|
var = dst;
|
||||||
c = dstlen - 1;
|
c = dstlen - 1;
|
||||||
|
|
||||||
#ifdef UNIX
|
#ifdef UNIX
|
||||||
/* Unix has ${var-name} type environment vars */
|
// Unix has ${var-name} type environment vars
|
||||||
if (*tail == '{' && !vim_isIDc('{')) {
|
if (*tail == '{' && !vim_isIDc('{')) {
|
||||||
tail++; /* ignore '{' */
|
tail++; /* ignore '{' */
|
||||||
while (c-- > 0 && *tail && *tail != '}')
|
while (c-- > 0 && *tail && *tail != '}')
|
||||||
@ -262,7 +260,8 @@ void expand_env_esc(char_u *srcp, char_u *dst, int dstlen, bool esc, bool one,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
*var = NUL;
|
*var = NUL;
|
||||||
var = vim_getenv(dst, &mustfree);
|
var = (char_u *)vim_getenv((char *)dst);
|
||||||
|
mustfree = true;
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -271,11 +270,9 @@ void expand_env_esc(char_u *srcp, char_u *dst, int dstlen, bool esc, bool one,
|
|||||||
|| vim_strchr((char_u *)" ,\t\n", src[1]) != NULL) {
|
|| vim_strchr((char_u *)" ,\t\n", src[1]) != NULL) {
|
||||||
var = homedir;
|
var = homedir;
|
||||||
tail = src + 1;
|
tail = src + 1;
|
||||||
} else { /* user directory */
|
} else { // user directory
|
||||||
#if defined(UNIX)
|
#if defined(UNIX)
|
||||||
/*
|
// Copy ~user to dst[], so we can put a NUL after it.
|
||||||
* Copy ~user to dst[], so we can put a NUL after it.
|
|
||||||
*/
|
|
||||||
tail = src;
|
tail = src;
|
||||||
var = dst;
|
var = dst;
|
||||||
c = dstlen - 1;
|
c = dstlen - 1;
|
||||||
@ -285,12 +282,10 @@ void expand_env_esc(char_u *srcp, char_u *dst, int dstlen, bool esc, bool one,
|
|||||||
&& !vim_ispathsep(*tail))
|
&& !vim_ispathsep(*tail))
|
||||||
*var++ = *tail++;
|
*var++ = *tail++;
|
||||||
*var = NUL;
|
*var = NUL;
|
||||||
/*
|
// Use os_get_user_directory() to get the user directory.
|
||||||
* Use os_get_user_directory() to get the user directory.
|
// If this function fails, the shell is used to
|
||||||
* If this function fails, the shell is used to
|
// expand ~user. This is slower and may fail if the shell
|
||||||
* expand ~user. This is slower and may fail if the shell
|
// does not support ~user (old versions of /bin/sh).
|
||||||
* does not support ~user (old versions of /bin/sh).
|
|
||||||
*/
|
|
||||||
var = (char_u *)os_get_user_directory((char *)dst + 1);
|
var = (char_u *)os_get_user_directory((char *)dst + 1);
|
||||||
mustfree = true;
|
mustfree = true;
|
||||||
if (var == NULL)
|
if (var == NULL)
|
||||||
@ -304,15 +299,15 @@ void expand_env_esc(char_u *srcp, char_u *dst, int dstlen, bool esc, bool one,
|
|||||||
mustfree = true;
|
mustfree = true;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* cannot expand user's home directory, so don't try */
|
// cannot expand user's home directory, so don't try
|
||||||
var = NULL;
|
var = NULL;
|
||||||
tail = (char_u *)""; /* for gcc */
|
tail = (char_u *)""; // for gcc
|
||||||
#endif /* UNIX */
|
#endif // UNIX
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef BACKSLASH_IN_FILENAME
|
#ifdef BACKSLASH_IN_FILENAME
|
||||||
/* If 'shellslash' is set change backslashes to forward slashes.
|
// If 'shellslash' is set change backslashes to forward slashes.
|
||||||
* Can't use slash_adjust(), p_ssl may be set temporarily. */
|
// Can't use slash_adjust(), p_ssl may be set temporarily.
|
||||||
if (p_ssl && var != NULL && vim_strchr(var, '\\') != NULL) {
|
if (p_ssl && var != NULL && vim_strchr(var, '\\') != NULL) {
|
||||||
char_u *p = vim_strsave(var);
|
char_u *p = vim_strsave(var);
|
||||||
|
|
||||||
@ -325,8 +320,8 @@ void expand_env_esc(char_u *srcp, char_u *dst, int dstlen, bool esc, bool one,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If "var" contains white space, escape it with a backslash.
|
// If "var" contains white space, escape it with a backslash.
|
||||||
* Required for ":e ~/tt" when $HOME includes a space. */
|
// Required for ":e ~/tt" when $HOME includes a space.
|
||||||
if (esc && var != NULL && vim_strpbrk(var, (char_u *)" \t") != NULL) {
|
if (esc && var != NULL && vim_strpbrk(var, (char_u *)" \t") != NULL) {
|
||||||
char_u *p = vim_strsave_escaped(var, (char_u *)" \t");
|
char_u *p = vim_strsave_escaped(var, (char_u *)" \t");
|
||||||
|
|
||||||
@ -341,9 +336,9 @@ void expand_env_esc(char_u *srcp, char_u *dst, int dstlen, bool esc, bool one,
|
|||||||
STRCPY(dst, var);
|
STRCPY(dst, var);
|
||||||
dstlen -= (int)STRLEN(var);
|
dstlen -= (int)STRLEN(var);
|
||||||
c = (int)STRLEN(var);
|
c = (int)STRLEN(var);
|
||||||
/* if var[] ends in a path separator and tail[] starts
|
// if var[] ends in a path separator and tail[] starts
|
||||||
* with it, skip a character */
|
// with it, skip a character
|
||||||
if (*var != NUL && after_pathsep(dst, dst + c)
|
if (*var != NUL && after_pathsep((char *)dst, (char *)dst + c)
|
||||||
#if defined(BACKSLASH_IN_FILENAME)
|
#if defined(BACKSLASH_IN_FILENAME)
|
||||||
&& dst[-1] != ':'
|
&& dst[-1] != ':'
|
||||||
#endif
|
#endif
|
||||||
@ -357,12 +352,10 @@ void expand_env_esc(char_u *srcp, char_u *dst, int dstlen, bool esc, bool one,
|
|||||||
xfree(var);
|
xfree(var);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (copy_char) { /* copy at least one char */
|
if (copy_char) { // copy at least one char
|
||||||
/*
|
// Recognize the start of a new name, for '~'.
|
||||||
* Recognize the start of a new name, for '~'.
|
// Don't do this when "one" is true, to avoid expanding "~" in
|
||||||
* Don't do this when "one" is true, to avoid expanding "~" in
|
// ":edit foo ~ foo".
|
||||||
* ":edit foo ~ foo".
|
|
||||||
*/
|
|
||||||
at_start = false;
|
at_start = false;
|
||||||
if (src[0] == '\\' && src[1] != NUL) {
|
if (src[0] == '\\' && src[1] != NUL) {
|
||||||
*dst++ = *src++;
|
*dst++ = *src++;
|
||||||
@ -384,7 +377,7 @@ void expand_env_esc(char_u *srcp, char_u *dst, int dstlen, bool esc, bool one,
|
|||||||
/// Check if the directory "vimdir/<version>" or "vimdir/runtime" exists.
|
/// Check if the directory "vimdir/<version>" or "vimdir/runtime" exists.
|
||||||
/// Return NULL if not, return its name in allocated memory otherwise.
|
/// Return NULL if not, return its name in allocated memory otherwise.
|
||||||
/// @param vimdir directory to test
|
/// @param vimdir directory to test
|
||||||
static char *vim_version_dir(char *vimdir)
|
static char *vim_version_dir(const char *vimdir)
|
||||||
{
|
{
|
||||||
char_u *p;
|
char_u *p;
|
||||||
|
|
||||||
@ -410,7 +403,7 @@ static char *remove_tail(char *p, char *pend, char *name)
|
|||||||
|
|
||||||
if (newend >= p
|
if (newend >= p
|
||||||
&& fnamencmp((char_u *)newend, (char_u *)name, len - 1) == 0
|
&& fnamencmp((char_u *)newend, (char_u *)name, len - 1) == 0
|
||||||
&& (newend == p || after_pathsep((char_u *)p, (char_u *)newend)))
|
&& (newend == p || after_pathsep(p, newend)))
|
||||||
return newend;
|
return newend;
|
||||||
return pend;
|
return pend;
|
||||||
}
|
}
|
||||||
@ -418,126 +411,112 @@ static char *remove_tail(char *p, char *pend, char *name)
|
|||||||
/// Vim's version of getenv().
|
/// Vim's version of getenv().
|
||||||
/// Special handling of $HOME, $VIM and $VIMRUNTIME, allowing the user to
|
/// Special handling of $HOME, $VIM and $VIMRUNTIME, allowing the user to
|
||||||
/// override the vim runtime directory at runtime. Also does ACP to 'enc'
|
/// override the vim runtime directory at runtime. Also does ACP to 'enc'
|
||||||
/// conversion for Win32.
|
/// conversion for Win32. Results must be freed by the calling function.
|
||||||
/// @param name Name of environment variable to expand
|
/// @param name Name of environment variable to expand
|
||||||
/// @param[out] mustfree Ouput parameter for the caller to determine if they are
|
char *vim_getenv(const char *name)
|
||||||
/// responsible for releasing memory. Must be initialized to false
|
|
||||||
/// by the caller.
|
|
||||||
char_u *vim_getenv(char_u *name, bool *mustfree)
|
|
||||||
{
|
{
|
||||||
char_u *p;
|
const char *kos_env_path = os_getenv(name);
|
||||||
char_u *pend;
|
if (kos_env_path != NULL
|
||||||
int vimruntime;
|
&& *kos_env_path == NUL) { // empty is the same as not set
|
||||||
|
kos_env_path = NULL;
|
||||||
|
|
||||||
p = (char_u *)os_getenv((char *)name);
|
|
||||||
if (p != NULL && *p == NUL) /* empty is the same as not set */
|
|
||||||
p = NULL;
|
|
||||||
|
|
||||||
if (p != NULL) {
|
|
||||||
return p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vimruntime = (STRCMP(name, "VIMRUNTIME") == 0);
|
if (kos_env_path != NULL) {
|
||||||
if (!vimruntime && STRCMP(name, "VIM") != 0)
|
return xstrdup(kos_env_path);
|
||||||
return NULL;
|
}
|
||||||
|
|
||||||
/*
|
bool vimruntime = (strcmp(name, "VIMRUNTIME") == 0);
|
||||||
* When expanding $VIMRUNTIME fails, try using $VIM/vim<version> or $VIM.
|
if (!vimruntime && strcmp(name, "VIM") != 0) {
|
||||||
* Don't do this when default_vimruntime_dir is non-empty.
|
return NULL;
|
||||||
*/
|
}
|
||||||
|
|
||||||
|
// When expanding $VIMRUNTIME fails, try using $VIM/vim<version> or $VIM.
|
||||||
|
// Don't do this when default_vimruntime_dir is non-empty.
|
||||||
|
char *vim_path = NULL;
|
||||||
if (vimruntime
|
if (vimruntime
|
||||||
#ifdef HAVE_PATHDEF
|
#ifdef HAVE_PATHDEF
|
||||||
&& *default_vimruntime_dir == NUL
|
&& *default_vimruntime_dir == NUL
|
||||||
#endif
|
#endif
|
||||||
) {
|
) {
|
||||||
p = (char_u *)os_getenv("VIM");
|
kos_env_path = os_getenv("VIM");
|
||||||
if (p != NULL && *p == NUL) /* empty is the same as not set */
|
if (kos_env_path != NULL
|
||||||
p = NULL;
|
&& *kos_env_path == NUL) { // empty is the same as not set
|
||||||
if (p != NULL) {
|
kos_env_path = NULL;
|
||||||
p = (char_u *)vim_version_dir((char *)p);
|
}
|
||||||
if (p != NULL)
|
if (kos_env_path != NULL) {
|
||||||
*mustfree = true;
|
vim_path = vim_version_dir(kos_env_path);
|
||||||
else
|
if (vim_path == NULL) {
|
||||||
p = (char_u *)os_getenv("VIM");
|
vim_path = xstrdup(kos_env_path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// When expanding $VIM or $VIMRUNTIME fails, try using:
|
||||||
* When expanding $VIM or $VIMRUNTIME fails, try using:
|
// - the directory name from 'helpfile' (unless it contains '$')
|
||||||
* - the directory name from 'helpfile' (unless it contains '$')
|
// - the executable name from argv[0]
|
||||||
* - the executable name from argv[0]
|
if (vim_path == NULL) {
|
||||||
*/
|
if (p_hf != NULL && vim_strchr(p_hf, '$') == NULL) {
|
||||||
if (p == NULL) {
|
vim_path = (char *)p_hf;
|
||||||
if (p_hf != NULL && vim_strchr(p_hf, '$') == NULL)
|
}
|
||||||
p = p_hf;
|
if (vim_path != NULL) {
|
||||||
if (p != NULL) {
|
// remove the file name
|
||||||
/* remove the file name */
|
char *vim_path_end = (char *)path_tail((char_u *)vim_path);
|
||||||
pend = path_tail(p);
|
|
||||||
|
|
||||||
/* remove "doc/" from 'helpfile', if present */
|
// remove "doc/" from 'helpfile', if present
|
||||||
if (p == p_hf)
|
if (vim_path == (char *)p_hf) {
|
||||||
pend = (char_u *)remove_tail((char *)p, (char *)pend, "doc");
|
vim_path_end = remove_tail(vim_path, vim_path_end, "doc");
|
||||||
|
}
|
||||||
|
|
||||||
/* for $VIM, remove "runtime/" or "vim54/", if present */
|
// for $VIM, remove "runtime/" or "vim54/", if present
|
||||||
if (!vimruntime) {
|
if (!vimruntime) {
|
||||||
pend = (char_u *)remove_tail((char *)p, (char *)pend,
|
vim_path_end = remove_tail(vim_path, vim_path_end, RUNTIME_DIRNAME);
|
||||||
RUNTIME_DIRNAME);
|
vim_path_end = remove_tail(vim_path, vim_path_end, VIM_VERSION_NODOT);
|
||||||
pend = (char_u *)remove_tail((char *)p, (char *)pend,
|
|
||||||
VIM_VERSION_NODOT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remove trailing path separator */
|
// remove trailing path separator
|
||||||
if (pend > p && after_pathsep(p, pend))
|
if (vim_path_end > vim_path && after_pathsep(vim_path, vim_path_end)) {
|
||||||
--pend;
|
vim_path_end--;
|
||||||
|
}
|
||||||
|
|
||||||
// check that the result is a directory name
|
// check that the result is a directory name
|
||||||
assert(pend >= p);
|
assert(vim_path_end >= vim_path);
|
||||||
p = vim_strnsave(p, (size_t)(pend - p));
|
vim_path = xstrndup(vim_path, (size_t)(vim_path_end - vim_path));
|
||||||
|
|
||||||
if (!os_isdir(p)) {
|
if (!os_isdir((char_u *)vim_path)) {
|
||||||
xfree(p);
|
xfree(vim_path);
|
||||||
p = NULL;
|
vim_path = NULL;
|
||||||
} else {
|
|
||||||
*mustfree = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_PATHDEF
|
#ifdef HAVE_PATHDEF
|
||||||
/* When there is a pathdef.c file we can use default_vim_dir and
|
// When there is a pathdef.c file we can use default_vim_dir and
|
||||||
* default_vimruntime_dir */
|
// default_vimruntime_dir
|
||||||
if (p == NULL) {
|
if (vim_path == NULL) {
|
||||||
/* Only use default_vimruntime_dir when it is not empty */
|
// Only use default_vimruntime_dir when it is not empty
|
||||||
if (vimruntime && *default_vimruntime_dir != NUL) {
|
if (vimruntime && *default_vimruntime_dir != NUL) {
|
||||||
p = (char_u *)default_vimruntime_dir;
|
vim_path = xstrdup(default_vimruntime_dir);
|
||||||
*mustfree = false;
|
|
||||||
} else if (*default_vim_dir != NUL) {
|
} else if (*default_vim_dir != NUL) {
|
||||||
if (vimruntime
|
if (vimruntime
|
||||||
&& (p = (char_u *)vim_version_dir(default_vim_dir)) != NULL) {
|
&& (vim_path = vim_version_dir(default_vim_dir)) == NULL) {
|
||||||
*mustfree = true;
|
vim_path = xstrdup(default_vim_dir);
|
||||||
} else {
|
|
||||||
p = (char_u *)default_vim_dir;
|
|
||||||
*mustfree = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
// Set the environment variable, so that the new value can be found fast
|
||||||
* Set the environment variable, so that the new value can be found fast
|
// next time, and others can also use it (e.g. Perl).
|
||||||
* next time, and others can also use it (e.g. Perl).
|
if (vim_path != NULL) {
|
||||||
*/
|
|
||||||
if (p != NULL) {
|
|
||||||
if (vimruntime) {
|
if (vimruntime) {
|
||||||
vim_setenv((char_u *)"VIMRUNTIME", p);
|
vim_setenv("VIMRUNTIME", vim_path);
|
||||||
didset_vimruntime = true;
|
didset_vimruntime = true;
|
||||||
} else {
|
} else {
|
||||||
vim_setenv((char_u *)"VIM", p);
|
vim_setenv("VIM", vim_path);
|
||||||
didset_vim = true;
|
didset_vim = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return p;
|
return vim_path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Replace home directory by "~" in each space or comma separated file name in
|
/// Replace home directory by "~" in each space or comma separated file name in
|
||||||
@ -666,16 +645,16 @@ char_u * home_replace_save(buf_T *buf, char_u *src) FUNC_ATTR_NONNULL_RET
|
|||||||
/// Our portable version of setenv.
|
/// Our portable version of setenv.
|
||||||
/// Has special handling for $VIMRUNTIME to keep the localization machinery
|
/// Has special handling for $VIMRUNTIME to keep the localization machinery
|
||||||
/// sane.
|
/// sane.
|
||||||
void vim_setenv(char_u *name, char_u *val)
|
void vim_setenv(const char *name, const char *val)
|
||||||
{
|
{
|
||||||
os_setenv((char *)name, (char *)val, 1);
|
os_setenv(name, val, 1);
|
||||||
/*
|
/*
|
||||||
* When setting $VIMRUNTIME adjust the directory to find message
|
* When setting $VIMRUNTIME adjust the directory to find message
|
||||||
* translations to $VIMRUNTIME/lang.
|
* translations to $VIMRUNTIME/lang.
|
||||||
*/
|
*/
|
||||||
if (*val != NUL && STRICMP(name, "VIMRUNTIME") == 0) {
|
if (*val != NUL && STRICMP(name, "VIMRUNTIME") == 0) {
|
||||||
char_u *buf = concat_str(val, (char_u *)"/lang");
|
char *buf = (char *)concat_str((char_u *)val, (char_u *)"/lang");
|
||||||
bindtextdomain(VIMPACKAGE, (char *)buf);
|
bindtextdomain(VIMPACKAGE, buf);
|
||||||
xfree(buf);
|
xfree(buf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ char_u *path_tail_with_sep(char_u *fname)
|
|||||||
// Don't remove the '/' from "c:/file".
|
// Don't remove the '/' from "c:/file".
|
||||||
char_u *past_head = get_past_head(fname);
|
char_u *past_head = get_past_head(fname);
|
||||||
char_u *tail = path_tail(fname);
|
char_u *tail = path_tail(fname);
|
||||||
while (tail > past_head && after_pathsep(fname, tail)) {
|
while (tail > past_head && after_pathsep((char *)fname, (char *)tail)) {
|
||||||
tail--;
|
tail--;
|
||||||
}
|
}
|
||||||
return tail;
|
return tail;
|
||||||
@ -353,7 +353,7 @@ char_u *concat_fnames(char_u *fname1, char_u *fname2, int sep)
|
|||||||
*/
|
*/
|
||||||
void add_pathsep(char_u *p)
|
void add_pathsep(char_u *p)
|
||||||
{
|
{
|
||||||
if (*p != NUL && !after_pathsep(p, p + STRLEN(p)))
|
if (*p != NUL && !after_pathsep((char *)p, (char *)p + STRLEN(p)))
|
||||||
STRCAT(p, PATHSEPSTR);
|
STRCAT(p, PATHSEPSTR);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1356,7 +1356,7 @@ void simplify_filename(char_u *filename)
|
|||||||
|
|
||||||
--p;
|
--p;
|
||||||
/* Skip back to after previous '/'. */
|
/* Skip back to after previous '/'. */
|
||||||
while (p > start && !after_pathsep(start, p))
|
while (p > start && !after_pathsep((char *)start, (char *)p))
|
||||||
mb_ptr_back(start, p);
|
mb_ptr_back(start, p);
|
||||||
|
|
||||||
if (!do_strip) {
|
if (!do_strip) {
|
||||||
@ -1682,10 +1682,10 @@ void path_fix_case(char_u *name)
|
|||||||
* Takes care of multi-byte characters.
|
* Takes care of multi-byte characters.
|
||||||
* "b" must point to the start of the file name
|
* "b" must point to the start of the file name
|
||||||
*/
|
*/
|
||||||
int after_pathsep(char_u *b, char_u *p)
|
int after_pathsep(const char *b, const char *p)
|
||||||
{
|
{
|
||||||
return p > b && vim_ispathsep(p[-1])
|
return p > b && vim_ispathsep(p[-1])
|
||||||
&& (!has_mbyte || (*mb_head_off)(b, p - 1) == 0);
|
&& (!has_mbyte || (*mb_head_off)((char_u *)b, (char_u *)p - 1) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1761,7 +1761,7 @@ int pathcmp(const char *p, const char *q, int maxlen)
|
|||||||
/* ignore a trailing slash, but not "//" or ":/" */
|
/* ignore a trailing slash, but not "//" or ":/" */
|
||||||
if (c2 == NUL
|
if (c2 == NUL
|
||||||
&& i > 0
|
&& i > 0
|
||||||
&& !after_pathsep((char_u *)s, (char_u *)s + i)
|
&& !after_pathsep(s, s + i)
|
||||||
#ifdef BACKSLASH_IN_FILENAME
|
#ifdef BACKSLASH_IN_FILENAME
|
||||||
&& (c1 == '/' || c1 == '\\')
|
&& (c1 == '/' || c1 == '\\')
|
||||||
#else
|
#else
|
||||||
|
Loading…
Reference in New Issue
Block a user