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.
This commit is contained in:
Michael Reed
2016-01-14 16:05:23 -05:00
parent 24fbb2c866
commit 07265d221f
7 changed files with 28 additions and 53 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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>

View File

@@ -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

View File

@@ -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.

View File

@@ -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;

View File

@@ -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)