aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--base/main.cpp22
-rw-r--r--common/util.h1
2 files changed, 20 insertions, 3 deletions
diff --git a/base/main.cpp b/base/main.cpp
index 84b26599af..6c67fbe013 100644
--- a/base/main.cpp
+++ b/base/main.cpp
@@ -489,13 +489,15 @@ extern "C" int main(int argc, char *argv[]) {
END_OF_MAIN();
#endif
-static void debugHelper(char *buf) {
+static void debugHelper(char *buf, bool caret = true) {
#ifndef _WIN32_WCE
- printf("%s\n", buf);
+ if (caret)
+ printf("%s\n", buf);
#endif
#if defined( USE_WINDBG )
- strcat(buf, "\n");
+ if (caret)
+ strcat(buf, "\n");
#if defined( _WIN32_WCE )
TCHAR buf_unicode[1024];
MultiByteToWideChar(CP_ACP, 0, buf, strlen(buf) + 1, buf_unicode, sizeof(buf_unicode));
@@ -522,6 +524,20 @@ void CDECL debug(int level, const char *s, ...) {
debugHelper(buf);
}
+void CDECL debugN(int level, const char *s, ...) {
+ char buf[STRINGBUFLEN];
+ va_list va;
+
+ if (level > gDebugLevel)
+ return;
+
+ va_start(va, s);
+ vsnprintf(buf, STRINGBUFLEN, s, va);
+ va_end(va);
+
+ debugHelper(buf, false);
+}
+
void CDECL debug(const char *s, ...) {
char buf[STRINGBUFLEN];
va_list va;
diff --git a/common/util.h b/common/util.h
index 05c1520513..cd97363376 100644
--- a/common/util.h
+++ b/common/util.h
@@ -209,6 +209,7 @@ void CDECL warning(const char *s, ...);
void CDECL debug(int level, const char *s, ...);
void CDECL debug(const char *s, ...);
+void CDECL debugN(int level, const char *s, ...);
void checkHeap();
extern int gDebugLevel;