From b6843a007da9c06bd8f9491cc12e5e0afd858f33 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 2 Aug 2017 22:07:12 +0200 Subject: [PATCH 1/5] patch 8.0.0840: MS-Windows: fopen() and open() prototypes are wrong Problem: MS-Windows: fopen() and open() prototypes do not match the ones in the system header file. Can't build without FEAT_MBYTE. Solution: Add "const". Move macro to after including protoo.h. --- src/macros.h | 7 ------- src/os_win32.c | 4 ++-- src/proto/os_win32.pro | 6 ++++-- src/version.c | 2 ++ src/vim.h | 5 +++++ 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/macros.h b/src/macros.h index d75d190723..c320a3f7d3 100644 --- a/src/macros.h +++ b/src/macros.h @@ -191,9 +191,6 @@ # ifndef WIN32 # define mch_access(n, p) access((n), (p)) # endif -# if !(defined(FEAT_MBYTE) && defined(WIN3264)) -# define mch_fopen(n, p) fopen((n), (p)) -# endif # define mch_fstat(n, p) fstat((n), (p)) # ifdef MSWIN /* has it's own mch_stat() function */ # define mch_stat(n, p) vim_stat((n), (p)) @@ -223,10 +220,6 @@ * but it is not recommended, because it can destroy indexes etc. */ # define mch_open(n, m, p) open(vms_fixfilename(n), (m), (p)) -# else -# if !(defined(FEAT_MBYTE) && defined(WIN3264)) -# define mch_open(n, m, p) open((n), (m), (p)) -# endif # endif #endif diff --git a/src/os_win32.c b/src/os_win32.c index 8a38bcc56c..4921b50f39 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -6503,7 +6503,7 @@ getout: * Version of open() that may use UTF-16 file name. */ int -mch_open(char *name, int flags, int mode) +mch_open(const char *name, int flags, int mode) { /* _wopen() does not work with Borland C 5.5: creates a read-only file. */ # ifndef __BORLANDC__ @@ -6536,7 +6536,7 @@ mch_open(char *name, int flags, int mode) * Version of fopen() that may use UTF-16 file name. */ FILE * -mch_fopen(char *name, char *mode) +mch_fopen(const char *name, const char *mode) { WCHAR *wn, *wm; FILE *f = NULL; diff --git a/src/proto/os_win32.pro b/src/proto/os_win32.pro index 6c5dc4fc01..754df4f975 100644 --- a/src/proto/os_win32.pro +++ b/src/proto/os_win32.pro @@ -4,6 +4,8 @@ HINSTANCE find_imported_module_by_funcname(HINSTANCE hInst, const char *funcname void *get_dll_import_func(HINSTANCE hInst, const char *funcname); int dyn_libintl_init(void); void dyn_libintl_end(void); +int null_libintl_putenv(const char *envstring); +int null_libintl_wputenv(const wchar_t *envstring); void PlatformId(void); void mch_setmouse(int on); void mch_update_cursor(void); @@ -56,8 +58,8 @@ int mch_wrename(WCHAR *wold, WCHAR *wnew); int mch_rename(const char *pszOldFile, const char *pszNewFile); char *default_shell(void); int mch_access(char *n, int p); -int mch_open(char *name, int flags, int mode); -FILE *mch_fopen(char *name, char *mode); +int mch_open(const char *name, int flags, int mode); +FILE *mch_fopen(const char *name, const char *mode); int mch_copy_file_attribute(char_u *from, char_u *to); int myresetstkoflw(void); int get_cmd_argsW(char ***argvp); diff --git a/src/version.c b/src/version.c index 19228375eb..d4a334dede 100644 --- a/src/version.c +++ b/src/version.c @@ -769,6 +769,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 840, /**/ 839, /**/ diff --git a/src/vim.h b/src/vim.h index 8b6337e232..2562d9e8b0 100644 --- a/src/vim.h +++ b/src/vim.h @@ -2141,6 +2141,11 @@ typedef enum { # define number_width(x) 7 #endif +/* This must come after including proto.h */ +#if !(defined(FEAT_MBYTE) && defined(WIN3264)) +# define mch_open(n, m, p) open((n), (m), (p)) +# define mch_fopen(n, p) fopen((n), (p)) +#endif #include "globals.h" /* global variables and messages */ From 5c838a3e7141f9950508c84439d2f959bc67e941 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 2 Aug 2017 22:10:34 +0200 Subject: [PATCH 2/5] patch 8.0.0841: term_getline() may cause a crash Problem: term_getline() may cause a crash. Solution: Check that the row is valid. (Hirohito Higashi) --- src/terminal.c | 2 ++ src/testdir/test_terminal.vim | 10 ++++++++++ src/version.c | 2 ++ 3 files changed, 14 insertions(+) diff --git a/src/terminal.c b/src/terminal.c index 4af0832901..5622ce3596 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -1847,6 +1847,8 @@ f_term_getline(typval_T *argvars, typval_T *rettv) int len; char_u *p; + if (row < 0 || row >= term->tl_rows) + return; len = term->tl_cols * MB_MAXBYTES + 1; p = alloc(len); if (p == NULL) diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim index 97f7d5c2d9..48ee1c4eca 100644 --- a/src/testdir/test_terminal.vim +++ b/src/testdir/test_terminal.vim @@ -81,6 +81,10 @@ func Test_terminal_hide_buffer() endfunc func Check_123(buf) + let l = term_scrape(a:buf, 0) + call assert_true(len(l) == 0) + let l = term_scrape(a:buf, 999) + call assert_true(len(l) == 0) let l = term_scrape(a:buf, 1) call assert_true(len(l) > 0) call assert_equal('1', l[0].chars) @@ -93,6 +97,12 @@ func Check_123(buf) call assert_equal('#000000', l[0].bg) endif + let l = term_getline(a:buf, -1) + call assert_equal('', l) + let l = term_getline(a:buf, 0) + call assert_equal('', l) + let l = term_getline(a:buf, 999) + call assert_equal('', l) let l = term_getline(a:buf, 1) call assert_equal('123', l) endfunc diff --git a/src/version.c b/src/version.c index d4a334dede..19ad732cbf 100644 --- a/src/version.c +++ b/src/version.c @@ -769,6 +769,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 841, /**/ 840, /**/ From 223896d3e9d4d511fc38fd9ee27ba16318733df6 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 2 Aug 2017 22:33:28 +0200 Subject: [PATCH 3/5] patch 8.0.0842: using slave pty after closing it Problem: Using slave pty after closing it. Solution: Do the ioctl() before dup'ing it. --- src/os_unix.c | 26 +++++++++++++------------- src/version.c | 2 ++ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/os_unix.c b/src/os_unix.c index fb2628c7e4..7c4b3180e5 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5316,6 +5316,17 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options) if (use_null_for_in || use_null_for_out || use_null_for_err) null_fd = open("/dev/null", O_RDWR | O_EXTRA, 0); + if (pty_slave_fd >= 0) + { + /* push stream discipline modules */ + SetupSlavePTY(pty_slave_fd); +# ifdef TIOCSCTTY + /* Try to become controlling tty (probably doesn't work, + * unless run by root) */ + ioctl(pty_slave_fd, TIOCSCTTY, (char *)NULL); +# endif + } + /* set up stdin for the child */ close(0); if (use_null_for_in && null_fd >= 0) @@ -5362,24 +5373,13 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options) close(fd_err[1]); if (pty_master_fd >= 0) { - close(pty_master_fd); /* not used */ - close(pty_slave_fd); /* duped above */ + close(pty_master_fd); /* not used in the child */ + close(pty_slave_fd); /* was duped above */ } if (null_fd >= 0) close(null_fd); - if (pty_slave_fd >= 0) - { - /* push stream discipline modules */ - SetupSlavePTY(pty_slave_fd); -# ifdef TIOCSCTTY - /* Try to become controlling tty (probably doesn't work, - * unless run by root) */ - ioctl(pty_slave_fd, TIOCSCTTY, (char *)NULL); -# endif - } - /* See above for type of argv. */ execvp(argv[0], argv); diff --git a/src/version.c b/src/version.c index 19ad732cbf..0ef1f452b0 100644 --- a/src/version.c +++ b/src/version.c @@ -769,6 +769,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 842, /**/ 841, /**/ From 66cd19fef1c5e86d798db164cc29f8ec2793411d Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 2 Aug 2017 23:13:27 +0200 Subject: [PATCH 4/5] patch 8.0.0843: MS-Windows: compiler warning for signed/unsigned Problem: MS-Windows: compiler warning for signed/unsigned. Solution: Add type cast. (Yasuhiro Matsumoto, closes #1912) --- src/terminal.c | 2 +- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/terminal.c b/src/terminal.c index 5622ce3596..53edb83c8b 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -968,7 +968,7 @@ terminal_loop(void) /* We don't know if the job can handle CTRL-C itself or not, this * may kill the shell instead of killing the command running in the * shell. */ - mch_stop_job(curbuf->b_term->tl_job, "quit") + mch_stop_job(curbuf->b_term->tl_job, (char_u *)"quit") #endif if (c == (termkey == 0 ? Ctrl_W : termkey)) diff --git a/src/version.c b/src/version.c index 0ef1f452b0..2db4ca9214 100644 --- a/src/version.c +++ b/src/version.c @@ -769,6 +769,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 843, /**/ 842, /**/ From e0ab979fa7404592eaf4180e6d7d3af4c7787e8f Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Wed, 2 Aug 2017 23:18:25 +0200 Subject: [PATCH 5/5] patch 8.0.0844: wrong function prototype because of missing static Problem: Wrong function prototype because of missing static. Solution: Add "static". --- src/os_win32.c | 5 +++-- src/proto/os_win32.pro | 2 -- src/version.c | 2 ++ 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/os_win32.c b/src/os_win32.c index 4921b50f39..d3cab02234 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -111,6 +111,7 @@ typedef int HICON; typedef int HINSTANCE; typedef int HWND; typedef int INPUT_RECORD; +typedef int INT; typedef int KEY_EVENT_RECORD; typedef int LOGFONT; typedef int LPBOOL; @@ -657,13 +658,13 @@ null_libintl_textdomain(const char *domainname UNUSED) return NULL; } - int + static int null_libintl_putenv(const char *envstring UNUSED) { return 0; } - int + static int null_libintl_wputenv(const wchar_t *envstring UNUSED) { return 0; diff --git a/src/proto/os_win32.pro b/src/proto/os_win32.pro index 754df4f975..4e0629867a 100644 --- a/src/proto/os_win32.pro +++ b/src/proto/os_win32.pro @@ -4,8 +4,6 @@ HINSTANCE find_imported_module_by_funcname(HINSTANCE hInst, const char *funcname void *get_dll_import_func(HINSTANCE hInst, const char *funcname); int dyn_libintl_init(void); void dyn_libintl_end(void); -int null_libintl_putenv(const char *envstring); -int null_libintl_wputenv(const wchar_t *envstring); void PlatformId(void); void mch_setmouse(int on); void mch_update_cursor(void); diff --git a/src/version.c b/src/version.c index 2db4ca9214..ee0a081bf8 100644 --- a/src/version.c +++ b/src/version.c @@ -769,6 +769,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 844, /**/ 843, /**/