| 319 | } |
| 320 | |
| 321 | static void trace_encoding(const char *context, const char *path, |
| 322 | const char *encoding, const char *buf, size_t len) |
| 323 | { |
| 324 | static struct trace_key coe = TRACE_KEY_INIT(WORKING_TREE_ENCODING); |
| 325 | struct strbuf trace = STRBUF_INIT; |
| 326 | int i; |
| 327 | |
| 328 | if (!trace_want(&coe)) |
| 329 | return; |
| 330 | |
| 331 | strbuf_addf(&trace, "%s (%s, considered %s):\n", context, path, encoding); |
| 332 | for (i = 0; i < len && buf; ++i) { |
| 333 | strbuf_addf( |
| 334 | &trace, "| \033[2m%2i:\033[0m %2x \033[2m%c\033[0m%c", |
| 335 | i, |
| 336 | (unsigned char) buf[i], |
| 337 | (buf[i] > 32 && buf[i] < 127 ? buf[i] : ' '), |
| 338 | ((i+1) % 8 && (i+1) < len ? ' ' : '\n') |
| 339 | ); |
| 340 | } |
| 341 | strbuf_addchars(&trace, '\n', 1); |
| 342 | |
| 343 | trace_strbuf(&coe, &trace); |
| 344 | strbuf_release(&trace); |
| 345 | } |
| 346 | |
| 347 | static int check_roundtrip(const char *enc_name) |
| 348 | { |
no test coverage detected