refactor: move function macros out of vim_defs.h (#26300)

This commit is contained in:
zeertzjq
2023-11-29 23:10:21 +08:00
committed by GitHub
parent 18c1fd8e9d
commit 86cc791deb
22 changed files with 86 additions and 89 deletions

View File

@@ -1,8 +1,5 @@
#pragma once
#include "nvim/pos_defs.h"
#include "nvim/types_defs.h"
// Some defines from the old feature.h
#define SESSION_FILE "Session.vim"
#define MAX_MSG_HIST_LEN 200
@@ -10,15 +7,6 @@
#define RUNTIME_DIRNAME "runtime"
#include "auto/config.h"
#define HAVE_PATHDEF
// Some file names are stored in pathdef.c, which is generated from the
// Makefile to make their value depend on the Makefile.
#ifdef HAVE_PATHDEF
extern char *default_vim_dir;
extern char *default_vimruntime_dir;
extern char *default_lib_dir;
#endif
// Check if configure correctly managed to find sizeof(int). If this failed,
// it becomes zero. This is likely a problem of not being able to run the
@@ -27,17 +15,14 @@ extern char *default_lib_dir;
# error Configure did not run properly.
#endif
#include "nvim/os/os_defs.h" // bring lots of system header files
// bring lots of system header files
#include "nvim/os/os_defs.h" // IWYU pragma: keep
/// length of a buffer to store a number in ASCII (64 bits binary + NUL)
enum { NUMBUFLEN = 65, };
#define MAX_TYPENR 65535
#include "nvim/gettext.h"
#include "nvim/keycodes.h"
#include "nvim/macros_defs.h"
/// Directions.
typedef enum {
kDirectionNotSet = 0,
@@ -54,44 +39,3 @@ typedef enum {
#endif
#define FAIL 0
#define NOTDONE 2 // not OK or FAIL but skipped
#define CLEAR_FIELD(field) memset(&(field), 0, sizeof(field))
#define CLEAR_POINTER(ptr) memset((ptr), 0, sizeof(*(ptr)))
// (vim_strchr() is now in strings.c)
#ifndef HAVE_STRNLEN
# define strnlen xstrnlen // Older versions of SunOS may not have strnlen
#endif
#define STRCPY(d, s) strcpy((char *)(d), (char *)(s)) // NOLINT(runtime/printf)
#ifdef HAVE_STRCASECMP
# define STRICMP(d, s) strcasecmp((char *)(d), (char *)(s))
#else
# ifdef HAVE_STRICMP
# define STRICMP(d, s) stricmp((char *)(d), (char *)(s))
# else
# define STRICMP(d, s) vim_stricmp((char *)(d), (char *)(s))
# endif
#endif
// Like strcpy() but allows overlapped source and destination.
#define STRMOVE(d, s) memmove((d), (s), strlen(s) + 1)
#ifdef HAVE_STRNCASECMP
# define STRNICMP(d, s, n) strncasecmp((char *)(d), (char *)(s), (size_t)(n))
#else
# ifdef HAVE_STRNICMP
# define STRNICMP(d, s, n) strnicmp((char *)(d), (char *)(s), (size_t)(n))
# else
# define STRNICMP(d, s, n) vim_strnicmp((char *)(d), (char *)(s), (size_t)(n))
# endif
#endif
#define STRCAT(d, s) strcat((char *)(d), (char *)(s)) // NOLINT(runtime/printf)
// BSD is supposed to cover FreeBSD and similar systems.
#if (defined(BSD) || defined(__FreeBSD_kernel__)) \
&& (defined(S_ISCHR) || defined(S_IFCHR))
# define OPEN_CHR_FILES
#endif