From 182707ac10d77359bf7a87c6b23ce4025d5b0ad4 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Mon, 21 Nov 2016 20:55:58 +0100 Subject: [PATCH 01/10] patch 8.0.0095 Problem: Problems with GTK 3.22.2 fixed in 3.22.4. Solution: Adjust the #ifdefs. (Kazunobu Kuriyama) --- src/gui_gtk_x11.c | 12 ++++++++++-- src/version.c | 2 ++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c index 5020177d95..514ac9e31a 100644 --- a/src/gui_gtk_x11.c +++ b/src/gui_gtk_x11.c @@ -3102,7 +3102,7 @@ drawarea_configure_event_cb(GtkWidget *widget, g_return_val_if_fail(event && event->width >= 1 && event->height >= 1, TRUE); -# if GTK_CHECK_VERSION(3,22,2) +# if GTK_CHECK_VERSION(3,22,2) && !GTK_CHECK_VERSION(3,22,4) /* As of 3.22.2, GdkWindows have started distributing configure events to * their "native" children (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=12579fe71b3b8f79eb9c1b80e429443bcc437dd0). * @@ -3123,6 +3123,10 @@ drawarea_configure_event_cb(GtkWidget *widget, * implementation details. Therefore, watch out any relevant internal * changes happening in GTK in the feature (sigh). */ + /* Follow-up + * After a few weeks later, the GdkWindow change mentioned above was + * reverted (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=f70039cb9603a02d2369fec4038abf40a1711155). + * The corresponding official release is 3.22.4. */ if (event->send_event == FALSE) return TRUE; # endif @@ -4492,7 +4496,7 @@ form_configure_event(GtkWidget *widget UNUSED, { int usable_height = event->height; -#if GTK_CHECK_VERSION(3,22,2) +#if GTK_CHECK_VERSION(3,22,2) && !GTK_CHECK_VERSION(3,22,4) /* As of 3.22.2, GdkWindows have started distributing configure events to * their "native" children (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=12579fe71b3b8f79eb9c1b80e429443bcc437dd0). * @@ -4508,6 +4512,10 @@ form_configure_event(GtkWidget *widget UNUSED, * To filter out such fallacious events, check if the given event is the * one that was sent out to the right place. Ignore it if not. */ + /* Follow-up + * After a few weeks later, the GdkWindow change mentioned above was + * reverted (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=f70039cb9603a02d2369fec4038abf40a1711155). + * The corresponding official release is 3.22.4. */ if (event->window != gtk_widget_get_window(gui.formwin)) return TRUE; #endif diff --git a/src/version.c b/src/version.c index 1224142b89..731a6850d4 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 95, /**/ 94, /**/ From 2cab0e191055a8145ccd46cd52869fbb9798b971 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 24 Nov 2016 15:09:07 +0100 Subject: [PATCH 02/10] patch 8.0.0096 Problem: When the input or output is not a tty Vim appears to hang. Solution: Add the --ttyfail argument. Also add the "ttyin" and "ttyout" features to be able to check in Vim script. --- runtime/doc/eval.txt | 2 ++ runtime/doc/starting.txt | 4 ++++ src/evalfunc.c | 4 ++++ src/globals.h | 2 ++ src/main.c | 14 ++++++++++---- src/structs.h | 2 +- src/version.c | 2 ++ 7 files changed, 25 insertions(+), 5 deletions(-) diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt index b34bf48087..1a11a41411 100644 --- a/runtime/doc/eval.txt +++ b/runtime/doc/eval.txt @@ -8416,6 +8416,8 @@ tgetent Compiled with tgetent support, able to use a termcap timers Compiled with |timer_start()| support. title Compiled with window title support |'title'|. toolbar Compiled with support for |gui-toolbar|. +ttyin input is a terminal (tty) +ttyout output is a terminal (tty) unix Unix version of Vim. user_commands User-defined commands. vertsplit Compiled with vertically split windows |:vsplit|. diff --git a/runtime/doc/starting.txt b/runtime/doc/starting.txt index 8ce3c63d2a..34500fc0ce 100644 --- a/runtime/doc/starting.txt +++ b/runtime/doc/starting.txt @@ -421,6 +421,10 @@ a slash. Thus "-R" means recovery and "-/R" readonly. not connected to a terminal. This will avoid the warning and the two second delay that would happen. {not in Vi} + *--ttyfail* +--ttyfail When the stdin or stdout is not a terminal (tty) then exit + right away. + *-d* -d Start in diff mode, like |vimdiff|. {not in Vi} {not available when compiled without the |+diff| diff --git a/src/evalfunc.c b/src/evalfunc.c index 1257aa0594..846a914165 100644 --- a/src/evalfunc.c +++ b/src/evalfunc.c @@ -5959,6 +5959,10 @@ f_has(typval_T *argvars, typval_T *rettv) } else if (STRICMP(name, "vim_starting") == 0) n = (starting != 0); + else if (STRICMP(name, "ttyin") == 0) + n = mch_input_isatty(); + else if (STRICMP(name, "ttyout") == 0) + n = stdout_isatty; #ifdef FEAT_MBYTE else if (STRICMP(name, "multi_byte_encoding") == 0) n = has_mbyte; diff --git a/src/globals.h b/src/globals.h index c15e4f9bb9..0b6abb0e85 100644 --- a/src/globals.h +++ b/src/globals.h @@ -643,6 +643,8 @@ EXTERN int exiting INIT(= FALSE); EXTERN int really_exiting INIT(= FALSE); /* TRUE when we are sure to exit, e.g., after * a deadly signal */ +EXTERN int stdout_isatty INIT(= TRUE); /* is stdout a terminal? */ + #if defined(FEAT_AUTOCHDIR) EXTERN int test_autochdir INIT(= FALSE); #endif diff --git a/src/main.c b/src/main.c index acc51f182a..f3c471a852 100644 --- a/src/main.c +++ b/src/main.c @@ -973,7 +973,7 @@ common_init(mparm_T *paramp) * (needed for :! to * work). mch_check_win() will also handle the -d or * -dev argument. */ - paramp->stdout_isatty = (mch_check_win(paramp->argc, paramp->argv) != FAIL); + stdout_isatty = (mch_check_win(paramp->argc, paramp->argv) != FAIL); TIME_MSG("window checked"); /* @@ -1828,6 +1828,7 @@ command_line_scan(mparm_T *parmp) /* "--literal" take files literally */ /* "--nofork" don't fork */ /* "--not-a-term" don't warn for not a term */ + /* "--ttyfail" exit if not a term */ /* "--noplugin[s]" skip plugins */ /* "--cmd " execute cmd before vimrc */ if (STRICMP(argv[0] + argv_idx, "help") == 0) @@ -1857,6 +1858,8 @@ command_line_scan(mparm_T *parmp) p_lpl = FALSE; else if (STRNICMP(argv[0] + argv_idx, "not-a-term", 10) == 0) parmp->not_a_term = TRUE; + else if (STRNICMP(argv[0] + argv_idx, "ttyfail", 7) == 0) + parmp->tty_fail = TRUE; else if (STRNICMP(argv[0] + argv_idx, "cmd", 3) == 0) { want_argument = TRUE; @@ -2489,7 +2492,7 @@ check_tty(mparm_T *parmp) if (!input_isatty) silent_mode = TRUE; } - else if (parmp->want_full_screen && (!parmp->stdout_isatty || !input_isatty) + else if (parmp->want_full_screen && (!stdout_isatty || !input_isatty) #ifdef FEAT_GUI /* don't want the delay when started from the desktop */ && !gui.starting @@ -2504,7 +2507,7 @@ check_tty(mparm_T *parmp) * input buffer so fast I can't even kill the process in under 2 * minutes (and it beeps continuously the whole time :-) */ - if (netbeans_active() && (!parmp->stdout_isatty || !input_isatty)) + if (netbeans_active() && (!stdout_isatty || !input_isatty)) { mch_errmsg(_("Vim: Error: Failure to start gvim from NetBeans\n")); exit(1); @@ -2517,11 +2520,13 @@ check_tty(mparm_T *parmp) exit(1); } #endif - if (!parmp->stdout_isatty) + if (!stdout_isatty) mch_errmsg(_("Vim: Warning: Output is not to a terminal\n")); if (!input_isatty) mch_errmsg(_("Vim: Warning: Input is not from a terminal\n")); out_flush(); + if (parmp->tty_fail && (!stdout_isatty || !input_isatty)) + exit(1); if (scriptin[0] == NULL) ui_delay(2000L, TRUE); TIME_MSG("Warning delay"); @@ -3287,6 +3292,7 @@ usage(void) #endif main_msg(_("-T \tSet terminal type to ")); main_msg(_("--not-a-term\t\tSkip warning for input/output not being a terminal")); + main_msg(_("--ttyfail\t\tExit if input or output is not a terminal")); main_msg(_("-u \t\tUse instead of any .vimrc")); #ifdef FEAT_GUI main_msg(_("-U \t\tUse instead of any .gvimrc")); diff --git a/src/structs.h b/src/structs.h index c749a3691d..1b73e37c28 100644 --- a/src/structs.h +++ b/src/structs.h @@ -3225,8 +3225,8 @@ typedef struct #endif int want_full_screen; - int stdout_isatty; /* is stdout a terminal? */ int not_a_term; /* no warning for missing term? */ + int tty_fail; /* exit if not a tty */ char_u *term; /* specified terminal name */ #ifdef FEAT_CRYPT int ask_for_key; /* -x argument */ diff --git a/src/version.c b/src/version.c index 731a6850d4..e259000c0f 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 96, /**/ 95, /**/ From 833eb1d752426689051bf2001083359899536939 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 24 Nov 2016 17:22:50 +0100 Subject: [PATCH 03/10] patch 8.0.0097 Problem: When a channel callback consumes a lot of time Vim becomes unresponsive. (skywind) Solution: Bail out of checking channel readahead after 100 msec. --- src/channel.c | 14 +++++++++- src/misc2.c | 31 ++++++++++++++++++++++ src/os_unix.c | 70 +++++++++++++++++++------------------------------- src/os_win32.c | 3 --- src/version.c | 2 ++ src/vim.h | 16 ++++++++++++ 6 files changed, 88 insertions(+), 48 deletions(-) diff --git a/src/channel.c b/src/channel.c index 778a30e17c..19520e2007 100644 --- a/src/channel.c +++ b/src/channel.c @@ -3815,6 +3815,11 @@ channel_parse_messages(void) int ret = FALSE; int r; ch_part_T part = PART_SOCK; +#ifdef ELAPSED_FUNC + ELAPSED_TYPE start_tv; + + ELAPSED_INIT(start_tv); +#endif ++safe_to_invoke_callback; @@ -3859,7 +3864,14 @@ channel_parse_messages(void) r = may_invoke_callback(channel, part); if (r == OK) ret = TRUE; - if (channel_unref(channel) || r == OK) + if (channel_unref(channel) || (r == OK +#ifdef ELAPSED_FUNC + /* Limit the time we loop here to 100 msec, otherwise + * Vim becomes unresponsive when the callback takes + * more than a bit of time. */ + && ELAPSED_FUNC(start_tv) < 100L +#endif + )) { /* channel was freed or something was done, start over */ channel = first_channel; diff --git a/src/misc2.c b/src/misc2.c index 27d26bece9..9fa11e3d25 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -6263,3 +6263,34 @@ parse_queued_messages(void) # endif } #endif + +#ifdef ELAPSED_TIMEVAL /* proto is defined in vim.h */ +/* + * Return time in msec since "start_tv". + */ + long +elapsed(struct timeval *start_tv) +{ + struct timeval now_tv; + + gettimeofday(&now_tv, NULL); + return (now_tv.tv_sec - start_tv->tv_sec) * 1000L + + (now_tv.tv_usec - start_tv->tv_usec) / 1000L; +} +#endif + +#ifdef ELAPSED_TICKCOUNT +/* + * Return time in msec since "start_tick". + */ + long +elapsed(DWORD start_tick) +{ + DWORD now = GetTickCount(); + + if (now < start_tick) + /* overflow */ + return (long)now; + return (long)now - (long)start_tick; +} +#endif diff --git a/src/os_unix.c b/src/os_unix.c index a63eb6e891..12fb33b7ae 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -376,21 +376,6 @@ mch_write(char_u *s, int len) RealWaitForChar(read_cmd_fd, p_wd, NULL, NULL); } -#if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) -/* - * Return time in msec since "start_tv". - */ - static long -elapsed(struct timeval *start_tv) -{ - struct timeval now_tv; - - gettimeofday(&now_tv, NULL); - return (now_tv.tv_sec - start_tv->tv_sec) * 1000L - + (now_tv.tv_usec - start_tv->tv_usec) / 1000L; -} -#endif - /* * mch_inchar(): low level input function. * Get a characters from the keyboard. @@ -411,10 +396,10 @@ mch_inchar( int did_start_blocking = FALSE; long wait_time; long elapsed_time = 0; -#if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) - struct timeval start_tv; +#ifdef ELAPSED_FUNC + ELAPSED_TYPE start_tv; - gettimeofday(&start_tv, NULL); + ELAPSED_INIT(start_tv); #endif /* repeat until we got a character or waited long enough */ @@ -438,8 +423,8 @@ mch_inchar( else /* going to block after p_ut */ wait_time = p_ut; -#if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) - elapsed_time = elapsed(&start_tv); +#ifdef ELAPSED_FUNC + elapsed_time = ELAPSED_FUNC(start_tv); #endif wait_time -= elapsed_time; if (wait_time < 0) @@ -1554,18 +1539,16 @@ mch_input_isatty(void) #ifdef FEAT_X11 -# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) \ +# if defined(ELAPSED_TIMEVAL) \ && (defined(FEAT_XCLIPBOARD) || defined(FEAT_TITLE)) -static void xopen_message(struct timeval *start_tv); - /* * Give a message about the elapsed time for opening the X window. */ static void -xopen_message(struct timeval *start_tv) +xopen_message(long elapsed_msec) { - smsg((char_u *)_("Opening the X display took %ld msec"), elapsed(start_tv)); + smsg((char_u *)_("Opening the X display took %ld msec"), elapsed_msec); } # endif #endif @@ -1864,11 +1847,11 @@ get_x11_windis(void) #endif if (x11_display != NULL) { -# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) +# ifdef ELAPSED_FUNC if (p_verbose > 0) { verbose_enter(); - xopen_message(&start_tv); + xopen_message(ELAPSED_FUNC(start_tv)); verbose_leave(); } # endif @@ -4630,8 +4613,8 @@ mch_call_shell( ga_init2(&ga, 1, BUFLEN); noread_cnt = 0; -# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) - gettimeofday(&start_tv, NULL); +# ifdef ELAPSED_FUNC + ELAPSED_INIT(start_tv); # endif for (;;) { @@ -4666,8 +4649,8 @@ mch_call_shell( /* Get extra characters when we don't have any. * Reset the counter and timer. */ noread_cnt = 0; -# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) - gettimeofday(&start_tv, NULL); +# ifdef ELAPSED_FUNC + ELAPSED_INIT(start_tv); # endif len = ui_inchar(ta_buf, BUFLEN, 10L, 0); } @@ -4886,10 +4869,10 @@ mch_call_shell( if (got_int) break; -# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) +# ifdef ELAPSED_FUNC if (wait_pid == 0) { - long msec = elapsed(&start_tv); + long msec = ELAPSED_FUNC(start_tv); /* Avoid that we keep looping here without * checking for a CTRL-C for a long time. Don't @@ -5632,15 +5615,14 @@ RealWaitForChar(int fd, long msec, int *check_for_gpm UNUSED, int *interrupted) /* May retry getting characters after an event was handled. */ # define MAY_LOOP -# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) +# ifdef ELAPSED_FUNC /* Remember at what time we started, so that we know how much longer we * should wait after being interrupted. */ -# define USE_START_TV long start_msec = msec; - struct timeval start_tv; + ELAPSED_TYPE start_tv; if (msec > 0) - gettimeofday(&start_tv, NULL); + ELAPSED_INIT(start_tv); # endif /* Handle being called recursively. This may happen for the session @@ -5947,9 +5929,9 @@ select_eintr: /* We're going to loop around again, find out for how long */ if (msec > 0) { -# ifdef USE_START_TV +# ifdef ELAPSED_FUNC /* Compute remaining wait time. */ - msec = start_msec - elapsed(&start_tv); + msec = start_msec - ELAPSED_FUNC(start_tv); # else /* Guess we got interrupted halfway. */ msec = msec / 2; @@ -7046,11 +7028,11 @@ setup_term_clip(void) #if defined(HAVE_SETJMP_H) int (*oldIOhandler)(); #endif -# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) - struct timeval start_tv; +# ifdef ELAPSED_FUNC + ELAPSED_TYPE start_tv; if (p_verbose > 0) - gettimeofday(&start_tv, NULL); + ELAPSED_INIT(start_tv); # endif /* Ignore X errors while opening the display */ @@ -7092,11 +7074,11 @@ setup_term_clip(void) /* Catch terminating error of the X server connection. */ (void)XSetIOErrorHandler(x_IOerror_handler); -# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) +# ifdef ELAPSED_FUNC if (p_verbose > 0) { verbose_enter(); - xopen_message(&start_tv); + xopen_message(ELAPSED_FUNC(start_tv)); verbose_leave(); } # endif diff --git a/src/os_win32.c b/src/os_win32.c index 34b2ca8384..23044381d0 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -4287,9 +4287,6 @@ mch_system_piped(char *cmd, int options) /* Get extra characters when we don't have any. Reset the * counter and timer. */ noread_cnt = 0; -# if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) - gettimeofday(&start_tv, NULL); -# endif len = ui_inchar(ta_buf, BUFLEN, 10L, 0); } if (ta_len > 0 || len > 0) diff --git a/src/version.c b/src/version.c index e259000c0f..076ed520ce 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 97, /**/ 96, /**/ diff --git a/src/vim.h b/src/vim.h index eec3e4f73f..c91e52bb2a 100644 --- a/src/vim.h +++ b/src/vim.h @@ -2503,4 +2503,20 @@ typedef enum # define OPEN_CHR_FILES #endif +#if defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) +# define ELAPSED_TIMEVAL +# define ELAPSED_INIT(v) gettimeofday(&v, NULL) +# define ELAPSED_FUNC(v) elapsed(&v) +# define ELAPSED_TYPE struct timeval + long elapsed(struct timeval *start_tv); +#else +# if defined(WIN32) +# define ELAPSED_TICKCOUNT +# define ELAPSED_INIT(v) v = GetTickCount +# define ELAPSED_FUNC(v) elapsed(v) +# define ELAPSED_TYPE DWORD + long elapsed(DWORD start_tick); +# endif +#endif + #endif /* VIM__H */ From 58c358753ef47e217e18c0bf8a2fca9d1ea23a8e Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 24 Nov 2016 17:33:17 +0100 Subject: [PATCH 04/10] patch 8.0.0098 Problem: Can't build on MS-Windows. Solution: Add missing parenthesis. --- src/version.c | 2 ++ src/vim.h | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/version.c b/src/version.c index 076ed520ce..47f8135ca1 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 98, /**/ 97, /**/ diff --git a/src/vim.h b/src/vim.h index c91e52bb2a..d7bf26fe22 100644 --- a/src/vim.h +++ b/src/vim.h @@ -2512,7 +2512,7 @@ typedef enum #else # if defined(WIN32) # define ELAPSED_TICKCOUNT -# define ELAPSED_INIT(v) v = GetTickCount +# define ELAPSED_INIT(v) v = GetTickCount() # define ELAPSED_FUNC(v) elapsed(v) # define ELAPSED_TYPE DWORD long elapsed(DWORD start_tick); From 73095288da839f7c738a49baa109773e76106806 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 24 Nov 2016 17:47:07 +0100 Subject: [PATCH 05/10] patch 8.0.0099 Problem: Popup menu always appears above the cursor when it is in the lower half of the screen. (Matt Gardner) Solution: Compute the available space better. (Hirohito Higashi, closes #1241) --- src/popupmnu.c | 3 ++- src/version.c | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/popupmnu.c b/src/popupmnu.c index 19d215b9f5..307dbbedc6 100644 --- a/src/popupmnu.c +++ b/src/popupmnu.c @@ -105,7 +105,8 @@ redo: /* Put the pum below "row" if possible. If there are few lines decide on * where there is more room. */ - if (row - above_row >= below_row - row) + if (row + 2 >= below_row - pum_height + && row - above_row > (below_row - above_row) / 2) { /* pum above "row" */ diff --git a/src/version.c b/src/version.c index 47f8135ca1..4064441c1b 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 99, /**/ 98, /**/ From 319afe3804741db5a6c188bd69535fa7ed044c62 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 24 Nov 2016 18:30:59 +0100 Subject: [PATCH 06/10] patch 8.0.0100 Problem: Options that are a file name may contain non-filename characters. Solution: Check for more invalid characters. --- src/option.c | 2 +- src/version.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/option.c b/src/option.c index 2b9ba2dcfa..35563c3d50 100644 --- a/src/option.c +++ b/src/option.c @@ -5880,7 +5880,7 @@ did_set_string_option( * separator (slash and/or backslash), wildcards and characters that are * often illegal in a file name. */ else if ((options[opt_idx].flags & P_NFNAME) - && vim_strpbrk(*varp, (char_u *)"/\\*?[|<>") != NULL) + && vim_strpbrk(*varp, (char_u *)"/\\*?[|;&<>\r\n") != NULL) { errmsg = e_invarg; } diff --git a/src/version.c b/src/version.c index 4064441c1b..5f13f76898 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 100, /**/ 99, /**/ From 031cb743ae154cfb727a9b7787bdcb61202ff1c8 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 24 Nov 2016 21:46:19 +0100 Subject: [PATCH 07/10] patch 8.0.0101 Problem: Some options are not strictly checked. Solution: Add flags for strickter checks. --- src/option.c | 20 +++++++++++--------- src/version.c | 2 ++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/option.c b/src/option.c index 35563c3d50..52330f7904 100644 --- a/src/option.c +++ b/src/option.c @@ -992,7 +992,7 @@ static struct vimoption options[] = (char_u *)NULL, PV_NONE, #endif {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, - {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP, + {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NFNAME, #ifdef FEAT_INS_EXPAND (char_u *)&p_dict, PV_DICT, #else @@ -2058,7 +2058,7 @@ static struct vimoption options[] = {(char_u *)NULL, (char_u *)0L} #endif SCRIPTID_INIT}, - {"printexpr", "pexpr", P_STRING|P_VI_DEF, + {"printexpr", "pexpr", P_STRING|P_VI_DEF|P_SECURE, #ifdef FEAT_POSTSCRIPT (char_u *)&p_pexpr, PV_NONE, {(char_u *)"", (char_u *)0L} @@ -7021,6 +7021,7 @@ did_set_string_option( #if defined(FEAT_TOOLBAR) && !defined(FEAT_GUI_W32) + /* 'toolbar' */ else if (varp == &p_toolbar) { if (opt_strings_flags(p_toolbar, p_toolbar_values, @@ -7235,6 +7236,7 @@ did_set_string_option( #endif #if defined(FEAT_RENDER_OPTIONS) + /* 'renderoptions' */ else if (varp == &p_rop && gui.in_use) { if (!gui_mch_set_rendering_options(p_rop)) @@ -7262,19 +7264,19 @@ did_set_string_option( else { p = NULL; - if (varp == &p_ww) + if (varp == &p_ww) /* 'whichwrap' */ p = (char_u *)WW_ALL; - if (varp == &p_shm) + if (varp == &p_shm) /* 'shortmess' */ p = (char_u *)SHM_ALL; - else if (varp == &(p_cpo)) + else if (varp == &(p_cpo)) /* 'cpoptions' */ p = (char_u *)CPO_ALL; - else if (varp == &(curbuf->b_p_fo)) + else if (varp == &(curbuf->b_p_fo)) /* 'formatoptions' */ p = (char_u *)FO_ALL; #ifdef FEAT_CONCEAL - else if (varp == &curwin->w_p_cocu) + else if (varp == &curwin->w_p_cocu) /* 'concealcursor' */ p = (char_u *)COCU_ALL; #endif - else if (varp == &p_mouse) + else if (varp == &p_mouse) /* 'mouse' */ { #ifdef FEAT_MOUSE p = (char_u *)MOUSE_ALL; @@ -7284,7 +7286,7 @@ did_set_string_option( #endif } #if defined(FEAT_GUI) - else if (varp == &p_go) + else if (varp == &p_go) /* 'guioptions' */ p = (char_u *)GO_ALL; #endif if (p != NULL) diff --git a/src/version.c b/src/version.c index 5f13f76898..449732f4a0 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 101, /**/ 100, /**/ From 7554da4033498c4da0af3cde542c3e87e9097b73 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Fri, 25 Nov 2016 22:04:13 +0100 Subject: [PATCH 08/10] patch 8.0.0102 Problem: Cannot set 'dictionary' to a path. Solution: Allow for slash and backslash. Add a test (partly by Daisuke Suzuki, closes #1279, closes #1284) --- src/option.c | 15 +++++++++------ src/testdir/test_options.vim | 15 +++++++++++++++ src/version.c | 2 ++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/option.c b/src/option.c index 52330f7904..5b6dbe358c 100644 --- a/src/option.c +++ b/src/option.c @@ -452,10 +452,11 @@ struct vimoption #define P_NFNAME 0x400000L /* only normal file name chars allowed */ #define P_INSECURE 0x800000L /* option was set from a modeline */ #define P_PRI_MKRC 0x1000000L /* priority for :mkvimrc (setting option has - side effects) */ + side effects) */ #define P_NO_ML 0x2000000L /* not allowed in modeline */ #define P_CURSWANT 0x4000000L /* update curswant required; not needed when * there is a redraw flag */ +#define P_NDNAME 0x8000000L /* only normal dir name chars allowed */ #define ISK_LATIN1 (char_u *)"@,48-57,_,192-255" @@ -992,7 +993,7 @@ static struct vimoption options[] = (char_u *)NULL, PV_NONE, #endif {(char_u *)FALSE, (char_u *)0L} SCRIPTID_INIT}, - {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NFNAME, + {"dictionary", "dict", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME, #ifdef FEAT_INS_EXPAND (char_u *)&p_dict, PV_DICT, #else @@ -5876,11 +5877,13 @@ did_set_string_option( errmsg = e_secure; } - /* Check for a "normal" file name in some options. Disallow a path - * separator (slash and/or backslash), wildcards and characters that are - * often illegal in a file name. */ - else if ((options[opt_idx].flags & P_NFNAME) + /* Check for a "normal" directory or file name in some options. Disallow a + * path separator (slash and/or backslash), wildcards and characters that + * are often illegal in a file name. */ + else if (((options[opt_idx].flags & P_NFNAME) && vim_strpbrk(*varp, (char_u *)"/\\*?[|;&<>\r\n") != NULL) + || ((options[opt_idx].flags & P_NDNAME) + && vim_strpbrk(*varp, (char_u *)"*?[|;&<>\r\n") != NULL)) { errmsg = e_invarg; } diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim index 3b6f6625f6..88be8f9c5f 100644 --- a/src/testdir/test_options.vim +++ b/src/testdir/test_options.vim @@ -106,3 +106,18 @@ func Test_keymap_valid() call assert_fails(":set kmp=trunc\x00name", "E544:") call assert_fails(":set kmp=trunc\x00name", "trunc") endfunc + +func Test_dictionary() + " Check that it's possible to set the option. + set dictionary=/usr/share/dict/words + call assert_equal('/usr/share/dict/words', &dictionary) + set dictionary=/usr/share/dict/words,/and/there + call assert_equal('/usr/share/dict/words,/and/there', &dictionary) + set dictionary=/usr/share/dict\ words + call assert_equal('/usr/share/dict words', &dictionary) + + " Check rejecting weird characters. + call assert_fails("set dictionary=/not&there", "E474:") + call assert_fails("set dictionary=/not>there", "E474:") + call assert_fails("set dictionary=/not.*there", "E474:") +endfunc diff --git a/src/version.c b/src/version.c index 449732f4a0..ed6a74e88b 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 102, /**/ 101, /**/ From 8a8199e4a1814b10630a770165502abb1121cd1b Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 26 Nov 2016 15:13:33 +0100 Subject: [PATCH 09/10] patch 8.0.0103 Problem: May not process channel readahead. (skywind) Solution: If there is readahead don't block on input. --- src/channel.c | 25 +++++++++++++++++++++++++ src/misc2.c | 5 +---- src/os_unix.c | 4 ++++ src/os_win32.c | 8 +++++++- src/proto/channel.pro | 1 + src/version.c | 2 ++ 6 files changed, 40 insertions(+), 5 deletions(-) diff --git a/src/channel.c b/src/channel.c index 19520e2007..6c5a4ff1d6 100644 --- a/src/channel.c +++ b/src/channel.c @@ -3899,6 +3899,31 @@ channel_parse_messages(void) return ret; } +/* + * Return TRUE if any channel has readahead. That means we should not block on + * waiting for input. + */ + int +channel_any_readahead(void) +{ + channel_T *channel = first_channel; + ch_part_T part = PART_SOCK; + + while (channel != NULL) + { + if (channel_has_readahead(channel, part)) + return TRUE; + if (part < PART_ERR) + ++part; + else + { + channel = channel->ch_next; + part = PART_SOCK; + } + } + return FALSE; +} + /* * Mark references to lists used in channels. */ diff --git a/src/misc2.c b/src/misc2.c index 9fa11e3d25..7f23c43e9a 100644 --- a/src/misc2.c +++ b/src/misc2.c @@ -6264,7 +6264,7 @@ parse_queued_messages(void) } #endif -#ifdef ELAPSED_TIMEVAL /* proto is defined in vim.h */ +#ifdef ELAPSED_TIMEVAL /* no PROTO here, proto is defined in vim.h */ /* * Return time in msec since "start_tv". */ @@ -6288,9 +6288,6 @@ elapsed(DWORD start_tick) { DWORD now = GetTickCount(); - if (now < start_tick) - /* overflow */ - return (long)now; return (long)now - (long)start_tick; } #endif diff --git a/src/os_unix.c b/src/os_unix.c index 12fb33b7ae..aa3c3e506d 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -462,6 +462,10 @@ mch_inchar( /* Checking if a job ended requires polling. Do this every 100 msec. */ if (has_pending_job() && (wait_time < 0 || wait_time > 100L)) wait_time = 100L; + /* If there is readahead then parse_queued_messages() timed out and we + * should call it again soon. */ + if ((wait_time < 0 || wait_time > 100L) && channel_any_readahead()) + wait_time = 10L; #endif /* diff --git a/src/os_win32.c b/src/os_win32.c index 23044381d0..e08adcbb19 100644 --- a/src/os_win32.c +++ b/src/os_win32.c @@ -1351,9 +1351,15 @@ WaitForChar(long msec) DWORD dwWaitTime = dwEndTime - dwNow; #ifdef FEAT_JOB_CHANNEL - /* Check channel while waiting input. */ + /* Check channel while waiting for input. */ if (dwWaitTime > 100) + { dwWaitTime = 100; + /* If there is readahead then parse_queued_messages() timed out + * and we should call it again soon. */ + if (channel_any_readahead()) + dwWaitTime = 10; + } #endif #ifdef FEAT_MZSCHEME if (mzthreads_allowed() && p_mzq > 0 diff --git a/src/proto/channel.pro b/src/proto/channel.pro index 6a52d8b2ba..8640fa7bb7 100644 --- a/src/proto/channel.pro +++ b/src/proto/channel.pro @@ -44,6 +44,7 @@ int channel_poll_check(int ret_in, void *fds_in); int channel_select_setup(int maxfd_in, void *rfds_in, void *wfds_in); int channel_select_check(int ret_in, void *rfds_in, void *wfds_in); int channel_parse_messages(void); +int channel_any_readahead(void); int set_ref_in_channel(int copyID); ch_part_T channel_part_send(channel_T *channel); ch_part_T channel_part_read(channel_T *channel); diff --git a/src/version.c b/src/version.c index ed6a74e88b..4dcbcfb733 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 103, /**/ 102, /**/ From f422bcc7f9615fe91fa69b059cfe4785093d3d4a Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Sat, 26 Nov 2016 17:45:53 +0100 Subject: [PATCH 10/10] patch 8.0.0104 Problem: Value of 'thesaurus' option not checked properly. Solution: Add P_NDNAME flag. (Daisuke Suzuki) --- src/option.c | 2 +- src/testdir/test_options.vim | 28 ++++++++++++++++++---------- src/version.c | 2 ++ 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/option.c b/src/option.c index 5b6dbe358c..fae10b6a2e 100644 --- a/src/option.c +++ b/src/option.c @@ -2660,7 +2660,7 @@ static struct vimoption options[] = {"textwidth", "tw", P_NUM|P_VI_DEF|P_VIM|P_RBUF, (char_u *)&p_tw, PV_TW, {(char_u *)0L, (char_u *)0L} SCRIPTID_INIT}, - {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP, + {"thesaurus", "tsr", P_STRING|P_EXPAND|P_VI_DEF|P_ONECOMMA|P_NODUP|P_NDNAME, #ifdef FEAT_INS_EXPAND (char_u *)&p_tsr, PV_TSR, #else diff --git a/src/testdir/test_options.vim b/src/testdir/test_options.vim index 88be8f9c5f..6dfb1bbe60 100644 --- a/src/testdir/test_options.vim +++ b/src/testdir/test_options.vim @@ -107,17 +107,25 @@ func Test_keymap_valid() call assert_fails(":set kmp=trunc\x00name", "trunc") endfunc -func Test_dictionary() +func Check_dir_option(name) " Check that it's possible to set the option. - set dictionary=/usr/share/dict/words - call assert_equal('/usr/share/dict/words', &dictionary) - set dictionary=/usr/share/dict/words,/and/there - call assert_equal('/usr/share/dict/words,/and/there', &dictionary) - set dictionary=/usr/share/dict\ words - call assert_equal('/usr/share/dict words', &dictionary) + exe 'set ' . a:name . '=/usr/share/dict/words' + call assert_equal('/usr/share/dict/words', eval('&' . a:name)) + exe 'set ' . a:name . '=/usr/share/dict/words,/and/there' + call assert_equal('/usr/share/dict/words,/and/there', eval('&' . a:name)) + exe 'set ' . a:name . '=/usr/share/dict\ words' + call assert_equal('/usr/share/dict words', eval('&' . a:name)) " Check rejecting weird characters. - call assert_fails("set dictionary=/not&there", "E474:") - call assert_fails("set dictionary=/not>there", "E474:") - call assert_fails("set dictionary=/not.*there", "E474:") + call assert_fails("set " . a:name . "=/not&there", "E474:") + call assert_fails("set " . a:name . "=/not>there", "E474:") + call assert_fails("set " . a:name . "=/not.*there", "E474:") +endfunc + +func Test_dictionary() + call Check_dir_option('dictionary') +endfunc + +func Test_thesaurus() + call Check_dir_option('thesaurus') endfunc diff --git a/src/version.c b/src/version.c index 4dcbcfb733..0e3554ddcb 100644 --- a/src/version.c +++ b/src/version.c @@ -764,6 +764,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 104, /**/ 103, /**/