]> granicus.if.org Git - vim/commitdiff
patch 7.4.1965 v7.4.1965
authorBram Moolenaar <Bram@vim.org>
Mon, 27 Jun 2016 19:10:31 +0000 (21:10 +0200)
committerBram Moolenaar <Bram@vim.org>
Mon, 27 Jun 2016 19:10:31 +0000 (21:10 +0200)
Problem:    When using a job in raw mode to append to a buffer garbage
            characters are added.
Solution:   Do not replace the trailing NUL with a NL. (Ozaki Kiichi)

src/channel.c
src/testdir/test_channel.vim
src/version.c

index 50028c83d14124b2a1afb15c69b44aceea6e163c..1c93b6c50ef562a09ce11d6c0d83386cc1427608 100644 (file)
@@ -1317,7 +1317,7 @@ write_buf_line(buf_T *buf, linenr_T lnum, channel_T *channel)
     /* Need to make a copy to be able to append a NL. */
     if ((p = alloc(len + 2)) == NULL)
        return;
-    STRCPY(p, line);
+    memcpy((char *)p, (char *)line, len);
     p[len] = NL;
     p[len + 1] = NUL;
     channel_send(channel, PART_IN, p, "write_buf_line()");
@@ -1616,7 +1616,7 @@ channel_get_all(channel_T *channel, int part)
 {
     readq_T *head = &channel->ch_part[part].ch_head;
     readq_T *node = head->rq_next;
-    long_u  len = 1;
+    long_u  len = 0;
     char_u  *res;
     char_u  *p;
 
@@ -1627,7 +1627,7 @@ channel_get_all(channel_T *channel, int part)
     /* Concatenate everything into one buffer. */
     for (node = head->rq_next; node != NULL; node = node->rq_next)
        len += node->rq_buflen;
-    res = lalloc(len, TRUE);
+    res = lalloc(len + 1, TRUE);
     if (res == NULL)
        return NULL;
     p = res;
index 9d68a14cce715fc9663608e3140d83dcc5a46880..8679a16872d0b49fccca64e0750190e4411a48e9 100644 (file)
@@ -1018,6 +1018,28 @@ func Test_pipe_null()
   call job_stop(job)
 endfunc
 
+func Test_pipe_to_buffer_raw()
+  if !has('job')
+    return
+  endif
+  call ch_log('Test_raw_pipe_to_buffer()')
+  let options = {'out_mode': 'raw', 'out_io': 'buffer', 'out_name': 'testout'}
+  split testout
+  let job = job_start([s:python, '-c', 
+        \ 'import sys; [sys.stdout.write(".") and sys.stdout.flush() for _ in range(10000)]'], options)
+  call assert_equal("run", job_status(job))
+  call s:waitFor('len(join(getline(2,line("$")),"") >= 10000')
+  try
+    for line in getline(2, '$')
+      let line = substitute(line, '^\.*', '', '')
+      call assert_equal('', line)
+    endfor
+  finally
+    call job_stop(job)
+    bwipe!
+  endtry
+endfunc
+
 func Test_reuse_channel()
   if !has('job')
     return
index 087c2d88151b49b05921cd2074c0e19cfe74e178..85019976bb1929e88ccd2d41ea60560a0de97085 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1965,
 /**/
     1964,
 /**/