Skip to content

Commit ea8b7ae

Browse files
committed
patch 8.2.0073: initializing globals with COMMA is clumsy
Problem: Initializing globals with COMMA is clumsy. Solution: Use INIT2(), INIT3(), etc.
1 parent bb062c1 commit ea8b7ae

3 files changed

Lines changed: 15 additions & 6 deletions

File tree

src/globals.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ EXTERN int msg_no_more INIT(= FALSE); // don't use more prompt, truncate
270270
* Stack of execution contexts. Each entry is an estack_T.
271271
* Current context is at ga_len - 1.
272272
*/
273-
EXTERN garray_T exestack INIT(= {0 COMMA 0 COMMA sizeof(estack_T) COMMA 50 COMMA NULL});
273+
EXTERN garray_T exestack INIT5(0, 0, sizeof(estack_T), 50, NULL);
274274
// name of error message source
275275
#define SOURCING_NAME (((estack_T *)exestack.ga_data)[exestack.ga_len - 1].es_name)
276276
// line number in the message source or zero
@@ -285,7 +285,7 @@ EXTERN int debug_backtrace_level INIT(= 0); // breakpoint backtrace level
285285
# ifdef FEAT_PROFILE
286286
EXTERN int do_profiling INIT(= PROF_NONE); // PROF_ values
287287
# endif
288-
EXTERN garray_T script_items INIT(= {0 COMMA 0 COMMA sizeof(scriptitem_T) COMMA 4 COMMA NULL});
288+
EXTERN garray_T script_items INIT5(0, 0, sizeof(scriptitem_T), 4, NULL);
289289
#define SCRIPT_ITEM(id) (((scriptitem_T *)script_items.ga_data)[(id) - 1])
290290
#define FUNCLINE(fp, j) ((char_u **)(fp->uf_lines.ga_data))[j]
291291

@@ -375,7 +375,7 @@ EXTERN int want_garbage_collect INIT(= FALSE);
375375
EXTERN int garbage_collect_at_exit INIT(= FALSE);
376376

377377
// Script CTX being sourced or was sourced to define the current function.
378-
EXTERN sctx_T current_sctx INIT(= {0 COMMA 0 COMMA 0 COMMA 0});
378+
EXTERN sctx_T current_sctx INIT4(0, 0, 0, 0);
379379
#endif
380380

381381
EXTERN int did_source_packages INIT(= FALSE);
@@ -468,7 +468,7 @@ EXTERN int au_did_filetype INIT(= FALSE);
468468

469469
// When deleting the current buffer, another one must be loaded. If we know
470470
// which one is preferred, au_new_curbuf is set to it
471-
EXTERN bufref_T au_new_curbuf INIT(= {NULL COMMA 0 COMMA 0});
471+
EXTERN bufref_T au_new_curbuf INIT3(NULL, 0, 0);
472472

473473
// When deleting a buffer/window and autocmd_busy is TRUE, do not free the
474474
// buffer/window. but link it in the list starting with
@@ -1412,7 +1412,7 @@ EXTERN int term_is_xterm INIT(= FALSE); // xterm-like 'term'
14121412
EXTERN char psepc INIT(= '\\'); // normal path separator character
14131413
EXTERN char psepcN INIT(= '/'); // abnormal path separator character
14141414
// normal path separator string
1415-
EXTERN char pseps[2] INIT(= {'\\' COMMA 0});
1415+
EXTERN char pseps[2] INIT2('\\', 0);
14161416
#endif
14171417

14181418
// Set to TRUE when an operator is being executed with virtual editing, MAYBE

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,8 @@ static char *(features[]) =
742742

743743
static int included_patches[] =
744744
{ /* Add new patch number below this line */
745+
/**/
746+
73,
745747
/**/
746748
72,
747749
/**/

src/vim.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1775,11 +1775,18 @@ void *vim_memset(void *, int, size_t);
17751775
#ifndef EXTERN
17761776
# define EXTERN extern
17771777
# define INIT(x)
1778+
# define INIT2(a, b)
1779+
# define INIT3(a, b, c)
1780+
# define INIT4(a, b, c, d)
1781+
# define INIT5(a, b, c, d, e)
17781782
#else
17791783
# ifndef INIT
17801784
# define INIT(x) x
1785+
# define INIT2(a, b) = {a, b}
1786+
# define INIT3(a, b, c) = {a, b, c}
1787+
# define INIT4(a, b, c, d) = {a, b, c, d}
1788+
# define INIT5(a, b, c, d, e) = {a, b, c, d, e}
17811789
# define DO_INIT
1782-
# define COMMA ,
17831790
# endif
17841791
#endif
17851792

0 commit comments

Comments
 (0)