diff options
author | ZyX <kp-pav@yandex.ru> | 2017-03-19 16:55:37 +0300 |
---|---|---|
committer | ZyX <kp-pav@yandex.ru> | 2017-03-19 16:56:00 +0300 |
commit | bd798a3267a496c644b339c45189b09e2a952014 (patch) | |
tree | af4dd543f54bd166b5b288484551df26995179d7 /src/nvim/main.c | |
parent | fdfa1ed578afd41a68f05c88dc419d88051b7240 (diff) | |
download | rneovim-bd798a3267a496c644b339c45189b09e2a952014.tar.gz rneovim-bd798a3267a496c644b339c45189b09e2a952014.tar.bz2 rneovim-bd798a3267a496c644b339c45189b09e2a952014.zip |
getchar: Use fileio instead of fdopen
Problem: as fileio is cached and reads blocks this is going to wait
until either EOF or reading enough characters to fill rbuffer. This is
not good when reading user input from stdin as script.
Diffstat (limited to 'src/nvim/main.c')
-rw-r--r-- | src/nvim/main.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/nvim/main.c b/src/nvim/main.c index ce0426bd8e..da3ec4381e 100644 --- a/src/nvim/main.c +++ b/src/nvim/main.c @@ -1056,14 +1056,20 @@ scripterror: mch_errmsg("\"\n"); mch_exit(2); } + int error; if (STRCMP(argv[0], "-") == 0) { - const int stdin_dup_fd = os_dup(STDIN_FILENO); - FILE *const stdin_dup = fdopen(stdin_dup_fd, "r"); + const int stdin_dup_fd = os_dup(OS_STDIN_FILENO); + FileDescriptor *const stdin_dup = file_open_fd_new( + &error, stdin_dup_fd, false, 0); + assert(stdin_dup != NULL); scriptin[0] = stdin_dup; - } else if ((scriptin[0] = mch_fopen(argv[0], READBIN)) == NULL) { + } else if ((scriptin[0] = file_open_new( + &error, argv[0], kFileReadOnly, 0)) == NULL) { mch_errmsg(_("Cannot open for reading: \"")); mch_errmsg(argv[0]); - mch_errmsg("\"\n"); + mch_errmsg("\": "); + mch_errmsg(os_strerror(error)); + mch_errmsg("\n"); mch_exit(2); } save_typebuf(); |