]> granicus.if.org Git - vim/commitdiff
patch 9.0.1390: FOR_ALL_ macros are defined in an unexpected file v9.0.1390
authorYegappan Lakshmanan <yegappan@yahoo.com>
Tue, 7 Mar 2023 17:13:51 +0000 (17:13 +0000)
committerBram Moolenaar <Bram@vim.org>
Tue, 7 Mar 2023 17:13:51 +0000 (17:13 +0000)
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)

31 files changed:
src/dict.c
src/diff.c
src/eval.c
src/evalfunc.c
src/evalvars.c
src/globals.h
src/hashtab.c
src/if_mzsch.c
src/if_ruby.c
src/job.c
src/macros.h
src/mbyte.c
src/os_unix.c
src/os_win32.c
src/popupwin.c
src/profiler.c
src/scriptfile.c
src/session.c
src/sign.c
src/spellfile.c
src/spellsuggest.c
src/syntax.c
src/testing.c
src/textprop.c
src/userfunc.c
src/version.c
src/vim9execute.c
src/vim9script.c
src/vim9type.c
src/viminfo.c
src/window.c

index 6941845cda143c309e063b582b6f6bab42b0a8d3..74501ffe31ae86b171170b594da11f115016e2f0 100644 (file)
@@ -128,7 +128,7 @@ hashtab_free_contents(hashtab_T *ht)
     // Lock the hashtab, we don't want it to resize while freeing items.
     hash_lock(ht);
     todo = (int)ht->ht_used;
