From 18feb2bfe7b0d0d49330ec46bf2db3d2a73662d4 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 21 Jul 2024 13:52:48 +1000 Subject: [PATCH] xo-indentlog: account for more-concise clang output when printing fn --- include/xo/indentlog/print/function.hpp | 27 +++++++++++++++---------- utest/function.test.cpp | 1 + 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/xo/indentlog/print/function.hpp b/include/xo/indentlog/print/function.hpp index 3c0f97a6..095df5c7 100644 --- a/include/xo/indentlog/print/function.hpp +++ b/include/xo/indentlog/print/function.hpp @@ -7,20 +7,20 @@ namespace xo { enum class function_style : std::uint8_t { - /* literal: print supplied text, no alterations */ + /** literal: print supplied text, no alterations **/ literal, - /* pretty: print name, surrounded by [] + /** pretty: print name, surrounded by [] * [double Quadratic::operator()(double) const] - */ + **/ pretty, - /* streamlined: remove extraneous detail, - * try to print something like class::method - * Quadratic::operator() - */ + /** streamlined: remove extraneous detail, + * try to print something like class::method + * Quadratic::operator() + **/ streamlined, - /* simple: remove everything except function/method name - * operator() - */ + /** simple: remove everything except function/method name + * operator() + **/ simple }; @@ -99,7 +99,7 @@ namespace xo { //std::cerr << "print_streamlined: s=[" << s << "]" << std::endl; //std::cerr << "print_streamlined: s2=[" << s2 << "] (excluded [with ..] suffix)" << std::endl; - //std::cerr << "print_streamlined: s3=[" << s3 << "], p=" << p << " (excluded const suffix)" << std::endl; + //std::cerr << "print_streamlined: s3=[" << s3 << "] (excluded const suffix)" << std::endl; //std::cerr << "print_streamlined: s4=[" << s4 << "], q=" << q << " (excluded return type)" << std::endl; //std::cerr << "print_streamlined: s5=[" << s5 << "], r=" << r << " (excluded ns qualifier)" << std::endl; @@ -143,7 +143,12 @@ namespace xo { * - left-to-right * - exclude ' [with '... to end of string */ +#if __clang__ + /* clang footnote like [CharT = char] instead of [with CharT = char] */ + std::size_t p = s.find(" ["); +#else std::size_t p = s.find(" [with "); +#endif return s.substr(0, p); } /*exclude_template_footnote_suffix*/ diff --git a/utest/function.test.cpp b/utest/function.test.cpp index 42d3c9b6..84b49515 100644 --- a/utest/function.test.cpp +++ b/utest/function.test.cpp @@ -38,6 +38,7 @@ namespace ut { function_tcase(function_style::pretty, color_spec_type::blue(), "void xo::class::foo() const", "[\033[31;34mvoid xo::class::foo() const\033[0m]"), function_tcase(function_style::streamlined, color_spec_type::none(), "void xo::reactor::FifoQueue::notify_ev(const T&) [with T = std::pair > >, long unsigned int>; EvTimeFn = xo::reactor::EventTimeFn > >, long unsigned int> >]", "FifoQueue::notify_ev"), + function_tcase(function_style::streamlined, color_spec_type::none(), "token_type xo::tok::tokenizer::assemble_token(const span_type &) const [CharT = char]", "tokenizer::assemble_token"), }); TEST_CASE("function", "[function]") {