aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fileio.c10
-rw-r--r--src/os/fs.c50
-rw-r--r--src/os/os.h20
-rw-r--r--src/os/shell.c2
-rw-r--r--src/os/signal.c2
-rw-r--r--src/os/users.c2
-rw-r--r--src/os_unix.c2
-rw-r--r--src/path.c2
-rw-r--r--src/quickfix.c2
9 files changed, 42 insertions, 50 deletions
diff --git a/src/fileio.c b/src/fileio.c
index bf845c4fda..903b84914b 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -490,17 +490,13 @@ readfile (
}
if (fd < 0) { /* cannot open at all */
-#ifndef UNIX
- int isdir_f;
-#endif
msg_scroll = msg_save;
#ifndef UNIX
/*
* On MSDOS and Amiga we can't open a directory, check here.
*/
- isdir_f = (os_isdir(fname));
perm = os_getperm(fname); /* check if the file exists */
- if (isdir_f) {
+ if (os_isdir(fname)) {
filemess(curbuf, sfname, (char_u *)_("is a directory"), 0);
curbuf->b_p_ro = TRUE; /* must use "w!" now */
} else
@@ -2496,7 +2492,7 @@ buf_write (
int device = FALSE; /* writing to a device */
struct stat st_old;
int prev_got_int = got_int;
- int file_readonly = FALSE; /* overwritten file is read-only */
+ bool file_readonly = false; /* overwritten file is read-only */
static char *err_readonly =
"is read-only (cannot override: \"W\" in 'cpoptions')";
#if defined(UNIX) || defined(__EMX__XX) /*XXX fix me sometime? */
@@ -5021,7 +5017,7 @@ int vim_rename(char_u *from, char_u *to)
STRCPY(tempname, from);
for (n = 123; n < 99999; ++n) {
sprintf((char *)path_tail(tempname), "%d", n);
- if (os_file_exists(tempname) == FALSE) {
+ if (!os_file_exists(tempname)) {
if (os_rename(from, tempname) == OK) {
if (os_rename(tempname, to) == OK)
return 0;
diff --git a/src/os/fs.c b/src/os/fs.c
index c472ad0da8..9d09e5eb25 100644
--- a/src/os/fs.c
+++ b/src/os/fs.c
@@ -141,24 +141,24 @@ int os_is_absolute_path(const char_u *fname)
return *fname == '/' || *fname == '~';
}
-int os_isdir(const char_u *name)
+bool os_isdir(const char_u *name)
{
int32_t mode = os_getperm(name);
if (mode < 0) {
- return FALSE;
+ return false;
}
if (!S_ISDIR(mode)) {
- return FALSE;
+ return false;
}
- return TRUE;
+ return true;
}
-static int is_executable(const char_u *name);
-static int is_executable_in_path(const char_u *name);
+static bool is_executable(const char_u *name);
+static bool is_executable_in_path(const char_u *name);
-int os_can_exe(const char_u *name)
+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) ||
@@ -170,32 +170,32 @@ int os_can_exe(const char_u *name)
return is_executable_in_path(name);
}
-// Return TRUE if "name" is an executable file, FALSE if not or it doesn't
+// Return true if "name" is an executable file, false if not or it doesn't
// exist.
-static int is_executable(const char_u *name)
+static bool is_executable(const char_u *name)
{
int32_t mode = os_getperm(name);
if (mode < 0) {
- return FALSE;
+ return false;
}
if (S_ISREG(mode) && (S_IEXEC & mode)) {
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
/// Check if a file is inside the $PATH and is executable.
///
-/// @return `TRUE` if `name` is an executable inside $PATH.
-static int is_executable_in_path(const char_u *name)
+/// @return `true` if `name` is an executable inside $PATH.
+static bool is_executable_in_path(const char_u *name)
{
const char *path = getenv("PATH");
// PATH environment variable does not exist or is empty.
if (path == NULL || *path == NUL) {
- return FALSE;
+ return false;
}
int buf_len = STRLEN(name) + STRLEN(path) + 2;
@@ -217,13 +217,13 @@ static int is_executable_in_path(const char_u *name)
if (is_executable(buf)) {
// Found our executable. Free buf and return.
vim_free(buf);
- return OK;
+ return true;
}
if (*e != ':') {
// End of $PATH without finding any executable called name.
vim_free(buf);
- return FALSE;
+ return false;
}
path = e + 1;
@@ -231,7 +231,7 @@ static int is_executable_in_path(const char_u *name)
// We should never get to this point.
assert(false);
- return FALSE;
+ return false;
}
int os_stat(const char_u *name, uv_stat_t *statbuf)
@@ -273,23 +273,19 @@ int os_setperm(const char_u *name, int perm)
return FAIL;
}
-int os_file_exists(const char_u *name)
+bool os_file_exists(const char_u *name)
{
uv_stat_t statbuf;
if (os_stat(name, &statbuf) == OK) {
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
-int os_file_is_readonly(const char *name)
+bool os_file_is_readonly(const char *name)
{
- if (access(name, W_OK) == 0) {
- return FALSE;
- }
-
- return TRUE;
+ return access(name, W_OK) != 0;
}
int os_file_is_writable(const char *name)
diff --git a/src/os/os.h b/src/os/os.h
index 8456f87473..fc66307d34 100644
--- a/src/os/os.h
+++ b/src/os/os.h
@@ -28,23 +28,23 @@ int os_get_absolute_path(char_u *fname, char_u *buf, int len, int force);
/// Check if the given file is absolute.
///
/// This just checks if the file name starts with '/' or '~'.
-/// @return `TRUE` if "fname" is absolute.
+/// @return `true` if "fname" is absolute.
int os_is_absolute_path(const char_u *fname);
/// Check if the given path is a directory or not.
///
-/// @return `TRUE` if `fname` is a directory.
-int os_isdir(const char_u *name);
+/// @return `true` if `fname` is a directory.
+bool os_isdir(const char_u *name);
/// Check if the given path represents an executable file.
///
-/// @return `TRUE` if `name` is executable and
+/// @return `true` if `name` is executable and
/// - can be found in $PATH,
/// - is relative to current dir or
/// - is absolute.
///
-/// @return `FALSE` otherwise.
-int os_can_exe(const char_u *name);
+/// @return `false` otherwise.
+bool os_can_exe(const char_u *name);
/// Get the file permissions for a given file.
///
@@ -58,13 +58,13 @@ int os_setperm(const char_u *name, int perm);
/// Check if a file exists.
///
-/// @return `TRUE` if `name` exists.
-int os_file_exists(const char_u *name);
+/// @return `true` if `name` exists.
+bool os_file_exists(const char_u *name);
/// Check if a file is readonly.
///
-/// @return `True` if `name` is readonly.
-int os_file_is_readonly(const char *name);
+/// @return `true` if `name` is readonly.
+bool os_file_is_readonly(const char *name);
/// Check if a file is writable.
///
diff --git a/src/os/shell.c b/src/os/shell.c
index e00c9b8d07..bc562474df 100644
--- a/src/os/shell.c
+++ b/src/os/shell.c
@@ -222,7 +222,7 @@ int os_call_shell(char_u *cmd, ShellOpts opts, char_u *extra_shell_arg)
// TODO for now this is only needed if the terminal is in raw mode, but
// when the UI is externalized we'll also need it, so leave it here
uv_process_kill(&proc, SIGINT);
- got_int = FALSE;
+ got_int = false;
}
}
diff --git a/src/os/signal.c b/src/os/signal.c
index dc404a6e99..3595c63acb 100644
--- a/src/os/signal.c
+++ b/src/os/signal.c
@@ -73,7 +73,7 @@ void signal_handle(Event event)
switch (signum) {
case SIGINT:
- got_int = TRUE;
+ got_int = true;
break;
#ifdef SIGPWR
case SIGPWR:
diff --git a/src/os/users.c b/src/os/users.c
index c8c2e773de..5972e3f1e8 100644
--- a/src/os/users.c
+++ b/src/os/users.c
@@ -14,7 +14,7 @@
int os_get_usernames(garray_T *users)
{
if (users == NULL) {
- return FALSE;
+ return FAIL;
}
ga_init(users, sizeof(char *), 20);
diff --git a/src/os_unix.c b/src/os_unix.c
index 06b4e30ffd..c0fcc63fb0 100644
--- a/src/os_unix.c
+++ b/src/os_unix.c
@@ -1039,7 +1039,7 @@ int flags; /* EW_* flags */
int i;
size_t len;
char_u *p;
- int dir;
+ bool dir;
char_u *extra_shell_arg = NULL;
ShellOpts shellopts = kShellOptExpand | kShellOptSilent;
/*
diff --git a/src/path.c b/src/path.c
index 595499f709..ed6c280059 100644
--- a/src/path.c
+++ b/src/path.c
@@ -1208,7 +1208,7 @@ addfile (
)
{
char_u *p;
- int isdir;
+ bool isdir;
/* if the file/dir doesn't exist, may not add it */
if (!(flags & EW_NOTFOUND) && !os_file_exists(f))
diff --git a/src/quickfix.c b/src/quickfix.c
index d693ea4304..fe0ef8ad6a 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -1174,7 +1174,7 @@ static char_u *qf_push_dir(char_u *dirbuf, struct dir_stack_T **stackptr)
vim_free((*stackptr)->dirname);
(*stackptr)->dirname = concat_fnames(ds_new->dirname, dirbuf,
TRUE);
- if (os_isdir((*stackptr)->dirname) == TRUE)
+ if (os_isdir((*stackptr)->dirname))
break;
ds_new = ds_new->next;