forked from aniani/vim
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)
This commit is contained in:
@@ -1090,15 +1090,24 @@ profile_zero(proftime_T *tm)
|
|||||||
static timer_T *first_timer = NULL;
|
static timer_T *first_timer = NULL;
|
||||||
static long last_timer_id = 0;
|
static long last_timer_id = 0;
|
||||||
|
|
||||||
|
static long
|
||||||
|
timer_time_left(timer_T *timer, proftime_T *now)
|
||||||
|
{
|
||||||
# ifdef WIN3264
|
# ifdef WIN3264
|
||||||
# define GET_TIMEDIFF(timer, now) \
|
LARGE_INTEGER fr;
|
||||||
(long)(((double)(timer->tr_due.QuadPart - now.QuadPart) \
|
|
||||||
/ (double)fr.QuadPart) * 1000)
|
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
|
# else
|
||||||
# define GET_TIMEDIFF(timer, now) \
|
if (now->tv_sec > timer->tr_due.tv_sec)
|
||||||
(timer->tr_due.tv_sec - now.tv_sec) * 1000 \
|
return 0;
|
||||||
+ (timer->tr_due.tv_usec - now.tv_usec) / 1000
|
return (timer->tr_due.tv_sec - now->tv_sec) * 1000
|
||||||
|
+ (timer->tr_due.tv_usec - now->tv_usec) / 1000;
|
||||||
# endif
|
# endif
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Insert a timer in the list of timers.
|
* Insert a timer in the list of timers.
|
||||||
@@ -1196,17 +1205,11 @@ check_due_timer(void)
|
|||||||
int did_one = FALSE;
|
int did_one = FALSE;
|
||||||
int need_update_screen = FALSE;
|
int need_update_screen = FALSE;
|
||||||
long current_id = last_timer_id;
|
long current_id = last_timer_id;
|
||||||
# ifdef WIN3264
|
|
||||||
LARGE_INTEGER fr;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
/* Don't run any timers while exiting or dealing with an error. */
|
/* Don't run any timers while exiting or dealing with an error. */
|
||||||
if (exiting || aborting())
|
if (exiting || aborting())
|
||||||
return next_due;
|
return next_due;
|
||||||
|
|
||||||
# ifdef WIN3264
|
|
||||||
QueryPerformanceFrequency(&fr);
|
|
||||||
# endif
|
|
||||||
profile_start(&now);
|
profile_start(&now);
|
||||||
for (timer = first_timer; timer != NULL && !got_int; timer = timer_next)
|
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)
|
if (timer->tr_id == -1 || timer->tr_firing || timer->tr_paused)
|
||||||
continue;
|
continue;
|
||||||
this_due = GET_TIMEDIFF(timer, now);
|
this_due = timer_time_left(timer, &now);
|
||||||
if (this_due <= 1)
|
if (this_due <= 1)
|
||||||
{
|
{
|
||||||
int save_timer_busy = timer_busy;
|
int save_timer_busy = timer_busy;
|
||||||
@@ -1266,7 +1269,7 @@ check_due_timer(void)
|
|||||||
&& timer->tr_emsg_count < 3)
|
&& timer->tr_emsg_count < 3)
|
||||||
{
|
{
|
||||||
profile_setlimit(timer->tr_interval, &timer->tr_due);
|
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)
|
if (this_due < 1)
|
||||||
this_due = 1;
|
this_due = 1;
|
||||||
if (timer->tr_repeat > 0)
|
if (timer->tr_repeat > 0)
|
||||||
@@ -1344,9 +1347,6 @@ add_timer_info(typval_T *rettv, timer_T *timer)
|
|||||||
dictitem_T *di;
|
dictitem_T *di;
|
||||||
long remaining;
|
long remaining;
|
||||||
proftime_T now;
|
proftime_T now;
|
||||||
# ifdef WIN3264
|
|
||||||
LARGE_INTEGER fr;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (dict == NULL)
|
if (dict == NULL)
|
||||||
return;
|
return;
|
||||||
@@ -1356,10 +1356,7 @@ add_timer_info(typval_T *rettv, timer_T *timer)
|
|||||||
dict_add_nr_str(dict, "time", (long)timer->tr_interval, NULL);
|
dict_add_nr_str(dict, "time", (long)timer->tr_interval, NULL);
|
||||||
|
|
||||||
profile_start(&now);
|
profile_start(&now);
|
||||||
# ifdef WIN3264
|
remaining = timer_time_left(timer, &now);
|
||||||
QueryPerformanceFrequency(&fr);
|
|
||||||
# endif
|
|
||||||
remaining = GET_TIMEDIFF(timer, now);
|
|
||||||
dict_add_nr_str(dict, "remaining", (long)remaining, NULL);
|
dict_add_nr_str(dict, "remaining", (long)remaining, NULL);
|
||||||
|
|
||||||
dict_add_nr_str(dict, "repeat",
|
dict_add_nr_str(dict, "repeat",
|
||||||
|
@@ -761,6 +761,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1127,
|
||||||
/**/
|
/**/
|
||||||
1126,
|
1126,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user