Commit f22ba056 authored by Alexandre Julliard's avatar Alexandre Julliard

Added support for #pragma code_page.

Fixed a few bugs in language handling. Added error message when Ansi->Unicode conversion in the current codepage loses information.
parent b64583e5
......@@ -17,6 +17,7 @@
*/
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL
#pragma code_page(936) /* FIXME: default for CHINESE_TRADITIONAL is 950 */
OPEN_FILE DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 275, 134
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
......@@ -220,3 +221,5 @@ STRINGTABLE DISCARDABLE
IDS_REPORTVIEW "詳細資料"
IDS_TODESKTOP "顯示桌面"
}
#pragma code_page(default)
......@@ -17,6 +17,7 @@
*/
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL
#pragma code_page(936) /* FIXME: default for CHINESE_TRADITIONAL is 950 */
SHELL_ABOUT_MSGBOX DIALOG LOADONCALL MOVEABLE DISCARDABLE 15, 40, 210, 152
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
......@@ -55,3 +56,5 @@ BEGIN
IDS_SHV_COLUMN6 "使用空間"
IDS_SHV_COLUMN7 "剩餘空間"
END
#pragma code_page(default)
......@@ -76,6 +76,7 @@ STRINGTABLE DISCARDABLE
}
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_TRADITIONAL
#pragma code_page(936) /* FIXME: default for CHINESE_TRADITIONAL is 950 */
SYSMENU MENU LOADONCALL MOVEABLE DISCARDABLE
{
......@@ -133,3 +134,5 @@ STRINGTABLE DISCARDABLE
{
MDI_IDS_MOREWINDOWS "更多視窗(&M)..." /* defined in mdi.h */
}
#pragma code_page(default)
......@@ -385,6 +385,7 @@ typedef LPCSTR PCTSTR, LPCTSTR;
#endif /* __WINE__ */
/* Misc common WIN32 types */
typedef char CCHAR;
typedef LONG HRESULT;
typedef DWORD LCID, *PLCID;
typedef WORD LANGID;
......@@ -1236,13 +1237,12 @@ static DWORD __builtin_return_address(int p_iDepth)
#define LOCALE_USER_DEFAULT (MAKELCID(LANG_USER_DEFAULT, SORT_DEFAULT))
#define LOCALE_NEUTRAL (MAKELCID(MAKELANGID(LANG_NEUTRAL,SUBLANG_NEUTRAL),SORT_DEFAULT))
/* FIXME: are the symbolic names correct for LIDs: 0x17, 0x20, 0x28,
* 0x2a, 0x2b, 0x2c, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35,
* 0x37, 0x39, 0x3a, 0x3b, 0x3c, 0x3e, 0x3f, 0x41, 0x43, 0x44,
* 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e,
* 0x4f, 0x57
/* FIXME: are the symbolic names correct for LIDs: 0x17, 0x28,
* 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x3a, 0x3b, 0x3c
*/
#define LANG_NEUTRAL 0x00
#define LANG_INVARIANT 0x7f
#define LANG_AFRIKAANS 0x36
#define LANG_ALBANIAN 0x1c
#define LANG_ARABIC 0x01
......@@ -1250,16 +1250,15 @@ static DWORD __builtin_return_address(int p_iDepth)
#define LANG_ASSAMESE 0x4d
#define LANG_AZERI 0x2c
#define LANG_BASQUE 0x2d
#define LANG_BELARUSIAN 0x23
#define LANG_BENGALI 0x45
#define LANG_BULGARIAN 0x02
#define LANG_BYELORUSSIAN 0x23
#define LANG_CATALAN 0x03
#define LANG_CHINESE 0x04
#define LANG_SERBO_CROATIAN 0x1a
#define LANG_CROATIAN LANG_SERBO_CROATIAN
#define LANG_SERBIAN LANG_SERBO_CROATIAN
#define LANG_CROATIAN 0x1a
#define LANG_CZECH 0x05
#define LANG_DANISH 0x06
#define LANG_DIVEHI 0x65
#define LANG_DUTCH 0x13
#define LANG_ENGLISH 0x09
#define LANG_ESTONIAN 0x25
......@@ -1267,12 +1266,12 @@ static DWORD __builtin_return_address(int p_iDepth)
#define LANG_FARSI 0x29
#define LANG_FINNISH 0x0b
#define LANG_FRENCH 0x0c
#define LANG_GAELIC 0x3c
#define LANG_GALICIAN 0x56
#define LANG_GEORGIAN 0x37
#define LANG_GERMAN 0x07
#define LANG_GREEK 0x08
#define LANG_GUJARATI 0x47
#define LANG_HEBREW 0x0D
#define LANG_HEBREW 0x0d
#define LANG_HINDI 0x39
#define LANG_HUNGARIAN 0x0e
#define LANG_ICELANDIC 0x0f
......@@ -1280,48 +1279,60 @@ static DWORD __builtin_return_address(int p_iDepth)
#define LANG_ITALIAN 0x10
#define LANG_JAPANESE 0x11
#define LANG_KANNADA 0x4b
#define LANG_KAZAKH 0x3f
#define LANG_KASHMIRI 0x60
#define LANG_KAZAK 0x3f
#define LANG_KONKANI 0x57
#define LANG_KOREAN 0x12
#define LANG_KYRGYZ 0x40
#define LANG_LATVIAN 0x26
#define LANG_LITHUANIAN 0x27
#define LANG_MACEDONIAN 0x2f
#define LANG_MALAY 0x3e
#define LANG_MALAYALAM 0x4c
#define LANG_MALTESE 0x3a
#define LANG_MAORI 0x28
#define LANG_MANIPURI 0x58
#define LANG_MARATHI 0x4e
#define LANG_MONGOLIAN 0x50
#define LANG_NEPALI 0x61
#define LANG_NORWEGIAN 0x14
#define LANG_ORIYA 0x48
#define LANG_POLISH 0x15
#define LANG_PORTUGUESE 0x16
#define LANG_PUNJABI 0x46
#define LANG_RHAETO_ROMANCE 0x17
#define LANG_ROMANIAN 0x18
#define LANG_RUSSIAN 0x19
#define LANG_SAAMI 0x3b
#define LANG_SANSKRIT 0x4f
#define LANG_SERBIAN 0x1a
#define LANG_SINDHI 0x59
#define LANG_SLOVAK 0x1b
#define LANG_SLOVENIAN 0x24
#define LANG_SORBIAN 0x2e
#define LANG_SPANISH 0x0a
#define LANG_SUTU 0x30
#define LANG_SWAHILI 0x41
#define LANG_SWEDISH 0x1d
#define LANG_SYRIAC 0x5a
#define LANG_TAMIL 0x49
#define LANG_TATAR 0x44
#define LANG_TELUGU 0x4a
#define LANG_THAI 0x1e
#define LANG_TSONGA 0x31
#define LANG_TSWANA 0x32
#define LANG_TURKISH 0x1f
#define LANG_UKRAINIAN 0x22
#define LANG_URDU 0x20
#define LANG_UZBEK 0x43
#define LANG_VENDA 0x33
#define LANG_VIETNAMESE 0x2a
/* FIXME: these are not in the Windows header */
#define LANG_GAELIC 0x3c
#define LANG_MALTESE 0x3a
#define LANG_MAORI 0x28
#define LANG_RHAETO_ROMANCE 0x17
#define LANG_SAAMI 0x3b
#define LANG_SORBIAN 0x2e
#define LANG_SUTU 0x30
#define LANG_TSONGA 0x31
#define LANG_TSWANA 0x32
#define LANG_VENDA 0x33
#define LANG_XHOSA 0x34
#define LANG_ZULU 0x35
/* non standard; keep the number high enough (but < 0xff) */
#define LANG_ESPERANTO 0x8f
#define LANG_WALON 0x90
......@@ -1334,7 +1345,6 @@ static DWORD __builtin_return_address(int p_iDepth)
#define SUBLANG_DEFAULT 0x01 /* user default */
#define SUBLANG_SYS_DEFAULT 0x02 /* system default */
#define SUBLANG_ARABIC 0x01
#define SUBLANG_ARABIC_SAUDI_ARABIA 0x01
#define SUBLANG_ARABIC_IRAQ 0x02
#define SUBLANG_ARABIC_EGYPT 0x03
......@@ -1351,6 +1361,8 @@ static DWORD __builtin_return_address(int p_iDepth)
#define SUBLANG_ARABIC_UAE 0x0e
#define SUBLANG_ARABIC_BAHRAIN 0x0f
#define SUBLANG_ARABIC_QATAR 0x10
#define SUBLANG_AZERI_LATIN 0x01
#define SUBLANG_AZERI_CYRILLIC 0x02
#define SUBLANG_CHINESE_TRADITIONAL 0x01
#define SUBLANG_CHINESE_SIMPLIFIED 0x02
#define SUBLANG_CHINESE_HONGKONG 0x03
......@@ -1358,16 +1370,15 @@ static DWORD __builtin_return_address(int p_iDepth)
#define SUBLANG_CHINESE_MACAU 0x05
#define SUBLANG_DUTCH 0x01
#define SUBLANG_DUTCH_BELGIAN 0x02
#define SUBLANG_DUTCH_SURINAM 0x03
#define SUBLANG_ENGLISH_US 0x01
#define SUBLANG_ENGLISH_UK 0x02
#define SUBLANG_ENGLISH_AUS 0x03
#define SUBLANG_ENGLISH_CAN 0x04
#define SUBLANG_ENGLISH_NZ 0x05
#define SUBLANG_ENGLISH_EIRE 0x06
#define SUBLANG_ENGLISH_SAFRICA 0x07
#define SUBLANG_ENGLISH_SOUTH_AFRICA 0x07
#define SUBLANG_ENGLISH_JAMAICA 0x08
#define SUBLANG_ENGLISH_CARRIBEAN 0x09
#define SUBLANG_ENGLISH_CARIBBEAN 0x09
#define SUBLANG_ENGLISH_BELIZE 0x0a
#define SUBLANG_ENGLISH_TRINIDAD 0x0b
#define SUBLANG_ENGLISH_ZIMBABWE 0x0c
......@@ -1385,19 +1396,26 @@ static DWORD __builtin_return_address(int p_iDepth)
#define SUBLANG_GERMAN_LIECHTENSTEIN 0x05
#define SUBLANG_ITALIAN 0x01
#define SUBLANG_ITALIAN_SWISS 0x02
#define SUBLANG_KASHMIRI_SASIA 0x02
#define SUBLANG_KASHMIRI_INDIA 0x02
#define SUBLANG_KOREAN 0x01
#define SUBLANG_KOREAN_JOHAB 0x02
#define SUBLANG_LITHUANIAN 0x01
#define SUBLANG_MALAY_MALAYSIA 0x01
#define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
#define SUBLANG_NEPALI_INDIA 0x02
#define SUBLANG_NORWEGIAN_BOKMAL 0x01
#define SUBLANG_NORWEGIAN_NYNORSK 0x02
#define SUBLANG_PORTUGUESE 0x02
#define SUBLANG_PORTUGUESE_BRAZILIAN 0x01
#define SUBLANG_SERBIAN_LATIN 0x02
#define SUBLANG_SERBIAN_CYRILLIC 0x03
#define SUBLANG_SPANISH 0x01
#define SUBLANG_SPANISH_MEXICAN 0x02
#define SUBLANG_SPANISH_MODERN 0x03
#define SUBLANG_SPANISH_GUATEMALA 0x04
#define SUBLANG_SPANISH_COSTARICA 0x05
#define SUBLANG_SPANISH_COSTA_RICA 0x05
#define SUBLANG_SPANISH_PANAMA 0x06
#define SUBLANG_SPANISH_DOMINICAN 0x07
#define SUBLANG_SPANISH_DOMINICAN_REPUBLIC 0x07
#define SUBLANG_SPANISH_VENEZUELA 0x08
#define SUBLANG_SPANISH_COLOMBIA 0x09
#define SUBLANG_SPANISH_PERU 0x0a
......@@ -1411,29 +1429,24 @@ static DWORD __builtin_return_address(int p_iDepth)
#define SUBLANG_SPANISH_HONDURAS 0x12
#define SUBLANG_SPANISH_NICARAGUA 0x13
#define SUBLANG_SPANISH_PUERTO_RICO 0x14
/* FIXME: I don't know the symbolic names for those */
#define SUBLANG_SWEDISH 0x01
#define SUBLANG_SWEDISH_FINLAND 0x02
#define SUBLANG_URDU_PAKISTAN 0x01
#define SUBLANG_URDU_INDIA 0x02
#define SUBLANG_UZBEK_LATIN 0x01
#define SUBLANG_UZBEK_CYRILLIC 0x02
/* FIXME: these are not in the Windows header */
#define SUBLANG_DUTCH_SURINAM 0x03
#define SUBLANG_ROMANIAN 0x01
#define SUBLANG_ROMANIAN_MOLDAVIA 0x02
#define SUBLANG_RUSSIAN 0x01
#define SUBLANG_RUSSIAN_MOLDAVIA 0x02
#define SUBLANG_CROATIAN 0x01
#define SUBLANG_SERBIAN 0x02
#define SUBLANG_SERBIAN_LATIN 0x03
#define SUBLANG_SWEDISH 0x01
#define SUBLANG_SWEDISH_FINLAND 0x02
#define SUBLANG_LITHUANIAN 0x01
#define SUBLANG_LITHUANIAN_CLASSIC 0x02
#define SUBLANG_AZERI 0x01
#define SUBLANG_AZERI_CYRILLIC 0x02
#define SUBLANG_GAELIC 0x01
#define SUBLANG_GAELIC_SCOTTISH 0x02
#define SUBLANG_GAELIC_MANX 0x03
#define SUBLANG_MALAY 0x01
#define SUBLANG_MALAY_BRUNEI_DARUSSALAM 0x02
#define SUBLANG_UZBEK 0x01
#define SUBLANG_UZBEK_CYRILLIC 0x02
#define SUBLANG_URDU_PAKISTAN 0x01
/*
......
......@@ -284,7 +284,7 @@ preprocessor
| tGCCLINE tNL /* The null-token */
| tERROR opt_text tNL { pperror("#error directive: '%s'", $2); if($2) free($2); }
| tWARNING opt_text tNL { ppwarning("#warning directive: '%s'", $2); if($2) free($2); }
| tPRAGMA opt_text tNL { if(pp_status.pedantic) ppwarning("#pragma ignored (arg: '%s')", $2); if($2) free($2); }
| tPRAGMA opt_text tNL { fprintf(ppout, "#pragma %s\n", $2 ? $2 : ""); if ($2) free($2); }
| tPPIDENT opt_text tNL { if(pp_status.pedantic) ppwarning("#ident ignored (arg: '%s')", $2); if($2) free($2); }
| tRCINCLUDE tRCINCLUDEPATH {
int nl=strlen($2) +3;
......
......@@ -82,6 +82,9 @@
%x pp_stripp_final
/* Set when scanning #line style directives */
%x pp_line
/* Set when scanning #pragma */
%x pp_pragma
%x pp_code_page
%option stack
%option never-interactive
......@@ -100,6 +103,7 @@ cident [a-zA-Z_][0-9a-zA-Z_]*
#include <ctype.h>
#include <assert.h>
#include "wine/unicode.h"
#include "wrc.h"
#include "utils.h"
#include "parser.h"
......@@ -115,7 +119,7 @@ cident [a-zA-Z_][0-9a-zA-Z_]*
#define YY_USER_ACTION char_number+=yyleng; wanted_id = want_id; want_id = 0;
static void addcchar(char c);
static void addwchar(short s);
static void addwchar(WCHAR s);
static string_t *get_buffered_cstring(void);
static string_t *get_buffered_wstring(void);
static string_t *make_string(char *s);
......@@ -123,13 +127,15 @@ static string_t *make_string(char *s);
static char *cbuffer; /* Buffers for string collection */
static int cbufidx;
static int cbufalloc = 0;
static short *wbuffer;
static WCHAR *wbuffer;
static int wbufidx;
static int wbufalloc = 0;
static int stripslevel = 0; /* Count {} during pp_strips/pp_stripe mode */
static int stripplevel = 0; /* Count () during pp_strips mode */
static int cjunk_tagline; /* Where did we start stripping (helps error tracking) */
static int current_codepage = -1; /* use language default */
/*
* This one is a bit tricky.
* We set 'want_id' in the parser to get the first
......@@ -316,6 +322,7 @@ static struct keyword *iskeyword(char *kw)
* because we only want to know the linenumber and
* filename.
*/
<INITIAL,pp_strips,pp_stripp>^{ws}*\#{ws}*pragma{ws}+ yy_push_state(pp_pragma);
<INITIAL,pp_strips,pp_stripp>^{ws}*\#{ws}* yy_push_state(pp_line);
<pp_line>[^\n]* {
int lineno;
......@@ -337,6 +344,23 @@ static struct keyword *iskeyword(char *kw)
input_name = xstrdup(fname);
}
<pp_pragma>code_page[^\n]* yyless(9); yy_pop_state(); yy_push_state(pp_code_page);
<pp_pragma>[^\n]* yy_pop_state(); if (pedantic) yywarning("Unrecognized #pragma directive '%s'",yytext);
<pp_code_page>\({ws}*default{ws}*\)[^\n]* current_codepage = -1; yy_pop_state();
<pp_code_page>\({ws}*[0-9]+{ws}*\)[^\n]* {
char *p = yytext;
yy_pop_state();
while (*p < '0' || *p > '9') p++;
current_codepage = strtol( p, NULL, 10 );
if (current_codepage && !cp_get_table( current_codepage ))
{
yyerror("Codepage %d not supported", current_codepage);
current_codepage = 0;
}
}
<pp_code_page>[^\n]* yy_pop_state(); yyerror("Malformed #pragma code_page directive");
/*
* Strip everything until a ';' taking
* into account braces {} for structures,
......@@ -418,16 +442,16 @@ L\" {
return tSTRING;
}
<yylstr>\\[0-7]{1,6} { /* octal escape sequence */
int result;
result = strtol(yytext+1, 0, 8);
unsigned int result;
result = strtoul(yytext+1, 0, 8);
if ( result > 0xffff )
yyerror("Character constant out of range");
addwchar((short)result);
addwchar((WCHAR)result);
}
<yylstr>\\x[0-9a-fA-F]{4} { /* hex escape sequence */
int result;
result = strtol(yytext+2, 0, 16);
addwchar((short)result);
unsigned int result;
result = strtoul(yytext+2, 0, 16);
addwchar((WCHAR)result);
}
<yylstr>\\x[0-9a-fA-F]{1,3} { yyerror("Invalid hex escape sequence '%s'", yytext); }
......@@ -441,8 +465,8 @@ L\" {
<yylstr>\\v addwchar('\v');
<yylstr>\\(\n|.) addwchar(yytext[1]);
<yylstr>\\\r\n addwchar(yytext[2]);
<yylstr>\"\" addcchar('\"'); /* "bla""bla" -> "bla\"bla" */
<yylstr>\\\"\" addcchar('\"'); /* "bla\""bla" -> "bla\"bla" */
<yylstr>\"\" addwchar('\"'); /* "bla""bla" -> "bla\"bla" */
<yylstr>\\\"\" addwchar('\"'); /* "bla\""bla" -> "bla\"bla" */
<yylstr>\"{ws}+\" ; /* "bla" "bla" -> "blabla" */
<yylstr>[^\\\n\"]+ {
char *yptr = yytext;
......@@ -596,7 +620,7 @@ static void addcchar(char c)
cbuffer[cbufidx++] = c;
}
static void addwchar(short s)
static void addwchar(WCHAR s)
{
if(wbufidx >= wbufalloc)
{
......@@ -605,27 +629,33 @@ static void addwchar(short s)
if(wbufalloc > 65536)
yywarning("Reallocating wide string buffer larger than 64kB");
}
/*
* BS 08-Aug-1999 FIXME: The '& 0xff' is probably a bug, but I have
* not experienced it yet and I seem to remember that this was for
* a reason. But, as so many things you tend to forget why.
* I guess that there were problems due to the sign extension of
* shorts WRT chars (e.g. 0x80 becomes 0xff80 instead of 0x0080).
* This should then be fixed in the lexer calling the function.
*/
wbuffer[wbufidx++] = (short)(s & 0xff);
wbuffer[wbufidx++] = s;
}
static string_t *get_buffered_cstring(void)
{
string_t *str = new_string();
str->size = cbufidx;
str->type = str_char;
str->str.cstr = (char *)xmalloc(cbufidx+1);
memcpy(str->str.cstr, cbuffer, cbufidx);
str->str.cstr[cbufidx] = '\0';
if (!current_codepage || current_codepage == -1 || !win32) /* store as ANSI string */
{
if (!current_codepage) yyerror("Codepage set to Unicode only, cannot use ASCII string here");
return str;
}
else /* convert to Unicode before storing */
{
string_t *str_w = convert_string( str, str_unicode, current_codepage );
if (!check_unicode_conversion( str, str_w, current_codepage ))
yyerror("String %s does not convert identically to Unicode and back in codepage %d. "
"Try using a Unicode string instead.", str->str.cstr, current_codepage );
free_string( str );
return str_w;
}
}
static string_t *get_buffered_wstring(void)
......@@ -633,8 +663,8 @@ static string_t *get_buffered_wstring(void)
string_t *str = new_string();
str->size = wbufidx;
str->type = str_unicode;
str->str.wstr = (short *)xmalloc(2*(wbufidx+1));
memcpy(str->str.wstr, wbuffer, wbufidx);
str->str.wstr = xmalloc((wbufidx+1)*sizeof(WCHAR));
memcpy(str->str.wstr, wbuffer, wbufidx*sizeof(WCHAR));
str->str.wstr[wbufidx] = 0;
return str;
}
......
......@@ -531,6 +531,8 @@ resource
yywarning("LANGUAGE not supported in 16-bit mode");
if(currentlanguage)
free(currentlanguage);
if (get_language_codepage($3, $5) == -1)
yyerror( "Language %04x is not supported", ($5<<10) + $3);
currentlanguage = new_language($3, $5);
$$ = NULL;
chat("Got LANGUAGE %d,%d (0x%04x)", $3, $5, ($5<<10) + $3);
......@@ -1752,7 +1754,10 @@ opt_lvc : /* Empty */ { $$ = new_lvc(); }
* The conflict is now moved to the expression handling below.
*/
opt_language
: tLANGUAGE expr ',' expr { $$ = new_language($2, $4); }
: tLANGUAGE expr ',' expr { $$ = new_language($2, $4);
if (get_language_codepage($2, $4) == -1)
yyerror( "Language %04x is not supported", ($4<<10) + $2);
}
;
opt_characts
......
......@@ -37,16 +37,16 @@ char *xstrdup(const char *str);
int yyerror(const char *s, ...) __attribute__((format (printf, 1, 2)));
int yywarning(const char *s, ...) __attribute__((format (printf, 1, 2)));
void internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4)));
void internal_error(const char *file, int line, const char *s, ...) __attribute__((format (printf, 3, 4), noreturn));
void error(const char *s, ...) __attribute__((format (printf, 1, 2)));
void warning(const char *s, ...) __attribute__((format (printf, 1, 2)));
void chat(const char *s, ...) __attribute__((format (printf, 1, 2)));
char *dup_basename(const char *name, const char *ext);
char *dupwstr2cstr(const short *str);
short *dupcstr2wstr(const char *str);
int compare_name_id(name_id_t *n1, name_id_t *n2);
string_t *convert_string(const string_t *str, enum str_e type);
void set_language(unsigned short lang, unsigned short sublang);
string_t *convert_string(const string_t *str, enum str_e type, int codepage);
void free_string( string_t *str );
int check_unicode_conversion( const string_t *str_a, const string_t *str_w, int codepage );
int get_language_codepage( unsigned short lang, unsigned short sublang );
#endif
......@@ -363,6 +363,8 @@ int main(int argc,char *argv[])
{
int lan;
lan = strtol(optarg, NULL, 0);
if (get_language_codepage(PRIMARYLANGID(lan), SUBLANGID(lan)) == -1)
error("Language %04x is not supported",lan);
currentlanguage = new_language(PRIMARYLANGID(lan), SUBLANGID(lan));
}
break;
......
......@@ -99,7 +99,7 @@ typedef struct string {
enum str_e type;
union {
char *cstr;
short *wstr;
WCHAR *wstr;
} str;
} string_t;
......
......@@ -243,26 +243,22 @@ static void write_name_str(FILE *fp, name_id_t *nid)
else if(!win32 && nid->name.s_name->type == str_unicode)
{
name_id_t lnid;
string_t str;
lnid.type = name_str;
lnid.name.s_name = &str;
str.type = str_char;
str.str.cstr = dupwstr2cstr(nid->name.s_name->str.wstr);
lnid.name.s_name = convert_string( nid->name.s_name, str_char,
get_language_codepage(0,0) );
write_name_str(fp, &lnid);
free(str.str.cstr);
free_string( lnid.name.s_name );
}
else if(win32 && nid->name.s_name->type == str_char)
{
name_id_t lnid;
string_t str;
lnid.type = name_str;
lnid.name.s_name = &str;
str.type = str_unicode;
str.str.wstr = dupcstr2wstr(nid->name.s_name->str.cstr);
lnid.name.s_name = convert_string( nid->name.s_name, str_unicode,
get_language_codepage(0,0) );
write_name_str(fp, &lnid);
free(str.str.wstr);
free_string( lnid.name.s_name );
}
else if(win32 && nid->name.s_name->type == str_unicode)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment