Mercurial > vim
comparison src/channel.c @ 8062:7fe3b9dc132b v7.4.1325
commit https://github.com/vim/vim/commit/2368917d8f0c0a997eac7a51ddfaa748dc528392
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Feb 15 22:37:37 2016 +0100
patch 7.4.1325
Problem: Channel test fails on difference between Unix and DOS line endings.
Solution: Strip off CR. Make assert show difference better.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Mon, 15 Feb 2016 22:45:05 +0100 |
parents | 19304db153bc |
children | e4c3f6720b03 |
comparison
equal
deleted
inserted
replaced
8061:abd64cf67bcf | 8062:7fe3b9dc132b |
---|---|
1260 int | 1260 int |
1261 channel_save(channel_T *channel, char_u *buf, int len) | 1261 channel_save(channel_T *channel, char_u *buf, int len) |
1262 { | 1262 { |
1263 readq_T *node; | 1263 readq_T *node; |
1264 readq_T *head = &channel->ch_head; | 1264 readq_T *head = &channel->ch_head; |
1265 char_u *p; | |
1266 int i; | |
1265 | 1267 |
1266 node = (readq_T *)alloc(sizeof(readq_T)); | 1268 node = (readq_T *)alloc(sizeof(readq_T)); |
1267 if (node == NULL) | 1269 if (node == NULL) |
1268 return FAIL; /* out of memory */ | 1270 return FAIL; /* out of memory */ |
1269 node->rq_buffer = alloc(len + 1); | 1271 node->rq_buffer = alloc(len + 1); |
1270 if (node->rq_buffer == NULL) | 1272 if (node->rq_buffer == NULL) |
1271 { | 1273 { |
1272 vim_free(node); | 1274 vim_free(node); |
1273 return FAIL; /* out of memory */ | 1275 return FAIL; /* out of memory */ |
1274 } | 1276 } |
1275 mch_memmove(node->rq_buffer, buf, (size_t)len); | 1277 |
1276 node->rq_buffer[len] = NUL; | 1278 /* TODO: don't strip CR when channel is in raw mode */ |
1279 p = node->rq_buffer; | |
1280 for (i = 0; i < len; ++i) | |
1281 if (buf[i] != CAR || i + 1 >= len || buf[i + 1] != NL) | |
1282 *p++ = buf[i]; | |
1283 *p = NUL; | |
1277 | 1284 |
1278 /* append node to the tail of the queue */ | 1285 /* append node to the tail of the queue */ |
1279 node->rq_next = NULL; | 1286 node->rq_next = NULL; |
1280 node->rq_prev = head->rq_prev; | 1287 node->rq_prev = head->rq_prev; |
1281 if (head->rq_prev == NULL) | 1288 if (head->rq_prev == NULL) |