comparison src/macros.h @ 32118:04d9dff67d99 v9.0.1390

patch 9.0.1390: FOR_ALL_ macros are defined in an unexpected file Commit: https://github.com/vim/vim/commit/14113fdf9cb3d588c0d1c3a210246b981cf5aad3 Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Tue Mar 7 17:13:51 2023 +0000 patch 9.0.1390: FOR_ALL_ macros are defined in an unexpected file Problem: FOR_ALL_ macros are defined in an unexpected file. Solution: Move FOR_ALL_ macros to macros.h. Add FOR_ALL_HASHTAB_ITEMS. (Yegappan Lakshmanan, closes #12109)
author Bram Moolenaar <Bram@vim.org>
date Tue, 07 Mar 2023 18:15:04 +0100
parents 50555279168b
children 6e96bd314ffe
comparison
equal deleted inserted replaced
32117:0741cc777264 32118:04d9dff67d99
394 # define MAX(a, b) ((a) > (b) ? (a) : (b)) 394 # define MAX(a, b) ((a) > (b) ? (a) : (b))
395 #endif 395 #endif
396 396
397 // Length of the array. 397 // Length of the array.
398 #define ARRAY_LENGTH(a) (sizeof(a) / sizeof((a)[0])) 398 #define ARRAY_LENGTH(a) (sizeof(a) / sizeof((a)[0]))
399
400 #ifdef FEAT_MENU
401 #define FOR_ALL_MENUS(m) \
402 for ((m) = root_menu; (m) != NULL; (m) = (m)->next)
403 #define FOR_ALL_CHILD_MENUS(p, c) \
404 for ((c) = (p)->children; (c) != NULL; (c) = (c)->next)
405 #endif
406
407 #define FOR_ALL_WINDOWS(wp) \
408 for ((wp) = firstwin; (wp) != NULL; (wp) = (wp)->w_next)
409 #define FOR_ALL_FRAMES(frp, first_frame) \
410 for ((frp) = first_frame; (frp) != NULL; (frp) = (frp)->fr_next)
411 #define FOR_ALL_TABPAGES(tp) \
412 for ((tp) = first_tabpage; (tp) != NULL; (tp) = (tp)->tp_next)
413 #define FOR_ALL_WINDOWS_IN_TAB(tp, wp) \
414 for ((wp) = ((tp) == NULL || (tp) == curtab) \
415 ? firstwin : (tp)->tp_firstwin; (wp); (wp) = (wp)->w_next)
416 /*
417 * When using this macro "break" only breaks out of the inner loop. Use "goto"
418 * to break out of the tabpage loop.
419 */
420 #define FOR_ALL_TAB_WINDOWS(tp, wp) \
421 for ((tp) = first_tabpage; (tp) != NULL; (tp) = (tp)->tp_next) \
422 for ((wp) = ((tp) == curtab) \
423 ? firstwin : (tp)->tp_firstwin; (wp); (wp) = (wp)->w_next)
424
425 #define FOR_ALL_POPUPWINS(wp) \
426 for ((wp) = first_popupwin; (wp) != NULL; (wp) = (wp)->w_next)
427 #define FOR_ALL_POPUPWINS_IN_TAB(tp, wp) \
428 for ((wp) = (tp)->tp_first_popupwin; (wp) != NULL; (wp) = (wp)->w_next)
429
430 #define FOR_ALL_BUFFERS(buf) \
431 for ((buf) = firstbuf; (buf) != NULL; (buf) = (buf)->b_next)
432
433 #define FOR_ALL_BUF_WININFO(buf, wip) \
434 for ((wip) = (buf)->b_wininfo; (wip) != NULL; (wip) = (wip)->wi_next)
435
436 // Iterate through all the signs placed in a buffer
437 #define FOR_ALL_SIGNS_IN_BUF(buf, sign) \
438 for ((sign) = (buf)->b_signlist; (sign) != NULL; (sign) = (sign)->se_next)
439
440 #ifdef FEAT_SPELL
441 #define FOR_ALL_SPELL_LANGS(slang) \
442 for ((slang) = first_lang; (slang) != NULL; (slang) = (slang)->sl_next)
443 #endif
444
445 // Iterate over all the items in a List
446 #define FOR_ALL_LIST_ITEMS(l, li) \
447 for ((li) = (l) == NULL ? NULL : (l)->lv_first; (li) != NULL; (li) = (li)->li_next)
448
449 // Iterate over all the items in a hash table
450 #define FOR_ALL_HASHTAB_ITEMS(ht, hi, todo) \
451 for ((hi) = (ht)->ht_array; (todo) > 0; ++(hi))