Mercurial > vim
comparison src/eval.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 | 6db4b1c863ec |
children | e4c3f6720b03 |
comparison
equal
deleted
inserted
replaced
8061:abd64cf67bcf | 8062:7fe3b9dc132b |
---|---|
9182 if (sourcing_name != NULL || sourcing_lnum > 0) | 9182 if (sourcing_name != NULL || sourcing_lnum > 0) |
9183 ga_concat(gap, (char_u *)": "); | 9183 ga_concat(gap, (char_u *)": "); |
9184 } | 9184 } |
9185 | 9185 |
9186 /* | 9186 /* |
9187 * Append "str" to "gap", escaping unprintable characters. | |
9188 * Changes NL to \n, CR to \r, etc. | |
9189 */ | |
9190 static void | |
9191 ga_concat_esc(garray_T *gap, char_u *str) | |
9192 { | |
9193 char_u *p; | |
9194 char_u buf[NUMBUFLEN]; | |
9195 | |
9196 for (p = str; *p != NUL; ++p) | |
9197 switch (*p) | |
9198 { | |
9199 case BS: ga_concat(gap, (char_u *)"\\b"); break; | |
9200 case ESC: ga_concat(gap, (char_u *)"\\e"); break; | |
9201 case FF: ga_concat(gap, (char_u *)"\\f"); break; | |
9202 case NL: ga_concat(gap, (char_u *)"\\n"); break; | |
9203 case TAB: ga_concat(gap, (char_u *)"\\t"); break; | |
9204 case CAR: ga_concat(gap, (char_u *)"\\r"); break; | |
9205 case '\\': ga_concat(gap, (char_u *)"\\\\"); break; | |
9206 default: | |
9207 if (*p < ' ') | |
9208 { | |
9209 vim_snprintf((char *)buf, NUMBUFLEN, "\\x%02x", *p); | |
9210 ga_concat(gap, buf); | |
9211 } | |
9212 else | |
9213 ga_append(gap, *p); | |
9214 break; | |
9215 } | |
9216 } | |
9217 | |
9218 /* | |
9187 * Fill "gap" with information about an assert error. | 9219 * Fill "gap" with information about an assert error. |
9188 */ | 9220 */ |
9189 static void | 9221 static void |
9190 fill_assert_error( | 9222 fill_assert_error( |
9191 garray_T *gap, | 9223 garray_T *gap, |
9205 else | 9237 else |
9206 { | 9238 { |
9207 ga_concat(gap, (char_u *)"Expected "); | 9239 ga_concat(gap, (char_u *)"Expected "); |
9208 if (exp_str == NULL) | 9240 if (exp_str == NULL) |
9209 { | 9241 { |
9210 ga_concat(gap, tv2string(exp_tv, &tofree, numbuf, 0)); | 9242 ga_concat_esc(gap, tv2string(exp_tv, &tofree, numbuf, 0)); |
9211 vim_free(tofree); | 9243 vim_free(tofree); |
9212 } | 9244 } |
9213 else | 9245 else |
9214 ga_concat(gap, exp_str); | 9246 ga_concat_esc(gap, exp_str); |
9215 ga_concat(gap, (char_u *)" but got "); | 9247 ga_concat(gap, (char_u *)" but got "); |
9216 ga_concat(gap, tv2string(got_tv, &tofree, numbuf, 0)); | 9248 ga_concat_esc(gap, tv2string(got_tv, &tofree, numbuf, 0)); |
9217 vim_free(tofree); | 9249 vim_free(tofree); |
9218 } | 9250 } |
9219 } | 9251 } |
9220 | 9252 |
9221 /* | 9253 /* |