To: vim_dev@googlegroups.com Subject: Patch 8.0.1127 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1127 Problem: Test_peek_and_get_char fails on 32 bit system. (Eliminate Riesebieter) Solution: Avoid an integer overflow. (James McCoy, closes #2116) Files: src/ex_cmds2.c *** ../vim-8.0.1126/src/ex_cmds2.c 2017-09-16 20:54:47.094560435 +0200 --- src/ex_cmds2.c 2017-09-18 21:47:11.749997206 +0200 *************** *** 1090,1104 **** 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 /* * Insert a timer in the list of timers. --- 1090,1113 ---- static timer_T *first_timer = NULL; static long last_timer_id = 0; ! 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,1212 **** 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) { --- 1205,1215 ---- *************** *** 1214,1220 **** if (timer->tr_id == -1 || timer->tr_firing || timer->tr_paused) continue; ! this_due = GET_TIMEDIFF(timer, now); if (this_due <= 1) { int save_timer_busy = timer_busy; --- 1217,1223 ---- if (timer->tr_id == -1 || timer->tr_firing || timer->tr_paused) continue; ! this_due = timer_time_left(timer, &now); if (this_due <= 1) { int save_timer_busy = timer_busy; *************** *** 1266,1272 **** && timer->tr_emsg_count < 3) { profile_setlimit(timer->tr_interval, &timer->tr_due); ! this_due = GET_TIMEDIFF(timer, now); if (this_due < 1) this_due = 1; if (timer->tr_repeat > 0) --- 1269,1275 ---- && timer->tr_emsg_count < 3) { profile_setlimit(timer->tr_interval, &timer->tr_due); ! this_due = timer_time_left(timer, &now); if (this_due < 1) this_due = 1; if (timer->tr_repeat > 0) *************** *** 1344,1352 **** dictitem_T *di; long remaining; proftime_T now; - # ifdef WIN3264 - LARGE_INTEGER fr; - #endif if (dict == NULL) return; --- 1347,1352 ---- *************** *** 1356,1365 **** dict_add_nr_str(dict, "time", (long)timer->tr_interval, NULL); profile_start(&now); ! # ifdef WIN3264 ! QueryPerformanceFrequency(&fr); ! # endif ! remaining = GET_TIMEDIFF(timer, now); dict_add_nr_str(dict, "remaining", (long)remaining, NULL); dict_add_nr_str(dict, "repeat", --- 1356,1362 ---- dict_add_nr_str(dict, "time", (long)timer->tr_interval, NULL); profile_start(&now); ! remaining = timer_time_left(timer, &now); dict_add_nr_str(dict, "remaining", (long)remaining, NULL); dict_add_nr_str(dict, "repeat", *** ../vim-8.0.1126/src/version.c 2017-09-18 21:23:02.938622902 +0200 --- src/version.c 2017-09-18 21:46:17.906315415 +0200 *************** *** 763,764 **** --- 763,766 ---- { /* Add new patch number below this line */ + /**/ + 1127, /**/ -- hundred-and-one symptoms of being an internet addict: 156. You forget your friend's name but not her e-mail address. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///