diff options
author | John Wiegley <johnw@newartisans.com> | 2004-08-13 18:23:34 -0400 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2004-08-13 18:23:34 -0400 |
commit | 02798277683dbc8a43e5908e62fadf9c28b321b2 (patch) | |
tree | 3ac5690645d9b694e1042f11439275f01c24dd16 /debug.h | |
parent | 0cac03ba7d0a5ab95e1d81d68102778cb995a363 (diff) | |
download | fork-ledger-02798277683dbc8a43e5908e62fadf9c28b321b2.tar.gz fork-ledger-02798277683dbc8a43e5908e62fadf9c28b321b2.tar.bz2 fork-ledger-02798277683dbc8a43e5908e62fadf9c28b321b2.zip |
added timing code
Diffstat (limited to 'debug.h')
-rw-r--r-- | debug.h | 15 |
1 files changed, 13 insertions, 2 deletions
@@ -59,6 +59,9 @@ namespace ledger { #if RELEASE_LEVEL >= ALPHA +#include <pcre.h> +#include <cstring> + #define DEBUG_ENABLED extern std::ostream * warning_stream; @@ -66,8 +69,16 @@ extern std::ostream * debug_stream; extern bool free_debug_stream; inline bool _debug_active(const char * const cls) { - char * debug = std::getenv("DEBUG_CLASS"); - return debug && std::strcmp(debug, cls) == 0; + if (char * debug = std::getenv("DEBUG_CLASS")) { + static const char * error; + static int erroffset; + static int ovec[30]; + static pcre * class_regexp = pcre_compile(debug, PCRE_CASELESS, + &error, &erroffset, NULL); + return pcre_exec(class_regexp, NULL, cls, std::strlen(cls), + 0, 0, ovec, 30) >= 0; + } + return false; } #define DEBUG_CLASS(cls) static const char * const _debug_cls = (cls) |