Loading parser.cpp +12 −7 Changes for parser.cpp: 12 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ #include <cstring> #include <cctype> #include <set> #include <regex> namespace fs = std::filesystem; using namespace makeplus; Loading Loading @@ -1441,13 +1442,17 @@ std::vector<std::string> Parser::split_func_args(const std::string& args, int ma std::string Parser::func_shell(const std::string& cmd) const { std::string modified_cmd = cmd; // Emulation für GNU printf '%b\n': // Wir ersetzen 'printf '%b\n'' durch ein echo -e oder übersetzen die Escapes direkt, // damit der an die Shell übergebene C-Code syntaktisch korrekt ankommt. size_t pos = 0; while ((pos = modified_cmd.find("printf '%b\\n'", pos)) != std::string::npos) { modified_cmd.replace(pos, 13, "printf '%s\\n'"); // Changed 12 to 13 pos += 13; // Advance by the correct length try { // 1. Verallgemeinerung für printf mit '%b' -> '%s' std::regex printf_b_regex(R"(printf\s+(['"])([^'"]*?)%b([^'"]*?)\1)"); modified_cmd = std::regex_replace(modified_cmd, printf_b_regex, "printf $1$2%s$3$1"); // 2. Ersetze literal übergebenes '\n' innerhalb von printf-Args durch echte Leerzeichen/Zeilenumbrüche, // damit der Compiler keine "-Werror,-Wextra-tokens" Fehler wirft. std::regex literal_newline_regex(R"(\\n)"); modified_cmd = std::regex_replace(modified_cmd, literal_newline_regex, "\n"); } catch (const std::regex_error& e) { // Fallback falls Regex fehlschlägt } FILE* pipe = popen(modified_cmd.c_str(), "r"); Loading Loading
parser.cpp +12 −7 Changes for parser.cpp: 12 added lines, 7 removed lines. Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ #include <cstring> #include <cctype> #include <set> #include <regex> namespace fs = std::filesystem; using namespace makeplus; Loading Loading @@ -1441,13 +1442,17 @@ std::vector<std::string> Parser::split_func_args(const std::string& args, int ma std::string Parser::func_shell(const std::string& cmd) const { std::string modified_cmd = cmd; // Emulation für GNU printf '%b\n': // Wir ersetzen 'printf '%b\n'' durch ein echo -e oder übersetzen die Escapes direkt, // damit der an die Shell übergebene C-Code syntaktisch korrekt ankommt. size_t pos = 0; while ((pos = modified_cmd.find("printf '%b\\n'", pos)) != std::string::npos) { modified_cmd.replace(pos, 13, "printf '%s\\n'"); // Changed 12 to 13 pos += 13; // Advance by the correct length try { // 1. Verallgemeinerung für printf mit '%b' -> '%s' std::regex printf_b_regex(R"(printf\s+(['"])([^'"]*?)%b([^'"]*?)\1)"); modified_cmd = std::regex_replace(modified_cmd, printf_b_regex, "printf $1$2%s$3$1"); // 2. Ersetze literal übergebenes '\n' innerhalb von printf-Args durch echte Leerzeichen/Zeilenumbrüche, // damit der Compiler keine "-Werror,-Wextra-tokens" Fehler wirft. std::regex literal_newline_regex(R"(\\n)"); modified_cmd = std::regex_replace(modified_cmd, literal_newline_regex, "\n"); } catch (const std::regex_error& e) { // Fallback falls Regex fehlschlägt } FILE* pipe = popen(modified_cmd.c_str(), "r"); Loading