diff src/channel.c @ 14301:3c80092eb211 v8.1.0166

patch 8.1.0166: using dict_add_nr_str() is clumsy commit https://github.com/vim/vim/commit/e0be167a805fd547c25ec1ec97fd4c7f13046236 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jul 8 16:50:37 2018 +0200 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 https://github.com/vim/vim/issues/3154)
author Christian Brabandt <cb@256bit.org>
date Sun, 08 Jul 2018 17:00:07 +0200
parents d053ec57d886
children f761a55a8aed
line wrap: on
line diff
--- a/src/channel.c
+++ b/src/channel.c
@@ -2809,7 +2809,7 @@ channel_part_info(channel_T *channel, di
 	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, di
 	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, di
 	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)