diff options
-rw-r--r-- | base/main.cpp | 62 | ||||
-rw-r--r-- | common/util.cpp | 65 | ||||
-rw-r--r-- | common/util.h | 4 |
3 files changed, 65 insertions, 66 deletions
diff --git a/base/main.cpp b/base/main.cpp index 4514da6041..e07ed1a961 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -517,65 +517,3 @@ extern "C" int scummvm_main(int argc, char *argv[]) { return 0; } - -static void debugHelper(char *buf, bool caret = true) { -#ifndef _WIN32_WCE - if (caret) - printf("%s\n", buf); - else - printf("%s", buf); -#endif - -#if defined( USE_WINDBG ) - 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)); - OutputDebugString(buf_unicode); -#else - OutputDebugString(buf); -#endif -#endif - - fflush(stdout); -} - -void CDECL debug(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); -} - -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; - - va_start(va, s); - vsnprintf(buf, STRINGBUFLEN, s, va); - va_end(va); - - debugHelper(buf); -} diff --git a/common/util.cpp b/common/util.cpp index e032601857..0945161c1b 100644 --- a/common/util.cpp +++ b/common/util.cpp @@ -341,6 +341,68 @@ const Array<EngineDebugLevel> &listSpecialDebugLevels() { } // End of namespace Common +static void debugHelper(char *buf, bool caret = true) { +#ifndef _WIN32_WCE + if (caret) + printf("%s\n", buf); + else + printf("%s", buf); +#endif + +#if defined( USE_WINDBG ) + 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)); + OutputDebugString(buf_unicode); +#else + OutputDebugString(buf); +#endif +#endif + + fflush(stdout); +} + +void CDECL debug(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); +} + +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; + + va_start(va, s); + vsnprintf(buf, STRINGBUFLEN, s, va); + va_end(va); + + debugHelper(buf); +} + void CDECL debugC(int level, uint32 engine_level, const char *s, ...) { char buf[STRINGBUFLEN]; va_list va; @@ -352,6 +414,5 @@ void CDECL debugC(int level, uint32 engine_level, const char *s, ...) { vsnprintf(buf, STRINGBUFLEN, s, va); va_end(va); - // pass it to debug for now - debug(level, buf); + debugHelper(buf); } diff --git a/common/util.h b/common/util.h index bb93ea8789..5f6088f176 100644 --- a/common/util.h +++ b/common/util.h @@ -272,10 +272,10 @@ void CDECL warning(const char *s, ...) GCC_PRINTF(1, 2); void CDECL debug(int level, const char *s, ...) GCC_PRINTF(2, 3); void CDECL debug(const char *s, ...) GCC_PRINTF(1, 2); void CDECL debugN(int level, const char *s, ...) GCC_PRINTF(2, 3); -void checkHeap(); - void CDECL debugC(int level, uint32 engine_level, const char *s, ...) GCC_PRINTF(3, 4); +void checkHeap(); + extern int gDebugLevel; |