-    for (hi = ht->ht_array; todo > 0; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
     {
        if (!HASHITEM_EMPTY(hi))
        {
@@ -781,7 +781,7 @@ dict2string(typval_T *tv, int copyID, int restore_copyID)
     ga_append(&ga, '{');
 
     todo = (int)d->dv_hashtab.ht_used;
-    for (hi = d->dv_hashtab.ht_array; todo > 0 && !got_int; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(&d->dv_hashtab, hi, todo)
     {
        if (!HASHITEM_EMPTY(hi))
        {
@@ -1114,7 +1114,8 @@ dict_extend(dict_T *d1, dict_T *d2, char_u *action, char *func_name)
        type = NULL;
 
     todo = (int)d2->dv_hashtab.ht_used;
-    for (hashitem_T *hi2 = d2->dv_hashtab.ht_array; todo > 0; ++hi2)
+    hashitem_T *hi2;
+    FOR_ALL_HASHTAB_ITEMS(&d2->dv_hashtab, hi2, todo)
     {
        if (!HASHITEM_EMPTY(hi2))
        {
@@ -1203,7 +1204,7 @@ dict_equal(
        return FALSE;
 
     todo = (int)d1->dv_hashtab.ht_used;
-    for (hi = d1->dv_hashtab.ht_array; todo > 0; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(&d1->dv_hashtab, hi, todo)
     {
        if (!HASHITEM_EMPTY(hi))
        {
@@ -1233,7 +1234,7 @@ dict_count(dict_T *d, typval_T *needle, int ic)
        return 0;
 
     todo = (int)d->dv_hashtab.ht_used;
-    for (hi = d->dv_hashtab.ht_array; todo > 0; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(&d->dv_hashtab, hi, todo)
     {
        if (!HASHITEM_EMPTY(hi))
        {
@@ -1369,7 +1370,7 @@ dict_filter_map(
     ht = &d->dv_hashtab;
     hash_lock(ht);
     todo = (int)ht->ht_used;
-    for (hi = ht->ht_array; todo > 0; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
     {
        if (!HASHITEM_EMPTY(hi))
        {
@@ -1502,7 +1503,7 @@ dict2list(typval_T *argvars, typval_T *rettv, dict2list_T what)
        return;
 
     todo = (int)d->dv_hashtab.ht_used;
-    for (hi = d->dv_hashtab.ht_array; todo > 0; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(&d->dv_hashtab, hi, todo)
     {
        if (!HASHITEM_EMPTY(hi))
        {
@@ -1587,7 +1588,7 @@ dict_set_items_ro(dict_T *di)
     hashitem_T *hi;
 
     // Set readonly
-    for (hi = di->dv_hashtab.ht_array; todo > 0 ; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(&di->dv_hashtab, hi, todo)
     {
        if (HASHITEM_EMPTY(hi))
            continue;
index a155c5eae430cc8ee9ee08fe0e58d8556fde2068..6c13d2ac4dc9bc8a2193dc234e3502faf7adf75c 100644 (file)
@@ -2650,7 +2650,7 @@ valid_diff(diff_T *diff)
 {
     diff_T     *dp;
 
-    for (dp = curtab->tp_first_diff; dp != NULL; dp = dp->df_next)
+    FOR_ALL_DIFFBLOCKS_IN_TAB(curtab, dp)
        if (dp == diff)
            return TRUE;
     return FALSE;
index a647b514f2884a606a5a245be00e7c7baab2f7ef..c82e7046d00dffdd84e443065db9cd7324c855a7 100644 (file)
@@ -5415,7 +5415,7 @@ set_ref_in_ht(hashtab_T *ht, int copyID, list_stack_T **list_stack)
            // it is added to ht_stack, if it contains a list it is added to
            // list_stack.
            todo = (int)cur_ht->ht_used;
-           for (hi = cur_ht->ht_array; todo > 0; ++hi)
+           FOR_ALL_HASHTAB_ITEMS(cur_ht, hi, todo)
                if (!HASHITEM_EMPTY(hi))
                {
                    --todo;
index 1dc723fdc9361f84e1a78c34576dbbbec7cc8c06..135cb58894f4dc3d80e1ab2487630db2a192093f 100644 (file)
@@ -7825,7 +7825,7 @@ max_min(typval_T *argvars, typval_T *rettv, int domax)
        if (d != NULL)
        {
            todo = (int)d->dv_hashtab.ht_used;
-           for (hi = d->dv_hashtab.ht_array; todo > 0; ++hi)
+           FOR_ALL_HASHTAB_ITEMS(&d->dv_hashtab, hi, todo)
            {
                if (!HASHITEM_EMPTY(hi))
                {
index b2343c0a2b3c80c1cd8b7488c4cfd193bbf8c22f..b1235428723c305480d7a9637370173b93ab0b64 100644 (file)
@@ -2317,7 +2317,7 @@ item_lock(typval_T *tv, int deep, int lock, int check_refcount)
                {
                    // recursive: lock/unlock the items the List contains
                    todo = (int)d->dv_hashtab.ht_used;
-                   for (hi = d->dv_hashtab.ht_array; todo > 0; ++hi)
+                   FOR_ALL_HASHTAB_ITEMS(&d->dv_hashtab, hi, todo)
                    {
                        if (!HASHITEM_EMPTY(hi))
                        {
@@ -3571,7 +3571,7 @@ vars_clear_ext(hashtab_T *ht, int free_val)
 
     hash_lock(ht);
     todo = (int)ht->ht_used;
-    for (hi = ht->ht_array; todo > 0; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
     {
        if (!HASHITEM_EMPTY(hi))
        {
index ea0c0b5886144465f0dc80118300ee36a858708c..3e8b7532e023665a9708a3c147fc390464088f95 100644 (file)
@@ -873,10 +873,6 @@ EXTERN vimmenu_T   *root_menu INIT(= NULL);
  * overruling of menus that the user already defined.
  */
 EXTERN int     sys_menu INIT(= FALSE);
-
-#define FOR_ALL_MENUS(m) for ((m) = root_menu; (m) != NULL; (m) = (m)->next)
-#define FOR_ALL_CHILD_MENUS(p, c) \
-    for ((c) = (p)->children; (c) != NULL; (c) = (c)->next)
 #endif
 
 #ifdef FEAT_GUI
@@ -968,27 +964,6 @@ EXTERN win_T       *lastwin;               // last window
 EXTERN win_T   *prevwin INIT(= NULL);  // previous window
 #define ONE_WINDOW (firstwin == lastwin)
 #define W_NEXT(wp) ((wp)->w_next)
-#define FOR_ALL_WINDOWS(wp) for ((wp) = firstwin; (wp) != NULL; (wp) = (wp)->w_next)
-#define FOR_ALL_FRAMES(frp, first_frame) \
-    for ((frp) = first_frame; (frp) != NULL; (frp) = (frp)->fr_next)
-#define FOR_ALL_TABPAGES(tp) for ((tp) = first_tabpage; (tp) != NULL; (tp) = (tp)->tp_next)
-#define FOR_ALL_WINDOWS_IN_TAB(tp, wp) \
-    for ((wp) = ((tp) == NULL || (tp) == curtab) \
-           ? firstwin : (tp)->tp_firstwin; (wp); (wp) = (wp)->w_next)
-/*
- * When using this macro "break" only breaks out of the inner loop. Use "goto"
- * to break out of the tabpage loop.
- */
-#define FOR_ALL_TAB_WINDOWS(tp, wp) \
-    for ((tp) = first_tabpage; (tp) != NULL; (tp) = (tp)->tp_next) \
-       for ((wp) = ((tp) == curtab) \
-               ? firstwin : (tp)->tp_firstwin; (wp); (wp) = (wp)->w_next)
-
-#define FOR_ALL_POPUPWINS(wp) \
-    for ((wp) = first_popupwin; (wp) != NULL; (wp) = (wp)->w_next)
-#define FOR_ALL_POPUPWINS_IN_TAB(tp, wp) \
-    for ((wp) = (tp)->tp_first_popupwin; (wp) != NULL; (wp) = (wp)->w_next)
-
 
 EXTERN win_T   *curwin;        // currently active window
 
@@ -1050,16 +1025,6 @@ EXTERN buf_T     *firstbuf INIT(= NULL); // first buffer
 EXTERN buf_T   *lastbuf INIT(= NULL);  // last buffer
 EXTERN buf_T   *curbuf INIT(= NULL);   // currently active buffer
 
-#define FOR_ALL_BUFFERS(buf) \
-    for ((buf) = firstbuf; (buf) != NULL; (buf) = (buf)->b_next)
-
-#define FOR_ALL_BUF_WININFO(buf, wip) \
-    for ((wip) = (buf)->b_wininfo; (wip) != NULL; (wip) = (wip)->wi_next)
-
-// Iterate through all the signs placed in a buffer
-#define FOR_ALL_SIGNS_IN_BUF(buf, sign) \
-       for ((sign) = (buf)->b_signlist; (sign) != NULL; (sign) = (sign)->se_next)
-
 // Flag that is set when switching off 'swapfile'.  It means that all blocks
 // are to be loaded into memory.  Shouldn't be global...
 EXTERN int     mf_dont_release INIT(= FALSE);  // don't release blocks
@@ -1874,9 +1839,6 @@ EXTERN disptick_T display_tick INIT(= 0);
 // Line in which spell checking wasn't highlighted because it touched the
 // cursor position in Insert mode.
 EXTERN linenr_T                spell_redraw_lnum INIT(= 0);
-
-#define FOR_ALL_SPELL_LANGS(slang) \
-    for ((slang) = first_lang; (slang) != NULL; (slang) = (slang)->sl_next)
 #endif
 
 #ifdef FEAT_CONCEAL
@@ -2015,11 +1977,6 @@ EXTERN char *ch_part_names[]
 
 // Whether a redraw is needed for appending a line to a buffer.
 EXTERN int channel_need_redraw INIT(= FALSE);
-
-# define FOR_ALL_CHANNELS(ch) \
-    for ((ch) = first_channel; (ch) != NULL; (ch) = (ch)->ch_next)
-# define FOR_ALL_JOBS(job) \
-    for ((job) = first_job; (job) != NULL; (job) = (job)->jv_next)
 #endif
 
 #ifdef FEAT_EVAL
@@ -2032,14 +1989,6 @@ EXTERN int did_repeated_msg INIT(= 0);
 # define REPEATED_MSG_SAFESTATE            2
 #endif
 
-#if defined(FEAT_DIFF)
-#define FOR_ALL_DIFFBLOCKS_IN_TAB(tp, dp) \
-    for ((dp) = (tp)->tp_first_diff; (dp) != NULL; (dp) = (dp)->df_next)
-#endif
-
-#define FOR_ALL_LIST_ITEMS(l, li) \
-    for ((li) = (l) == NULL ? NULL : (l)->lv_first; (li) != NULL; (li) = (li)->li_next)
-
 // While executing a regexp and set to OPTION_MAGIC_ON or OPTION_MAGIC_OFF this
 // overrules p_magic.  Otherwise set to OPTION_MAGIC_NOT_SET.
 EXTERN optmagic_T magic_overruled INIT(= OPTION_MAGIC_NOT_SET);
index ddf1877693bac37b141d75e36d5309ce748a8dd4..b7f86587ac56d24106b6980cf57fa56c98d19e31 100644 (file)
@@ -108,7 +108,7 @@ hash_clear_all(hashtab_T *ht, int off)
     hashitem_T *hi;
 
     todo = (long)ht->ht_used;
-    for (hi = ht->ht_array; todo > 0; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
     {
        if (!HASHITEM_EMPTY(hi))
        {
index e4ebf29f490f155b1f4fa2525f24dbd81d2e0364..e44714acf84320109d42ddd100cd7aa7dfc42eba 100644 (file)
@@ -3067,7 +3067,7 @@ vim_to_mzscheme_impl(typval_T *vim_value, int depth, Scheme_Hash_Table *visited)
            hashitem_T  *hi;
            dictitem_T  *di;
 
-           for (hi = ht->ht_array; todo > 0; ++hi)
+           FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
            {
                if (!HASHITEM_EMPTY(hi))
                {
index 8f9b35623106122e2d65b8b786def9c92afc160d..dd0f5db4431e0ff7f0d63c76f0dee56ba1160b1f 100644 (file)
@@ -1147,7 +1147,7 @@ vim_to_ruby(typval_T *tv)
            hashitem_T  *hi;
            dictitem_T  *di;
 
-           for (hi = ht->ht_array; todo > 0; ++hi)
+           FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
            {
                if (!HASHITEM_EMPTY(hi))
                {
index c3ba3b8542fbf9d62543411afbf001811776f336..1d18abb9254c6c50e1c2dd4e3863d46d2011c190 100644 (file)
--- a/src/job.c
+++ b/src/job.c
@@ -140,7 +140,7 @@ get_job_options(typval_T *tv, jobopt_T *opt, int supported, int supported2)
        return OK;
 
     todo = (int)dict->dv_hashtab.ht_used;
-    for (hi = dict->dv_hashtab.ht_array; todo > 0; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(&dict->dv_hashtab, hi, todo)
        if (!HASHITEM_EMPTY(hi))
        {
            item = &dict_lookup(hi)->di_tv;
index 4f3ad43f2512fd0e4ccba0b22921ca7c5422fdd0..c7e7238234883bac908123d98132fbede86faf65 100644 (file)
 
 // Length of the array.
 #define ARRAY_LENGTH(a) (sizeof(a) / sizeof((a)[0]))
+
+#ifdef FEAT_MENU
+#define FOR_ALL_MENUS(m) \
+    for ((m) = root_menu; (m) != NULL; (m) = (m)->next)
+#define FOR_ALL_CHILD_MENUS(p, c) \
+    for ((c) = (p)->children; (c) != NULL; (c) = (c)->next)
+#endif
+
+#define FOR_ALL_WINDOWS(wp) \
+    for ((wp) = firstwin; (wp) != NULL; (wp) = (wp)->w_next)
+#define FOR_ALL_FRAMES(frp, first_frame) \
+    for ((frp) = first_frame; (frp) != NULL; (frp) = (frp)->fr_next)
+#define FOR_ALL_TABPAGES(tp) \
+    for ((tp) = first_tabpage; (tp) != NULL; (tp) = (tp)->tp_next)
+#define FOR_ALL_WINDOWS_IN_TAB(tp, wp) \
+    for ((wp) = ((tp) == NULL || (tp) == curtab) \
+           ? firstwin : (tp)->tp_firstwin; (wp); (wp) = (wp)->w_next)
+/*
+ * When using this macro "break" only breaks out of the inner loop. Use "goto"
+ * to break out of the tabpage loop.
+ */
+#define FOR_ALL_TAB_WINDOWS(tp, wp) \
+    for ((tp) = first_tabpage; (tp) != NULL; (tp) = (tp)->tp_next) \
+       for ((wp) = ((tp) == curtab) \
+               ? firstwin : (tp)->tp_firstwin; (wp); (wp) = (wp)->w_next)
+
+#define FOR_ALL_POPUPWINS(wp) \
+    for ((wp) = first_popupwin; (wp) != NULL; (wp) = (wp)->w_next)
+#define FOR_ALL_POPUPWINS_IN_TAB(tp, wp) \
+    for ((wp) = (tp)->tp_first_popupwin; (wp) != NULL; (wp) = (wp)->w_next)
+
+#define FOR_ALL_BUFFERS(buf) \
+    for ((buf) = firstbuf; (buf) != NULL; (buf) = (buf)->b_next)
+
+#define FOR_ALL_BUF_WININFO(buf, wip) \
+    for ((wip) = (buf)->b_wininfo; (wip) != NULL; (wip) = (wip)->wi_next)
+
+// Iterate through all the signs placed in a buffer
+#define FOR_ALL_SIGNS_IN_BUF(buf, sign) \
+    for ((sign) = (buf)->b_signlist; (sign) != NULL; (sign) = (sign)->se_next)
+
+#ifdef FEAT_SPELL
+#define FOR_ALL_SPELL_LANGS(slang) \
+    for ((slang) = first_lang; (slang) != NULL; (slang) = (slang)->sl_next)
+#endif
+
+// Iterate over all the items in a List
+#define FOR_ALL_LIST_ITEMS(l, li) \
+    for ((li) = (l) == NULL ? NULL : (l)->lv_first; (li) != NULL; (li) = (li)->li_next)
+
+// Iterate over all the items in a hash table
+#define FOR_ALL_HASHTAB_ITEMS(ht, hi, todo) \
+    for ((hi) = (ht)->ht_array; (todo) > 0; ++(hi))
index 57aa619990056409f8d4e6d1c676e6429271e6ac..5e6aed02bbdee298cbccb62933ad440fe9bb9861 100644 (file)
@@ -1579,7 +1579,7 @@ utf_char2cells(int c)
        // values of them.
        //
        // Note that these symbols are of varying widths, as they are symbols
-       // representing differents things ranging from a simple gear icon to an
+       // representing different things ranging from a simple gear icon to an
        // airplane. Some of them are in fact wider than double-width, but Vim
        // doesn't support non-fixed-width font, and tagging them as
        // double-width is the best way to handle them.
@@ -5647,7 +5647,7 @@ f_setcellwidths(typval_T *argvars, typval_T *rettv UNUSED)
     // Check that all entries are a list with three numbers, the range is
     // valid and the cell width is valid.
     item = 0;
-    for (li = l->lv_first; li != NULL; li = li->li_next)
+    FOR_ALL_LIST_ITEMS(l, li)
     {
        listitem_T *lili;
        varnumber_T n1;
index b9514d24828040dd839b8c534751223815ca5b04..746bcff797c9cdbdcfb51c6233a1f76165283483 100644 (file)
@@ -2335,10 +2335,20 @@ mch_restore_title(int which)
 {
     int        do_push_pop = unix_did_set_title || did_set_icon;
 
-    // only restore the title or icon when it has been set
-    mch_settitle(((which & SAVE_RESTORE_TITLE) && unix_did_set_title) ?
-                       (oldtitle ? oldtitle : p_titleold) : NULL,
+    // Only restore the title or icon when it has been set.
+    // When using "oldtitle" make a copy, it might be freed halfway.
+    char_u *title = ((which & SAVE_RESTORE_TITLE) && unix_did_set_title)
+                       ? (oldtitle ? oldtitle : p_titleold) : NULL;
+    char_u *tofree = NULL;
+    if (title == oldtitle && oldtitle != NULL)
+    {
+       tofree = vim_strsave(title);
+       if (tofree != NULL)
+           title = tofree;
+    }
+    mch_settitle(title,
               ((which & SAVE_RESTORE_ICON) && did_set_icon) ? oldicon : NULL);
+    vim_free(tofree);
 
     if (do_push_pop)
     {
@@ -5654,7 +5664,7 @@ mch_job_start(char **argv, job_T *job, jobopt_T *options, int is_terminal)
            hashitem_T  *hi;
            int         todo = (int)dict->dv_hashtab.ht_used;
 
-           for (hi = dict->dv_hashtab.ht_array; todo > 0; ++hi)
+           FOR_ALL_HASHTAB_ITEMS(&dict->dv_hashtab, hi, todo)
                if (!HASHITEM_EMPTY(hi))
                {
                    typval_T *item = &dict_lookup(hi)->di_tv;
index a151b19b04e390e7346477dbdb44c8714cf4aeb8..b519bf0ecac5279299d2531032d7a2d52b202219 100644 (file)
@@ -1308,9 +1308,9 @@ encode_key_event(dict_T *args, INPUT_RECORD *ir)
        if (mods)
        {
            // If "modifiers" is explicitly set in the args, then we reset any
-           // remembered modifer key state that may have been set from earlier
-           // mod-key-down events, even if they are not yet unset by earlier
-           // mod-key-up events.
+           // remembered modifier key state that may have been set from
+           // earlier mod-key-down events, even if they are not yet unset by
+           // earlier mod-key-up events.
            s_dwMods = 0;
            if (mods & MOD_MASK_SHIFT)
                ker.dwControlKeyState |= SHIFT_PRESSED;
@@ -2017,7 +2017,7 @@ test_mswin_event(char_u *event, dict_T *args)
     }
 
     // Ideally, WriteConsoleInput would be used to inject these low-level
-    // events.  But, this doesnt work well in the CI test environment.  So
+    // events.  But, this doesn't work well in the CI test environment.  So
     // implementing an input_record_buffer instead.
     if (input_encoded)
        lpEventsWritten = write_input_record_buffer(&ir, 1);
@@ -5737,7 +5737,7 @@ win32_build_env(dict_T *env, garray_T *gap, int is_terminal)
 
     if (env != NULL)
     {
-       for (hi = env->dv_hashtab.ht_array; todo > 0; ++hi)
+       FOR_ALL_HASHTAB_ITEMS(&env->dv_hashtab, hi, todo)
        {
            if (!HASHITEM_EMPTY(hi))
            {
index 6e1d925690a0d922e7a063300d365f04a9aaf064..c34ee9fe325e2810c18ed7103c74b1f1f3cbfaaf 100644 (file)
@@ -2413,8 +2413,7 @@ popup_close_and_callback(win_T *wp, typval_T *arg)
            win_enter(owp, FALSE);
        else
        {
-           for (owp = curtab->tp_first_popupwin; owp != NULL;
-                                                            owp = owp->w_next)
+           FOR_ALL_POPUPWINS_IN_TAB(curtab, owp)
                if (owp != curwin && owp->w_buffer->b_term != NULL)
                    break;
            if (owp != NULL)
index b971cd79098e6e5b2383b8c47655b3cccbf58c81..692e764615976d0f27db5260e055a5543683a09f 100644 (file)
@@ -335,7 +335,7 @@ profile_reset(void)
     functbl = func_tbl_get();
     todo = (int)functbl->ht_used;
 
-    for (hi = functbl->ht_array; todo > 0; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(functbl, hi, todo)
     {
        ufunc_T *fp;
        int     i;
@@ -825,7 +825,7 @@ func_dump_profile(FILE *fd)
 
     sorttab = ALLOC_MULT(ufunc_T *, todo);
 
-    for (hi = functbl->ht_array; todo > 0; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(functbl, hi, todo)
     {
        if (!HASHITEM_EMPTY(hi))
        {
index 008c7b3d41e8e2fd847b9810aaf7a2933f19399f..acc1deb58de6678baa253fb1d26e9b4c853ce5cf 100644 (file)
@@ -1672,7 +1672,7 @@ do_source_ext(
                // is encountered without the "noclear" argument.
                ht = &SCRIPT_VARS(sid);
                todo = (int)ht->ht_used;
-               for (hi = ht->ht_array; todo > 0; ++hi)
+               FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
                    if (!HASHITEM_EMPTY(hi))
                    {
                        --todo;
@@ -2063,7 +2063,7 @@ get_script_local_funcs(scid_T sid)
     // looking for functions with script ID 'sid'.
     functbl = func_tbl_get();
     todo = functbl->ht_used;
-    for (hi = functbl->ht_array; todo > 0; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(functbl, hi, todo)
     {
        ufunc_T *fp;
 
index a34eedf57fe9087e4c15a767a6dc29bf6a4721d7..e39ce4d4d1ec7222573be22963f4c295d7d032f1 100644 (file)
@@ -543,7 +543,7 @@ store_session_globals(FILE *fd)
     char_u     *p, *t;
 
     todo = (int)gvht->ht_used;
-    for (hi = gvht->ht_array; todo > 0; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(gvht, hi, todo)
     {
        if (!HASHITEM_EMPTY(hi))
        {
index 64b64c9787a20354c5fb62c2d0985a1edc45258f..8aa043bc458fde6fdbd769624e34713c600bb0d9 100644 (file)
@@ -2058,7 +2058,7 @@ get_nth_sign_group_name(int idx)
     // Complete with name of sign groups already defined
     current_idx = 0;
     todo = (int)sg_table.ht_used;
-    for (hi = sg_table.ht_array; todo > 0; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(&sg_table, hi, todo)
     {
        if (!HASHITEM_EMPTY(hi))
        {
index a9fa70cfa4537e9986300606aad7e4d364c8fc5a..85956b7b667b58088af193e7a23f3e46cb9ab6ed 100644 (file)
@@ -3466,7 +3466,7 @@ spell_free_aff(afffile_T *aff)
     for (ht = &aff->af_pref; ; ht = &aff->af_suff)
     {
        todo = (int)ht->ht_used;
-       for (hi = ht->ht_array; todo > 0; ++hi)
+       FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
        {
            if (!HASHITEM_EMPTY(hi))
            {
@@ -5117,7 +5117,7 @@ write_vim_spell(spellinfo_T *spin, char_u *fname)
            hashitem_T  *hi;
 
            todo = (int)spin->si_commonwords.ht_used;
-           for (hi = spin->si_commonwords.ht_array; todo > 0; ++hi)
+           FOR_ALL_HASHTAB_ITEMS(&spin->si_commonwords, hi, todo)
                if (!HASHITEM_EMPTY(hi))
                {
                    l = (int)STRLEN(hi->hi_key) + 1;
index a60055728be436e55f4dbfb98c0b478776c4289c..1084230a574582f04894ca0ebb3fa4f43dab04ae 100644 (file)
@@ -3176,7 +3176,7 @@ suggest_try_soundalike_finish(void)
        {
            // Free the info about handled words.
            todo = (int)slang->sl_sounddone.ht_used;
-           for (hi = slang->sl_sounddone.ht_array; todo > 0; ++hi)
+           FOR_ALL_HASHTAB_ITEMS(&slang->sl_sounddone, hi, todo)
                if (!HASHITEM_EMPTY(hi))
                {
                    vim_free(HI2SFT(hi));
index 719bc9c797e619245ae53b7f100e334e2b863aa6..a4fa249fa375580742729a0d84462da6b1a57c75 100644 (file)
@@ -4323,7 +4323,7 @@ syn_clear_keyword(int id, hashtab_T *ht)
 
     hash_lock(ht);
     todo = (int)ht->ht_used;
-    for (hi = ht->ht_array; todo > 0; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
     {
        if (!HASHITEM_EMPTY(hi))
        {
@@ -4371,7 +4371,7 @@ clear_keywtab(hashtab_T *ht)
     keyentry_T *kp_next;
 
     todo = (int)ht->ht_used;
-    for (hi = ht->ht_array; todo > 0; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
     {
        if (!HASHITEM_EMPTY(hi))
        {
index b31d192a639276344ac89b1dca1c30593492eb4b..3f4387c4989d7f1691449c9bed466df87b02e1a9 100644 (file)
@@ -181,7 +181,7 @@ fill_assert_error(
                return;
 
            todo = (int)exp_d->dv_hashtab.ht_used;
-           for (hi = exp_d->dv_hashtab.ht_array; todo > 0; ++hi)
+           FOR_ALL_HASHTAB_ITEMS(&exp_d->dv_hashtab, hi, todo)
            {
                if (!HASHITEM_EMPTY(hi))
                {
@@ -204,7 +204,7 @@ fill_assert_error(
 
            // Add items only present in got_d.
            todo = (int)got_d->dv_hashtab.ht_used;
-           for (hi = got_d->dv_hashtab.ht_array; todo > 0; ++hi)
+           FOR_ALL_HASHTAB_ITEMS(&got_d->dv_hashtab, hi, todo)
            {
                if (!HASHITEM_EMPTY(hi))
                {
index bee45b63f5882fcb05589fed20b1cda5a8de6060..bead1463361502886605d12b149888d1341e4592 100644 (file)
@@ -723,7 +723,8 @@ count_props(linenr_T lnum, int only_starting, int last_line)
 static textprop_T      *text_prop_compare_props;
 static buf_T           *text_prop_compare_buf;
 
-/* Score for sorting on position of the text property: 0: above,
+/*
+ * Score for sorting on position of the text property: 0: above,
  * 1: after (default), 2: right, 3: below (comes last)
  */
     static int
@@ -933,7 +934,7 @@ find_type_by_id(hashtab_T *ht, proptype_T ***array, int id)
        if (*array == NULL)
            return NULL;
        todo = (long)ht->ht_used;
-       for (hi = ht->ht_array; todo > 0; ++hi)
+       FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
        {
            if (!HASHITEM_EMPTY(hi))
            {
@@ -1958,7 +1959,7 @@ f_prop_type_delete(typval_T *argvars, typval_T *rettv UNUSED)
     hash_remove(ht, hi, "prop type delete");
     vim_free(prop);
 
-    // currently visibile text properties will disappear
+    // currently visible text properties will disappear
     redraw_all_later(UPD_CLEAR);
     changed_window_setting_buf(buf == NULL ? curbuf : buf);
 }
@@ -2021,7 +2022,7 @@ list_types(hashtab_T *ht, list_T *l)
     hashitem_T *hi;
 
     todo = (long)ht->ht_used;
-    for (hi = ht->ht_array; todo > 0; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
     {
        if (!HASHITEM_EMPTY(hi))
        {
@@ -2074,7 +2075,7 @@ clear_ht_prop_types(hashtab_T *ht)
        return;
 
     todo = (long)ht->ht_used;
-    for (hi = ht->ht_array; todo > 0; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
     {
        if (!HASHITEM_EMPTY(hi))
        {
index 9e24b79587ec8c75a4c76a19d958e5ef8e779dcf..878e07f91fea96234d03ff0297cb0a328ffb4399 100644 (file)
@@ -2313,7 +2313,7 @@ cleanup_function_call(funccall_T *fc)
 
        // Make a copy of the a: variables, since we didn't do that above.
        todo = (int)fc->fc_l_avars.dv_hashtab.ht_used;
-       for (hi = fc->fc_l_avars.dv_hashtab.ht_array; todo > 0; ++hi)
+       FOR_ALL_HASHTAB_ITEMS(&fc->fc_l_avars.dv_hashtab, hi, todo)
        {
            if (!HASHITEM_EMPTY(hi))
            {
@@ -3296,7 +3296,7 @@ delete_script_functions(int sid)
     while (todo > 0)
     {
        todo = func_hashtab.ht_used;
-       for (hi = func_hashtab.ht_array; todo > 0; ++hi)
+       FOR_ALL_HASHTAB_ITEMS(&func_hashtab, hi, todo)
            if (!HASHITEM_EMPTY(hi))
            {
                fp = HI2UF(hi);
@@ -3353,7 +3353,7 @@ free_all_functions(void)
     while (todo > 0)
     {
        todo = func_hashtab.ht_used;
-       for (hi = func_hashtab.ht_array; todo > 0; ++hi)
+       FOR_ALL_HASHTAB_ITEMS(&func_hashtab, hi, todo)
            if (!HASHITEM_EMPTY(hi))
            {
                // clear the def function index now
@@ -3385,7 +3385,7 @@ free_all_functions(void)
     while (func_hashtab.ht_used > skipped)
     {
        todo = func_hashtab.ht_used;
-       for (hi = func_hashtab.ht_array; todo > 0; ++hi)
+       FOR_ALL_HASHTAB_ITEMS(&func_hashtab, hi, todo)
            if (!HASHITEM_EMPTY(hi))
            {
                --todo;
index 2a5069431bbff703f85166c092f953f62da636d5..326379cac1f08c764823891279bfdc7d6f7e27c5 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1390,
 /**/
     1389,
 /**/
index f8ce10170f5bb35053a2737c10258297bc8fa6b2..18cebdba8c52542f6eef1cdb6303244aff5e1abf 100644 (file)
@@ -1052,7 +1052,7 @@ invoke_defer_funcs(ectx_T *ectx)
 
     if (defer_tv->v_type != VAR_LIST)
        return;  // no function added
-    for (li = defer_tv->vval.v_list->lv_first; li != NULL; li = li->li_next)
+    FOR_ALL_LIST_ITEMS(defer_tv->vval.v_list, li)
     {
        list_T      *l = li->li_tv.vval.v_list;
        typval_T    rettv;
index b946fb918ac2a9ae878b0545f138f73edee4a4e1..5bf2cc7f997eb36b6023a477e2a5a186a48a01cd 100644 (file)
@@ -281,7 +281,7 @@ free_all_script_vars(scriptitem_T *si)
 
     hash_lock(ht);
     todo = (int)ht->ht_used;
-    for (hi = ht->ht_array; todo > 0; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(ht, hi, todo)
     {
        if (!HASHITEM_EMPTY(hi))
        {
index 1a7b0a6761d296c9454e35b58d43e6d179e4ecb4..95252dbafeda3e68df92440ac5f165db905addc1 100644 (file)
@@ -213,7 +213,7 @@ set_tv_type(typval_T *tv, type_T *type)
                hashitem_T      *hi;
                dictitem_T      *di;
 
-               for (hi = d->dv_hashtab.ht_array; todo > 0; ++hi)
+               FOR_ALL_HASHTAB_ITEMS(&d->dv_hashtab, hi, todo)
                {
                    if (!HASHITEM_EMPTY(hi))
                    {
index 7247394773fc9a0d15aa46a10286668f647dac5b..b772fc8f32d3846ece9abf4684bebfae4a89ccfb 100644 (file)
@@ -1319,7 +1319,7 @@ write_viminfo_varlist(FILE *fp)
     fputs(_("\n# global variables:\n"), fp);
 
     todo = (int)gvht->ht_used;
-    for (hi = gvht->ht_array; todo > 0; ++hi)
+    FOR_ALL_HASHTAB_ITEMS(gvht, hi, todo)
     {
        if (!HASHITEM_EMPTY(hi))
        {
index a804b4f1b9147728dbfd62d9a0c38c7644577f0b..a967f92179ec7a83d97e34d4d7636c0c475ac75f 100644 (file)
@@ -5622,7 +5622,7 @@ win_free(
                // If there already is an entry with "wi_win" set to NULL it
                // must be removed, it would never be used.
                // Skip "wip" itself, otherwise Coverity complains.
-               for (wip2 = buf->b_wininfo; wip2 != NULL; wip2 = wip2->wi_next)
+               FOR_ALL_BUF_WININFO(buf, wip2)
                    if (wip2 != wip && wip2->wi_win == NULL)
                    {
                        if (wip2->wi_next != NULL)
@@ -7378,7 +7378,7 @@ reset_lnums(void)
 
 /*
  * A snapshot of the window sizes, to restore them after closing the help
- * window.
+ * or other window.
  * Only these fields are used:
  * fr_layout
  * fr_width
@@ -7390,6 +7390,7 @@ reset_lnums(void)
 
 /*
  * Create a snapshot of the current frame sizes.
+ * "idx" is SNAP_HELP_IDX or SNAP_AUCMD_IDX.
  */
     void
 make_snapshot(int idx)
@@ -7473,6 +7474,7 @@ get_snapshot_curwin(int idx)
  * Restore a previously created snapshot, if there is any.
  * This is only done if the screen size didn't change and the window layout is
  * still the same.
+ * "idx" is SNAP_HELP_IDX or SNAP_AUCMD_IDX.
  */
     void
 restore_snapshot(