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_unix.c b/src/os_unix.c index d0dc7243db..356cceaa11 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -5338,6 +5338,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) @@ -5384,24 +5395,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/os_win32.c b/src/os_win32.c index 8a38bcc56c..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; @@ -6503,7 +6504,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 +6537,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..4e0629867a 100644 --- a/src/proto/os_win32.pro +++ b/src/proto/os_win32.pro @@ -56,8 +56,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/terminal.c b/src/terminal.c index 6f440ec912..3a3a8860f8 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -973,7 +973,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)) @@ -1852,6 +1852,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 52dfc2fe78..ab886941f9 100644 --- a/src/version.c +++ b/src/version.c @@ -784,6 +784,16 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 844, +/**/ + 843, +/**/ + 842, +/**/ + 841, +/**/ + 840, /**/ 839, /**/ diff --git a/src/vim.h b/src/vim.h index 0b1463332d..8be8a00ff0 100644 --- a/src/vim.h +++ b/src/vim.h @@ -2144,6 +2144,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 */