Support debugging on WinCE. From Savannah patch #6536; this fixes

bug #23497.

* builds/win32/ftdebug.c (OutputDebugStringEx): New function/macro
as a replacement for OutputDebugStringA (which WinCE doesn't have).
Update all callers.
(ft_debug_init) [_WIN32_CE]: WinCE apparently doesn't have
environment variables.
This commit is contained in:
Werner Lemberg 2008-06-09 21:20:18 +00:00
parent a984fda881
commit 630e24d965
2 changed files with 63 additions and 17 deletions

View File

@ -1,3 +1,14 @@
2008-06-09 VaDiM <s_sliva@rambler.ru>
Support debugging on WinCE. From Savannah patch #6536; this fixes
bug #23497.
* builds/win32/ftdebug.c (OutputDebugStringEx): New function/macro
as a replacement for OutputDebugStringA (which WinCE doesn't have).
Update all callers.
(ft_debug_init) [_WIN32_CE]: WinCE apparently doesn't have
environment variables.
2008-06-09 Werner Lemberg <wl@gnu.org> 2008-06-09 Werner Lemberg <wl@gnu.org>
* README.CVS: Updated. * README.CVS: Updated.

View File

@ -4,7 +4,7 @@
/* */ /* */
/* Debugging and logging component for Win32 (body). */ /* Debugging and logging component for Win32 (body). */
/* */ /* */
/* Copyright 1996-2001, 2002, 2005 by */ /* Copyright 1996-2001, 2002, 2005, 2008 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */ /* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */ /* */
/* This file is part of the FreeType project, and may only be used, */ /* This file is part of the FreeType project, and may only be used, */
@ -48,25 +48,48 @@
#ifdef FT_DEBUG_LEVEL_ERROR #ifdef FT_DEBUG_LEVEL_ERROR
# include <stdarg.h> #include <stdarg.h>
# include <stdlib.h> #include <stdlib.h>
# include <string.h> #include <string.h>
# include <windows.h> #include <windows.h>
#ifdef _WIN32_WCE
void
OutputDebugStringEx( const char* str )
{
static WCHAR buf[8192];
int sz = MultiByteToWideChar( CP_ACP, 0, str, -1, buf,
sizeof ( buf ) / sizeof ( *buf ) );
if ( !sz )
lstrcpyW( buf, L"OutputDebugStringEx: MultiByteToWideChar failed" );
OutputDebugStringW( buf );
}
#else
#define OutputDebugStringEx OutputDebugStringA
#endif
FT_BASE_DEF( void ) FT_BASE_DEF( void )
FT_Message( const char* fmt, ... ) FT_Message( const char* fmt, ... )
{ {
static char buf[8192]; static char buf[8192];
va_list ap; va_list ap;
va_start( ap, fmt ); va_start( ap, fmt );
vprintf( fmt, ap ); vprintf( fmt, ap );
/* send the string to the debugger as well */ /* send the string to the debugger as well */
vsprintf( buf, fmt, ap ); vsprintf( buf, fmt, ap );
OutputDebugStringA( buf ); OutputDebugStringEx( buf );
va_end( ap ); va_end( ap );
} }
@ -74,35 +97,35 @@
FT_BASE_DEF( void ) FT_BASE_DEF( void )
FT_Panic( const char* fmt, ... ) FT_Panic( const char* fmt, ... )
{ {
static char buf[8192]; static char buf[8192];
va_list ap; va_list ap;
va_start( ap, fmt ); va_start( ap, fmt );
vsprintf( buf, fmt, ap ); vsprintf( buf, fmt, ap );
OutputDebugStringA( buf ); OutputDebugStringEx( buf );
va_end( ap ); va_end( ap );
exit( EXIT_FAILURE ); exit( EXIT_FAILURE );
} }
# ifdef FT_DEBUG_LEVEL_TRACE #ifdef FT_DEBUG_LEVEL_TRACE
/* array of trace levels, initialized to 0 */ /* array of trace levels, initialized to 0 */
int ft_trace_levels[trace_count]; int ft_trace_levels[trace_count];
/* define array of trace toggle names */ /* define array of trace toggle names */
# define FT_TRACE_DEF( x ) #x , #define FT_TRACE_DEF( x ) #x ,
static const char* ft_trace_toggles[trace_count + 1] = static const char* ft_trace_toggles[trace_count + 1] =
{ {
# include FT_INTERNAL_TRACE_H #include FT_INTERNAL_TRACE_H
NULL NULL
}; };
# undef FT_TRACE_DEF #undef FT_TRACE_DEF
/*************************************************************************/ /*************************************************************************/
@ -126,8 +149,19 @@
FT_BASE_DEF( void ) FT_BASE_DEF( void )
ft_debug_init( void ) ft_debug_init( void )
{ {
#ifdef _WIN32_WCE
/* Windows Mobile doesn't have environment API: */
/* GetEnvironmentStrings, GetEnvironmentVariable, getenv. */
/* */
/* FIXME!!! How to set debug mode? */
const char* ft2_debug = 0;
#else
const char* ft2_debug = getenv( "FT2_DEBUG" ); const char* ft2_debug = getenv( "FT2_DEBUG" );
#endif
if ( ft2_debug ) if ( ft2_debug )
{ {
@ -196,7 +230,7 @@
} }
# else /* !FT_DEBUG_LEVEL_TRACE */ #else /* !FT_DEBUG_LEVEL_TRACE */
FT_BASE_DEF( void ) FT_BASE_DEF( void )
@ -206,8 +240,9 @@
} }
# endif /* !FT_DEBUG_LEVEL_TRACE */ #endif /* !FT_DEBUG_LEVEL_TRACE */
#endif /* FT_DEBUG_LEVEL_ERROR */ #endif /* FT_DEBUG_LEVEL_ERROR */
/* END */ /* END */