Mercurial > vim
comparison src/channel.c @ 9367:2465b6cda394 v7.4.1965
commit https://github.com/vim/vim/commit/adb78a77ebb47627bcf73bd16ac1119d970e17c8
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Jun 27 21:10:31 2016 +0200
patch 7.4.1965
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)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 27 Jun 2016 21:15:05 +0200 |
parents | 40c8a8b012b5 |
children | 8f904a323b3f |
comparison
equal
deleted
inserted
replaced
9366:7626b6fba7fc | 9367:2465b6cda394 |
---|---|
1315 char_u *p; | 1315 char_u *p; |
1316 | 1316 |
1317 /* Need to make a copy to be able to append a NL. */ | 1317 /* Need to make a copy to be able to append a NL. */ |
1318 if ((p = alloc(len + 2)) == NULL) | 1318 if ((p = alloc(len + 2)) == NULL) |
1319 return; | 1319 return; |
1320 STRCPY(p, line); | 1320 memcpy((char *)p, (char *)line, len); |
1321 p[len] = NL; | 1321 p[len] = NL; |
1322 p[len + 1] = NUL; | 1322 p[len + 1] = NUL; |
1323 channel_send(channel, PART_IN, p, "write_buf_line()"); | 1323 channel_send(channel, PART_IN, p, "write_buf_line()"); |
1324 vim_free(p); | 1324 vim_free(p); |
1325 } | 1325 } |
1614 static char_u * | 1614 static char_u * |
1615 channel_get_all(channel_T *channel, int part) | 1615 channel_get_all(channel_T *channel, int part) |
1616 { | 1616 { |
1617 readq_T *head = &channel->ch_part[part].ch_head; | 1617 readq_T *head = &channel->ch_part[part].ch_head; |
1618 readq_T *node = head->rq_next; | 1618 readq_T *node = head->rq_next; |
1619 long_u len = 1; | 1619 long_u len = 0; |
1620 char_u *res; | 1620 char_u *res; |
1621 char_u *p; | 1621 char_u *p; |
1622 | 1622 |
1623 /* If there is only one buffer just get that one. */ | 1623 /* If there is only one buffer just get that one. */ |
1624 if (head->rq_next == NULL || head->rq_next->rq_next == NULL) | 1624 if (head->rq_next == NULL || head->rq_next->rq_next == NULL) |
1625 return channel_get(channel, part); | 1625 return channel_get(channel, part); |
1626 | 1626 |
1627 /* Concatenate everything into one buffer. */ | 1627 /* Concatenate everything into one buffer. */ |
1628 for (node = head->rq_next; node != NULL; node = node->rq_next) | 1628 for (node = head->rq_next; node != NULL; node = node->rq_next) |
1629 len += node->rq_buflen; | 1629 len += node->rq_buflen; |
1630 res = lalloc(len, TRUE); | 1630 res = lalloc(len + 1, TRUE); |
1631 if (res == NULL) | 1631 if (res == NULL) |
1632 return NULL; | 1632 return NULL; |
1633 p = res; | 1633 p = res; |
1634 for (node = head->rq_next; node != NULL; node = node->rq_next) | 1634 for (node = head->rq_next; node != NULL; node = node->rq_next) |
1635 { | 1635 { |