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
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
41 deletions
+68
-41
lang.c
tools/wmc/lang.c
+52
-3
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
+5
-24
No files found.
tools/wmc/lang.c
View file @
cd372015
...
@@ -168,7 +168,7 @@ void show_languages(void)
...
@@ -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)
...
@@ -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)
...
@@ -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 @@
...
@@ -21,7 +21,7 @@
#ifndef __WMC_LANG_H
#ifndef __WMC_LANG_H
#define __WMC_LANG_H
#define __WMC_LANG_H
#include "win
e/unicode
.h"
#include "win
nls
.h"
typedef
struct
language
{
typedef
struct
language
{
unsigned
id
;
unsigned
id
;
...
@@ -34,6 +34,8 @@ typedef struct language {
...
@@ -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
tools/wmc/mcl.c
View file @
cd372015
...
@@ -149,13 +149,11 @@ static int isisochar(int ch)
...
@@ -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:
...
@@ -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
)
...
...
tools/wmc/mcy.y
View file @
cd372015
...
@@ -254,9 +254,9 @@ cmap : clan '=' tNUMBER ':' tNUMBER {
...
@@ -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 && !fin
d_codepage($3))
if($3 &&
!is_vali
d_codepage($3))
xyyerror(err_nocp, $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);
xyyerror(err_nocp, $5);
add_cpxlat($1, $3, $5);
add_cpxlat($1, $3, $5);
}
}
...
...
tools/wmc/po.c
View file @
cd372015
...
@@ -405,7 +405,7 @@ static char *get_message_context( char **msgid )
...
@@ -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
=
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
;
buffer
[
len
]
=
0
;
return
buffer
;
return
buffer
;
}
}
...
@@ -656,9 +656,9 @@ static lanmsg_t *translate_string( lanmsg_t *str, int lang, int *found )
...
@@ -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
=
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
)
);
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
)
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
);
...
...
tools/wmc/write.c
View file @
cd372015
...
@@ -98,17 +98,11 @@ static char *dup_u2c(int cp, const WCHAR *uc)
...
@@ -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)
...
@@ -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
);
cc
=
tmp
=
dup_u2c
(
codepage
,
uc
);
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
);
}
*
cptr
++
=
' '
;
*
cptr
++
=
' '
;
*
cptr
++
=
'"'
;
*
cptr
++
=
'"'
;
for
(
i
=
b
=
0
;
i
<
len
;
i
++
,
cc
++
)
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