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.
This commit is contained in:
parent
b80be29eab
commit
034985c71f
@ -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
|
||||
|
@ -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()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user