comparison src/time.c @ 19934:3ff714d765ba v8.2.0523

patch 8.2.0523: loops are repeated Commit: https://github.com/vim/vim/commit/00d253e2b2f435a5386582c3f857008e7ac355c2 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Apr 6 22:13:01 2020 +0200 patch 8.2.0523: loops are repeated Problem: Loops are repeated. Solution: Use FOR_ALL_ macros. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/5882)
author Bram Moolenaar <Bram@vim.org>
date Mon, 06 Apr 2020 22:15:39 +0200
parents a961efb326e5
children aadd1cae2ff5
comparison
equal deleted inserted replaced
19933:005e707a7988 19934:3ff714d765ba
18 * where unset, up to 64 octets long including trailing null byte. 18 * where unset, up to 64 octets long including trailing null byte.
19 */ 19 */
20 #if defined(HAVE_LOCALTIME_R) && defined(HAVE_TZSET) 20 #if defined(HAVE_LOCALTIME_R) && defined(HAVE_TZSET)
21 static char tz_cache[64]; 21 static char tz_cache[64];
22 #endif 22 #endif
23
24 #define FOR_ALL_TIMERS(t) \
25 for ((t) = first_timer; (t) != NULL; (t) = (t)->tr_next)
23 26
24 /* 27 /*
25 * Call either localtime(3) or localtime_r(3) from POSIX libc time.h, with the 28 * Call either localtime(3) or localtime_r(3) from POSIX libc time.h, with the
26 * latter version preferred for reentrancy. 29 * latter version preferred for reentrancy.
27 * 30 *
581 { 584 {
582 timer_T *timer; 585 timer_T *timer;
583 586
584 if (id >= 0) 587 if (id >= 0)
585 { 588 {
586 for (timer = first_timer; timer != NULL; timer = timer->tr_next) 589 FOR_ALL_TIMERS(timer)
587 if (timer->tr_id == id) 590 if (timer->tr_id == id)
588 return timer; 591 return timer;
589 } 592 }
590 return NULL; 593 return NULL;
591 } 594 }
657 static void 660 static void
658 add_timer_info_all(typval_T *rettv) 661 add_timer_info_all(typval_T *rettv)
659 { 662 {
660 timer_T *timer; 663 timer_T *timer;
661 664
662 for (timer = first_timer; timer != NULL; timer = timer->tr_next) 665 FOR_ALL_TIMERS(timer)
663 if (timer->tr_id != -1) 666 if (timer->tr_id != -1)
664 add_timer_info(rettv, timer); 667 add_timer_info(rettv, timer);
665 } 668 }
666 669
667 /* 670 /*