mirror of
https://github.com/vim/vim.git
synced 2025-10-13 06:54:15 -04:00
patch 8.1.0166: using dict_add_nr_str() is clumsy
Problem: Using dict_add_nr_str() is clumsy. Solution: Split into two functions. (Ozaki Kiichi, closes #3154)
This commit is contained in:
134
src/evalfunc.c
134
src/evalfunc.c
@@ -4338,9 +4338,9 @@ get_buffer_signs(buf_T *buf, list_T *l)
|
||||
|
||||
if (d != NULL)
|
||||
{
|
||||
dict_add_nr_str(d, "id", sign->id, NULL);
|
||||
dict_add_nr_str(d, "lnum", sign->lnum, NULL);
|
||||
dict_add_nr_str(d, "name", 0L, sign_typenr2name(sign->typenr));
|
||||
dict_add_number(d, "id", sign->id);
|
||||
dict_add_number(d, "lnum", sign->lnum);
|
||||
dict_add_string(d, "name", sign_typenr2name(sign->typenr));
|
||||
|
||||
list_append_dict(l, d);
|
||||
}
|
||||
@@ -4363,18 +4363,16 @@ get_buffer_info(buf_T *buf)
|
||||
if (dict == NULL)
|
||||
return NULL;
|
||||
|
||||
dict_add_nr_str(dict, "bufnr", buf->b_fnum, NULL);
|
||||
dict_add_nr_str(dict, "name", 0L,
|
||||
buf->b_ffname != NULL ? buf->b_ffname : (char_u *)"");
|
||||
dict_add_nr_str(dict, "lnum", buf == curbuf ? curwin->w_cursor.lnum
|
||||
: buflist_findlnum(buf), NULL);
|
||||
dict_add_nr_str(dict, "loaded", buf->b_ml.ml_mfp != NULL, NULL);
|
||||
dict_add_nr_str(dict, "listed", buf->b_p_bl, NULL);
|
||||
dict_add_nr_str(dict, "changed", bufIsChanged(buf), NULL);
|
||||
dict_add_nr_str(dict, "changedtick", CHANGEDTICK(buf), NULL);
|
||||
dict_add_nr_str(dict, "hidden",
|
||||
buf->b_ml.ml_mfp != NULL && buf->b_nwindows == 0,
|
||||
NULL);
|
||||
dict_add_number(dict, "bufnr", buf->b_fnum);
|
||||
dict_add_string(dict, "name", buf->b_ffname);
|
||||
dict_add_number(dict, "lnum", buf == curbuf ? curwin->w_cursor.lnum
|
||||
: buflist_findlnum(buf));
|
||||
dict_add_number(dict, "loaded", buf->b_ml.ml_mfp != NULL);
|
||||
dict_add_number(dict, "listed", buf->b_p_bl);
|
||||
dict_add_number(dict, "changed", bufIsChanged(buf));
|
||||
dict_add_number(dict, "changedtick", CHANGEDTICK(buf));
|
||||
dict_add_number(dict, "hidden",
|
||||
buf->b_ml.ml_mfp != NULL && buf->b_nwindows == 0);
|
||||
|
||||
/* Get a reference to buffer variables */
|
||||
dict_add_dict(dict, "variables", buf->b_vars);
|
||||
@@ -4663,10 +4661,10 @@ f_getchangelist(typval_T *argvars, typval_T *rettv)
|
||||
return;
|
||||
if (list_append_dict(l, d) == FAIL)
|
||||
return;
|
||||
dict_add_nr_str(d, "lnum", (long)buf->b_changelist[i].lnum, NULL);
|
||||
dict_add_nr_str(d, "col", (long)buf->b_changelist[i].col, NULL);
|
||||
dict_add_number(d, "lnum", (long)buf->b_changelist[i].lnum);
|
||||
dict_add_number(d, "col", (long)buf->b_changelist[i].col);
|
||||
# ifdef FEAT_VIRTUALEDIT
|
||||
dict_add_nr_str(d, "coladd", (long)buf->b_changelist[i].coladd, NULL);
|
||||
dict_add_number(d, "coladd", (long)buf->b_changelist[i].coladd);
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
@@ -4790,9 +4788,9 @@ f_getcharsearch(typval_T *argvars UNUSED, typval_T *rettv)
|
||||
{
|
||||
dict_T *dict = rettv->vval.v_dict;
|
||||
|
||||
dict_add_nr_str(dict, "char", 0L, last_csearch());
|
||||
dict_add_nr_str(dict, "forward", last_csearch_forward(), NULL);
|
||||
dict_add_nr_str(dict, "until", last_csearch_until(), NULL);
|
||||
dict_add_string(dict, "char", last_csearch());
|
||||
dict_add_number(dict, "forward", last_csearch_forward());
|
||||
dict_add_number(dict, "until", last_csearch_until());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5193,17 +5191,14 @@ f_getjumplist(typval_T *argvars, typval_T *rettv)
|
||||
return;
|
||||
if (list_append_dict(l, d) == FAIL)
|
||||
return;
|
||||
dict_add_nr_str(d, "lnum", (long)wp->w_jumplist[i].fmark.mark.lnum,
|
||||
NULL);
|
||||
dict_add_nr_str(d, "col", (long)wp->w_jumplist[i].fmark.mark.col,
|
||||
NULL);
|
||||
dict_add_number(d, "lnum", (long)wp->w_jumplist[i].fmark.mark.lnum);
|
||||
dict_add_number(d, "col", (long)wp->w_jumplist[i].fmark.mark.col);
|
||||
# ifdef FEAT_VIRTUALEDIT
|
||||
dict_add_nr_str(d, "coladd", (long)wp->w_jumplist[i].fmark.mark.coladd,
|
||||
NULL);
|
||||
dict_add_number(d, "coladd", (long)wp->w_jumplist[i].fmark.mark.coladd);
|
||||
# endif
|
||||
dict_add_nr_str(d, "bufnr", (long)wp->w_jumplist[i].fmark.fnum, NULL);
|
||||
dict_add_number(d, "bufnr", (long)wp->w_jumplist[i].fmark.fnum);
|
||||
if (wp->w_jumplist[i].fname != NULL)
|
||||
dict_add_nr_str(d, "filename", 0L, wp->w_jumplist[i].fname);
|
||||
dict_add_string(d, "filename", wp->w_jumplist[i].fname);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -5321,18 +5316,18 @@ f_getmatches(typval_T *argvars UNUSED, typval_T *rettv UNUSED)
|
||||
}
|
||||
else
|
||||
{
|
||||
dict_add_nr_str(dict, "pattern", 0L, cur->pattern);
|
||||
dict_add_string(dict, "pattern", cur->pattern);
|
||||
}
|
||||
dict_add_nr_str(dict, "group", 0L, syn_id2name(cur->hlg_id));
|
||||
dict_add_nr_str(dict, "priority", (long)cur->priority, NULL);
|
||||
dict_add_nr_str(dict, "id", (long)cur->id, NULL);
|
||||
dict_add_string(dict, "group", syn_id2name(cur->hlg_id));
|
||||
dict_add_number(dict, "priority", (long)cur->priority);
|
||||
dict_add_number(dict, "id", (long)cur->id);
|
||||
# if defined(FEAT_CONCEAL) && defined(FEAT_MBYTE)
|
||||
if (cur->conceal_char)
|
||||
{
|
||||
char_u buf[MB_MAXBYTES + 1];
|
||||
|
||||
buf[(*mb_char2bytes)((int)cur->conceal_char, buf)] = NUL;
|
||||
dict_add_nr_str(dict, "conceal", 0L, (char_u *)&buf);
|
||||
dict_add_string(dict, "conceal", (char_u *)&buf);
|
||||
}
|
||||
# endif
|
||||
list_append_dict(rettv->vval.v_list, dict);
|
||||
@@ -5533,7 +5528,7 @@ get_tabpage_info(tabpage_T *tp, int tp_idx)
|
||||
if (dict == NULL)
|
||||
return NULL;
|
||||
|
||||
dict_add_nr_str(dict, "tabnr", tp_idx, NULL);
|
||||
dict_add_number(dict, "tabnr", tp_idx);
|
||||
|
||||
l = list_alloc();
|
||||
if (l != NULL)
|
||||
@@ -5649,23 +5644,23 @@ get_win_info(win_T *wp, short tpnr, short winnr)
|
||||
if (dict == NULL)
|
||||
return NULL;
|
||||
|
||||
dict_add_nr_str(dict, "tabnr", tpnr, NULL);
|
||||
dict_add_nr_str(dict, "winnr", winnr, NULL);
|
||||
dict_add_nr_str(dict, "winid", wp->w_id, NULL);
|
||||
dict_add_nr_str(dict, "height", wp->w_height, NULL);
|
||||
dict_add_number(dict, "tabnr", tpnr);
|
||||
dict_add_number(dict, "winnr", winnr);
|
||||
dict_add_number(dict, "winid", wp->w_id);
|
||||
dict_add_number(dict, "height", wp->w_height);
|
||||
#ifdef FEAT_MENU
|
||||
dict_add_nr_str(dict, "winbar", wp->w_winbar_height, NULL);
|
||||
dict_add_number(dict, "winbar", wp->w_winbar_height);
|
||||
#endif
|
||||
dict_add_nr_str(dict, "width", wp->w_width, NULL);
|
||||
dict_add_nr_str(dict, "bufnr", wp->w_buffer->b_fnum, NULL);
|
||||
dict_add_number(dict, "width", wp->w_width);
|
||||
dict_add_number(dict, "bufnr", wp->w_buffer->b_fnum);
|
||||
|
||||
#ifdef FEAT_TERMINAL
|
||||
dict_add_nr_str(dict, "terminal", bt_terminal(wp->w_buffer), NULL);
|
||||
dict_add_number(dict, "terminal", bt_terminal(wp->w_buffer));
|
||||
#endif
|
||||
#ifdef FEAT_QUICKFIX
|
||||
dict_add_nr_str(dict, "quickfix", bt_quickfix(wp->w_buffer), NULL);
|
||||
dict_add_nr_str(dict, "loclist",
|
||||
(bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL), NULL);
|
||||
dict_add_number(dict, "quickfix", bt_quickfix(wp->w_buffer));
|
||||
dict_add_number(dict, "loclist",
|
||||
(bt_quickfix(wp->w_buffer) && wp->w_llist_ref != NULL));
|
||||
#endif
|
||||
|
||||
/* Add a reference to window variables */
|
||||
@@ -7652,15 +7647,15 @@ get_maparg(typval_T *argvars, typval_T *rettv, int exact)
|
||||
char_u *mapmode = map_mode_to_chars(mp->m_mode);
|
||||
dict_T *dict = rettv->vval.v_dict;
|
||||
|
||||
dict_add_nr_str(dict, "lhs", 0L, lhs);
|
||||
dict_add_nr_str(dict, "rhs", 0L, mp->m_orig_str);
|
||||
dict_add_nr_str(dict, "noremap", mp->m_noremap ? 1L : 0L , NULL);
|
||||
dict_add_nr_str(dict, "expr", mp->m_expr ? 1L : 0L, NULL);
|
||||
dict_add_nr_str(dict, "silent", mp->m_silent ? 1L : 0L, NULL);
|
||||
dict_add_nr_str(dict, "sid", (long)mp->m_script_ID, NULL);
|
||||
dict_add_nr_str(dict, "buffer", (long)buffer_local, NULL);
|
||||
dict_add_nr_str(dict, "nowait", mp->m_nowait ? 1L : 0L, NULL);
|
||||
dict_add_nr_str(dict, "mode", 0L, mapmode);
|
||||
dict_add_string(dict, "lhs", lhs);
|
||||
dict_add_string(dict, "rhs", mp->m_orig_str);
|
||||
dict_add_number(dict, "noremap", mp->m_noremap ? 1L : 0L);
|
||||
dict_add_number(dict, "expr", mp->m_expr ? 1L : 0L);
|
||||
dict_add_number(dict, "silent", mp->m_silent ? 1L : 0L);
|
||||
dict_add_number(dict, "sid", (long)mp->m_script_ID);
|
||||
dict_add_number(dict, "buffer", (long)buffer_local);
|
||||
dict_add_number(dict, "nowait", mp->m_nowait ? 1L : 0L);
|
||||
dict_add_string(dict, "mode", mapmode);
|
||||
|
||||
vim_free(lhs);
|
||||
vim_free(mapmode);
|
||||
@@ -13652,13 +13647,12 @@ f_undotree(typval_T *argvars UNUSED, typval_T *rettv)
|
||||
dict_T *dict = rettv->vval.v_dict;
|
||||
list_T *list;
|
||||
|
||||
dict_add_nr_str(dict, "synced", (long)curbuf->b_u_synced, NULL);
|
||||
dict_add_nr_str(dict, "seq_last", curbuf->b_u_seq_last, NULL);
|
||||
dict_add_nr_str(dict, "save_last",
|
||||
(long)curbuf->b_u_save_nr_last, NULL);
|
||||
dict_add_nr_str(dict, "seq_cur", curbuf->b_u_seq_cur, NULL);
|
||||
dict_add_nr_str(dict, "time_cur", (long)curbuf->b_u_time_cur, NULL);
|
||||
dict_add_nr_str(dict, "save_cur", (long)curbuf->b_u_save_nr_cur, NULL);
|
||||
dict_add_number(dict, "synced", (long)curbuf->b_u_synced);
|
||||
dict_add_number(dict, "seq_last", curbuf->b_u_seq_last);
|
||||
dict_add_number(dict, "save_last", (long)curbuf->b_u_save_nr_last);
|
||||
dict_add_number(dict, "seq_cur", curbuf->b_u_seq_cur);
|
||||
dict_add_number(dict, "time_cur", (long)curbuf->b_u_time_cur);
|
||||
dict_add_number(dict, "save_cur", (long)curbuf->b_u_save_nr_cur);
|
||||
|
||||
list = list_alloc();
|
||||
if (list != NULL)
|
||||
@@ -13882,20 +13876,20 @@ f_winsaveview(typval_T *argvars UNUSED, typval_T *rettv)
|
||||
return;
|
||||
dict = rettv->vval.v_dict;
|
||||
|
||||
dict_add_nr_str(dict, "lnum", (long)curwin->w_cursor.lnum, NULL);
|
||||
dict_add_nr_str(dict, "col", (long)curwin->w_cursor.col, NULL);
|
||||
dict_add_number(dict, "lnum", (long)curwin->w_cursor.lnum);
|
||||
dict_add_number(dict, "col", (long)curwin->w_cursor.col);
|
||||
#ifdef FEAT_VIRTUALEDIT
|
||||
dict_add_nr_str(dict, "coladd", (long)curwin->w_cursor.coladd, NULL);
|
||||
dict_add_number(dict, "coladd", (long)curwin->w_cursor.coladd);
|
||||
#endif
|
||||
update_curswant();
|
||||
dict_add_nr_str(dict, "curswant", (long)curwin->w_curswant, NULL);
|
||||
dict_add_number(dict, "curswant", (long)curwin->w_curswant);
|
||||
|
||||
dict_add_nr_str(dict, "topline", (long)curwin->w_topline, NULL);
|
||||
dict_add_number(dict, "topline", (long)curwin->w_topline);
|
||||
#ifdef FEAT_DIFF
|
||||
dict_add_nr_str(dict, "topfill", (long)curwin->w_topfill, NULL);
|
||||
dict_add_number(dict, "topfill", (long)curwin->w_topfill);
|
||||
#endif
|
||||
dict_add_nr_str(dict, "leftcol", (long)curwin->w_leftcol, NULL);
|
||||
dict_add_nr_str(dict, "skipcol", (long)curwin->w_skipcol, NULL);
|
||||
dict_add_number(dict, "leftcol", (long)curwin->w_leftcol);
|
||||
dict_add_number(dict, "skipcol", (long)curwin->w_skipcol);
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user