Mercurial > vim
comparison src/eval.c @ 20007:aadd1cae2ff5 v8.2.0559
patch 8.2.0559: clearing a struct is verbose
Commit: https://github.com/vim/vim/commit/a80faa8930ed5a554beeb2727762538873135e83
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Apr 12 19:37:17 2020 +0200
patch 8.2.0559: clearing a struct is verbose
Problem: Clearing a struct is verbose.
Solution: Define and use CLEAR_FIELD() and CLEAR_POINTER().
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 12 Apr 2020 19:45:05 +0200 |
parents | 1f42c49c3d29 |
children | de756b3f4dee |
comparison
equal
deleted
inserted
replaced
20006:aee3c9266968 | 20007:aadd1cae2ff5 |
---|---|
232 if (expr->v_type == VAR_FUNC) | 232 if (expr->v_type == VAR_FUNC) |
233 { | 233 { |
234 s = expr->vval.v_string; | 234 s = expr->vval.v_string; |
235 if (s == NULL || *s == NUL) | 235 if (s == NULL || *s == NUL) |
236 return FAIL; | 236 return FAIL; |
237 vim_memset(&funcexe, 0, sizeof(funcexe)); | 237 CLEAR_FIELD(funcexe); |
238 funcexe.evaluate = TRUE; | 238 funcexe.evaluate = TRUE; |
239 if (call_func(s, -1, rettv, argc, argv, &funcexe) == FAIL) | 239 if (call_func(s, -1, rettv, argc, argv, &funcexe) == FAIL) |
240 return FAIL; | 240 return FAIL; |
241 } | 241 } |
242 else if (expr->v_type == VAR_PARTIAL) | 242 else if (expr->v_type == VAR_PARTIAL) |
251 else | 251 else |
252 { | 252 { |
253 s = partial_name(partial); | 253 s = partial_name(partial); |
254 if (s == NULL || *s == NUL) | 254 if (s == NULL || *s == NUL) |
255 return FAIL; | 255 return FAIL; |
256 vim_memset(&funcexe, 0, sizeof(funcexe)); | 256 CLEAR_FIELD(funcexe); |
257 funcexe.evaluate = TRUE; | 257 funcexe.evaluate = TRUE; |
258 funcexe.partial = partial; | 258 funcexe.partial = partial; |
259 if (call_func(s, -1, rettv, argc, argv, &funcexe) == FAIL) | 259 if (call_func(s, -1, rettv, argc, argv, &funcexe) == FAIL) |
260 return FAIL; | 260 return FAIL; |
261 } | 261 } |
473 { | 473 { |
474 int ret; | 474 int ret; |
475 funcexe_T funcexe; | 475 funcexe_T funcexe; |
476 | 476 |
477 rettv->v_type = VAR_UNKNOWN; // clear_tv() uses this | 477 rettv->v_type = VAR_UNKNOWN; // clear_tv() uses this |
478 vim_memset(&funcexe, 0, sizeof(funcexe)); | 478 CLEAR_FIELD(funcexe); |
479 funcexe.firstline = curwin->w_cursor.lnum; | 479 funcexe.firstline = curwin->w_cursor.lnum; |
480 funcexe.lastline = curwin->w_cursor.lnum; | 480 funcexe.lastline = curwin->w_cursor.lnum; |
481 funcexe.evaluate = TRUE; | 481 funcexe.evaluate = TRUE; |
482 ret = call_func(func, -1, rettv, argc, argv, &funcexe); | 482 ret = call_func(func, -1, rettv, argc, argv, &funcexe); |
483 if (ret == FAIL) | 483 if (ret == FAIL) |
647 int len; | 647 int len; |
648 hashtab_T *ht; | 648 hashtab_T *ht; |
649 int quiet = flags & GLV_QUIET; | 649 int quiet = flags & GLV_QUIET; |
650 | 650 |
651 // Clear everything in "lp". | 651 // Clear everything in "lp". |
652 vim_memset(lp, 0, sizeof(lval_T)); | 652 CLEAR_POINTER(lp); |
653 | 653 |
654 if (skip) | 654 if (skip) |
655 { | 655 { |
656 // When skipping just find the end of the name. | 656 // When skipping just find the end of the name. |
657 lp->ll_name = name; | 657 lp->ll_name = name; |
1713 else | 1713 else |
1714 { | 1714 { |
1715 funcexe_T funcexe; | 1715 funcexe_T funcexe; |
1716 | 1716 |
1717 // Invoke the function. | 1717 // Invoke the function. |
1718 vim_memset(&funcexe, 0, sizeof(funcexe)); | 1718 CLEAR_FIELD(funcexe); |
1719 funcexe.firstline = curwin->w_cursor.lnum; | 1719 funcexe.firstline = curwin->w_cursor.lnum; |
1720 funcexe.lastline = curwin->w_cursor.lnum; | 1720 funcexe.lastline = curwin->w_cursor.lnum; |
1721 funcexe.evaluate = evaluate; | 1721 funcexe.evaluate = evaluate; |
1722 funcexe.partial = partial; | 1722 funcexe.partial = partial; |
1723 funcexe.basetv = basetv; | 1723 funcexe.basetv = basetv; |
2803 s = functv.vval.v_string; | 2803 s = functv.vval.v_string; |
2804 } | 2804 } |
2805 else | 2805 else |
2806 s = (char_u *)""; | 2806 s = (char_u *)""; |
2807 | 2807 |
2808 vim_memset(&funcexe, 0, sizeof(funcexe)); | 2808 CLEAR_FIELD(funcexe); |
2809 funcexe.firstline = curwin->w_cursor.lnum; | 2809 funcexe.firstline = curwin->w_cursor.lnum; |
2810 funcexe.lastline = curwin->w_cursor.lnum; | 2810 funcexe.lastline = curwin->w_cursor.lnum; |
2811 funcexe.evaluate = evaluate; | 2811 funcexe.evaluate = evaluate; |
2812 funcexe.partial = pt; | 2812 funcexe.partial = pt; |
2813 funcexe.selfdict = selfdict; | 2813 funcexe.selfdict = selfdict; |
5505 */ | 5505 */ |
5506 void | 5506 void |
5507 init_tv(typval_T *varp) | 5507 init_tv(typval_T *varp) |
5508 { | 5508 { |
5509 if (varp != NULL) | 5509 if (varp != NULL) |
5510 vim_memset(varp, 0, sizeof(typval_T)); | 5510 CLEAR_POINTER(varp); |
5511 } | 5511 } |
5512 | 5512 |
5513 /* | 5513 /* |
5514 * Get the number value of a variable. | 5514 * Get the number value of a variable. |
5515 * If it is a String variable, uses vim_str2nr(). | 5515 * If it is a String variable, uses vim_str2nr(). |