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
6d409d27
Commit
6d409d27
authored
Nov 02, 2016
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/icu: migrate from class Error to C++ exceptions
parent
e9c2885f
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
23 additions
and
88 deletions
+23
-88
Makefile.am
Makefile.am
+1
-2
Main.cxx
src/Main.cxx
+1
-4
Collate.cxx
src/lib/icu/Collate.cxx
+6
-12
Collate.hxx
src/lib/icu/Collate.hxx
+5
-2
Error.cxx
src/lib/icu/Error.cxx
+0
-24
Error.hxx
src/lib/icu/Error.hxx
+0
-29
Init.cxx
src/lib/icu/Init.cxx
+7
-10
Init.hxx
src/lib/icu/Init.hxx
+3
-5
No files found.
Makefile.am
View file @
6d409d27
...
...
@@ -508,8 +508,7 @@ libevent_a_SOURCES = \
libicu_a_SOURCES
=
\
src/lib/icu/Collate.cxx src/lib/icu/Collate.hxx
\
src/lib/icu/Converter.cxx src/lib/icu/Converter.hxx
\
src/lib/icu/Error.cxx src/lib/icu/Error.hxx
src/lib/icu/Converter.cxx src/lib/icu/Converter.hxx
if
HAVE_ICU
libicu_a_SOURCES
+=
\
...
...
src/Main.cxx
View file @
6d409d27
...
...
@@ -400,10 +400,7 @@ try {
#endif
#endif
if
(
!
IcuInit
(
error
))
{
LogError
(
error
);
return
EXIT_FAILURE
;
}
IcuInit
();
winsock_init
();
io_thread_init
();
...
...
src/lib/icu/Collate.cxx
View file @
6d409d27
...
...
@@ -23,10 +23,9 @@
#ifdef HAVE_ICU
#include "Util.hxx"
#include "Error.hxx"
#include "util/AllocatedArray.hxx"
#include "util/ConstBuffer.hxx"
#include "util/Error.hxx"
#include "util/
Runtime
Error.hxx"
#include <unicode/ucol.h>
#include <unicode/ustring.h>
...
...
@@ -53,21 +52,16 @@ static UCollator *collator;
#ifdef HAVE_ICU
bool
IcuCollateInit
(
Error
&
error
)
void
IcuCollateInit
()
{
assert
(
collator
==
nullptr
);
assert
(
!
error
.
IsDefined
());
UErrorCode
code
=
U_ZERO_ERROR
;
collator
=
ucol_open
(
""
,
&
code
);
if
(
collator
==
nullptr
)
{
error
.
Format
(
icu_domain
,
int
(
code
),
"ucol_open() failed: %s"
,
u_errorName
(
code
));
return
false
;
}
return
true
;
if
(
collator
==
nullptr
)
throw
FormatRuntimeError
(
"ucol_open() failed: %s"
,
u_errorName
(
code
));
}
void
...
...
src/lib/icu/Collate.hxx
View file @
6d409d27
...
...
@@ -26,8 +26,11 @@
class
Error
;
template
<
typename
T
>
class
AllocatedString
;
bool
IcuCollateInit
(
Error
&
error
);
/**
* Throws #std::runtime_error on error.
*/
void
IcuCollateInit
();
void
IcuCollateFinish
();
...
...
src/lib/icu/Error.cxx
deleted
100644 → 0
View file @
e9c2885f
/*
* Copyright 2003-2016 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "config.h"
#include "Error.hxx"
#include "util/Domain.hxx"
const
Domain
icu_domain
(
"icu"
);
src/lib/icu/Error.hxx
deleted
100644 → 0
View file @
e9c2885f
/*
* Copyright 2003-2016 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef MPD_ICU_ERROR_HXX
#define MPD_ICU_ERROR_HXX
#include "check.h"
class
Domain
;
extern
const
Domain
icu_domain
;
#endif
src/lib/icu/Init.cxx
View file @
6d409d27
...
...
@@ -19,24 +19,21 @@
#include "config.h"
#include "Init.hxx"
#include "Error.hxx"
#include "Collate.hxx"
#include "util/Error.hxx"
#include "util/
Runtime
Error.hxx"
#include <unicode/uclean.h>
bool
IcuInit
(
Error
&
error
)
void
IcuInit
()
{
UErrorCode
code
=
U_ZERO_ERROR
;
u_init
(
&
code
);
if
(
U_FAILURE
(
code
))
{
error
.
Format
(
icu_domain
,
int
(
code
),
"u_init() failed: %s"
,
u_errorName
(
code
));
return
false
;
}
if
(
U_FAILURE
(
code
))
throw
FormatRuntimeError
(
"u_init() failed: %s"
,
u_errorName
(
code
));
return
IcuCollateInit
(
error
);
IcuCollateInit
(
);
}
void
...
...
src/lib/icu/Init.hxx
View file @
6d409d27
...
...
@@ -22,19 +22,17 @@
#include "check.h"
class
Error
;
#ifdef HAVE_ICU
bool
IcuInit
(
Error
&
error
);
void
IcuInit
();
void
IcuFinish
();
#else
static
inline
bool
IcuInit
(
Error
&
)
{
return
true
;
}
static
inline
void
IcuInit
()
{
}
static
inline
void
IcuFinish
()
{}
#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