From 60a341a05f2d2a351a172b36e7f01e579e49ab02 Mon Sep 17 00:00:00 2001 From: b-r-o-c-k Date: Wed, 28 Feb 2018 19:14:27 -0600 Subject: [PATCH] build/msvc: Fix standard IO file number definitions With MSVC, STDOUT_FILENO and STDERR_FILENO are defined as function calls instead of constants, meaning they can't be assigned to enum values. The enum was only used in one file, so it has been removed. A definition for STDIN_FILENO has been added that is consistent with the other two definitions. --- src/nvim/main.c | 8 ++++---- src/nvim/os/os_defs.h | 7 ------- src/nvim/os/win_defs.h | 3 +++ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/nvim/main.c b/src/nvim/main.c index 4fd55f1491..25fb0f14d8 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -795,7 +795,7 @@ static void command_line_scan(mparm_T *parmp) mch_exit(0); } else if (STRICMP(argv[0] + argv_idx, "api-info") == 0) { FileDescriptor fp; - const int fof_ret = file_open_fd(&fp, OS_STDOUT_FILENO, true); + const int fof_ret = file_open_fd(&fp, STDOUT_FILENO, true); msgpack_packer *p = msgpack_packer_new(&fp, msgpack_file_write); if (fof_ret != 0) { @@ -1256,10 +1256,10 @@ static void check_and_set_isatty(mparm_T *paramp) paramp->err_isatty = os_isatty(fileno(stderr)); #ifndef WIN32 int tty_fd = paramp->input_isatty - ? OS_STDIN_FILENO + ? STDIN_FILENO : (paramp->output_isatty - ? OS_STDOUT_FILENO - : (paramp->err_isatty ? OS_STDERR_FILENO : -1)); + ? STDOUT_FILENO + : (paramp->err_isatty ? STDERR_FILENO : -1)); pty_process_save_termios(tty_fd); #endif TIME_MSG("window checked"); diff --git a/src/nvim/os/os_defs.h b/src/nvim/os/os_defs.h index 923a362b41..f81785675e 100644 --- a/src/nvim/os/os_defs.h +++ b/src/nvim/os/os_defs.h @@ -13,13 +13,6 @@ # include "nvim/os/unix_defs.h" #endif -/// File descriptor number used for standard IO streams -enum { - OS_STDIN_FILENO = STDIN_FILENO, - OS_STDOUT_FILENO = STDOUT_FILENO, - OS_STDERR_FILENO = STDERR_FILENO, -}; - #define BASENAMELEN (NAME_MAX - 5) // Use the system path length if it makes sense. diff --git a/src/nvim/os/win_defs.h b/src/nvim/os/win_defs.h index 48607845cc..faee06304c 100644 --- a/src/nvim/os/win_defs.h +++ b/src/nvim/os/win_defs.h @@ -45,6 +45,9 @@ # ifndef restrict # define restrict __restrict # endif +# ifndef STDIN_FILENO +# define STDIN_FILENO _fileno(stdin) +# endif # ifndef STDOUT_FILENO # define STDOUT_FILENO _fileno(stdout) # endif