diff options
Diffstat (limited to 'lib/output.c')
-rw-r--r-- | lib/output.c | 37 |
1 files changed, 34 insertions, 3 deletions
diff --git a/lib/output.c b/lib/output.c index b398c2ad..34ff7dab 100644 --- a/lib/output.c +++ b/lib/output.c | |||
@@ -368,9 +368,39 @@ static inline char *fmt_subcheck_output(mp_output_format output_format, mp_subch | |||
368 | mp_subcheck_list *subchecks = NULL; | 368 | mp_subcheck_list *subchecks = NULL; |
369 | 369 | ||
370 | switch (output_format) { | 370 | switch (output_format) { |
371 | case MP_FORMAT_MULTI_LINE: | 371 | case MP_FORMAT_MULTI_LINE: { |
372 | asprintf(&result, "%s\\_[%s] - %s", generate_indentation_string(indentation), | 372 | char *tmp_string = NULL; |
373 | state_text(mp_compute_subcheck_state(check)), check.output); | 373 | if ((tmp_string = strchr(check.output, '\n')) != NULL) { |
374 | // This is a multiline string, put the correct indentation in before proceeding | ||
375 | char *intermediate_string = ""; | ||
376 | bool have_residual_chars = false; | ||
377 | |||
378 | while (tmp_string != NULL) { | ||
379 | *tmp_string = '\0'; | ||
380 | asprintf(&intermediate_string, "%s%s\n%s", intermediate_string,check.output, generate_indentation_string(indentation+1)); // one more indentation to make it look better | ||
381 | |||
382 | if (*(tmp_string + 1) != '\0') { | ||
383 | check.output = tmp_string + 1; | ||
384 | have_residual_chars = true; | ||
385 | } else { | ||
386 | // Null after the \n, so this is the end | ||
387 | have_residual_chars = false; | ||
388 | break; | ||
389 | } | ||
390 | |||
391 | tmp_string = strchr(check.output, '\n'); | ||
392 | } | ||
393 | |||
394 | // add the rest (if any) | ||
395 | if (have_residual_chars) { | ||
396 | char *tmp = check.output; | ||
397 | xasprintf(&check.output, "%s\n%s%s", intermediate_string, generate_indentation_string(indentation+1), tmp); | ||
398 | } else { | ||
399 | check.output = intermediate_string; | ||
400 | } | ||
401 | } | ||
402 | asprintf(&result, "%s\\_[%s] - %s", generate_indentation_string(indentation), state_text(mp_compute_subcheck_state(check)), | ||
403 | check.output); | ||
374 | 404 | ||
375 | subchecks = check.subchecks; | 405 | subchecks = check.subchecks; |
376 | 406 | ||
@@ -380,6 +410,7 @@ static inline char *fmt_subcheck_output(mp_output_format output_format, mp_subch | |||
380 | subchecks = subchecks->next; | 410 | subchecks = subchecks->next; |
381 | } | 411 | } |
382 | return result; | 412 | return result; |
413 | } | ||
383 | default: | 414 | default: |
384 | die(STATE_UNKNOWN, "Invalid format"); | 415 | die(STATE_UNKNOWN, "Invalid format"); |
385 | } | 416 | } |