freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Git][freetype/freetype][master] [builds/windows] Improve debugging.


From: Alexei Podtelezhnikov (@apodtele)
Subject: [Git][freetype/freetype][master] [builds/windows] Improve debugging.
Date: Tue, 30 Nov 2021 01:54:28 +0000

Alexei Podtelezhnikov pushed to branch master at FreeType / FreeType

Commits:

1 changed file:

Changes:

  • builds/windows/ftdebug.c
    ... ... @@ -93,28 +93,57 @@
    93 93
     
    
    94 94
     #ifdef FT_DEBUG_LEVEL_ERROR
    
    95 95
     
    
    96
    -#include <stdarg.h>
    
    97
    -#include <stdlib.h>
    
    98
    -#include <string.h>
    
    99
    -
    
    96
    +#define WIN32_LEAN_AND_MEAN
    
    100 97
     #include <windows.h>
    
    101 98
     
    
    102 99
     
    
    100
    +#ifdef _WIN32_WCE
    
    101
    +
    
    102
    +  FT_LOACAL_DEF( void )
    
    103
    +  OutputDebugStringA( LPCSTR lpOutputString )
    
    104
    +  {
    
    105
    +    int            len;
    
    106
    +    LPWSTR         lpOutputStringW;
    
    107
    +
    
    108
    +
    
    109
    +    /* allocate memory space for converted string */
    
    110
    +    len = MultiByteToWideChar( CP_ACP, MB_ERR_INVALID_CHARS,
    
    111
    +                               lpOutputString, -1, NULL, 0 );
    
    112
    +
    
    113
    +    lpOutputStringW = (LPWSTR)_alloca( len * sizeof ( WCHAR ) );
    
    114
    +
    
    115
    +    if ( !len || !lpOutputStringW )
    
    116
    +      return;
    
    117
    +
    
    118
    +    /* now it is safe to do the translation */
    
    119
    +    MultiByteToWideChar( CP_ACP, MB_ERR_INVALID_CHARS,
    
    120
    +                         lpOutputString, -1, lpOutputStringW, len );
    
    121
    +
    
    122
    +    OutputDebugStringW( lpOutputStringW );
    
    123
    +  }
    
    124
    +
    
    125
    +#endif /* _WIN32_WCE */
    
    126
    +
    
    127
    +
    
    103 128
       /* documentation is in ftdebug.h */
    
    104 129
     
    
    105 130
       FT_BASE_DEF( void )
    
    106 131
       FT_Message( const char*  fmt,
    
    107 132
                   ... )
    
    108 133
       {
    
    109
    -    static char  buf[8192];
    
    110
    -    va_list      ap;
    
    134
    +    va_list  ap;
    
    111 135
     
    
    112 136
     
    
    113 137
         va_start( ap, fmt );
    
    114 138
         vfprintf( stderr, fmt, ap );
    
    115
    -    /* send the string to the debugger as well */
    
    116
    -    vsprintf( buf, fmt, ap );
    
    117
    -    OutputDebugStringA( buf );
    
    139
    +    if ( IsDebuggerPresent() )
    
    140
    +    {
    
    141
    +      static char  buf[1024];
    
    142
    +
    
    143
    +
    
    144
    +      vsnprintf( buf, sizeof buf, fmt, ap );
    
    145
    +      OutputDebugStringA( buf );
    
    146
    +    }
    
    118 147
         va_end( ap );
    
    119 148
       }
    
    120 149
     
    
    ... ... @@ -125,13 +154,19 @@
    125 154
       FT_Panic( const char*  fmt,
    
    126 155
                 ... )
    
    127 156
       {
    
    128
    -    static char  buf[8192];
    
    129
    -    va_list      ap;
    
    157
    +    va_list  ap;
    
    130 158
     
    
    131 159
     
    
    132 160
         va_start( ap, fmt );
    
    133
    -    vsprintf( buf, fmt, ap );
    
    134
    -    OutputDebugStringA( buf );
    
    161
    +    vfprintf( stderr, fmt, ap );
    
    162
    +    if ( IsDebuggerPresent() )
    
    163
    +    {
    
    164
    +      static char  buf[1024];
    
    165
    +
    
    166
    +
    
    167
    +      vsnprintf( buf, sizeof buf, fmt, ap );
    
    168
    +      OutputDebugStringA( buf );
    
    169
    +    }
    
    135 170
         va_end( ap );
    
    136 171
     
    
    137 172
         exit( EXIT_FAILURE );
    


  • reply via email to

    [Prev in Thread] Current Thread [Next in Thread]