To: vim_dev@googlegroups.com Subject: Patch 7.4.1325 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ 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. Files: src/eval.c, src/channel.c *** ../vim-7.4.1324/src/eval.c 2016-02-15 20:39:42.581803383 +0100 --- src/eval.c 2016-02-15 22:28:40.944925802 +0100 *************** *** 9184,9189 **** --- 9184,9221 ---- } /* + * Append "str" to "gap", escaping unprintable characters. + * Changes NL to \n, CR to \r, etc. + */ + static void + ga_concat_esc(garray_T *gap, char_u *str) + { + char_u *p; + char_u buf[NUMBUFLEN]; + + for (p = str; *p != NUL; ++p) + switch (*p) + { + case BS: ga_concat(gap, (char_u *)"\\b"); break; + case ESC: ga_concat(gap, (char_u *)"\\e"); break; + case FF: ga_concat(gap, (char_u *)"\\f"); break; + case NL: ga_concat(gap, (char_u *)"\\n"); break; + case TAB: ga_concat(gap, (char_u *)"\\t"); break; + case CAR: ga_concat(gap, (char_u *)"\\r"); break; + case '\\': ga_concat(gap, (char_u *)"\\\\"); break; + default: + if (*p < ' ') + { + vim_snprintf((char *)buf, NUMBUFLEN, "\\x%02x", *p); + ga_concat(gap, buf); + } + else + ga_append(gap, *p); + break; + } + } + + /* * Fill "gap" with information about an assert error. */ static void *************** *** 9207,9219 **** ga_concat(gap, (char_u *)"Expected "); if (exp_str == NULL) { ! ga_concat(gap, tv2string(exp_tv, &tofree, numbuf, 0)); vim_free(tofree); } else ! ga_concat(gap, exp_str); ga_concat(gap, (char_u *)" but got "); ! ga_concat(gap, tv2string(got_tv, &tofree, numbuf, 0)); vim_free(tofree); } } --- 9239,9251 ---- ga_concat(gap, (char_u *)"Expected "); if (exp_str == NULL) { ! ga_concat_esc(gap, tv2string(exp_tv, &tofree, numbuf, 0)); vim_free(tofree); } else ! ga_concat_esc(gap, exp_str); ga_concat(gap, (char_u *)" but got "); ! ga_concat_esc(gap, tv2string(got_tv, &tofree, numbuf, 0)); vim_free(tofree); } } *** ../vim-7.4.1324/src/channel.c 2016-02-15 21:56:42.721119732 +0100 --- src/channel.c 2016-02-15 22:35:24.228691583 +0100 *************** *** 1262,1267 **** --- 1262,1269 ---- { readq_T *node; readq_T *head = &channel->ch_head; + char_u *p; + int i; node = (readq_T *)alloc(sizeof(readq_T)); if (node == NULL) *************** *** 1272,1279 **** vim_free(node); return FAIL; /* out of memory */ } ! mch_memmove(node->rq_buffer, buf, (size_t)len); ! node->rq_buffer[len] = NUL; /* append node to the tail of the queue */ node->rq_next = NULL; --- 1274,1286 ---- vim_free(node); return FAIL; /* out of memory */ } ! ! /* TODO: don't strip CR when channel is in raw mode */ ! p = node->rq_buffer; ! for (i = 0; i < len; ++i) ! if (buf[i] != CAR || i + 1 >= len || buf[i + 1] != NL) ! *p++ = buf[i]; ! *p = NUL; /* append node to the tail of the queue */ node->rq_next = NULL; *** ../vim-7.4.1324/src/version.c 2016-02-15 21:56:42.725119689 +0100 --- src/version.c 2016-02-15 22:36:51.447775794 +0100 *************** *** 749,750 **** --- 749,752 ---- { /* Add new patch number below this line */ + /**/ + 1325, /**/ -- hundred-and-one symptoms of being an internet addict: 269. You wonder how you can make your dustbin produce Sesame Street's Oscar's the Garbage Monster song when you empty it. /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///