]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 7.4.1325 v7.4.1325
authorBram Moolenaar <Bram@vim.org>
Mon, 15 Feb 2016 21:37:37 +0000 (22:37 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 15 Feb 2016 21:37:37 +0000 (22:37 +0100)
Problem:    Channel test fails on difference between Unix and DOS line endings.
Solution:   Strip off CR.  Make assert show difference better.

src/channel.c
src/eval.c
src/version.c

index c86304b606e70eb73c981711e7932749dc2cddbf..d5d7ffb49b3b81e9423ea18c02a492cc39cd3fce 100644 (file)
@@ -1262,6 +1262,8 @@ channel_save(channel_T *channel, char_u *buf, int len)
 {
     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,8 +1274,13 @@ channel_save(channel_T *channel, char_u *buf, int len)
        vim_free(node);
        return FAIL;        /* out of memory */
     }
-    mch_memmove(node->rq_buffer, buf, (size_t)len);
-    node->rq_buffer[len] = NUL;
+
+    /* 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;
index 53d41d1d98dc72be45610e145842736c759cf477..a90dd0b732be6b8460c360d1b967291395b3c962 100644 (file)
@@ -9183,6 +9183,38 @@ prepare_assert_error(garray_T *gap)
        ga_concat(gap, (char_u *)": ");
 }
 
+/*
+ * 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.
  */
@@ -9207,13 +9239,13 @@ fill_assert_error(
        ga_concat(gap, (char_u *)"Expected ");
        if (exp_str == NULL)
        {
-           ga_concat(gap, tv2string(exp_tv, &tofree, numbuf, 0));
+           ga_concat_esc(gap, tv2string(exp_tv, &tofree, numbuf, 0));
            vim_free(tofree);
        }
        else
-           ga_concat(gap, exp_str);
+           ga_concat_esc(gap, exp_str);
        ga_concat(gap, (char_u *)" but got ");
-       ga_concat(gap, tv2string(got_tv, &tofree, numbuf, 0));
+       ga_concat_esc(gap, tv2string(got_tv, &tofree, numbuf, 0));
        vim_free(tofree);
     }
 }
index f2887c9a41fd8293181a570dd39d967a4623805f..8520ec5153c8e9861dcda0f3ced55d7b8874d783 100644 (file)
@@ -747,6 +747,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1325,
 /**/
     1324,
 /**/