From 45d6b4dc589a67ef6c35f115c4f73d0b540ec4d8 Mon Sep 17 00:00:00 2001 From: anon Date: Thu, 7 Sep 2023 21:51:42 +0200 Subject: [PATCH] proper quoting --- source/main.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/source/main.cpp b/source/main.cpp index 318bbb9..7b52262 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -1,4 +1,5 @@ #include +#include #include "regex.h" static int test_counter = 0; @@ -25,7 +26,20 @@ TEST(const char * const what, } else { printf("\033[31;1mFailiour\033[0;1m. - \033[0m"); } - printf("'%12s'\033[1m vs \033[0m'%12s'\033[1m:\033[0m Result = %d, Expected = %d\n", what, on, result, expect); + int len; + len = strlen(what); + char quoted_what[len+3]; + quoted_what[0] = '\''; + memcpy(quoted_what+1, what, len); + quoted_what[len+1] = '\''; + quoted_what[len+2] = '\0'; + len = strlen(on); + char quoted_on[strlen(on)+3]; + quoted_on[0] = '\''; + memcpy(quoted_on+1, on, len); + quoted_on[len+1] = '\''; + quoted_on[len+2] = '\0'; + printf("%12s\033[1m vs \033[0m%12s\033[1m:\033[0m Result = %d, Expected = %d\n", quoted_what, quoted_on, result, expect); if (passed) { ++passed_tests; }