Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
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-cw
Commits
20459500
Commit
20459500
authored
Feb 07, 2020
by
Alexandre Julliard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wrc: Export the convert_string_utf8() helper function.
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
499d772c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
25 deletions
+22
-25
parser.y
tools/wrc/parser.y
+10
-12
po.c
tools/wrc/po.c
+3
-13
utils.c
tools/wrc/utils.c
+8
-0
utils.h
tools/wrc/utils.h
+1
-0
No files found.
tools/wrc/parser.y
View file @
20459500
...
...
@@ -2161,19 +2161,17 @@ static itemex_opt_t *new_itemex_opt(int id, int type, int state, int helpid)
static
raw_data_t
*
load_file
(
string_t
*
filename
,
language_t
*
lang
)
{
FILE
*fp
=
NULL;
char
*path;
char
*path
,
*name
;
raw_data_t
*rd;
string_t
*name;
int
codepage
=
get_language_codepage(lang->id,
lang->sub);
/* FIXME: we may want to use utf-8 here */
if
(codepage
<=
0
&&
filename->type
!=
str_char)
yyerror("Cannot
convert
filename
to
ASCII
string");
name
=
convert_string(
filename,
str_char,
codepage
);
if
(!(path
=
wpp_find_include(name->str.cstr,
input_name)))
yyerror("Cannot
open
file
%s",
name->str.cstr);
if
(filename->type
==
str_unicode)
name
=
convert_string_utf8(
filename,
0
);
else
name
=
xstrdup(
filename->str.cstr
);
if
(!(path
=
wpp_find_include(name,
input_name)))
yyerror("Cannot
open
file
%s",
name);
if
(!(fp
=
fopen(
path,
"rb"
)))
yyerror("Cannot
open
file
%s",
name
->str.cstr
);
yyerror("Cannot
open
file
%s",
name);
free(
path
);
rd
=
new_raw_data();
fseek(fp,
0,
SEEK_END);
...
...
@@ -2187,7 +2185,7 @@ static raw_data_t *load_file(string_t *filename, language_t *lang)
else
rd-
>
data
=
NULL
;
fclose
(
fp
);
rd-
>
lvc
.language
=
lang
;
free
_string
(
name
);
free
(
name
);
return
rd
;
}
...
...
tools/wrc/po.c
View file @
20459500
...
...
@@ -557,14 +557,6 @@ static void po_xerror2( int severity, po_message_t message1,
static
const
struct
po_xerror_handler
po_xerror_handler
=
{
po_xerror
,
po_xerror2
};
static
string_t
*
convert_string_utf8
(
const
string_t
*
str
,
int
codepage
)
{
string_t
*
wstr
=
convert_string
(
str
,
str_unicode
,
codepage
);
string_t
*
ustr
=
convert_string
(
wstr
,
str_char
,
CP_UTF8
);
free_string
(
wstr
);
return
ustr
;
}
static
po_message_t
find_message
(
po_file_t
po
,
const
char
*
msgid
,
const
char
*
msgctxt
,
po_message_iterator_t
*
iterator
)
{
...
...
@@ -589,8 +581,7 @@ static void add_po_string( po_file_t po, const string_t *msgid, const string_t *
po_message_t
msg
;
po_message_iterator_t
iterator
;
int
codepage
;
string_t
*
str_buffer
=
NULL
;
char
*
id
,
*
id_buffer
,
*
context
,
*
str
=
NULL
;
char
*
id
,
*
id_buffer
,
*
context
,
*
str
=
NULL
,
*
str_buffer
=
NULL
;
if
(
!
msgid
->
size
)
return
;
...
...
@@ -608,8 +599,7 @@ static void add_po_string( po_file_t po, const string_t *msgid, const string_t *
if
(
lang
)
codepage
=
get_language_codepage
(
lang
->
id
,
lang
->
sub
);
else
codepage
=
get_language_codepage
(
0
,
0
);
assert
(
codepage
!=
-
1
);
str_buffer
=
convert_string_utf8
(
msgstr
,
codepage
);
str
=
str_buffer
->
str
.
cstr
;
str
=
str_buffer
=
convert_string_utf8
(
msgstr
,
codepage
);
if
(
is_english
(
lang
))
get_message_context
(
&
str
);
}
if
(
!
(
msg
=
find_message
(
po
,
id
,
context
,
&
iterator
)))
...
...
@@ -623,7 +613,7 @@ static void add_po_string( po_file_t po, const string_t *msgid, const string_t *
if
(
msgid
->
loc
.
file
)
po_message_add_filepos
(
msg
,
msgid
->
loc
.
file
,
msgid
->
loc
.
line
);
po_message_iterator_free
(
iterator
);
free
(
id_buffer
);
if
(
str_buffer
)
free_string
(
str_buffer
);
free
(
str_buffer
);
}
struct
po_file_lang
...
...
tools/wrc/utils.c
View file @
20459500
...
...
@@ -503,6 +503,14 @@ string_t *convert_string(const string_t *str, enum str_e type, int codepage)
return
ret
;
}
char
*
convert_string_utf8
(
const
string_t
*
str
,
int
codepage
)
{
int
len
;
string_t
*
wstr
=
convert_string
(
str
,
str_unicode
,
codepage
);
char
*
ret
=
unicode_to_utf8
(
wstr
->
str
.
wstr
,
wstr
->
size
,
&
len
);
free_string
(
wstr
);
return
ret
;
}
void
free_string
(
string_t
*
str
)
{
...
...
tools/wrc/utils.h
View file @
20459500
...
...
@@ -47,6 +47,7 @@ void chat(const char *s, ...) __attribute__((format (printf, 1, 2)));
char
*
dup_basename
(
const
char
*
name
,
const
char
*
ext
);
int
compare_name_id
(
const
name_id_t
*
n1
,
const
name_id_t
*
n2
);
string_t
*
convert_string
(
const
string_t
*
str
,
enum
str_e
type
,
int
codepage
);
char
*
convert_string_utf8
(
const
string_t
*
str
,
int
codepage
);
void
free_string
(
string_t
*
str
);
int
check_valid_utf8
(
const
string_t
*
str
,
int
codepage
);
int
check_unicode_conversion
(
const
string_t
*
str_a
,
const
string_t
*
str_w
,
int
codepage
);
...
...
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