summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2016-07-07 20:45:06 +0200
committerBram Moolenaar <Bram@vim.org>2016-07-07 20:45:06 +0200
commitbf2cc5f36d5ffd5de445e6970602000c7869b65a (patch)
tree5f781b03b478365b69a33b8a37d1bc39b5456c15
parentdcb170018642ec144cd87d9d9fe076575b8d1263 (diff)
downloadvim-git-bf2cc5f36d5ffd5de445e6970602000c7869b65a.tar.gz
patch 7.4.1998v7.4.1998
Problem: When writing buffer lines to a job there is no NL to NUL conversion. Solution: Make it work symmetrical with writing lines from a job into a buffer.
-rw-r--r--src/channel.c15
-rw-r--r--src/netbeans.c3
-rw-r--r--src/proto/channel.pro2
-rw-r--r--src/version.c2
4 files changed, 15 insertions, 7 deletions
diff --git a/src/channel.c b/src/channel.c
index 1c93b6c50..bb818dcd1 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -1313,14 +1313,20 @@ write_buf_line(buf_T *buf, linenr_T lnum, channel_T *channel)
char_u *line = ml_get_buf(buf, lnum, FALSE);
int len = (int)STRLEN(line);
char_u *p;
+ int i;
/* Need to make a copy to be able to append a NL. */
if ((p = alloc(len + 2)) == NULL)
return;
memcpy((char *)p, (char *)line, len);
+
+ for (i = 0; i < len; ++i)
+ if (p[i] == NL)
+ p[i] = NUL;
+
p[len] = NL;
p[len + 1] = NUL;
- channel_send(channel, PART_IN, p, "write_buf_line()");
+ channel_send(channel, PART_IN, p, len + 1, "write_buf_line()");
vim_free(p);
}
@@ -2185,7 +2191,7 @@ channel_exe_cmd(channel_T *channel, int part, typval_T *argv)
{
channel_send(channel,
part == PART_SOCK ? PART_SOCK : PART_IN,
- json, (char *)cmd);
+ json, (int)STRLEN(json), (char *)cmd);
vim_free(json);
}
}
@@ -3380,9 +3386,8 @@ channel_handle_events(void)
* Return FAIL or OK.
*/
int
-channel_send(channel_T *channel, int part, char_u *buf, char *fun)
+channel_send(channel_T *channel, int part, char_u *buf, int len, char *fun)
{
- int len = (int)STRLEN(buf);
int res;
sock_T fd;
@@ -3470,7 +3475,7 @@ send_common(
opt->jo_callback, opt->jo_partial, id);
}
- if (channel_send(channel, part_send, text, fun) == OK
+ if (channel_send(channel, part_send, text, (int)STRLEN(text), fun) == OK
&& opt->jo_callback == NULL)
return channel;
return NULL;
diff --git a/src/netbeans.c b/src/netbeans.c
index aadddc2c2..e326af8f3 100644
--- a/src/netbeans.c
+++ b/src/netbeans.c
@@ -765,7 +765,8 @@ netbeans_end(void)
nb_send(char *buf, char *fun)
{
if (nb_channel != NULL)
- channel_send(nb_channel, PART_SOCK, (char_u *)buf, fun);
+ channel_send(nb_channel, PART_SOCK, (char_u *)buf,
+ (int)STRLEN(buf), fun);
}
/*
diff --git a/src/proto/channel.pro b/src/proto/channel.pro
index 8a059a3a9..1acae9a10 100644
--- a/src/proto/channel.pro
+++ b/src/proto/channel.pro
@@ -34,7 +34,7 @@ int channel_read_json_block(channel_T *channel, int part, int timeout_arg, int i
void common_channel_read(typval_T *argvars, typval_T *rettv, int raw);
channel_T *channel_fd2channel(sock_T fd, int *partp);
void channel_handle_events(void);
-int channel_send(channel_T *channel, int part, char_u *buf, char *fun);
+int channel_send(channel_T *channel, int part, char_u *buf, int len, char *fun);
channel_T *send_common(typval_T *argvars, char_u *text, int id, int eval, jobopt_T *opt, char *fun, int *part_read);
void ch_expr_common(typval_T *argvars, typval_T *rettv, int eval);
void ch_raw_common(typval_T *argvars, typval_T *rettv, int eval);
diff --git a/src/version.c b/src/version.c
index d606bab2a..368d1b8be 100644
--- a/src/version.c
+++ b/src/version.c
@@ -759,6 +759,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 1998,
+/**/
1997,
/**/
1996,