From 034985c71fd52098706967cbc625bc59a7c31682 Mon Sep 17 00:00:00 2001 From: prefect Date: Mon, 24 Oct 2005 01:43:37 +0000 Subject: [PATCH] app_hooks.cpp: Remove "inline" from ah_xyz functions (gcc doesn't export those functions when inline). debug_putws converts to non-wide characters before printing. This was SVN commit r2993. --- source/lib/app_hooks.cpp | 2 +- source/lib/sysdep/unix/udbg.cpp | 55 ++++++++++----------------------- 2 files changed, 17 insertions(+), 40 deletions(-) diff --git a/source/lib/app_hooks.cpp b/source/lib/app_hooks.cpp index 727a6a5745..98395f555d 100644 --- a/source/lib/app_hooks.cpp +++ b/source/lib/app_hooks.cpp @@ -158,6 +158,6 @@ void set_app_hooks(AppHooks* ah_) // trampolines used by lib code; they call the hooks or fall back to the // default implementation if not set. -#define FUNC(ret, name, params, param_names, call_prefix) inline ret ah_##name params { call_prefix ah.name param_names; } +#define FUNC(ret, name, params, param_names, call_prefix) ret ah_##name params { call_prefix ah.name param_names; } #include "app_hooks.h" #undef FUNC diff --git a/source/lib/sysdep/unix/udbg.cpp b/source/lib/sysdep/unix/udbg.cpp index 0113cd7d86..958edb35d7 100755 --- a/source/lib/sysdep/unix/udbg.cpp +++ b/source/lib/sysdep/unix/udbg.cpp @@ -415,7 +415,22 @@ void debug_puts(const char* text) void debug_putws(const wchar_t* text) { - fputws(text, stdout); + // According to fwide(3) and assorted manpage, FILEs are in single character or in + // wide character mode. When a FILE is in single character mode, wide character writes + // will fail, and no conversion is done automatically. Thus the manual conversion. + size_t convbuflen = wcstombs(NULL, text, 0)+1; + char* convbuf = (char*)malloc(convbuflen); + int ret = wcstombs(convbuf, text, convbuflen); + + if (ret < 0 || ret >= convbuflen) { + printf("debug_wprintf: wcstombs failed\n"); + free(convbuf); + fflush(stdout); + return; + } + + fputs(convbuf, stdout); + free(convbuf); fflush(stdout); } @@ -445,44 +460,6 @@ void debug_heap_enable(DebugHeapChecks what) // No-op until we find out if glibc has heap debugging } -void debug_wprintf(const wchar_t* fmt, ...) -{ - wchar_t buf[512]; - int ret; - - va_list args; - va_start(args, fmt); - ret = vswprintf(buf, ARRAY_SIZE(buf), fmt, args); - va_end(args); - - if (ret < 0) - { - char errbuf[256]; - strerror_r(errno, errbuf, ARRAY_SIZE(errbuf)); - printf("debug_wprintf: %s (%ls)\n", errbuf, fmt); - fflush(stdout); - return; - } - - // According to fwide(3) and assorted manpage, FILEs are in single character or in - // wide character mode. When a FILE is in single character mode, wide character writes - // will fail, and no conversion is done automatically. Thus the manual conversion. - size_t convbuflen = wcstombs(NULL, buf, 0)+1; - char* convbuf = (char*)malloc(convbuflen); - ret = wcstombs(convbuf, buf, convbuflen); - - if (ret < 0 || ret >= convbuflen) { - printf("debug_wprintf: wcstombs failed\n"); - free(convbuf); - fflush(stdout); - return; - } - - fputs(convbuf, stdout); - free(convbuf); - fflush(stdout); -} - // disable all automatic checks until the next debug_heap_enable. void debug_heap_disable() {