From 128e055a74378d4b5091a0d47fe9f13448c6c472 Mon Sep 17 00:00:00 2001 From: Ben Barsdell Date: Tue, 21 Nov 2023 21:14:50 +1100 Subject: [PATCH] Fix bad parsing in extract_used_header_warnings - This makes it more robust to changes in formatting in the compiler log output between different nvrtc versions. --- jitify2.hpp | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/jitify2.hpp b/jitify2.hpp index 28496f4..9466ff6 100644 --- a/jitify2.hpp +++ b/jitify2.hpp @@ -7215,14 +7215,12 @@ inline bool extract_used_header_warnings( start = (size_t)-1; } ++start; - // Each full warning message is 4 lines. - for (int i = 0; i < 4; ++i) { - size_t new_end = compile_log->find_first_of('\n', end + 1); - if (new_end == std::string::npos) break; // End of log - end = new_end; - } - ++end; - std::string tail = compile_log->substr(end); + std::string tail; + // Log messages are separated by a blank line. + end = compile_log->find("\n\n", end + 1); + if (end != std::string::npos) { + tail = compile_log->substr(end + 2); + } compile_log->resize(start); *compile_log += tail; } @@ -7237,14 +7235,11 @@ inline bool extract_used_header_warnings( start = (size_t)-1; } ++start; - size_t end = - compile_log->find_first_of('\n', pos + std::strlen("-diag-suppress")); - assert(end != std::string::npos); - end = compile_log->find_first_of('\n', end + 1); std::string tail; + size_t end = + compile_log->find("\n\n", pos + std::strlen("-diag-suppress")); if (end != std::string::npos) { - ++end; - tail = compile_log->substr(end); + tail = compile_log->substr(end + 2); } compile_log->resize(start); *compile_log += tail;