shithub: freetype+ttf2subf

Download patch

ref: 630e24d9656817da8b6a24d9383a3b16f94ec656
parent: a984fda881ef98281627614e4ddae2936c12bf73
author: Werner Lemberg <[email protected]>
date: Mon Jun 9 17:20:18 EDT 2008

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.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2008-06-09  VaDiM  <[email protected]>
+
+	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  <[email protected]>
 
 	* README.CVS: Updated.
--- a/builds/win32/ftdebug.c
+++ b/builds/win32/ftdebug.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    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.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -48,18 +48,41 @@
 #ifdef FT_DEBUG_LEVEL_ERROR
 
 
-#  include <stdarg.h>
-#  include <stdlib.h>
-#  include <string.h>
+#include <stdarg.h>
+#include <stdlib.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_Message( const char*  fmt, ... )
   {
-    static char buf[8192];
-    va_list     ap;
+    static char  buf[8192];
+    va_list      ap;
 
 
     va_start( ap, fmt );
@@ -66,7 +89,7 @@
     vprintf( fmt, ap );
     /* send the string to the debugger as well */
     vsprintf( buf, fmt, ap );
-    OutputDebugStringA( buf );
+    OutputDebugStringEx( buf );
     va_end( ap );
   }
 
@@ -74,13 +97,13 @@
   FT_BASE_DEF( void )
   FT_Panic( const char*  fmt, ... )
   {
-    static char buf[8192];
-    va_list     ap;
+    static char  buf[8192];
+    va_list      ap;
 
 
     va_start( ap, fmt );
     vsprintf( buf, fmt, ap );
-    OutputDebugStringA( buf );
+    OutputDebugStringEx( buf );
     va_end( ap );
 
     exit( EXIT_FAILURE );
@@ -87,7 +110,7 @@
   }
 
 
-#  ifdef FT_DEBUG_LEVEL_TRACE
+#ifdef FT_DEBUG_LEVEL_TRACE
 
 
   /* array of trace levels, initialized to 0 */
@@ -94,15 +117,15 @@
   int  ft_trace_levels[trace_count];
 
   /* 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] =
   {
-#    include FT_INTERNAL_TRACE_H
+#include FT_INTERNAL_TRACE_H
     NULL
   };
 
-#    undef FT_TRACE_DEF
+#undef FT_TRACE_DEF
 
 
   /*************************************************************************/
@@ -126,8 +149,19 @@
   FT_BASE_DEF( 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" );
 
+#endif
 
     if ( ft2_debug )
     {
@@ -196,7 +230,7 @@
   }
 
 
-#  else  /* !FT_DEBUG_LEVEL_TRACE */
+#else  /* !FT_DEBUG_LEVEL_TRACE */
 
 
   FT_BASE_DEF( void )
@@ -206,8 +240,9 @@
   }
 
 
-#  endif /* !FT_DEBUG_LEVEL_TRACE */
+#endif /* !FT_DEBUG_LEVEL_TRACE */
 
 #endif /* FT_DEBUG_LEVEL_ERROR */
+
 
 /* END */