Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
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
Иван Мажукин
mpd
Commits
ed327c59
Commit
ed327c59
authored
Nov 04, 2019
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/icu/Converter: Create() returns std::unique_ptr
parent
496f43e2
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
16 deletions
+11
-16
IcyMetaDataParser.cxx
src/IcyMetaDataParser.cxx
+1
-1
SidplayDecoderPlugin.cxx
src/decoder/plugins/SidplayDecoderPlugin.cxx
+1
-4
Charset.cxx
src/fs/Charset.cxx
+2
-3
Converter.cxx
src/lib/icu/Converter.cxx
+3
-3
Converter.hxx
src/lib/icu/Converter.hxx
+3
-1
TestIcu.cxx
test/TestIcu.cxx
+1
-4
No files found.
src/IcyMetaDataParser.cxx
View file @
ed327c59
...
...
@@ -32,7 +32,7 @@
void
IcyMetaDataParser
::
SetCharset
(
const
char
*
charset
)
{
icu_converter
.
reset
(
IcuConverter
::
Create
(
charset
)
);
icu_converter
=
IcuConverter
::
Create
(
charset
);
}
#endif
...
...
src/decoder/plugins/SidplayDecoderPlugin.cxx
View file @
ed327c59
...
...
@@ -456,10 +456,7 @@ Windows1252ToUTF8(const char *s) noexcept
{
#ifdef HAVE_ICU_CONVERTER
try
{
std
::
unique_ptr
<
IcuConverter
>
converter
(
IcuConverter
::
Create
(
"windows-1252"
));
return
converter
->
ToUTF8
(
s
);
return
IcuConverter
::
Create
(
"windows-1252"
)
->
ToUTF8
(
s
);
}
catch
(...)
{
}
#endif
...
...
src/fs/Charset.cxx
View file @
ed327c59
...
...
@@ -38,7 +38,7 @@
static
std
::
string
fs_charset
;
static
IcuConverter
*
fs_converter
;
static
std
::
unique_ptr
<
IcuConverter
>
fs_converter
;
void
SetFSCharset
(
const
char
*
charset
)
...
...
@@ -59,8 +59,7 @@ void
DeinitFSCharset
()
noexcept
{
#ifdef HAVE_ICU_CONVERTER
delete
fs_converter
;
fs_converter
=
nullptr
;
fs_converter
.
reset
();
#endif
}
...
...
src/lib/icu/Converter.cxx
View file @
ed327c59
...
...
@@ -46,7 +46,7 @@ IcuConverter::~IcuConverter()
#ifdef HAVE_ICU_CONVERTER
IcuConverter
*
std
::
unique_ptr
<
IcuConverter
>
IcuConverter
::
Create
(
const
char
*
charset
)
{
#ifdef HAVE_ICU
...
...
@@ -56,7 +56,7 @@ IcuConverter::Create(const char *charset)
throw
std
::
runtime_error
(
FormatString
(
"Failed to initialize charset '%s': %s"
,
charset
,
u_errorName
(
code
)).
c_str
());
return
new
IcuConverter
(
converter
);
return
std
::
unique_ptr
<
IcuConverter
>
(
new
IcuConverter
(
converter
)
);
#elif defined(HAVE_ICONV)
iconv_t
to
=
iconv_open
(
"utf-8"
,
charset
);
iconv_t
from
=
iconv_open
(
charset
,
"utf-8"
);
...
...
@@ -70,7 +70,7 @@ IcuConverter::Create(const char *charset)
charset
);
}
return
new
IcuConverter
(
to
,
from
);
return
std
::
unique_ptr
<
IcuConverter
>
(
new
IcuConverter
(
to
,
from
)
);
#endif
}
...
...
src/lib/icu/Converter.hxx
View file @
ed327c59
...
...
@@ -33,6 +33,8 @@
#ifdef HAVE_ICU_CONVERTER
#include <memory>
#ifdef HAVE_ICU
struct
UConverter
;
#endif
...
...
@@ -74,7 +76,7 @@ public:
/**
* Throws std::runtime_error on error.
*/
static
IcuConverter
*
Create
(
const
char
*
charset
);
static
std
::
unique_ptr
<
IcuConverter
>
Create
(
const
char
*
charset
);
/**
* Convert the string to UTF-8.
...
...
test/TestIcu.cxx
View file @
ed327c59
...
...
@@ -30,8 +30,7 @@ TEST(IcuConverter, InvalidCharset)
TEST
(
IcuConverter
,
Latin1
)
{
IcuConverter
*
const
converter
=
IcuConverter
::
Create
(
"iso-8859-1"
);
const
auto
converter
=
IcuConverter
::
Create
(
"iso-8859-1"
);
ASSERT_NE
(
converter
,
nullptr
);
for
(
const
auto
i
:
invalid_utf8
)
{
...
...
@@ -45,8 +44,6 @@ TEST(IcuConverter, Latin1)
auto
t
=
converter
->
ToUTF8
(
i
.
other
);
EXPECT_STREQ
(
t
.
c_str
(),
i
.
utf8
);
}
delete
converter
;
}
#endif
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