# HG changeset patch # User Christian Brabandt # Date 1505764804 -7200 # Node ID 65f8c6fcfd836fa00934df0138f899aaaf45e8bc # Parent b08f916fec046bb125e09842510bea7549b31c96 patch 8.0.1127: Test_peek_and_get_char fails on 32 bit system commit https://github.com/vim/vim/commit/a8e93d63e308020ee06eb5782e766941ac417a5a Author: Bram Moolenaar Date: Mon Sep 18 21:50:47 2017 +0200 patch 8.0.1127: Test_peek_and_get_char fails on 32 bit system Problem: Test_peek_and_get_char fails on 32 bit system. (Eliminate Riesebieter) Solution: Avoid an integer overflow. (James McCoy, closes #2116) diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c --- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -1090,15 +1090,24 @@ profile_zero(proftime_T *tm) static timer_T *first_timer = NULL; static long last_timer_id = 0; -# ifdef WIN3264 -# define GET_TIMEDIFF(timer, now) \ - (long)(((double)(timer->tr_due.QuadPart - now.QuadPart) \ - / (double)fr.QuadPart) * 1000) -# else -# define GET_TIMEDIFF(timer, now) \ - (timer->tr_due.tv_sec - now.tv_sec) * 1000 \ - + (timer->tr_due.tv_usec - now.tv_usec) / 1000 -# endif + static long +timer_time_left(timer_T *timer, proftime_T *now) +{ +# ifdef WIN3264 + LARGE_INTEGER fr; + + if (now->QuadPart > timer->tr_due.QuadPart) + return 0; + QueryPerformanceFrequency(&fr); + return (long)(((double)(timer->tr_due.QuadPart - now->QuadPart) + / (double)fr.QuadPart) * 1000); +# else + if (now->tv_sec > timer->tr_due.tv_sec) + return 0; + return (timer->tr_due.tv_sec - now->tv_sec) * 1000 + + (timer->tr_due.tv_usec - now->tv_usec) / 1000; +# endif +} /* * Insert a timer in the list of timers. @@ -1196,17 +1205,11 @@ check_due_timer(void) int did_one = FALSE; int need_update_screen = FALSE; long current_id = last_timer_id; -# ifdef WIN3264 - LARGE_INTEGER fr; -# endif /* Don't run any timers while exiting or dealing with an error. */ if (exiting || aborting()) return next_due; -# ifdef WIN3264 - QueryPerformanceFrequency(&fr); -# endif profile_start(&now); for (timer = first_timer; timer != NULL && !got_int; timer = timer_next) { @@ -1214,7 +1217,7 @@ check_due_timer(void) if (timer->tr_id == -1 || timer->tr_firing || timer->tr_paused) continue; - this_due = GET_TIMEDIFF(timer, now); + this_due = timer_time_left(timer, &now); if (this_due <= 1) { int save_timer_busy = timer_busy; @@ -1266,7 +1269,7 @@ check_due_timer(void) && timer->tr_emsg_count < 3) { profile_setlimit(timer->tr_interval, &timer->tr_due); - this_due = GET_TIMEDIFF(timer, now); + this_due = timer_time_left(timer, &now); if (this_due < 1) this_due = 1; if (timer->tr_repeat > 0) @@ -1344,9 +1347,6 @@ add_timer_info(typval_T *rettv, timer_T dictitem_T *di; long remaining; proftime_T now; -# ifdef WIN3264 - LARGE_INTEGER fr; -#endif if (dict == NULL) return; @@ -1356,10 +1356,7 @@ add_timer_info(typval_T *rettv, timer_T dict_add_nr_str(dict, "time", (long)timer->tr_interval, NULL); profile_start(&now); -# ifdef WIN3264 - QueryPerformanceFrequency(&fr); -# endif - remaining = GET_TIMEDIFF(timer, now); + remaining = timer_time_left(timer, &now); dict_add_nr_str(dict, "remaining", (long)remaining, NULL); dict_add_nr_str(dict, "repeat", diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -762,6 +762,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 1127, +/**/ 1126, /**/ 1125,