diff options
author | Bram Moolenaar <Bram@vim.org> | 2018-07-08 16:50:37 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2018-07-08 16:50:37 +0200 |
commit | e0be167a805fd547c25ec1ec97fd4c7f13046236 (patch) | |
tree | 423fb96f7b30329ef0b7ccf3d4b2a02620e7929c /src/channel.c | |
parent | 4cde86c2ef885e82fff3d925dee9fb5671c025cf (diff) |
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)
Diffstat (limited to 'src/channel.c')
-rw-r--r-- | src/channel.c | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/src/channel.c b/src/channel.c index 1363ee9299..c62da8bd31 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) |