From d3d13329d98b2b26378813a91ad0d4e49045a426 Mon Sep 17 00:00:00 2001 From: John Wiegley Date: Tue, 28 Feb 2012 01:37:19 -0600 Subject: Made the --debug option's argument a regex --- src/utils.h | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'src/utils.h') diff --git a/src/utils.h b/src/utils.h index e1a03d79..c7aaac52 100644 --- a/src/utils.h +++ b/src/utils.h @@ -338,10 +338,32 @@ extern uint8_t _trace_level; #if defined(DEBUG_ON) -extern optional _log_category; +extern optional _log_category; +#if defined(HAVE_BOOST_REGEX_UNICODE) + extern optional _log_category_re; +#else + extern optional _log_category_re; +#endif inline bool category_matches(const char * cat) { - return _log_category && starts_with(cat, *_log_category); + if (_log_category) { + if (! _log_category_re) { + _log_category_re = +#if defined(HAVE_BOOST_REGEX_UNICODE) + boost::make_u32regex(_log_category->c_str(), + boost::regex::perl | boost::regex::icase); +#else + boost::make_regex(_log_category->c_str(), + boost::regex::perl | boost::regex::icase); +#endif + } +#if defined(HAVE_BOOST_REGEX_UNICODE) + return boost::u32regex_search(cat, *_log_category_re); +#else + return boost::regex_search(cat, *_log_category_re); +#endif + } + return false; } #define SHOW_DEBUG(cat) \ -- cgit v1.2.3