mirror of
https://github.com/neovim/neovim.git
synced 2025-09-19 09:48:19 +00:00
Move same_directory from misc2.c
This commit is contained in:

committed by
Thiago de Arruda

parent
e29e956348
commit
2a6df95fb5
21
src/misc2.c
21
src/misc2.c
@@ -1613,27 +1613,6 @@ int get_real_state(void)
|
|||||||
return State;
|
return State;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Return TRUE if file names "f1" and "f2" are in the same directory.
|
|
||||||
* "f1" may be a short name, "f2" must be a full path.
|
|
||||||
*/
|
|
||||||
int same_directory(char_u *f1, char_u *f2)
|
|
||||||
{
|
|
||||||
char_u ffname[MAXPATHL];
|
|
||||||
char_u *t1;
|
|
||||||
char_u *t2;
|
|
||||||
|
|
||||||
/* safety check */
|
|
||||||
if (f1 == NULL || f2 == NULL)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
(void)vim_FullName(f1, ffname, MAXPATHL, FALSE);
|
|
||||||
t1 = gettail_sep(ffname);
|
|
||||||
t2 = gettail_sep(f2);
|
|
||||||
return t1 - ffname == t2 - f2
|
|
||||||
&& pathcmp((char *)ffname, (char *)f2, (int)(t1 - ffname)) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(FEAT_SESSION) || defined(MSWIN) || defined(FEAT_GUI_MAC) \
|
#if defined(FEAT_SESSION) || defined(MSWIN) || defined(FEAT_GUI_MAC) \
|
||||||
|| ((defined(FEAT_GUI_GTK)) \
|
|| ((defined(FEAT_GUI_GTK)) \
|
||||||
&& ( defined(FEAT_WINDOWS) || defined(FEAT_DND)) ) \
|
&& ( defined(FEAT_WINDOWS) || defined(FEAT_DND)) ) \
|
||||||
|
@@ -68,7 +68,6 @@ void set_fileformat(int t, int opt_flags);
|
|||||||
int default_fileformat(void);
|
int default_fileformat(void);
|
||||||
int call_shell(char_u *cmd, ShellOpts opts, char_u *extra_shell_arg);
|
int call_shell(char_u *cmd, ShellOpts opts, char_u *extra_shell_arg);
|
||||||
int get_real_state(void);
|
int get_real_state(void);
|
||||||
int same_directory(char_u *f1, char_u *f2);
|
|
||||||
int vim_chdirfile(char_u *fname);
|
int vim_chdirfile(char_u *fname);
|
||||||
int illegal_slash(char *name);
|
int illegal_slash(char *name);
|
||||||
int vim_chdir(char_u *new_dir);
|
int vim_chdir(char_u *new_dir);
|
||||||
|
21
src/path.c
21
src/path.c
@@ -1673,3 +1673,24 @@ int after_pathsep(char_u *b, char_u *p)
|
|||||||
&& (!has_mbyte || (*mb_head_off)(b, p - 1) == 0);
|
&& (!has_mbyte || (*mb_head_off)(b, p - 1) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return TRUE if file names "f1" and "f2" are in the same directory.
|
||||||
|
* "f1" may be a short name, "f2" must be a full path.
|
||||||
|
*/
|
||||||
|
int same_directory(char_u *f1, char_u *f2)
|
||||||
|
{
|
||||||
|
char_u ffname[MAXPATHL];
|
||||||
|
char_u *t1;
|
||||||
|
char_u *t2;
|
||||||
|
|
||||||
|
/* safety check */
|
||||||
|
if (f1 == NULL || f2 == NULL)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
(void)vim_FullName(f1, ffname, MAXPATHL, FALSE);
|
||||||
|
t1 = gettail_sep(ffname);
|
||||||
|
t2 = gettail_sep(f2);
|
||||||
|
return t1 - ffname == t2 - f2
|
||||||
|
&& pathcmp((char *)ffname, (char *)f2, (int)(t1 - ffname)) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -32,4 +32,5 @@ int vim_isAbsName(char_u *name);
|
|||||||
int vim_FullName(char_u *fname, char_u *buf, int len, int force);
|
int vim_FullName(char_u *fname, char_u *buf, int len, int force);
|
||||||
char_u *fix_fname(char_u *fname);
|
char_u *fix_fname(char_u *fname);
|
||||||
int after_pathsep(char_u *b, char_u *p);
|
int after_pathsep(char_u *b, char_u *p);
|
||||||
|
int same_directory(char_u *f1, char_u *f2);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user