summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-07-08 16:50:37 +0200
committerBram Moolenaar <Bram@vim.org>2018-07-08 16:50:37 +0200
commite0be167a805fd547c25ec1ec97fd4c7f13046236 (patch)
tree423fb96f7b30329ef0b7ccf3d4b2a02620e7929c
parent4cde86c2ef885e82fff3d925dee9fb5671c025cf (diff)
downloadvim-git-e0be167a805fd547c25ec1ec97fd4c7f13046236.tar.gz
patch 8.1.0166: using dict_add_nr_str() is clumsyv8.1.0166
Problem: Using dict_add_nr_str() is clumsy. Solution: Split into two functions. (Ozaki Kiichi, closes #3154)
-rw-r--r--src/channel.c34
-rw-r--r--src/dict.c40
-rw-r--r--src/edit.c19
-rw-r--r--src/evalfunc.c134
-rw-r--r--src/ex_cmds2.c14
-rw-r--r--src/ops.c26
-rw-r--r--src/option.c6
-rw-r--r--src/proto/dict.pro3
-rw-r--r--src/quickfix.c65
-rw-r--r--src/tag.c12
-rw-r--r--src/terminal.c21
-rw-r--r--src/undo.c10
-rw-r--r--src/version.c2
13 files changed, 188 insertions, 198 deletions
diff --git a/src/channel.c b/src/channel.c
index 1363ee929..c62da8bd3 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -2809,7 +2809,7 @@ channel_part_info(channel_T *channel, dict_T *dict, char *name, ch_part_T part)
status = "buffered";
else
status = "closed";
- dict_add_nr_str(dict, namebuf, 0, (char_u *)status);
+ dict_add_string(dict, namebuf, (char_u *)status);
STRCPY(namebuf + tail, "mode");
switch (chanpart->ch_mode)
@@ -2819,7 +2819,7 @@ channel_part_info(channel_T *channel, dict_T *dict, char *name, ch_part_T part)
case MODE_JSON: s = "JSON"; break;
case MODE_JS: s = "JS"; break;
}
- dict_add_nr_str(dict, namebuf, 0, (char_u *)s);
+ dict_add_string(dict, namebuf, (char_u *)s);
STRCPY(namebuf + tail, "io");
if (part == PART_SOCK)
@@ -2832,22 +2832,22 @@ channel_part_info(channel_T *channel, dict_T *dict, char *name, ch_part_T part)
case JIO_BUFFER: s = "buffer"; break;
case JIO_OUT: s = "out"; break;
}
- dict_add_nr_str(dict, namebuf, 0, (char_u *)s);
+ dict_add_string(dict, namebuf, (char_u *)s);
STRCPY(namebuf + tail, "timeout");
- dict_add_nr_str(dict, namebuf, chanpart->ch_timeout, NULL);
+ dict_add_number(dict, namebuf, chanpart->ch_timeout);
}
void
channel_info(channel_T *channel, dict_T *dict)
{
- dict_add_nr_str(dict, "id", channel->ch_id, NULL);
- dict_add_nr_str(dict, "status", 0, (char_u *)channel_status(channel, -1));
+ dict_add_number(dict, "id", channel->ch_id);
+ dict_add_string(dict, "status", (char_u *)channel_status(channel, -1));
if (channel->ch_hostname != NULL)
{
- dict_add_nr_str(dict, "hostname", 0, (char_u *)channel->ch_hostname);
- dict_add_nr_str(dict, "port", channel->ch_port, NULL);
+ dict_add_string(dict, "hostname", (char_u *)channel->ch_hostname);
+ dict_add_number(dict, "port", channel->ch_port);
channel_part_info(channel, dict, "sock", PART_SOCK);
}
else
@@ -5737,7 +5737,7 @@ job_info(job_T *job, dict_T *dict)
list_T *l;
int i;
- dict_add_nr_str(dict, "status", 0L, (char_u *)job_status(job));
+ dict_add_string(dict, "status", (char_u *)job_status(job));
item = dictitem_alloc((char_u *)"channel");
if (item == NULL)
@@ -5755,15 +5755,13 @@ job_info(job_T *job, dict_T *dict)
#else
nr = job->jv_proc_info.dwProcessId;
#endif
- dict_add_nr_str(dict, "process", nr, NULL);
- dict_add_nr_str(dict, "tty_in", 0L,
- job->jv_tty_in != NULL ? job->jv_tty_in : (char_u *)"");
- dict_add_nr_str(dict, "tty_out", 0L,
- job->jv_tty_out != NULL ? job->jv_tty_out : (char_u *)"");
-
- dict_add_nr_str(dict, "exitval", job->jv_exitval, NULL);
- dict_add_nr_str(dict, "exit_cb", 0L, job->jv_exit_cb);
- dict_add_nr_str(dict, "stoponexit", 0L, job->jv_stoponexit);
+ dict_add_number(dict, "process", nr);
+ dict_add_string(dict, "tty_in", job->jv_tty_in);
+ dict_add_string(dict, "tty_out", job->jv_tty_out);
+
+ dict_add_number(dict, "exitval", job->jv_exitval);
+ dict_add_string(dict, "exit_cb", job->jv_exit_cb);
+ dict_add_string(dict, "stoponexit", job->jv_stoponexit);
l = list_alloc();
if (l != NULL)
diff --git a/src/dict.c b/src/dict.c
index 55069783f..e1f7fa23e 100644
--- a/src/dict.c
+++ b/src/dict.c
@@ -327,16 +327,11 @@ dict_add(dict_T *d, dictitem_T *item)
}
/*
- * Add a number or string entry to dictionary "d".
- * When "str" is NULL use number "nr", otherwise use "str".
+ * Add a number entry to dictionary "d".
* Returns FAIL when out of memory and when key already exists.
*/
int
-dict_add_nr_str(
- dict_T *d,
- char *key,
- varnumber_T nr,
- char_u *str)
+dict_add_number(dict_T *d, char *key, varnumber_T nr)
{
dictitem_T *item;
@@ -344,16 +339,31 @@ dict_add_nr_str(
if (item == NULL)
return FAIL;
item->di_tv.v_lock = 0;
- if (str == NULL)
- {
- item->di_tv.v_type = VAR_NUMBER;
- item->di_tv.vval.v_number = nr;
- }
- else
+ item->di_tv.v_type = VAR_NUMBER;
+ item->di_tv.vval.v_number = nr;
+ if (dict_add(d, item) == FAIL)
{
- item->di_tv.v_type = VAR_STRING;
- item->di_tv.vval.v_string = vim_strsave(str);
+ dictitem_free(item);
+ return FAIL;
}
+ return OK;
+}
+
+/*
+ * Add a string entry to dictionary "d".
+ * Returns FAIL when out of memory and when key already exists.
+ */
+ int
+dict_add_string(dict_T *d, char *key, char_u *str)
+{
+ dictitem_T *item;
+
+ item = dictitem_alloc((char_u *)key);
+ if (item == NULL)
+ return FAIL;
+ item->di_tv.v_lock = 0;
+ item->di_tv.v_type = VAR_STRING;
+ item->di_tv.vval.v_string = str != NULL ? vim_strsave(str) : NULL;
if (dict_add(d, item) == FAIL)
{
dictitem_free(item);
diff --git a/src/edit.c b/src/edit.c
index 5f6ac19a0..657bd2c86 100644
--- a/src/edit.c
+++ b/src/edit.c
@@ -4884,18 +4884,13 @@ ins_compl_insert(int in_compl_func)
dict = dict_alloc_lock(VAR_FIXED);
if (dict != NULL)
{
- dict_add_nr_str(dict, "word", 0L,
- EMPTY_IF_NULL(compl_shown_match->cp_str));
- dict_add_nr_str(dict, "abbr", 0L,
- EMPTY_IF_NULL(compl_shown_match->cp_text[CPT_ABBR]));
- dict_add_nr_str(dict, "menu", 0L,
- EMPTY_IF_NULL(compl_shown_match->cp_text[CPT_MENU]));
- dict_add_nr_str(dict, "kind", 0L,
- EMPTY_IF_NULL(compl_shown_match->cp_text[CPT_KIND]));
- dict_add_nr_str(dict, "info", 0L,
- EMPTY_IF_NULL(compl_shown_match->cp_text[CPT_INFO]));
- dict_add_nr_str(dict, "user_data", 0L,
- EMPTY_IF_NULL(compl_shown_match->cp_text[CPT_USER_DATA]));
+ dict_add_string(dict, "word", compl_shown_match->cp_str);
+ dict_add_string(dict, "abbr", compl_shown_match->cp_text[CPT_ABBR]);
+ dict_add_string(dict, "menu", compl_shown_match->cp_text[CPT_MENU]);
+ dict_add_string(dict, "kind", compl_shown_match->cp_text[CPT_KIND]);
+ dict_add_string(dict, "info", compl_shown_match->cp_text[CPT_INFO]);
+ dict_add_string(dict, "user_data",
+ compl_shown_match->cp_text[CPT_USER_DATA]);
}
set_vim_var_dict(VV_COMPLETED_ITEM, dict);
if (!in_compl_func)
diff --git a/src/evalfunc.c b/src/evalfunc.c
index ce45ad82a..5775c78db 100644
--- a/src/evalfunc.c
+++ b/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);
}
/*
diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 5f58fedfb..6887ca135 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -689,7 +689,7 @@ dbg_parsearg(
}
/*
- * ":breakadd".
+ * ":breakadd". Also used for ":profile".
*/
void
ex_breakadd(exarg_T *eap)
@@ -1497,16 +1497,16 @@ add_timer_info(typval_T *rettv, timer_T *timer)
return;
list_append_dict(list, dict);
- dict_add_nr_str(dict, "id", timer->tr_id, NULL);
- dict_add_nr_str(dict, "time", (long)timer->tr_interval, NULL);
+ dict_add_number(dict, "id", timer->tr_id);
+ dict_add_number(dict, "time", (long)timer->tr_interval);
profile_start(&now);
remaining = proftime_time_left(&timer->tr_due, &now);
- dict_add_nr_str(dict, "remaining", (long)remaining, NULL);
+ dict_add_number(dict, "remaining", (long)remaining);
- dict_add_nr_str(dict, "repeat",
- (long)(timer->tr_repeat < 0 ? -1 : timer->tr_repeat + 1), NULL);
- dict_add_nr_str(dict, "paused", (long)(timer->tr_paused), NULL);
+ dict_add_number(dict, "repeat",
+ (long)(timer->tr_repeat < 0 ? -1 : timer->tr_repeat + 1));
+ dict_add_number(dict, "paused", (long)(timer->tr_paused));
di = dictitem_alloc((char_u *)"callback");
if (di != NULL)
diff --git a/src/ops.c b/src/ops.c
index 2e08a5329..26e15f753 100644
--- a/src/ops.c
+++ b/src/ops.c
@@ -1723,12 +1723,12 @@ yank_do_autocmd(oparg_T *oap, yankreg_T *reg)
buf[0] = (char_u)oap->regname;
buf[1] = NUL;
- dict_add_nr_str(v_event, "regname", 0, buf);
+ dict_add_string(v_event, "regname", buf);
buf[0] = get_op_char(oap->op_type);
buf[1] = get_extra_op_char(oap->op_type);
buf[2] = NUL;
- dict_add_nr_str(v_event, "operator", 0, buf);
+ dict_add_string(v_event, "operator", buf);
buf[0] = NUL;
buf[1] = NUL;
@@ -1741,7 +1741,7 @@ yank_do_autocmd(oparg_T *oap, yankreg_T *reg)
reglen + 1);
break;
}
- dict_add_nr_str(v_event, "regtype", 0, buf);
+ dict_add_string(v_event, "regtype", buf);
/* Lock the dictionary and its keys */
dict_set_items_ro(v_event);
@@ -7641,19 +7641,19 @@ cursor_pos_info(dict_T *dict)
#if defined(FEAT_EVAL)
if (dict != NULL)
{
- dict_add_nr_str(dict, "words", word_count, NULL);
- dict_add_nr_str(dict, "chars", char_count, NULL);
- dict_add_nr_str(dict, "bytes", byte_count
+ dict_add_number(dict, "words", word_count);
+ dict_add_number(dict, "chars", char_count);
+ dict_add_number(dict, "bytes", byte_count
# ifdef FEAT_MBYTE
+ bom_count
# endif
- , NULL);
- dict_add_nr_str(dict, VIsual_active ? "visual_bytes" : "cursor_bytes",
- byte_count_cursor, NULL);
- dict_add_nr_str(dict, VIsual_active ? "visual_chars" : "cursor_chars",
- char_count_cursor, NULL);
- dict_add_nr_str(dict, VIsual_active ? "visual_words" : "cursor_words",
- word_count_cursor, NULL);
+ );
+ dict_add_number(dict, VIsual_active ? "visual_bytes" : "cursor_bytes",
+ byte_count_cursor);
+ dict_add_number(dict, VIsual_active ? "visual_chars" : "cursor_chars",
+ char_count_cursor);
+ dict_add_number(dict, VIsual_active ? "visual_words" : "cursor_words",
+ word_count_cursor);
}
#endif
}
diff --git a/src/option.c b/src/option.c
index 504b92a71..0cfc39c61 100644
--- a/src/option.c
+++ b/src/option.c
@@ -13222,11 +13222,11 @@ get_winbuf_options(int bufopt)
if (varp != NULL)
{
if (opt->flags & P_STRING)
- dict_add_nr_str(d, opt->fullname, 0L, *(char_u **)varp);
+ dict_add_string(d, opt->fullname, *(char_u **)varp);
else if (opt->flags & P_NUM)
- dict_add_nr_str(d, opt->fullname, *(long *)varp, NULL);
+ dict_add_number(d, opt->fullname, *(long *)varp);
else
- dict_add_nr_str(d, opt->fullname, *(int *)varp, NULL);
+ dict_add_number(d, opt->fullname, *(int *)varp);
}
}
}
diff --git a/src/proto/dict.pro b/src/proto/dict.pro
index 9db43b944..ede4f873b 100644
--- a/src/proto/dict.pro
+++ b/src/proto/dict.pro
@@ -12,7 +12,8 @@ void dictitem_remove(dict_T *dict, dictitem_T *item);
void dictitem_free(dictitem_T *item);
dict_T *dict_copy(dict_T *orig, int deep, int copyID);
int dict_add(dict_T *d, dictitem_T *item);
-int dict_add_nr_str(dict_T *d, char *key, varnumber_T nr, char_u *str);
+int dict_add_number(dict_T *d, char *key, varnumber_T nr);
+int dict_add_string(dict_T *d, char *key, char_u *str);
int dict_add_list(dict_T *d, char *key, list_T *list);
int dict_add_dict(dict_T *d, char *key, dict_T *dict);
long dict_len(dict_T *d);
diff --git a/src/quickfix.c b/src/quickfix.c
index ddb9230a6..e7e34e4be 100644
--- a/src/quickfix.c
+++ b/src/quickfix.c
@@ -5360,19 +5360,16 @@ get_errorlist(qf_info_T *qi_arg, win_T *wp, int qf_idx, list_T *list)
buf[0] = qfp->qf_type;
buf[1] = NUL;
- if ( dict_add_nr_str(dict, "bufnr", (long)bufnum, NULL) == FAIL
- || dict_add_nr_str(dict, "lnum", (long)qfp->qf_lnum, NULL) == FAIL
- || dict_add_nr_str(dict, "col", (long)qfp->qf_col, NULL) == FAIL
- || dict_add_nr_str(dict, "vcol", (long)qfp->qf_viscol, NULL) == FAIL
- || dict_add_nr_str(dict, "nr", (long)qfp->qf_nr, NULL) == FAIL
- || dict_add_nr_str(dict, "module", 0L,
- qfp->qf_module == NULL ? (char_u *)"" : qfp->qf_module) == FAIL
- || dict_add_nr_str(dict, "pattern", 0L,
- qfp->qf_pattern == NULL ? (char_u *)"" : qfp->qf_pattern) == FAIL
- || dict_add_nr_str(dict, "text", 0L,
- qfp->qf_text == NULL ? (char_u *)"" : qfp->qf_text) == FAIL
- || dict_add_nr_str(dict, "type", 0L, buf) == FAIL
- || dict_add_nr_str(dict, "valid", (long)qfp->qf_valid, NULL) == FAIL)
+ if ( dict_add_number(dict, "bufnr", (long)bufnum) == FAIL
+ || dict_add_number(dict, "lnum", (long)qfp->qf_lnum) == FAIL
+ || dict_add_number(dict, "col", (long)qfp->qf_col) == FAIL
+ || dict_add_number(dict, "vcol", (long)qfp->qf_viscol) == FAIL
+ || dict_add_number(dict, "nr", (long)qfp->qf_nr) == FAIL
+ || dict_add_string(dict, "module", qfp->qf_module) == FAIL
+ || dict_add_string(dict, "pattern", qfp->qf_pattern) == FAIL
+ || dict_add_string(dict, "text", qfp->qf_text) == FAIL
+ || dict_add_string(dict, "type", buf) == FAIL
+ || dict_add_number(dict, "valid", (long)qfp->qf_valid) == FAIL)
return FAIL;
qfp = qfp->qf_next;
@@ -5576,7 +5573,7 @@ qf_getprop_defaults(qf_info_T *qi, int flags, dict_T *retdict)
int status = OK;
if (flags & QF_GETLIST_TITLE)
- status = dict_add_nr_str(retdict, "title", 0L, (char_u *)"");
+ status = dict_add_string(retdict, "title", (char_u *)"");
if ((status == OK) && (flags & QF_GETLIST_ITEMS))
{
list_T *l = list_alloc();
@@ -5586,19 +5583,19 @@ qf_getprop_defaults(qf_info_T *qi, int flags, dict_T *retdict)
status = FAIL;
}
if ((status == OK) && (flags & QF_GETLIST_NR))
- status = dict_add_nr_str(retdict, "nr", 0L, NULL);
+ status = dict_add_number(retdict, "nr", 0);
if ((status == OK) && (flags & QF_GETLIST_WINID))
- status = dict_add_nr_str(retdict, "winid", qf_winid(qi), NULL);
+ status = dict_add_number(retdict, "winid", qf_winid(qi));
if ((status == OK) && (flags & QF_GETLIST_CONTEXT))
- status = dict_add_nr_str(retdict, "context", 0L, (char_u *)"");
+ status = dict_add_string(retdict, "context", (char_u *)"");
if ((status == OK) && (flags & QF_GETLIST_ID))
- status = dict_add_nr_str(retdict, "id", 0L, NULL);
+ status = dict_add_number(retdict, "id", 0);
if ((status == OK) && (flags & QF_GETLIST_IDX))
- status = dict_add_nr_str(retdict, "idx", 0L, NULL);
+ status = dict_add_number(retdict, "idx", 0);
if ((status == OK) && (flags & QF_GETLIST_SIZE))
- status = dict_add_nr_str(retdict, "size", 0L, NULL);
+ status = dict_add_number(retdict, "size", 0);
if ((status == OK) && (flags & QF_GETLIST_TICK))
- status = dict_add_nr_str(retdict, "changedtick", 0L, NULL);
+ status = dict_add_number(retdict, "changedtick", 0);
return status;
}
@@ -5609,12 +5606,7 @@ qf_getprop_defaults(qf_info_T *qi, int flags, dict_T *retdict)
static int
qf_getprop_title(qf_info_T *qi, int qf_idx, dict_T *retdict)
{
- char_u *t;
-
- t = qi->qf_lists[qf_idx].qf_title;
- if (t == NULL)
- t = (char_u *)"";
- return dict_add_nr_str(retdict, "title", 0L, t);
+ return dict_add_string(retdict, "title", qi->qf_lists[qf_idx].qf_title);
}
/*
@@ -5659,7 +5651,7 @@ qf_getprop_ctx(qf_info_T *qi, int qf_idx, dict_T *retdict)
status = FAIL;
}
else
- status = dict_add_nr_str(retdict, "context", 0L, (char_u *)"");
+ status = dict_add_string(retdict, "context", (char_u *)"");
return status;
}
@@ -5674,7 +5666,7 @@ qf_getprop_idx(qf_info_T *qi, int qf_idx, dict_T *retdict)
if (qi->qf_lists[qf_idx].qf_count == 0)
/* For empty lists, qf_index is set to 1 */
idx = 0;
- return dict_add_nr_str(retdict, "idx", idx, NULL);
+ return dict_add_number(retdict, "idx", idx);
}
/*
@@ -5709,24 +5701,23 @@ qf_get_properties(win_T *wp, dict_T *what, dict_T *retdict)
if (flags & QF_GETLIST_TITLE)
status = qf_getprop_title(qi, qf_idx, retdict);
if ((status == OK) && (flags & QF_GETLIST_NR))
- status = dict_add_nr_str(retdict, "nr", qf_idx + 1, NULL);
+ status = dict_add_number(retdict, "nr", qf_idx + 1);
if ((status == OK) && (flags & QF_GETLIST_WINID))
- status = dict_add_nr_str(retdict, "winid", qf_winid(qi), NULL);
+ status = dict_add_number(retdict, "winid", qf_winid(qi));
if ((status == OK) && (flags & QF_GETLIST_ITEMS))
status = qf_getprop_items(qi, qf_idx, retdict);
if ((status == OK) && (flags & QF_GETLIST_CONTEXT))
status = qf_getprop_ctx(qi, qf_idx, retdict);
if ((status == OK) && (flags & QF_GETLIST_ID))
- status = dict_add_nr_str(retdict, "id", qi->qf_lists[qf_idx].qf_id,
- NULL);
+ status = dict_add_number(retdict, "id", qi->qf_lists[qf_idx].qf_id);
if ((status == OK) && (flags & QF_GETLIST_IDX))
status = qf_getprop_idx(qi, qf_idx, retdict);
if ((status == OK) && (flags & QF_GETLIST_SIZE))
- status = dict_add_nr_str(retdict, "size",
- qi->qf_lists[qf_idx].qf_count, NULL);
+ status = dict_add_number(retdict, "size",
+ qi->qf_lists[qf_idx].qf_count);
if ((status == OK) && (flags & QF_GETLIST_TICK))
- status = dict_add_nr_str(retdict, "changedtick",
- qi->qf_lists[qf_idx].qf_changedtick, NULL);
+ status = dict_add_number(retdict, "changedtick",
+ qi->qf_lists[qf_idx].qf_changedtick);
return status;
}
diff --git a/src/tag.c b/src/tag.c
index b23cb5aab..f0c92f5b2 100644
--- a/src/tag.c
+++ b/src/tag.c
@@ -905,11 +905,11 @@ do_tag(
continue;
}
- dict_add_nr_str(dict, "text", 0L, tag_name);
- dict_add_nr_str(dict, "filename", 0L, fname);
- dict_add_nr_str(dict, "lnum", lnum, NULL);
+ dict_add_string(dict, "text", tag_name);
+ dict_add_string(dict, "filename", fname);
+ dict_add_number(dict, "lnum", lnum);
if (lnum == 0)
- dict_add_nr_str(dict, "pattern", 0L, cmd);
+ dict_add_string(dict, "pattern", cmd);
}
vim_snprintf((char *)IObuff, IOSIZE, "ltag %s", tag);
@@ -3923,7 +3923,7 @@ add_tag_field(
vim_strncpy(buf, start, len);
}
buf[len] = NUL;
- retval = dict_add_nr_str(dict, field_name, 0L, buf);
+ retval = dict_add_string(dict, field_name, buf);
vim_free(buf);
return retval;
}
@@ -3968,7 +3968,7 @@ get_tags(list_T *list, char_u *pat, char_u *buf_fname)
tp.command_end) == FAIL
|| add_tag_field(dict, "kind", tp.tagkind,
tp.tagkind_end) == FAIL
- || dict_add_nr_str(dict, "static", is_static, NULL) == FAIL)
+ || dict_add_number(dict, "static", is_static) == FAIL)
ret = FAIL;
vim_free(full_fname);
diff --git a/src/terminal.c b/src/terminal.c
index 6195ad51d..2e99a8598 100644
--- a/src/terminal.c
+++ b/src/terminal.c
@@ -4729,11 +4729,11 @@ f_term_getcursor(typval_T *argvars, typval_T *rettv)
d = dict_alloc();
if (d != NULL)
{
- dict_add_nr_str(d, "visible", term->tl_cursor_visible, NULL);
- dict_add_nr_str(d, "blink", blink_state_is_inverted()
- ? !term->tl_cursor_blink : term->tl_cursor_blink, NULL);
- dict_add_nr_str(d, "shape", term->tl_cursor_shape, NULL);
- dict_add_nr_str(d, "color", 0L, cursor_color_get(term->tl_cursor_color));
+ dict_add_number(d, "visible", term->tl_cursor_visible);
+ dict_add_number(d, "blink", blink_state_is_inverted()
+ ? !term->tl_cursor_blink : term->tl_cursor_blink);
+ dict_add_number(d, "shape", term->tl_cursor_shape);
+ dict_add_string(d, "color", cursor_color_get(term->tl_cursor_color));
list_append_dict(l, d);
}
}
@@ -5059,18 +5059,17 @@ f_term_scrape(typval_T *argvars, typval_T *rettv)
break;
list_append_dict(l, dcell);
- dict_add_nr_str(dcell, "chars", 0, mbs);
+ dict_add_string(dcell, "chars", mbs);
vim_snprintf((char *)rgb, 8, "#%02x%02x%02x",
fg.red, fg.green, fg.blue);
- dict_add_nr_str(dcell, "fg", 0, rgb);
+ dict_add_string(dcell, "fg", rgb);
vim_snprintf((char *)rgb, 8, "#%02x%02x%02x",
bg.red, bg.green, bg.blue);
- dict_add_nr_str(dcell, "bg", 0, rgb);
+ dict_add_string(dcell, "bg", rgb);
- dict_add_nr_str(dcell, "attr",
- cell2attr(attrs, fg, bg), NULL);
- dict_add_nr_str(dcell, "width", width, NULL);
+ dict_add_number(dcell, "attr", cell2attr(attrs, fg, bg));
+ dict_add_number(dcell, "width", width);
++pos.col;
if (width == 2)
diff --git a/src/undo.c b/src/undo.c
index be4e22ed6..b3a627686 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -3567,14 +3567,14 @@ u_eval_tree(u_header_T *first_uhp, list_T *list)
dict = dict_alloc();
if (dict == NULL)
return;
- dict_add_nr_str(dict, "seq", uhp->uh_seq, NULL);
- dict_add_nr_str(dict, "time", (long)uhp->uh_time, NULL);
+ dict_add_number(dict, "seq", uhp->uh_seq);
+ dict_add_number(dict, "time", (long)uhp->uh_time);
if (uhp == curbuf->b_u_newhead)
- dict_add_nr_str(dict, "newhead", 1, NULL);
+ dict_add_number(dict, "newhead", 1);
if (uhp == curbuf->b_u_curhead)
- dict_add_nr_str(dict, "curhead", 1, NULL);
+ dict_add_number(dict, "curhead", 1);
if (uhp->uh_save_nr > 0)
- dict_add_nr_str(dict, "save", uhp->uh_save_nr, NULL);
+ dict_add_number(dict, "save", uhp->uh_save_nr);
if (uhp->uh_alt_next.ptr != NULL)
{
diff --git a/src/version.c b/src/version.c
index 24de53fdc..dd3fb19f3 100644
--- a/src/version.c
+++ b/src/version.c
@@ -790,6 +790,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 166,
+/**/
165,
/**/
164,