summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/lto/20091013-1_1.c
blob: 68294fa62cbd4d9b071e5eae57016cdcf4748def (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
typedef struct HDC__ { int unused; } *HDC;
typedef struct HFONT__ { int unused; } *HFONT;

typedef struct
{
  unsigned int ciACP;
} CHARSETINFO, *PCHARSETINFO, *LPCHARSETINFO;

typedef struct tagTEXTMETRICW
{
    int tmCharSet;
} TEXTMETRICW, *LPTEXTMETRICW, *PTEXTMETRICW;

struct gdi_obj_funcs
{
    void* (*pSelectObject)( void* handle, void* hdc );
};

typedef struct tagGdiFont GdiFont;

typedef struct tagDC
{
    int xunused;
    GdiFont *gdiFont;
    unsigned int font_code_page;
} DC;

extern GdiFont* WineEngCreateFontInstance(DC*, HFONT);
extern unsigned int WineEngGetTextCharsetInfo(GdiFont *font, void* fs, unsigned int flags);
extern int WineEngGetTextMetrics(GdiFont*, LPTEXTMETRICW);
extern void* alloc_gdi_handle( void *obj, unsigned short type, const struct gdi_obj_funcs *funcs );

enum __wine_debug_class
{
    __WINE_DBCL_FIXME,
    __WINE_DBCL_ERR,
    __WINE_DBCL_WARN,
    __WINE_DBCL_TRACE,

    __WINE_DBCL_INIT = 7
};

struct __wine_debug_channel
{
    unsigned char flags;
    char name[15];
};

extern int wine_dbg_log( enum __wine_debug_class cls, struct __wine_debug_channel *ch, const char *func,
                         const char *format, ... ) __attribute__((format (printf,4,5)));

static struct __wine_debug_channel __wine_dbch_font = { ~0, "font" };
static struct __wine_debug_channel * const __wine_dbch___default = &__wine_dbch_font;

static void* FONT_SelectObject( void* handle, void* hdc );

static const struct gdi_obj_funcs font_funcs =
{
    FONT_SelectObject,
};

HFONT CreateFontIndirectW( const void *plf )
{
    return alloc_gdi_handle( 0, 6, &font_funcs );
}

static void update_font_code_page( DC *dc )
{
    CHARSETINFO csi;
    int charset = (unsigned char)1;

    if (dc->gdiFont)
        charset = WineEngGetTextCharsetInfo( dc->gdiFont, ((void *)0), 0 );

    if (TranslateCharsetInfo( ((void *)(unsigned long)((unsigned long)charset)), &csi, 1) )
        dc->font_code_page = csi.ciACP;
    else {
        switch(charset) {
        case (unsigned char)1:
            dc->font_code_page = GetACP();
            break;

        case (unsigned char)246:
            dc->font_code_page = 0;
            break;

        default:
            do { if((((__wine_dbch___default))->flags & (1 << __WINE_DBCL_FIXME))) { struct __wine_debug_channel * const __dbch = (__wine_dbch___default); const enum __wine_debug_class __dbcl = __WINE_DBCL_FIXME; wine_dbg_log( __dbcl, __dbch, __FUNCTION__, "Can't find codepage for charset %d\n", charset); } } while(0);
            dc->font_code_page = 0;
            break;
        }
    }

    do { if((((__wine_dbch___default))->flags & (1 << __WINE_DBCL_TRACE))) { struct __wine_debug_channel * const __dbch = (__wine_dbch___default); const enum __wine_debug_class __dbcl = __WINE_DBCL_TRACE; wine_dbg_log( __dbcl, __dbch, __FUNCTION__, "charset %d => cp %d\n", charset, dc->font_code_page); } } while(0);
}

static void* FONT_SelectObject( void* handle, void* hdc )
{
    DC *dc;

    dc->gdiFont = WineEngCreateFontInstance( dc, handle );
    update_font_code_page( dc );
    return 0;
}

int GetTextMetricsW( HDC hdc, TEXTMETRICW *metrics )
{
    DC * dc;
    return WineEngGetTextMetrics(dc->gdiFont, metrics);
}