wmc: Avoid using wine/unicode.h on Windows.
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
0cb79db12a
commit
cd37201517
|
@ -168,7 +168,7 @@ void show_languages(void)
|
||||||
printf(" Code | DOS-cp | WIN-cp | Language | Country\n");
|
printf(" Code | DOS-cp | WIN-cp | Language | Country\n");
|
||||||
printf("-------+--------+--------+--------------+---------\n");
|
printf("-------+--------+--------+--------------+---------\n");
|
||||||
for(i = 0; i < ARRAY_SIZE(languages); i++)
|
for(i = 0; i < ARRAY_SIZE(languages); i++)
|
||||||
printf("0x%04x | %5d | %5d | %-12s | %s\n",
|
printf("0x%04x | %5d | %5d | %-12s | %s\n",
|
||||||
languages[i].id,
|
languages[i].id,
|
||||||
languages[i].doscp,
|
languages[i].doscp,
|
||||||
languages[i].wincp,
|
languages[i].wincp,
|
||||||
|
@ -187,6 +187,41 @@ const language_t *find_language(unsigned id)
|
||||||
sizeof(languages[0]), langcmp);
|
sizeof(languages[0]), langcmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
static BOOL CALLBACK proc( char *cp )
|
||||||
|
{
|
||||||
|
CPINFOEXA info;
|
||||||
|
GetCPInfoExA( atoi(cp), 0, &info );
|
||||||
|
printf("%-5s %s\n", cp, info.CodePageName );
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void show_codepages(void)
|
||||||
|
{
|
||||||
|
printf("Codepages:\n");
|
||||||
|
EnumSystemCodePagesA( proc, 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
int is_valid_codepage(int id)
|
||||||
|
{
|
||||||
|
return IsValidCodePage( id );
|
||||||
|
}
|
||||||
|
|
||||||
|
int wmc_mbstowcs( int codepage, int flags, const char *src, int srclen, WCHAR *dst, int dstlen )
|
||||||
|
{
|
||||||
|
return MultiByteToWideChar( codepage, flags, src, srclen, dst, dstlen );
|
||||||
|
}
|
||||||
|
|
||||||
|
int wmc_wcstombs( int codepage, int flags, const WCHAR *src, int srclen, char *dst, int dstlen )
|
||||||
|
{
|
||||||
|
return WideCharToMultiByte( codepage, flags, src, srclen, dst, dstlen, NULL, NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
#else /* _WIN32 */
|
||||||
|
|
||||||
|
#include "wine/unicode.h"
|
||||||
|
|
||||||
void show_codepages(void)
|
void show_codepages(void)
|
||||||
{
|
{
|
||||||
unsigned i;
|
unsigned i;
|
||||||
|
@ -198,7 +233,21 @@ void show_codepages(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const union cptable *find_codepage(int id)
|
int is_valid_codepage(int id)
|
||||||
{
|
{
|
||||||
return wine_cp_get_table(id);
|
return id == CP_UTF8 || wine_cp_get_table(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int wmc_mbstowcs( int codepage, int flags, const char *src, int srclen, WCHAR *dst, int dstlen )
|
||||||
|
{
|
||||||
|
if (codepage == CP_UTF8) return wine_utf8_mbstowcs( flags, src, srclen, dst, dstlen );
|
||||||
|
return wine_cp_mbstowcs( wine_cp_get_table( codepage ), flags, src, srclen, dst, dstlen );
|
||||||
|
}
|
||||||
|
|
||||||
|
int wmc_wcstombs( int codepage, int flags, const WCHAR *src, int srclen, char *dst, int dstlen )
|
||||||
|
{
|
||||||
|
if (codepage == CP_UTF8) return wine_utf8_wcstombs( flags, src, srclen, dst, dstlen );
|
||||||
|
return wine_cp_wcstombs( wine_cp_get_table( codepage ), flags, src, srclen, dst, dstlen, NULL, NULL );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* _WIN32 */
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
#ifndef __WMC_LANG_H
|
#ifndef __WMC_LANG_H
|
||||||
#define __WMC_LANG_H
|
#define __WMC_LANG_H
|
||||||
|
|
||||||
#include "wine/unicode.h"
|
#include "winnls.h"
|
||||||
|
|
||||||
typedef struct language {
|
typedef struct language {
|
||||||
unsigned id;
|
unsigned id;
|
||||||
|
@ -34,6 +34,8 @@ typedef struct language {
|
||||||
void show_languages(void);
|
void show_languages(void);
|
||||||
const language_t *find_language(unsigned id);
|
const language_t *find_language(unsigned id);
|
||||||
void show_codepages(void);
|
void show_codepages(void);
|
||||||
const union cptable *find_codepage(int id);
|
int is_valid_codepage(int id);
|
||||||
|
int wmc_mbstowcs( int codepage, int flags, const char *src, int srclen, WCHAR *dst, int dstlen );
|
||||||
|
int wmc_wcstombs( int codepage, int flags, const WCHAR *src, int srclen, char *dst, int dstlen );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -149,13 +149,11 @@ static int isisochar(int ch)
|
||||||
}
|
}
|
||||||
|
|
||||||
static int codepage;
|
static int codepage;
|
||||||
static const union cptable *codepage_def;
|
|
||||||
|
|
||||||
void set_codepage(int cp)
|
void set_codepage(int cp)
|
||||||
{
|
{
|
||||||
codepage = cp;
|
codepage = cp;
|
||||||
codepage_def = find_codepage(codepage);
|
if (!is_valid_codepage( cp ))
|
||||||
if(!codepage_def && codepage != CP_UTF8)
|
|
||||||
xyyerror("Codepage %d not found; cannot process\n", codepage);
|
xyyerror("Codepage %d not found; cannot process\n", codepage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,10 +198,7 @@ try_again:
|
||||||
xyyerror(err_fatalread);
|
xyyerror(err_fatalread);
|
||||||
else if(!cptr)
|
else if(!cptr)
|
||||||
return 0;
|
return 0;
|
||||||
if (codepage_def)
|
n = wmc_mbstowcs(codepage, 0, xlatebuffer, strlen(xlatebuffer)+1, inputbuffer, INPUTBUFFER_SIZE);
|
||||||
n = wine_cp_mbstowcs(codepage_def, 0, xlatebuffer, strlen(xlatebuffer)+1, inputbuffer, INPUTBUFFER_SIZE);
|
|
||||||
else
|
|
||||||
n = wine_utf8_mbstowcs(0, xlatebuffer, strlen(xlatebuffer)+1, inputbuffer, INPUTBUFFER_SIZE);
|
|
||||||
if(n < 0)
|
if(n < 0)
|
||||||
internal_error(__FILE__, __LINE__, "Could not translate to unicode (%d)\n", n);
|
internal_error(__FILE__, __LINE__, "Could not translate to unicode (%d)\n", n);
|
||||||
if(n <= 1)
|
if(n <= 1)
|
||||||
|
|
|
@ -254,9 +254,9 @@ cmap : clan '=' tNUMBER ':' tNUMBER {
|
||||||
static const char err_nocp[] = "Codepage %d not builtin; cannot convert\n";
|
static const char err_nocp[] = "Codepage %d not builtin; cannot convert\n";
|
||||||
if(find_cpxlat($1))
|
if(find_cpxlat($1))
|
||||||
xyyerror("Codepage translation already defined for language 0x%x\n", $1);
|
xyyerror("Codepage translation already defined for language 0x%x\n", $1);
|
||||||
if($3 && $3 != CP_UTF8 && !find_codepage($3))
|
if($3 && !is_valid_codepage($3))
|
||||||
xyyerror(err_nocp, $3);
|
xyyerror(err_nocp, $3);
|
||||||
if($5 && $5 != CP_UTF8 && !find_codepage($5))
|
if($5 && !is_valid_codepage($5))
|
||||||
xyyerror(err_nocp, $5);
|
xyyerror(err_nocp, $5);
|
||||||
add_cpxlat($1, $3, $5);
|
add_cpxlat($1, $3, $5);
|
||||||
}
|
}
|
||||||
|
|
|
@ -405,7 +405,7 @@ static char *get_message_context( char **msgid )
|
||||||
static char *convert_string_utf8( const lanmsg_t *msg )
|
static char *convert_string_utf8( const lanmsg_t *msg )
|
||||||
{
|
{
|
||||||
char *buffer = xmalloc( msg->len * 4 + 1 );
|
char *buffer = xmalloc( msg->len * 4 + 1 );
|
||||||
int len = wine_utf8_wcstombs( 0, msg->msg, msg->len, buffer, msg->len * 4 );
|
int len = wmc_wcstombs( CP_UTF8, 0, msg->msg, msg->len, buffer, msg->len * 4 );
|
||||||
buffer[len] = 0;
|
buffer[len] = 0;
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
@ -656,9 +656,9 @@ static lanmsg_t *translate_string( lanmsg_t *str, int lang, int *found )
|
||||||
new->cp = 0; /* FIXME */
|
new->cp = 0; /* FIXME */
|
||||||
new->file = str->file;
|
new->file = str->file;
|
||||||
new->line = str->line;
|
new->line = str->line;
|
||||||
new->len = wine_utf8_mbstowcs( 0, transl, strlen(transl) + 1, NULL, 0 );
|
new->len = wmc_mbstowcs( CP_UTF8, 0, transl, strlen(transl) + 1, NULL, 0 );
|
||||||
new->msg = xmalloc( new->len * sizeof(WCHAR) );
|
new->msg = xmalloc( new->len * sizeof(WCHAR) );
|
||||||
res = wine_utf8_mbstowcs( MB_ERR_INVALID_CHARS, transl, strlen(transl) + 1, new->msg, new->len );
|
res = wmc_mbstowcs( CP_UTF8, MB_ERR_INVALID_CHARS, transl, strlen(transl) + 1, new->msg, new->len );
|
||||||
if (res == -2)
|
if (res == -2)
|
||||||
error( "Invalid utf-8 character in string '%s'\n", transl );
|
error( "Invalid utf-8 character in string '%s'\n", transl );
|
||||||
free( buffer );
|
free( buffer );
|
||||||
|
|
|
@ -98,17 +98,11 @@ static char *dup_u2c(int cp, const WCHAR *uc)
|
||||||
{
|
{
|
||||||
int len;
|
int len;
|
||||||
char *cptr;
|
char *cptr;
|
||||||
const union cptable *cpdef = find_codepage(cp);
|
|
||||||
|
|
||||||
if(cpdef)
|
if (!cp) cp = CP_UTF8;
|
||||||
len = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, NULL, 0, NULL, NULL);
|
len = wmc_wcstombs(cp, 0, uc, unistrlen(uc)+1, NULL, 0);
|
||||||
else
|
|
||||||
len = wine_utf8_wcstombs(0, uc, unistrlen(uc)+1, NULL, 0);
|
|
||||||
cptr = xmalloc(len);
|
cptr = xmalloc(len);
|
||||||
if (cpdef)
|
len = wmc_wcstombs(cp, 0, uc, unistrlen(uc)+1, cptr, len);
|
||||||
len = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, cptr, len, NULL, NULL);
|
|
||||||
else
|
|
||||||
len = wine_utf8_wcstombs(0, uc, unistrlen(uc)+1, cptr, len);
|
|
||||||
if (len < 0)
|
if (len < 0)
|
||||||
internal_error(__FILE__, __LINE__, "Buffer overflow? code %d\n", len);
|
internal_error(__FILE__, __LINE__, "Buffer overflow? code %d\n", len);
|
||||||
return cptr;
|
return cptr;
|
||||||
|
@ -385,21 +379,8 @@ static char *make_string(WCHAR *uc, int len, int codepage)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *tmp, *cc;
|
char *tmp, *cc;
|
||||||
int mlen;
|
|
||||||
const union cptable *cpdef = find_codepage(codepage);
|
|
||||||
|
|
||||||
if (cpdef)
|
cc = tmp = dup_u2c(codepage, uc);
|
||||||
mlen = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, NULL, 0, NULL, NULL);
|
|
||||||
else
|
|
||||||
mlen = wine_utf8_wcstombs(0, uc, unistrlen(uc)+1, NULL, 0);
|
|
||||||
cc = tmp = xmalloc(mlen);
|
|
||||||
if (cpdef) {
|
|
||||||
if((i = wine_cp_wcstombs(cpdef, 0, uc, unistrlen(uc)+1, tmp, mlen, NULL, NULL)) < 0)
|
|
||||||
internal_error(__FILE__, __LINE__, "Buffer overflow? code %d\n", i);
|
|
||||||
} else {
|
|
||||||
if((i = wine_utf8_wcstombs(0, uc, unistrlen(uc)+1, tmp, mlen)) < 0)
|
|
||||||
internal_error(__FILE__, __LINE__, "Buffer overflow? code %d\n", i);
|
|
||||||
}
|
|
||||||
*cptr++ = ' ';
|
*cptr++ = ' ';
|
||||||
*cptr++ = '"';
|
*cptr++ = '"';
|
||||||
for(i = b = 0; i < len; i++, cc++)
|
for(i = b = 0; i < len; i++, cc++)
|
||||||
|
|
Loading…
Reference in New Issue