To: vim_dev@googlegroups.com Subject: Patch 8.1.0166 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.0166 Problem: Using dict_add_nr_str() is clumsy. Solution: Split into two functions. (Ozaki Kiichi, closes #3154) Files: src/channel.c, src/dict.c, src/edit.c, src/evalfunc.c, src/ex_cmds2.c, src/ops.c, src/option.c, src/proto/dict.pro, src/quickfix.c, src/tag.c, src/terminal.c, src/undo.c *** ../vim-8.1.0165/src/channel.c Sun Jun 17 19:36:30 2018 --- src/channel.c Sun Jul 8 16:42:07 2018 *************** *** 2809,2815 **** status = "buffered"; else status = "closed"; ! dict_add_nr_str(dict, namebuf, 0, (char_u *)status); STRCPY(namebuf + tail, "mode"); switch (chanpart->ch_mode) --- 2809,2815 ---- status = "buffered"; else status = "closed"; ! dict_add_string(dict, namebuf, (char_u *)status); STRCPY(namebuf + tail, "mode"); switch (chanpart->ch_mode) *************** *** 2819,2825 **** case MODE_JSON: s = "JSON"; break; case MODE_JS: s = "JS"; break; } ! dict_add_nr_str(dict, namebuf, 0, (char_u *)s); STRCPY(namebuf + tail, "io"); if (part == PART_SOCK) --- 2819,2825 ---- case MODE_JSON: s = "JSON"; break; case MODE_JS: s = "JS"; break; } ! dict_add_string(dict, namebuf, (char_u *)s); STRCPY(namebuf + tail, "io"); if (part == PART_SOCK) *************** *** 2832,2853 **** case JIO_BUFFER: s = "buffer"; break; case JIO_OUT: s = "out"; break; } ! dict_add_nr_str(dict, namebuf, 0, (char_u *)s); STRCPY(namebuf + tail, "timeout"); ! dict_add_nr_str(dict, namebuf, chanpart->ch_timeout, NULL); } 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)); 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); channel_part_info(channel, dict, "sock", PART_SOCK); } else --- 2832,2853 ---- case JIO_BUFFER: s = "buffer"; break; case JIO_OUT: s = "out"; break; } ! dict_add_string(dict, namebuf, (char_u *)s); STRCPY(namebuf + tail, "timeout"); ! dict_add_number(dict, namebuf, chanpart->ch_timeout); } void channel_info(channel_T *channel, dict_T *dict) { ! 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_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,5743 **** list_T *l; int i; ! dict_add_nr_str(dict, "status", 0L, (char_u *)job_status(job)); item = dictitem_alloc((char_u *)"channel"); if (item == NULL) --- 5737,5743 ---- list_T *l; int i; ! dict_add_string(dict, "status", (char_u *)job_status(job)); item = dictitem_alloc((char_u *)"channel"); if (item == NULL) *************** *** 5755,5769 **** #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); l = list_alloc(); if (l != NULL) --- 5755,5767 ---- #else nr = job->jv_proc_info.dwProcessId; #endif ! 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) *** ../vim-8.1.0165/src/dict.c Sat Dec 16 18:21:39 2017 --- src/dict.c Sun Jul 8 16:42:07 2018 *************** *** 327,342 **** } /* ! * Add a number or string entry to dictionary "d". ! * When "str" is NULL use number "nr", otherwise use "str". * 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) { dictitem_T *item; --- 327,337 ---- } /* ! * Add a number entry to dictionary "d". * Returns FAIL when out of memory and when key already exists. */ int ! dict_add_number(dict_T *d, char *key, varnumber_T nr) { dictitem_T *item; *************** *** 344,359 **** 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_STRING; ! item->di_tv.vval.v_string = vim_strsave(str); } if (dict_add(d, item) == FAIL) { dictitem_free(item); --- 339,369 ---- if (item == NULL) return FAIL; item->di_tv.v_lock = 0; ! item->di_tv.v_type = VAR_NUMBER; ! item->di_tv.vval.v_number = nr; ! if (dict_add(d, item) == FAIL) { ! 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); *** ../vim-8.1.0165/src/edit.c Thu Jul 5 22:27:04 2018 --- src/edit.c Sun Jul 8 16:42:07 2018 *************** *** 4884,4901 **** 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])); } set_vim_var_dict(VV_COMPLETED_ITEM, dict); if (!in_compl_func) --- 4884,4896 ---- dict = dict_alloc_lock(VAR_FIXED); if (dict != NULL) { ! 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) *** ../vim-8.1.0165/src/evalfunc.c Thu Jun 28 15:50:23 2018 --- src/evalfunc.c Sun Jul 8 16:42:07 2018 *************** *** 4338,4346 **** 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)); list_append_dict(l, d); } --- 4338,4346 ---- if (d != NULL) { ! 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,4380 **** 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); /* Get a reference to buffer variables */ dict_add_dict(dict, "variables", buf->b_vars); --- 4363,4378 ---- if (dict == NULL) return 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,4672 **** 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); # ifdef FEAT_VIRTUALEDIT ! dict_add_nr_str(d, "coladd", (long)buf->b_changelist[i].coladd, NULL); # endif } #endif --- 4661,4670 ---- return; if (list_append_dict(l, d) == FAIL) return; ! 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_number(d, "coladd", (long)buf->b_changelist[i].coladd); # endif } #endif *************** *** 4790,4798 **** { 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); } } --- 4788,4796 ---- { dict_T *dict = rettv->vval.v_dict; ! dict_add_string(dict, "char", last_csearch()); ! dict_add_number(dict, "forward", last_csearch_forward()); ! dict_add_number(dict, "until", last_csearch_until()); } } *************** *** 5193,5209 **** 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); # ifdef FEAT_VIRTUALEDIT ! dict_add_nr_str(d, "coladd", (long)wp->w_jumplist[i].fmark.mark.coladd, ! NULL); # endif ! dict_add_nr_str(d, "bufnr", (long)wp->w_jumplist[i].fmark.fnum, NULL); if (wp->w_jumplist[i].fname != NULL) ! dict_add_nr_str(d, "filename", 0L, wp->w_jumplist[i].fname); } #endif } --- 5191,5204 ---- return; if (list_append_dict(l, d) == FAIL) return; ! 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_number(d, "coladd", (long)wp->w_jumplist[i].fmark.mark.coladd); # endif ! dict_add_number(d, "bufnr", (long)wp->w_jumplist[i].fmark.fnum); if (wp->w_jumplist[i].fname != NULL) ! dict_add_string(d, "filename", wp->w_jumplist[i].fname); } #endif } *************** *** 5321,5338 **** } else { ! dict_add_nr_str(dict, "pattern", 0L, 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); # 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); } # endif list_append_dict(rettv->vval.v_list, dict); --- 5316,5333 ---- } else { ! dict_add_string(dict, "pattern", cur->pattern); } ! 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_string(dict, "conceal", (char_u *)&buf); } # endif list_append_dict(rettv->vval.v_list, dict); *************** *** 5533,5539 **** if (dict == NULL) return NULL; ! dict_add_nr_str(dict, "tabnr", tp_idx, NULL); l = list_alloc(); if (l != NULL) --- 5528,5534 ---- if (dict == NULL) return NULL; ! dict_add_number(dict, "tabnr", tp_idx); l = list_alloc(); if (l != NULL) *************** *** 5649,5671 **** 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); #ifdef FEAT_MENU ! dict_add_nr_str(dict, "winbar", wp->w_winbar_height, NULL); #endif ! dict_add_nr_str(dict, "width", wp->w_width, NULL); ! dict_add_nr_str(dict, "bufnr", wp->w_buffer->b_fnum, NULL); #ifdef FEAT_TERMINAL ! dict_add_nr_str(dict, "terminal", bt_terminal(wp->w_buffer), NULL); #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); #endif /* Add a reference to window variables */ --- 5644,5666 ---- if (dict == NULL) return 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_number(dict, "winbar", wp->w_winbar_height); #endif ! dict_add_number(dict, "width", wp->w_width); ! dict_add_number(dict, "bufnr", wp->w_buffer->b_fnum); #ifdef FEAT_TERMINAL ! dict_add_number(dict, "terminal", bt_terminal(wp->w_buffer)); #endif #ifdef FEAT_QUICKFIX ! 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,7666 **** 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); vim_free(lhs); vim_free(mapmode); --- 7647,7661 ---- char_u *mapmode = map_mode_to_chars(mp->m_mode); dict_T *dict = rettv->vval.v_dict; ! 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,13664 **** 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); list = list_alloc(); if (list != NULL) --- 13647,13658 ---- dict_T *dict = rettv->vval.v_dict; list_T *list; ! 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,13901 **** 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); #ifdef FEAT_VIRTUALEDIT ! dict_add_nr_str(dict, "coladd", (long)curwin->w_cursor.coladd, NULL); #endif update_curswant(); ! dict_add_nr_str(dict, "curswant", (long)curwin->w_curswant, NULL); ! dict_add_nr_str(dict, "topline", (long)curwin->w_topline, NULL); #ifdef FEAT_DIFF ! dict_add_nr_str(dict, "topfill", (long)curwin->w_topfill, NULL); #endif ! dict_add_nr_str(dict, "leftcol", (long)curwin->w_leftcol, NULL); ! dict_add_nr_str(dict, "skipcol", (long)curwin->w_skipcol, NULL); } /* --- 13876,13895 ---- return; dict = rettv->vval.v_dict; ! 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_number(dict, "coladd", (long)curwin->w_cursor.coladd); #endif update_curswant(); ! dict_add_number(dict, "curswant", (long)curwin->w_curswant); ! dict_add_number(dict, "topline", (long)curwin->w_topline); #ifdef FEAT_DIFF ! dict_add_number(dict, "topfill", (long)curwin->w_topfill); #endif ! dict_add_number(dict, "leftcol", (long)curwin->w_leftcol); ! dict_add_number(dict, "skipcol", (long)curwin->w_skipcol); } /* *** ../vim-8.1.0165/src/ex_cmds2.c Thu Jun 28 12:05:07 2018 --- src/ex_cmds2.c Sun Jul 8 16:42:07 2018 *************** *** 689,695 **** } /* ! * ":breakadd". */ void ex_breakadd(exarg_T *eap) --- 689,695 ---- } /* ! * ":breakadd". Also used for ":profile". */ void ex_breakadd(exarg_T *eap) *************** *** 1497,1512 **** 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); profile_start(&now); remaining = proftime_time_left(&timer->tr_due, &now); ! dict_add_nr_str(dict, "remaining", (long)remaining, NULL); ! 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); di = dictitem_alloc((char_u *)"callback"); if (di != NULL) --- 1497,1512 ---- return; list_append_dict(list, dict); ! 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_number(dict, "remaining", (long)remaining); ! 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) *** ../vim-8.1.0165/src/ops.c Thu Jun 28 19:26:24 2018 --- src/ops.c Sun Jul 8 16:42:07 2018 *************** *** 1723,1734 **** buf[0] = (char_u)oap->regname; buf[1] = NUL; ! dict_add_nr_str(v_event, "regname", 0, 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); buf[0] = NUL; buf[1] = NUL; --- 1723,1734 ---- buf[0] = (char_u)oap->regname; buf[1] = NUL; ! 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_string(v_event, "operator", buf); buf[0] = NUL; buf[1] = NUL; *************** *** 1741,1747 **** reglen + 1); break; } ! dict_add_nr_str(v_event, "regtype", 0, buf); /* Lock the dictionary and its keys */ dict_set_items_ro(v_event); --- 1741,1747 ---- reglen + 1); break; } ! dict_add_string(v_event, "regtype", buf); /* Lock the dictionary and its keys */ dict_set_items_ro(v_event); *************** *** 7641,7659 **** #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 # 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); } #endif } --- 7641,7659 ---- #if defined(FEAT_EVAL) if (dict != NULL) { ! 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 ! ); ! 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 } *** ../vim-8.1.0165/src/option.c Mon Jul 2 20:51:21 2018 --- src/option.c Sun Jul 8 16:42:07 2018 *************** *** 13222,13232 **** if (varp != NULL) { if (opt->flags & P_STRING) ! dict_add_nr_str(d, opt->fullname, 0L, *(char_u **)varp); else if (opt->flags & P_NUM) ! dict_add_nr_str(d, opt->fullname, *(long *)varp, NULL); else ! dict_add_nr_str(d, opt->fullname, *(int *)varp, NULL); } } } --- 13222,13232 ---- if (varp != NULL) { if (opt->flags & P_STRING) ! dict_add_string(d, opt->fullname, *(char_u **)varp); else if (opt->flags & P_NUM) ! dict_add_number(d, opt->fullname, *(long *)varp); else ! dict_add_number(d, opt->fullname, *(int *)varp); } } } *** ../vim-8.1.0165/src/proto/dict.pro Thu May 17 13:52:31 2018 --- src/proto/dict.pro Sun Jul 8 16:42:07 2018 *************** *** 12,18 **** 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_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); --- 12,19 ---- 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_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); *** ../vim-8.1.0165/src/quickfix.c Sun Jul 8 16:01:04 2018 --- src/quickfix.c Sun Jul 8 16:42:07 2018 *************** *** 5360,5378 **** 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) return FAIL; qfp = qfp->qf_next; --- 5360,5375 ---- buf[0] = qfp->qf_type; buf[1] = NUL; ! 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,5582 **** int status = OK; if (flags & QF_GETLIST_TITLE) ! status = dict_add_nr_str(retdict, "title", 0L, (char_u *)""); if ((status == OK) && (flags & QF_GETLIST_ITEMS)) { list_T *l = list_alloc(); --- 5573,5579 ---- int status = OK; if (flags & QF_GETLIST_TITLE) ! status = dict_add_string(retdict, "title", (char_u *)""); if ((status == OK) && (flags & QF_GETLIST_ITEMS)) { list_T *l = list_alloc(); *************** *** 5586,5604 **** status = FAIL; } if ((status == OK) && (flags & QF_GETLIST_NR)) ! status = dict_add_nr_str(retdict, "nr", 0L, NULL); if ((status == OK) && (flags & QF_GETLIST_WINID)) ! status = dict_add_nr_str(retdict, "winid", qf_winid(qi), NULL); if ((status == OK) && (flags & QF_GETLIST_CONTEXT)) ! status = dict_add_nr_str(retdict, "context", 0L, (char_u *)""); if ((status == OK) && (flags & QF_GETLIST_ID)) ! status = dict_add_nr_str(retdict, "id", 0L, NULL); if ((status == OK) && (flags & QF_GETLIST_IDX)) ! status = dict_add_nr_str(retdict, "idx", 0L, NULL); if ((status == OK) && (flags & QF_GETLIST_SIZE)) ! status = dict_add_nr_str(retdict, "size", 0L, NULL); if ((status == OK) && (flags & QF_GETLIST_TICK)) ! status = dict_add_nr_str(retdict, "changedtick", 0L, NULL); return status; } --- 5583,5601 ---- status = FAIL; } if ((status == OK) && (flags & QF_GETLIST_NR)) ! status = dict_add_number(retdict, "nr", 0); if ((status == OK) && (flags & QF_GETLIST_WINID)) ! status = dict_add_number(retdict, "winid", qf_winid(qi)); if ((status == OK) && (flags & QF_GETLIST_CONTEXT)) ! status = dict_add_string(retdict, "context", (char_u *)""); if ((status == OK) && (flags & QF_GETLIST_ID)) ! status = dict_add_number(retdict, "id", 0); if ((status == OK) && (flags & QF_GETLIST_IDX)) ! status = dict_add_number(retdict, "idx", 0); if ((status == OK) && (flags & QF_GETLIST_SIZE)) ! status = dict_add_number(retdict, "size", 0); if ((status == OK) && (flags & QF_GETLIST_TICK)) ! status = dict_add_number(retdict, "changedtick", 0); return status; } *************** *** 5609,5620 **** 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); } /* --- 5606,5612 ---- static int qf_getprop_title(qf_info_T *qi, int qf_idx, dict_T *retdict) { ! return dict_add_string(retdict, "title", qi->qf_lists[qf_idx].qf_title); } /* *************** *** 5659,5665 **** status = FAIL; } else ! status = dict_add_nr_str(retdict, "context", 0L, (char_u *)""); return status; } --- 5651,5657 ---- status = FAIL; } else ! status = dict_add_string(retdict, "context", (char_u *)""); return status; } *************** *** 5674,5680 **** 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); } /* --- 5666,5672 ---- if (qi->qf_lists[qf_idx].qf_count == 0) /* For empty lists, qf_index is set to 1 */ idx = 0; ! return dict_add_number(retdict, "idx", idx); } /* *************** *** 5709,5732 **** 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); if ((status == OK) && (flags & QF_GETLIST_WINID)) ! status = dict_add_nr_str(retdict, "winid", qf_winid(qi), NULL); 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); 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); if ((status == OK) && (flags & QF_GETLIST_TICK)) ! status = dict_add_nr_str(retdict, "changedtick", ! qi->qf_lists[qf_idx].qf_changedtick, NULL); return status; } --- 5701,5723 ---- if (flags & QF_GETLIST_TITLE) status = qf_getprop_title(qi, qf_idx, retdict); if ((status == OK) && (flags & QF_GETLIST_NR)) ! status = dict_add_number(retdict, "nr", qf_idx + 1); if ((status == OK) && (flags & QF_GETLIST_WINID)) ! 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_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_number(retdict, "size", ! qi->qf_lists[qf_idx].qf_count); if ((status == OK) && (flags & QF_GETLIST_TICK)) ! status = dict_add_number(retdict, "changedtick", ! qi->qf_lists[qf_idx].qf_changedtick); return status; } *** ../vim-8.1.0165/src/tag.c Sat Jun 30 22:40:39 2018 --- src/tag.c Sun Jul 8 16:42:07 2018 *************** *** 905,915 **** 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); if (lnum == 0) ! dict_add_nr_str(dict, "pattern", 0L, cmd); } vim_snprintf((char *)IObuff, IOSIZE, "ltag %s", tag); --- 905,915 ---- continue; } ! dict_add_string(dict, "text", tag_name); ! dict_add_string(dict, "filename", fname); ! dict_add_number(dict, "lnum", lnum); if (lnum == 0) ! dict_add_string(dict, "pattern", cmd); } vim_snprintf((char *)IObuff, IOSIZE, "ltag %s", tag); *************** *** 3923,3929 **** vim_strncpy(buf, start, len); } buf[len] = NUL; ! retval = dict_add_nr_str(dict, field_name, 0L, buf); vim_free(buf); return retval; } --- 3923,3929 ---- vim_strncpy(buf, start, len); } buf[len] = NUL; ! retval = dict_add_string(dict, field_name, buf); vim_free(buf); return retval; } *************** *** 3968,3974 **** 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) ret = FAIL; vim_free(full_fname); --- 3968,3974 ---- tp.command_end) == FAIL || add_tag_field(dict, "kind", tp.tagkind, tp.tagkind_end) == FAIL ! || dict_add_number(dict, "static", is_static) == FAIL) ret = FAIL; vim_free(full_fname); *** ../vim-8.1.0165/src/terminal.c Tue Jun 19 19:59:15 2018 --- src/terminal.c Sun Jul 8 16:42:07 2018 *************** *** 4729,4739 **** 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)); list_append_dict(l, d); } } --- 4729,4739 ---- d = dict_alloc(); if (d != NULL) { ! 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,5076 **** break; list_append_dict(l, dcell); ! dict_add_nr_str(dcell, "chars", 0, mbs); vim_snprintf((char *)rgb, 8, "#%02x%02x%02x", fg.red, fg.green, fg.blue); ! dict_add_nr_str(dcell, "fg", 0, 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_nr_str(dcell, "attr", ! cell2attr(attrs, fg, bg), NULL); ! dict_add_nr_str(dcell, "width", width, NULL); ++pos.col; if (width == 2) --- 5059,5075 ---- break; list_append_dict(l, dcell); ! dict_add_string(dcell, "chars", mbs); vim_snprintf((char *)rgb, 8, "#%02x%02x%02x", fg.red, fg.green, fg.blue); ! dict_add_string(dcell, "fg", rgb); vim_snprintf((char *)rgb, 8, "#%02x%02x%02x", bg.red, bg.green, bg.blue); ! dict_add_string(dcell, "bg", rgb); ! dict_add_number(dcell, "attr", cell2attr(attrs, fg, bg)); ! dict_add_number(dcell, "width", width); ++pos.col; if (width == 2) *** ../vim-8.1.0165/src/undo.c Sun Jul 1 16:43:59 2018 --- src/undo.c Sun Jul 8 16:42:07 2018 *************** *** 3567,3580 **** 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); if (uhp == curbuf->b_u_newhead) ! dict_add_nr_str(dict, "newhead", 1, NULL); if (uhp == curbuf->b_u_curhead) ! dict_add_nr_str(dict, "curhead", 1, NULL); if (uhp->uh_save_nr > 0) ! dict_add_nr_str(dict, "save", uhp->uh_save_nr, NULL); if (uhp->uh_alt_next.ptr != NULL) { --- 3567,3580 ---- dict = dict_alloc(); if (dict == NULL) return; ! 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_number(dict, "newhead", 1); if (uhp == curbuf->b_u_curhead) ! dict_add_number(dict, "curhead", 1); if (uhp->uh_save_nr > 0) ! dict_add_number(dict, "save", uhp->uh_save_nr); if (uhp->uh_alt_next.ptr != NULL) { *** ../vim-8.1.0165/src/version.c Sun Jul 8 16:01:04 2018 --- src/version.c Sun Jul 8 16:43:50 2018 *************** *** 791,792 **** --- 791,794 ---- { /* Add new patch number below this line */ + /**/ + 166, /**/ -- hundred-and-one symptoms of being an internet addict: 207. You're given one phone call in prison and you ask them for a laptop. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///