aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Schmidt <john.schmidt.h@gmail.com>2014-04-07 18:04:18 +0200
committerThiago de Arruda <tpadilha84@gmail.com>2014-04-08 21:56:05 -0300
commit6fb58d1c5c859402871e1d546f7fea1a91dd2995 (patch)
tree4244498e670f344ef20eeb5c3782604d22e770b2
parentaa7218b646e52554621471df3668c2e1d95aa9c9 (diff)
downloadrneovim-6fb58d1c5c859402871e1d546f7fea1a91dd2995.tar.gz
rneovim-6fb58d1c5c859402871e1d546f7fea1a91dd2995.tar.bz2
rneovim-6fb58d1c5c859402871e1d546f7fea1a91dd2995.zip
Change prefix from `os_*` to `path_*`
-rw-r--r--src/buffer.c2
-rw-r--r--src/eval.c4
-rw-r--r--src/ex_getln.c2
-rw-r--r--src/fileio.c2
-rw-r--r--src/memline.c2
-rw-r--r--src/os_unix.c2
-rw-r--r--src/path.c24
-rw-r--r--src/path.h6
-rw-r--r--src/syntax.c2
-rw-r--r--test/unit/os/fs.moon16
-rw-r--r--test/unit/path.moon32
11 files changed, 47 insertions, 47 deletions
diff --git a/src/buffer.c b/src/buffer.c
index b104abfa40..2f214f45ac 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -2418,7 +2418,7 @@ void buflist_altfpos(win_T *win)
/*
* Return TRUE if 'ffname' is not the same file as current file.
- * Fname must have a full path (expanded by os_get_absolute_path()).
+ * Fname must have a full path (expanded by path_get_absolute_path()).
*/
int otherfile(char_u *ffname)
{
diff --git a/src/eval.c b/src/eval.c
index 802012758a..c643d64c10 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -8562,7 +8562,7 @@ static void f_eventhandler(typval_T *argvars, typval_T *rettv)
*/
static void f_executable(typval_T *argvars, typval_T *rettv)
{
- rettv->vval.v_number = os_can_exe(get_tv_string(&argvars[0]));
+ rettv->vval.v_number = path_can_exe(get_tv_string(&argvars[0]));
}
/*
@@ -12617,7 +12617,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv)
q[-1] = NUL;
q = path_tail(p);
}
- if (q > p && !os_is_absolute_path(buf)) {
+ if (q > p && !path_is_absolute_path(buf)) {
/* symlink is relative to directory of argument */
cpy = alloc((unsigned)(STRLEN(p) + STRLEN(buf) + 1));
if (cpy != NULL) {
diff --git a/src/ex_getln.c b/src/ex_getln.c
index 51c596e1ce..0cf9ff2dd8 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -3964,7 +3964,7 @@ expand_shellcmd (
flags |= EW_FILE | EW_EXEC;
/* For an absolute name we don't use $PATH. */
- if (os_is_absolute_path(pat))
+ if (path_is_absolute_path(pat))
path = (char_u *)" ";
else if ((pat[0] == '.' && (vim_ispathsep(pat[1])
|| (pat[1] == '.' && vim_ispathsep(pat[2])))))
diff --git a/src/fileio.c b/src/fileio.c
index 92ebb9ff19..7f2d7b1098 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4670,7 +4670,7 @@ void shorten_fnames(int force)
&& !path_with_url(buf->b_fname)
&& (force
|| buf->b_sfname == NULL
- || os_is_absolute_path(buf->b_sfname))) {
+ || path_is_absolute_path(buf->b_sfname))) {
vim_free(buf->b_sfname);
buf->b_sfname = NULL;
p = shorten_fname(buf->b_ffname, dirname);
diff --git a/src/memline.c b/src/memline.c
index 8d3dc47d7b..d60f348fc4 100644
--- a/src/memline.c
+++ b/src/memline.c
@@ -3381,7 +3381,7 @@ int resolve_symlink(char_u *fname, char_u *buf)
* portion of the filename (if any) and the path the symlink
* points to.
*/
- if (os_is_absolute_path(buf))
+ if (path_is_absolute_path(buf))
STRCPY(tmp, buf);
else {
char_u *tail;
diff --git a/src/os_unix.c b/src/os_unix.c
index 9727140597..3a3ecda276 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -1418,7 +1418,7 @@ int flags; /* EW_* flags */
continue;
/* Skip files that are not executable if we check for that. */
- if (!dir && (flags & EW_EXEC) && !os_can_exe((*file)[i]))
+ if (!dir && (flags & EW_EXEC) && !path_can_exe((*file)[i]))
continue;
p = alloc((unsigned)(STRLEN((*file)[i]) + 1 + dir));
diff --git a/src/path.c b/src/path.c
index b63fd28cf4..26ab66a362 100644
--- a/src/path.c
+++ b/src/path.c
@@ -656,7 +656,7 @@ static void expand_path_option(char_u *curdir, garray_T *gap)
else if (path_with_url(buf))
/* URL can't be used here */
continue;
- else if (!os_is_absolute_path(buf)) {
+ else if (!path_is_absolute_path(buf)) {
/* Expand relative path to their full path equivalent */
len = (int)STRLEN(curdir);
if (len + (int)STRLEN(buf) + 3 > MAXPATHL)
@@ -794,7 +794,7 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
break;
}
- if (os_is_absolute_path(path)) {
+ if (path_is_absolute_path(path)) {
/*
* Last resort: shorten relative to curdir if possible.
* 'possible' means:
@@ -1090,7 +1090,7 @@ gen_expand_wildcards (
*/
if (mch_has_exp_wildcard(p)) {
if ((flags & EW_PATH)
- && !os_is_absolute_path(p)
+ && !path_is_absolute_path(p)
&& !(p[0] == '.'
&& (vim_ispathsep(p[1])
|| (p[1] == '.' && vim_ispathsep(p[2]))))
@@ -1229,7 +1229,7 @@ addfile (
return;
/* If the file isn't executable, may not add it. Do accept directories. */
- if (!isdir && (flags & EW_EXEC) && !os_can_exe(f))
+ if (!isdir && (flags & EW_EXEC) && !path_can_exe(f))
return;
/* Make room for another item in the file list. */
@@ -1532,7 +1532,7 @@ int path_with_url(char_u *fname)
*/
int vim_isAbsName(char_u *name)
{
- return path_with_url(name) != 0 || os_is_absolute_path(name);
+ return path_with_url(name) != 0 || path_is_absolute_path(name);
}
/*
@@ -1557,7 +1557,7 @@ vim_FullName (
url = path_with_url(fname);
if (!url)
- retval = os_get_absolute_path(fname, buf, len, force);
+ retval = path_get_absolute_path(fname, buf, len, force);
if (url || retval == FAIL) {
/* something failed; use the file name (truncate when too long) */
vim_strncpy(buf, fname, len - 1);
@@ -1947,7 +1947,7 @@ int match_suffix(char_u *fname)
///
/// @param directory Directory name, relative to current directory.
/// @return `FAIL` for failure, `OK` for success.
-int os_full_dir_name(char *directory, char *buffer, int len)
+int path_full_dir_name(char *directory, char *buffer, int len)
{
int SUCCESS = 0;
int retval = OK;
@@ -2031,7 +2031,7 @@ int append_path(char *path, const char *to_append, int max_len)
/// @param len Length of `buf`.
/// @param force Also expand when `fname` is already absolute.
/// @return `FAIL` for failure, `OK` for success.
-static int os_get_absolute_path(char_u *fname, char_u *buf, int len, int force)
+static int path_get_absolute_path(char_u *fname, char_u *buf, int len, int force)
{
char_u *p;
*buf = NUL;
@@ -2040,7 +2040,7 @@ static int os_get_absolute_path(char_u *fname, char_u *buf, int len, int force)
char *end_of_path = (char *) fname;
// expand it if forced or not an absolute path
- if (force || !os_is_absolute_path(fname)) {
+ if (force || !path_is_absolute_path(fname)) {
if ((p = vim_strrchr(fname, '/')) != NULL) {
STRNCPY(relative_directory, fname, p-fname);
relative_directory[p-fname] = NUL;
@@ -2050,14 +2050,14 @@ static int os_get_absolute_path(char_u *fname, char_u *buf, int len, int force)
end_of_path = (char *) fname;
}
- if (FAIL == os_full_dir_name(relative_directory, (char *) buf, len)) {
+ if (FAIL == path_full_dir_name(relative_directory, (char *) buf, len)) {
return FAIL;
}
}
return append_path((char *) buf, (char *) end_of_path, len);
}
-int os_is_absolute_path(const char_u *fname)
+int path_is_absolute_path(const char_u *fname)
{
return *fname == '/' || *fname == '~';
}
@@ -2065,7 +2065,7 @@ int os_is_absolute_path(const char_u *fname)
bool os_can_exe(const char_u *name)
{
// If it's an absolute or relative path don't need to use $PATH.
- if (os_is_absolute_path(name) ||
+ if (path_is_absolute_path(name) ||
(name[0] == '.' && (name[1] == '/' ||
(name[1] == '.' && name[2] == '/')))) {
return is_executable(name);
diff --git a/src/path.h b/src/path.h
index ebd773ab18..cb0a8b958f 100644
--- a/src/path.h
+++ b/src/path.h
@@ -92,7 +92,7 @@ int match_suffix(char_u *fname);
///
/// @param directory Directory name, relative to current directory.
/// @return `FAIL` for failure, `OK` for success.
-int os_full_dir_name(char *directory, char *buffer, int len);
+int path_full_dir_name(char *directory, char *buffer, int len);
// Append to_append to path with a slash in between.
int append_path(char *path, const char *to_append, int max_len);
@@ -101,7 +101,7 @@ int append_path(char *path, const char *to_append, int max_len);
///
/// This just checks if the file name starts with '/' or '~'.
/// @return `TRUE` if "fname" is absolute.
-int os_is_absolute_path(const char_u *fname);
+int path_is_absolute_path(const char_u *fname);
/// Check if the given path represents an executable file.
///
@@ -111,6 +111,6 @@ int os_is_absolute_path(const char_u *fname);
/// - is absolute.
///
/// @return `FALSE` otherwise.
-int os_can_exe(const char_u *name);
+int path_can_exe(const char_u *name);
#endif
diff --git a/src/syntax.c b/src/syntax.c
index 3d11a8f603..31e72a23d1 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -4202,7 +4202,7 @@ static void syn_cmd_include(exarg_T *eap, int syncing)
*/
eap->argt |= (XFILE | NOSPC);
separate_nextcmd(eap);
- if (*eap->arg == '<' || *eap->arg == '$' || os_is_absolute_path(eap->arg)) {
+ if (*eap->arg == '<' || *eap->arg == '$' || path_is_absolute_path(eap->arg)) {
/* For an absolute path, "$VIM/..." or "<sfile>.." we ":source" the
* file. Need to expand the file name first. In other cases
* ":runtime!" is used. */
diff --git a/test/unit/os/fs.moon b/test/unit/os/fs.moon
index fdbb2e8ee3..c45e64d2d4 100644
--- a/test/unit/os/fs.moon
+++ b/test/unit/os/fs.moon
@@ -61,12 +61,12 @@ describe 'fs function', ->
buf = cstr (len-1), ''
eq FAIL, (os_dirname buf, (len-1))
- describe 'os_full_dir_name', ->
- ffi.cdef 'int os_full_dir_name(char *directory, char *buffer, int len);'
+ describe 'path_full_dir_name', ->
+ ffi.cdef 'int path_full_dir_name(char *directory, char *buffer, int len);'
- os_full_dir_name = (directory, buffer, len) ->
+ path_full_dir_name = (directory, buffer, len) ->
directory = to_cstr directory
- fs.os_full_dir_name directory, buffer, len
+ fs.path_full_dir_name directory, buffer, len
before_each ->
-- Create empty string buffer which will contain the resulting path.
@@ -74,7 +74,7 @@ describe 'fs function', ->
export buffer = cstr len, ''
it 'returns the absolute directory name of a given relative one', ->
- result = os_full_dir_name '..', buffer, len
+ result = path_full_dir_name '..', buffer, len
eq OK, result
old_dir = lfs.currentdir!
lfs.chdir '..'
@@ -83,14 +83,14 @@ describe 'fs function', ->
eq expected, (ffi.string buffer)
it 'returns the current directory name if the given string is empty', ->
- eq OK, (os_full_dir_name '', buffer, len)
+ eq OK, (path_full_dir_name '', buffer, len)
eq lfs.currentdir!, (ffi.string buffer)
it 'fails if the given directory does not exist', ->
- eq FAIL, os_full_dir_name('does_not_exist', buffer, len)
+ eq FAIL, path_full_dir_name('does_not_exist', buffer, len)
it 'works with a normal relative dir', ->
- result = os_full_dir_name('unit-test-directory', buffer, len)
+ result = path_full_dir_name('unit-test-directory', buffer, len)
eq lfs.currentdir! .. '/unit-test-directory', (ffi.string buffer)
eq OK, result
diff --git a/test/unit/path.moon b/test/unit/path.moon
index 71350b7925..f2fd0a99a5 100644
--- a/test/unit/path.moon
+++ b/test/unit/path.moon
@@ -12,7 +12,7 @@ char_u *path_tail(char_u *fname);
char_u *path_tail_with_sep(char_u *fname);
char_u *path_next_component(char_u *fname);
int is_executable(char_u *name);
-int os_can_exe(char_u *name);
+int path_can_exe(char_u *name);
]]
@@ -249,41 +249,41 @@ describe 'more path function', ->
eq OK, (path.append_path path1, to_append, 7)
eq '/path2', (ffi.string path1)
- describe 'os_is_absolute_path', ->
- ffi.cdef 'int os_is_absolute_path(char *fname);'
+ describe 'path_is_absolute_path', ->
+ ffi.cdef 'int path_is_absolute_path(char *fname);'
- os_is_absolute_path = (filename) ->
+ path_is_absolute_path = (filename) ->
filename = to_cstr filename
- path.os_is_absolute_path filename
+ path.path_is_absolute_path filename
it 'returns true if filename starts with a slash', ->
- eq OK, os_is_absolute_path '/some/directory/'
+ eq OK, path_is_absolute_path '/some/directory/'
it 'returns true if filename starts with a tilde', ->
- eq OK, os_is_absolute_path '~/in/my/home~/directory'
+ eq OK, path_is_absolute_path '~/in/my/home~/directory'
it 'returns false if filename starts not with slash nor tilde', ->
- eq FAIL, os_is_absolute_path 'not/in/my/home~/directory'
+ eq FAIL, path_is_absolute_path 'not/in/my/home~/directory'
- describe 'os_can_exe', ->
- os_can_exe = (name) ->
- path.os_can_exe (to_cstr name)
+ describe 'path_can_exe', ->
+ path_can_exe = (name) ->
+ path.path_can_exe (to_cstr name)
it 'returns false when given a directory', ->
- eq FALSE, (os_can_exe './unit-test-directory')
+ eq FALSE, (path_can_exe './unit-test-directory')
it 'returns false when given a regular file without executable bit set', ->
- eq FALSE, (os_can_exe 'unit-test-directory/test.file')
+ eq FALSE, (path_can_exe 'unit-test-directory/test.file')
it 'returns false when the given file does not exists', ->
- eq FALSE, (os_can_exe 'does-not-exist.file')
+ eq FALSE, (path_can_exe 'does-not-exist.file')
it 'returns true when given an executable inside $PATH', ->
- eq TRUE, (os_can_exe executable_name)
+ eq TRUE, (path_can_exe executable_name)
it 'returns true when given an executable relative to the current dir', ->
old_dir = lfs.currentdir!
lfs.chdir directory
relative_executable = './' .. executable_name
- eq TRUE, (os_can_exe relative_executable)
+ eq TRUE, (path_can_exe relative_executable)
lfs.chdir old_dir