mirror of
https://github.com/neovim/neovim.git
synced 2025-10-09 11:26:37 +00:00
refactor(build): remove unused stdlib function and include checks
In addition: merge some checks for the same feature into one test_compile. This reduces the total number of test compiles which speeds up the cmake configure stage.
This commit is contained in:
@@ -240,13 +240,15 @@ endif()
|
||||
if(UNIX)
|
||||
# -fstack-protector breaks non Unix builds even in Mingw-w64
|
||||
check_c_compiler_flag(-fstack-protector-strong HAS_FSTACK_PROTECTOR_STRONG_FLAG)
|
||||
check_c_compiler_flag(-fstack-protector HAS_FSTACK_PROTECTOR_FLAG)
|
||||
if(HAS_FSTACK_PROTECTOR_STRONG_FLAG)
|
||||
target_compile_options(main_lib INTERFACE -fstack-protector-strong)
|
||||
target_link_libraries(main_lib INTERFACE -fstack-protector-strong)
|
||||
elseif(HAS_FSTACK_PROTECTOR_FLAG)
|
||||
target_compile_options(main_lib INTERFACE -fstack-protector --param ssp-buffer-size=4)
|
||||
target_link_libraries(main_lib INTERFACE -fstack-protector --param ssp-buffer-size=4)
|
||||
else()
|
||||
check_c_compiler_flag(-fstack-protector HAS_FSTACK_PROTECTOR_FLAG)
|
||||
if(HAS_FSTACK_PROTECTOR_FLAG)
|
||||
target_compile_options(main_lib INTERFACE -fstack-protector --param ssp-buffer-size=4)
|
||||
target_link_libraries(main_lib INTERFACE -fstack-protector --param ssp-buffer-size=4)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@@ -1446,7 +1446,7 @@ long getdigits_long(char **pp, bool strict, long def)
|
||||
int32_t getdigits_int32(char **pp, bool strict, long def)
|
||||
{
|
||||
intmax_t number = getdigits(pp, strict, def);
|
||||
#if SIZEOF_INTMAX_T > SIZEOF_INT32_T
|
||||
#if SIZEOF_INTMAX_T > 4
|
||||
if (strict) {
|
||||
assert(number >= INT32_MIN && number <= INT32_MAX);
|
||||
} else if (!(number >= INT32_MIN && number <= INT32_MAX)) {
|
||||
|
@@ -68,7 +68,7 @@
|
||||
# include "nvim/charset.h"
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_FLOCK) && defined(HAVE_DIRFD)
|
||||
#ifdef HAVE_DIRFD_AND_FLOCK
|
||||
# include <dirent.h>
|
||||
# include <sys/file.h>
|
||||
#endif
|
||||
@@ -5146,7 +5146,7 @@ void forward_slash(char *fname)
|
||||
|
||||
/// Path to Nvim's own temp dir. Ends in a slash.
|
||||
static char *vim_tempdir = NULL;
|
||||
#if defined(HAVE_FLOCK) && defined(HAVE_DIRFD)
|
||||
#ifdef HAVE_DIRFD_AND_FLOCK
|
||||
DIR *vim_tempdir_dp = NULL; ///< File descriptor of temp dir
|
||||
#endif
|
||||
|
||||
@@ -5316,7 +5316,7 @@ int delete_recursive(const char *name)
|
||||
return result;
|
||||
}
|
||||
|
||||
#if defined(HAVE_FLOCK) && defined(HAVE_DIRFD)
|
||||
#ifdef HAVE_DIRFD_AND_FLOCK
|
||||
/// Open temporary directory and take file lock to prevent
|
||||
/// to be auto-cleaned.
|
||||
static void vim_opentempdir(void)
|
||||
@@ -5353,7 +5353,7 @@ void vim_deltempdir(void)
|
||||
return;
|
||||
}
|
||||
|
||||
#if defined(HAVE_FLOCK) && defined(HAVE_DIRFD)
|
||||
#ifdef HAVE_DIRFD_AND_FLOCK
|
||||
vim_closetempdir();
|
||||
#endif
|
||||
// remove the trailing path separator
|
||||
@@ -5391,7 +5391,7 @@ static bool vim_settempdir(char *tempdir)
|
||||
vim_FullName(tempdir, buf, MAXPATHL, false);
|
||||
add_pathsep(buf);
|
||||
vim_tempdir = xstrdup(buf);
|
||||
#if defined(HAVE_FLOCK) && defined(HAVE_DIRFD)
|
||||
#ifdef HAVE_DIRFD_AND_FLOCK
|
||||
vim_opentempdir();
|
||||
#endif
|
||||
xfree(buf);
|
||||
|
@@ -36,10 +36,9 @@
|
||||
// Command-processing buffer. Use large buffers for all platforms.
|
||||
#define CMDBUFFSIZE 1024
|
||||
|
||||
// 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.
|
||||
// Note: Some systems need both string.h and strings.h (Savage).
|
||||
#include <string.h>
|
||||
#if defined(HAVE_STRINGS_H) && !defined(NO_STRINGS_WITH_STRING_H)
|
||||
#ifdef HAVE_STRINGS_H
|
||||
# include <strings.h>
|
||||
#endif
|
||||
|
||||
|
@@ -399,8 +399,8 @@ int os_expand_wildcards(int num_pat, char **pat, int *num_file, char ***file, in
|
||||
fclose(fd);
|
||||
return FAIL;
|
||||
}
|
||||
#if SIZEOF_LONG_LONG > SIZEOF_SIZE_T
|
||||
assert(templen <= (long long)SIZE_MAX); // NOLINT(runtime/int)
|
||||
#if 8 > SIZEOF_SIZE_T
|
||||
assert(templen <= SIZE_MAX); // NOLINT(runtime/int)
|
||||
#endif
|
||||
len = (size_t)templen;
|
||||
fseek(fd, 0L, SEEK_SET);
|
||||
|
@@ -15,7 +15,7 @@
|
||||
#include "nvim/os/os.h"
|
||||
#include "nvim/types.h"
|
||||
#include "nvim/vim.h"
|
||||
#ifdef HAVE_PWD_H
|
||||
#ifdef HAVE_PWD_FUNCS
|
||||
# include <pwd.h>
|
||||
#endif
|
||||
#ifdef MSWIN
|
||||
@@ -50,7 +50,7 @@ int os_get_usernames(garray_T *users)
|
||||
}
|
||||
ga_init(users, sizeof(char *), 20);
|
||||
|
||||
#if defined(HAVE_GETPWENT) && defined(HAVE_PWD_H)
|
||||
#ifdef HAVE_PWD_FUNCS
|
||||
{
|
||||
struct passwd *pw;
|
||||
|
||||
@@ -81,7 +81,7 @@ int os_get_usernames(garray_T *users)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#if defined(HAVE_GETPWNAM)
|
||||
#ifdef HAVE_PWD_FUNCS
|
||||
{
|
||||
const char *user_env = os_getenv("USER");
|
||||
|
||||
@@ -141,7 +141,7 @@ int os_get_username(char *s, size_t len)
|
||||
/// @return OK if a username was found, else FAIL.
|
||||
int os_get_uname(uv_uid_t uid, char *s, size_t len)
|
||||
{
|
||||
#if defined(HAVE_PWD_H) && defined(HAVE_GETPWUID)
|
||||
#ifdef HAVE_PWD_FUNCS
|
||||
struct passwd *pw;
|
||||
|
||||
if ((pw = getpwuid(uid)) != NULL // NOLINT(runtime/threadsafe_fn)
|
||||
@@ -159,7 +159,7 @@ int os_get_uname(uv_uid_t uid, char *s, size_t len)
|
||||
/// Caller must free() the returned string.
|
||||
char *os_get_userdir(const char *name)
|
||||
{
|
||||
#if defined(HAVE_GETPWNAM) && defined(HAVE_PWD_H)
|
||||
#ifdef HAVE_PWD_FUNCS
|
||||
if (name == NULL || *name == NUL) {
|
||||
return NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user