aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Wienecke <wienecke.t@gmail.com>2014-03-05 12:34:15 +0100
committerThiago de Arruda <tpadilha84@gmail.com>2014-03-06 13:10:58 -0300
commitfc8686640250561156913387c62924d2bdb5e1ac (patch)
tree470fc2e2d3cfdf978dceb565a099b67285717efe /src
parentfdba1761f655ece7d6124570d20cc498c67f947e (diff)
downloadrneovim-fc8686640250561156913387c62924d2bdb5e1ac.tar.gz
rneovim-fc8686640250561156913387c62924d2bdb5e1ac.tar.bz2
rneovim-fc8686640250561156913387c62924d2bdb5e1ac.zip
Fix style issues.
* Rename mch_full_name to mch_get_absolute_path. * Rename mch_is_full_name to mch_is_absolute_path. * Add a lot of missing parentheses. * Remove yoda-conditions for consistency. * Remove spaces in function declaration.
Diffstat (limited to 'src')
-rw-r--r--src/buffer.c2
-rw-r--r--src/eval.c2
-rw-r--r--src/ex_getln.c2
-rw-r--r--src/fileio.c2
-rw-r--r--src/memline.c2
-rw-r--r--src/misc1.c6
-rw-r--r--src/os/fs.c31
-rw-r--r--src/os/os.h4
-rw-r--r--src/os_unix.c2
-rw-r--r--src/syntax.c2
-rw-r--r--src/window.c4
11 files changed, 33 insertions, 26 deletions
diff --git a/src/buffer.c b/src/buffer.c
index 4a13e4bcc9..af16d7580a 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 mch_full_name()).
+ * Fname must have a full path (expanded by mch_get_absolute_path()).
*/
int otherfile(char_u *ffname)
{
diff --git a/src/eval.c b/src/eval.c
index 2116652942..cfcf4ce712 100644
--- a/src/eval.c
+++ b/src/eval.c
@@ -12468,7 +12468,7 @@ static void f_resolve(typval_T *argvars, typval_T *rettv)
q[-1] = NUL;
q = gettail(p);
}
- if (q > p && !mch_is_full_name(buf)) {
+ if (q > p && !mch_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 621afd9f55..fc5a445c2c 100644
--- a/src/ex_getln.c
+++ b/src/ex_getln.c
@@ -3945,7 +3945,7 @@ expand_shellcmd (
flags |= EW_FILE | EW_EXEC;
/* For an absolute name we don't use $PATH. */
- if (mch_is_full_name(pat))
+ if (mch_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 6eddf06dc6..0bfa3ebfb2 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -4770,7 +4770,7 @@ void shorten_fnames(int force)
&& !path_with_url(buf->b_fname)
&& (force
|| buf->b_sfname == NULL
- || mch_is_full_name(buf->b_sfname))) {
+ || mch_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 a75b70a992..463aeb4b58 100644
--- a/src/memline.c
+++ b/src/memline.c
@@ -3382,7 +3382,7 @@ int resolve_symlink(char_u *fname, char_u *buf)
* portion of the filename (if any) and the path the symlink
* points to.
*/
- if (mch_is_full_name(buf))
+ if (mch_is_absolute_path(buf))
STRCPY(tmp, buf);
else {
char_u *tail;
diff --git a/src/misc1.c b/src/misc1.c
index 770e870069..ab21f8d6a5 100644
--- a/src/misc1.c
+++ b/src/misc1.c
@@ -7945,7 +7945,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 (!mch_is_full_name(buf)) {
+ else if (!mch_is_absolute_path(buf)) {
/* Expand relative path to their full path equivalent */
len = (int)STRLEN(curdir);
if (len + (int)STRLEN(buf) + 3 > MAXPATHL)
@@ -8086,7 +8086,7 @@ static void uniquefy_paths(garray_T *gap, char_u *pattern)
break;
}
- if (mch_is_full_name(path)) {
+ if (mch_is_absolute_path(path)) {
/*
* Last resort: shorten relative to curdir if possible.
* 'possible' means:
@@ -8375,7 +8375,7 @@ gen_expand_wildcards (
*/
if (mch_has_exp_wildcard(p)) {
if ((flags & EW_PATH)
- && !mch_is_full_name(p)
+ && !mch_is_absolute_path(p)
&& !(p[0] == '.'
&& (vim_ispathsep(p[1])
|| (p[1] == '.' && vim_ispathsep(p[2]))))
diff --git a/src/os/fs.c b/src/os/fs.c
index bf9de63355..b55c132027 100644
--- a/src/os/fs.c
+++ b/src/os/fs.c
@@ -50,35 +50,38 @@ int mch_full_dir_name(char *directory, char *buffer, int len)
{
int retval = OK;
- if(0 == STRLEN(directory)) {
+ if(STRLEN(directory) == 0) {
return mch_dirname((char_u *) buffer, len);
}
char old_dir[MAXPATHL];
/* Get current directory name. */
- if (FAIL == mch_dirname((char_u *) old_dir, MAXPATHL)) {
+ if (mch_dirname((char_u *) old_dir, MAXPATHL) == FAIL) {
return FAIL;
}
/* We have to get back to the current dir at the end, check if that works. */
- if (0 != mch_chdir(old_dir)) {
+ if (mch_chdir(old_dir) != 0) {
return FAIL;
}
- if (0 != mch_chdir(directory)) {
+ if (mch_chdir(directory) != 0) {
+ /* Do not return immediatly since we may be in the wrong directory. */
retval = FAIL;
}
- if ((FAIL == retval) || (FAIL == mch_dirname((char_u *) buffer, len))) {
+ if (retval == FAIL || mch_dirname((char_u *) buffer, len) == FAIL) {
+ /* Do not return immediatly since we are in the wrong directory. */
retval = FAIL;
}
- if (0 != mch_chdir(old_dir)) {
+ if (mch_chdir(old_dir) != 0) {
/* That shouldn't happen, since we've tested if it works. */
retval = FAIL;
EMSG(_(e_prev_dir));
}
+
return retval;
}
@@ -91,19 +94,23 @@ int append_path(char *path, char *to_append, int max_len)
int to_append_length = STRLEN(to_append);
/* Do not append empty strings. */
- if (0 == to_append_length)
+ if (to_append_length == 0) {
return OK;
+ }
/* Do not append a dot. */
- if (STRCMP(to_append, ".") == 0)
+ if (STRCMP(to_append, ".") == 0) {
return OK;
+ }
/* Glue both paths with a slash. */
if (current_length > 0 && path[current_length-1] != '/') {
current_length += 1; /* Count the trailing slash. */
- if (current_length > max_len)
+ /* +1 for the NUL at the end. */
+ if (current_length +1 > max_len) {
return FAIL;
+ }
STRCAT(path, "/");
}
@@ -125,7 +132,7 @@ int append_path(char *path, char *to_append, int max_len)
*
* return FAIL for failure, OK for success
*/
-int mch_full_name(char_u *fname, char_u *buf, int len, int force)
+int mch_get_absolute_path(char_u *fname, char_u *buf, int len, int force)
{
char_u *p;
*buf = NUL;
@@ -134,7 +141,7 @@ int mch_full_name(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 || !mch_is_full_name(fname)) {
+ if (force || !mch_is_absolute_path(fname)) {
if ((p = vim_strrchr(fname, '/')) != NULL) {
STRNCPY(relative_directory, fname, p-fname);
@@ -155,7 +162,7 @@ int mch_full_name(char_u *fname, char_u *buf, int len, int force)
/*
* Return TRUE if "fname" does not depend on the current directory.
*/
-int mch_is_full_name(char_u *fname)
+int mch_is_absolute_path(char_u *fname)
{
return *fname == '/' || *fname == '~';
}
diff --git a/src/os/os.h b/src/os/os.h
index 8d3caa849f..bc7496ed58 100644
--- a/src/os/os.h
+++ b/src/os/os.h
@@ -6,8 +6,8 @@
long_u mch_total_mem(int special);
int mch_chdir(char *path);
int mch_dirname(char_u *buf, int len);
-int mch_full_name (char_u *fname, char_u *buf, int len, int force);
-int mch_is_full_name (char_u *fname);
+int mch_get_absolute_path(char_u *fname, char_u *buf, int len, int force);
+int mch_is_absolute_path(char_u *fname);
int mch_isdir(char_u *name);
#endif
diff --git a/src/os_unix.c b/src/os_unix.c
index 045c731cd6..40eba52da8 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -1344,7 +1344,7 @@ int mch_can_exe(char_u *name)
int retval;
/* If it's an absolute or relative path don't need to use $PATH. */
- if (mch_is_full_name(name) || (name[0] == '.' && (name[1] == '/'
+ if (mch_is_absolute_path(name) || (name[0] == '.' && (name[1] == '/'
|| (name[1] == '.' &&
name[2] == '/'))))
return executable_file(name);
diff --git a/src/syntax.c b/src/syntax.c
index 5361ea4be3..5c4ed03030 100644
--- a/src/syntax.c
+++ b/src/syntax.c
@@ -4188,7 +4188,7 @@ static void syn_cmd_include(exarg_T *eap, int syncing)
*/
eap->argt |= (XFILE | NOSPC);
separate_nextcmd(eap);
- if (*eap->arg == '<' || *eap->arg == '$' || mch_is_full_name(eap->arg)) {
+ if (*eap->arg == '<' || *eap->arg == '$' || mch_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/src/window.c b/src/window.c
index 16acf013ab..f3c14a568d 100644
--- a/src/window.c
+++ b/src/window.c
@@ -5065,7 +5065,7 @@ int path_with_url(char_u *fname)
*/
int vim_isAbsName(char_u *name)
{
- return path_with_url(name) != 0 || mch_is_full_name(name);
+ return path_with_url(name) != 0 || mch_is_absolute_path(name);
}
/*
@@ -5090,7 +5090,7 @@ vim_FullName (
url = path_with_url(fname);
if (!url)
- retval = mch_full_name(fname, buf, len, force);
+ retval = mch_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);