diff options
author | Michael Reed <m.reed@mykolab.com> | 2016-01-14 16:05:23 -0500 |
---|---|---|
committer | Michael Reed <m.reed@mykolab.com> | 2016-01-14 23:38:26 -0500 |
commit | 07265d221fbd3b4fd16440caab49c70d14370079 (patch) | |
tree | 07118b6756dfe5c34204112c228bb72b7f83aa11 /src | |
parent | 24fbb2c866039d61107fa1f6a2efe86bb6951e55 (diff) | |
download | rneovim-07265d221fbd3b4fd16440caab49c70d14370079.tar.gz rneovim-07265d221fbd3b4fd16440caab49c70d14370079.tar.bz2 rneovim-07265d221fbd3b4fd16440caab49c70d14370079.zip |
Misc. macro cleanup
- ROOT_UID's comment is misleading, as it's always defined to 0.
- SEEK_{SET,END} & O_NOFOLLOW should already be defined on Unix-like
systems in <stdio.h> and <fcntl.h>, respectively. In any case,
neither of those #ifdef blocks should be in the middle of source files.
- The S_IS{LNK,DIR,...} macros should only be undefined on Windows.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/misc1.c | 7 | ||||
-rw-r--r-- | src/nvim/option.c | 7 | ||||
-rw-r--r-- | src/nvim/os/os_defs.h | 22 | ||||
-rw-r--r-- | src/nvim/os/win_defs.h | 22 | ||||
-rw-r--r-- | src/nvim/os_unix.c | 7 | ||||
-rw-r--r-- | src/nvim/shada.c | 4 | ||||
-rw-r--r-- | src/nvim/vim.h | 12 |
7 files changed, 28 insertions, 53 deletions
diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index b2cec82121..6c969a43fc 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -2729,13 +2729,6 @@ void fast_breakcheck(void) } } -#ifndef SEEK_SET -# define SEEK_SET 0 -#endif -#ifndef SEEK_END -# define SEEK_END 2 -#endif - /* * Get the stdout of an external command. * If "ret_len" is NULL replace NUL characters with NL. When "ret_len" is not diff --git a/src/nvim/option.c b/src/nvim/option.c index 2ac1abeeba..e3df559c49 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -837,9 +837,10 @@ set_option_default ( } else { /* P_BOOL */ *(int *)varp = (int)(intptr_t)options[opt_idx].def_val[dvi]; #ifdef UNIX - /* 'modeline' defaults to off for root */ - if (options[opt_idx].indir == PV_ML && getuid() == ROOT_UID) - *(int *)varp = FALSE; + // 'modeline' defaults to off for root + if (options[opt_idx].indir == PV_ML && getuid() == 0) { + *(int *)varp = false; + } #endif /* May also set global value for local option. */ if (both) diff --git a/src/nvim/os/os_defs.h b/src/nvim/os/os_defs.h index 8afbd29292..eee0cdd10b 100644 --- a/src/nvim/os/os_defs.h +++ b/src/nvim/os/os_defs.h @@ -34,28 +34,6 @@ # define DFLT_MAXMEMTOT (10*1024) #endif -#if !defined(S_ISDIR) && defined(S_IFDIR) -# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -#endif -#if !defined(S_ISREG) && defined(S_IFREG) -# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -#endif -#if !defined(S_ISLNK) && defined(S_IFLNK) -# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) -#endif -#if !defined(S_ISBLK) && defined(S_IFBLK) -# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) -#endif -#if !defined(S_ISSOCK) && defined(S_IFSOCK) -# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) -#endif -#if !defined(S_ISFIFO) && defined(S_IFIFO) -# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) -#endif -#if !defined(S_ISCHR) && defined(S_IFCHR) -# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) -#endif - // Note: Some systems need both string.h and strings.h (Savage). However, // some systems can't handle both, only use string.h in that case. #include <string.h> diff --git a/src/nvim/os/win_defs.h b/src/nvim/os/win_defs.h index 673fff3ad0..2ce74c9818 100644 --- a/src/nvim/os/win_defs.h +++ b/src/nvim/os/win_defs.h @@ -50,4 +50,26 @@ typedef SSIZE_T ssize_t; # endif #endif +#if !defined(S_ISDIR) && defined(S_IFDIR) +# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#endif +#if !defined(S_ISREG) && defined(S_IFREG) +# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#endif +#if !defined(S_ISLNK) && defined(S_IFLNK) +# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK) +#endif +#if !defined(S_ISBLK) && defined(S_IFBLK) +# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK) +#endif +#if !defined(S_ISSOCK) && defined(S_IFSOCK) +# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK) +#endif +#if !defined(S_ISFIFO) && defined(S_IFIFO) +# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO) +#endif +#if !defined(S_ISCHR) && defined(S_IFCHR) +# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR) +#endif + #endif // NVIM_OS_WIN_DEFS_H diff --git a/src/nvim/os_unix.c b/src/nvim/os_unix.c index 6c7cb3bba7..cb9a58cc77 100644 --- a/src/nvim/os_unix.c +++ b/src/nvim/os_unix.c @@ -175,13 +175,6 @@ void mch_exit(int r) exit(r); } -#ifndef SEEK_SET -# define SEEK_SET 0 -#endif -#ifndef SEEK_END -# define SEEK_END 2 -#endif - #define SHELL_SPECIAL (char_u *)"\t \"&'$;<>()\\|" /// Does wildcard pattern matching using the shell. diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 59ef2a0d28..f7d71f458d 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -3082,8 +3082,8 @@ shada_write_file_nomerge: {} // viminfo file that the user can't read. FileInfo old_info; if (os_fileinfo((char *)fname, &old_info)) { - if (getuid() == ROOT_UID) { - if (old_info.stat.st_uid != ROOT_UID + if (getuid() == 0) { + if (old_info.stat.st_uid != 0 || old_info.stat.st_gid != getgid()) { const uv_uid_t old_uid = (uv_uid_t) old_info.stat.st_uid; const uv_gid_t old_gid = (uv_gid_t) old_info.stat.st_gid; diff --git a/src/nvim/vim.h b/src/nvim/vim.h index fa00d9efcf..98ef5eb4fd 100644 --- a/src/nvim/vim.h +++ b/src/nvim/vim.h @@ -27,9 +27,6 @@ Error: configure did not run properly.Check auto/config.log. # endif #endif -/* user ID of root is usually zero, but not for everybody */ -#define ROOT_UID 0 - /* Can't use "PACKAGE" here, conflicts with a Perl include file. */ #ifndef VIMPACKAGE @@ -232,15 +229,6 @@ enum { /* Size in bytes of the hash used in the undo file. */ #define UNDO_HASH_SIZE 32 -#ifdef HAVE_FCNTL_H -# include <fcntl.h> -#endif - - -#ifndef O_NOFOLLOW -# define O_NOFOLLOW 0 -#endif - /* * defines to avoid typecasts from (char_u *) to (char *) and back * (vim_strchr() and vim_strrchr() are now in alloc.c) |