summaryrefslogtreecommitdiff
path: root/debug.h
diff options
context:
space:
mode:
authorJohn Wiegley <johnw@newartisans.com>2004-08-13 18:23:34 -0400
committerJohn Wiegley <johnw@newartisans.com>2004-08-13 18:23:34 -0400
commit02798277683dbc8a43e5908e62fadf9c28b321b2 (patch)
tree3ac5690645d9b694e1042f11439275f01c24dd16 /debug.h
parent0cac03ba7d0a5ab95e1d81d68102778cb995a363 (diff)
downloadfork-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.h15
1 files changed, 13 insertions, 2 deletions
diff --git a/debug.h b/debug.h
index 86f57339..7fb97c7f 100644
--- a/debug.h
+++ b/debug.h
@@ -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)