Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
cd372015
Commit
cd372015
authored
Apr 12, 2019
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wmc: Avoid using wine/unicode.h on Windows.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
0cb79db1
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
39 deletions
+66
-39
lang.c
tools/wmc/lang.c
+51
-2
lang.h
tools/wmc/lang.h
+4
-2
mcl.c
tools/wmc/mcl.c
+2
-7
mcy.y
tools/wmc/mcy.y
+2
-2
po.c
tools/wmc/po.c
+3
-3
write.c
tools/wmc/write.c
+4
-23
No files found.
tools/wmc/lang.c
View file @
cd372015
...
...
@@ -187,6 +187,41 @@ const language_t *find_language(unsigned id)
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
)
{
unsigned
i
;
...
...
@@ -198,7 +233,21 @@ void show_codepages(void)
}
}
const
union
cptable
*
fin
d_codepage
(
int
id
)
int
is_vali
d_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 */
tools/wmc/lang.h
View file @
cd372015
...
...
@@ -21,7 +21,7 @@
#ifndef __WMC_LANG_H
#define __WMC_LANG_H
#include "win
e/unicode
.h"
#include "win
nls
.h"
typedef
struct
language
{
unsigned
id
;
...
...
@@ -34,6 +34,8 @@ typedef struct language {
void
show_languages
(
void
);
const
language_t
*
find_language
(
unsigned
id
);
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
tools/wmc/mcl.c
View file @
cd372015
...
...
@@ -149,13 +149,11 @@ static int isisochar(int ch)
}
static
int
codepage
;
static
const
union
cptable
*
codepage_def
;
void
set_codepage
(
int
cp
)
{
codepage
=
cp
;
codepage_def
=
find_codepage
(
codepage
);
if
(
!
codepage_def
&&
codepage
!=
CP_UTF8
)
if
(
!
is_valid_codepage
(
cp
))
xyyerror
(
"Codepage %d not found; cannot process
\n
"
,
codepage
);
}
...
...
@@ -200,10 +198,7 @@ try_again:
xyyerror
(
err_fatalread
);
else
if
(
!
cptr
)
return
0
;
if
(
codepage_def
)
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
);
n
=
wmc_mbstowcs
(
codepage
,
0
,
xlatebuffer
,
strlen
(
xlatebuffer
)
+
1
,
inputbuffer
,
INPUTBUFFER_SIZE
);
if
(
n
<
0
)
internal_error
(
__FILE__
,
__LINE__
,
"Could not translate to unicode (%d)
\n
"
,
n
);
if
(
n
<=
1
)
...
...
tools/wmc/mcy.y
View file @
cd372015
...
...
@@ -254,9 +254,9 @@ cmap : clan '=' tNUMBER ':' tNUMBER {
static const char err_nocp[] = "Codepage %d not builtin; cannot convert\n";
if(find_cpxlat($1))
xyyerror("Codepage translation already defined for language 0x%x\n", $1);
if($3 &&
$3 != CP_UTF8 && !fin
d_codepage($3))
if($3 &&
!is_vali
d_codepage($3))
xyyerror(err_nocp, $3);
if($5 &&
$5 != CP_UTF8 && !fin
d_codepage($5))
if($5 &&
!is_vali
d_codepage($5))
xyyerror(err_nocp, $5);
add_cpxlat($1, $3, $5);
}
...
...
tools/wmc/po.c
View file @
cd372015
...
...
@@ -405,7 +405,7 @@ static char *get_message_context( char **msgid )
static
char
*
convert_string_utf8
(
const
lanmsg_t
*
msg
)
{
char
*
buffer
=
xmalloc
(
msg
->
len
*
4
+
1
);
int
len
=
w
ine_utf8_wcstombs
(
0
,
msg
->
msg
,
msg
->
len
,
buffer
,
msg
->
len
*
4
);
int
len
=
w
mc_wcstombs
(
CP_UTF8
,
0
,
msg
->
msg
,
msg
->
len
,
buffer
,
msg
->
len
*
4
);
buffer
[
len
]
=
0
;
return
buffer
;
}
...
...
@@ -656,9 +656,9 @@ static lanmsg_t *translate_string( lanmsg_t *str, int lang, int *found )
new
->
cp
=
0
;
/* FIXME */
new
->
file
=
str
->
file
;
new
->
line
=
str
->
line
;
new
->
len
=
w
ine_utf8_mbstowcs
(
0
,
transl
,
strlen
(
transl
)
+
1
,
NULL
,
0
);
new
->
len
=
w
mc_mbstowcs
(
CP_UTF8
,
0
,
transl
,
strlen
(
transl
)
+
1
,
NULL
,
0
);
new
->
msg
=
xmalloc
(
new
->
len
*
sizeof
(
WCHAR
)
);
res
=
w
ine_utf8_mbstowcs
(
MB_ERR_INVALID_CHARS
,
transl
,
strlen
(
transl
)
+
1
,
new
->
msg
,
new
->
len
);
res
=
w
mc_mbstowcs
(
CP_UTF8
,
MB_ERR_INVALID_CHARS
,
transl
,
strlen
(
transl
)
+
1
,
new
->
msg
,
new
->
len
);
if
(
res
==
-
2
)
error
(
"Invalid utf-8 character in string '%s'
\n
"
,
transl
);
free
(
buffer
);
...
...
tools/wmc/write.c
View file @
cd372015
...
...
@@ -98,17 +98,11 @@ static char *dup_u2c(int cp, const WCHAR *uc)
{
int
len
;
char
*
cptr
;
const
union
cptable
*
cpdef
=
find_codepage
(
cp
);
if
(
cpdef
)
len
=
wine_cp_wcstombs
(
cpdef
,
0
,
uc
,
unistrlen
(
uc
)
+
1
,
NULL
,
0
,
NULL
,
NULL
);
else
len
=
wine_utf8_wcstombs
(
0
,
uc
,
unistrlen
(
uc
)
+
1
,
NULL
,
0
);
if
(
!
cp
)
cp
=
CP_UTF8
;
len
=
wmc_wcstombs
(
cp
,
0
,
uc
,
unistrlen
(
uc
)
+
1
,
NULL
,
0
);
cptr
=
xmalloc
(
len
);
if
(
cpdef
)
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
);
len
=
wmc_wcstombs
(
cp
,
0
,
uc
,
unistrlen
(
uc
)
+
1
,
cptr
,
len
);
if
(
len
<
0
)
internal_error
(
__FILE__
,
__LINE__
,
"Buffer overflow? code %d
\n
"
,
len
);
return
cptr
;
...
...
@@ -385,21 +379,8 @@ static char *make_string(WCHAR *uc, int len, int codepage)
else
{
char
*
tmp
,
*
cc
;
int
mlen
;
const
union
cptable
*
cpdef
=
find_codepage
(
codepage
);
if
(
cpdef
)
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
);
}
cc
=
tmp
=
dup_u2c
(
codepage
,
uc
);
*
cptr
++
=
' '
;
*
cptr
++
=
'"'
;
for
(
i
=
b
=
0
;
i
<
len
;
i
++
,
cc
++
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment