mirror of
https://github.com/vim/vim.git
synced 2025-09-29 04:34:16 -04:00
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.
This commit is contained in:
38
src/eval.c
38
src/eval.c
@@ -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);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user