diff -rupN exiv2-0.27.1/include/exiv2/error.hpp exiv2-0.27.1-new/include/exiv2/error.hpp
--- exiv2-0.27.1/include/exiv2/error.hpp 2019-04-25 22:18:55.000000000 +0200
+++ exiv2-0.27.1-new/include/exiv2/error.hpp 2019-04-29 11:27:05.873234423 +0200
@@ -179,6 +179,9 @@ namespace Exiv2 {
virtual ~AnyError() throw();
///@brief Return the error code.
virtual int code() const throw() =0;
+
+ protected:
+ std::string localizedErrMsg(int code);
};
//! %AnyError output operator
@@ -304,7 +307,7 @@ namespace Exiv2 {
//! @name Manipulators
//@{
//! Assemble the error message from the arguments
- EXIV2API void setMsg();
+ void setMsg();
//@}
// DATA
@@ -390,6 +393,77 @@ namespace Exiv2 {
}
#endif
+ template<>
+ inline void BasicError<char>::setMsg()
+ {
+ std::string msg = localizedErrMsg(code_);
+ std::string::size_type pos;
+ pos = msg.find("%0");
+ if (pos != std::string::npos) {
+ msg.replace(pos, 2, toString(code_));
+ }
+ if (count_ > 0) {
+ pos = msg.find("%1");
+ if (pos != std::string::npos) {
+ msg.replace(pos, 2, arg1_);
+ }
+ }
+ if (count_ > 1) {
+ pos = msg.find("%2");
+ if (pos != std::string::npos) {
+ msg.replace(pos, 2, arg2_);
+ }
+ }
+ if (count_ > 2) {
+ pos = msg.find("%3");
+ if (pos != std::string::npos) {
+ msg.replace(pos, 2, arg3_);
+ }
+ }
+ msg_ = msg;
+#ifdef EXV_UNICODE_PATH
+ wmsg_ = s2ws(msg);
+#endif
+ }
+#ifdef __APPLE__
+ template class EXIV2API BasicError<char>;
+#endif
+
+#ifdef EXV_UNICODE_PATH
+ template<>
+ inline void BasicError<wchar_t>::setMsg()
+ {
+ std::string s = localizedErrMsg(code_);
+ std::wstring wmsg(s.begin(), s.end());
+ std::wstring::size_type pos;
+ pos = wmsg.find(L"%0");
+ if (pos != std::wstring::npos) {
+ wmsg.replace(pos, 2, toBasicString<wchar_t>(code_));
+ }
+ if (count_ > 0) {
+ pos = wmsg.find(L"%1");
+ if (pos != std::wstring::npos) {
+ wmsg.replace(pos, 2, arg1_);
+ }
+ }
+ if (count_ > 1) {
+ pos = wmsg.find(L"%2");
+ if (pos != std::wstring::npos) {
+ wmsg.replace(pos, 2, arg2_);
+ }
+ }
+ if (count_ > 2) {
+ pos = wmsg.find(L"%3");
+ if (pos != std::wstring::npos) {
+ wmsg.replace(pos, 2, arg3_);
+ }
+ }
+ wmsg_ = wmsg;
+ msg_ = ws2s(wmsg);
+ }
+ template class EXIV2API BasicError<wchar_t>;
+#endif
+
#ifdef _MSC_VER
# pragma warning( default : 4275 )
#endif
diff -rupN exiv2-0.27.1/src/error.cpp exiv2-0.27.1-new/src/error.cpp
--- exiv2-0.27.1/src/error.cpp 2019-04-25 22:18:55.000000000 +0200
+++ exiv2-0.27.1-new/src/error.cpp 2019-04-29 11:27:05.873234423 +0200
@@ -224,76 +224,10 @@ namespace Exiv2 {
{
}
- template<>
- void BasicError<char>::setMsg()
+ std::string AnyError::localizedErrMsg(int code)
{
- std::string msg = _(errMsg(code_));
- std::string::size_type pos;
- pos = msg.find("%0");
- if (pos != std::string::npos) {
- msg.replace(pos, 2, toString(code_));
- }
- if (count_ > 0) {
- pos = msg.find("%1");
- if (pos != std::string::npos) {
- msg.replace(pos, 2, arg1_);
- }
- }
- if (count_ > 1) {
- pos = msg.find("%2");
- if (pos != std::string::npos) {
- msg.replace(pos, 2, arg2_);
- }
- }
- if (count_ > 2) {
- pos = msg.find("%3");
- if (pos != std::string::npos) {
- msg.replace(pos, 2, arg3_);
- }
- }
- msg_ = msg;
-#ifdef EXV_UNICODE_PATH
- wmsg_ = s2ws(msg);
-#endif
+ return _(errMsg(code));
}
-#ifdef __APPLE__
- template class EXIV2API BasicError<char>;
-#endif
-
-#ifdef EXV_UNICODE_PATH
- template<>
- void BasicError<wchar_t>::setMsg()
- {
- std::string s = _(errMsg(code_));
- std::wstring wmsg(s.begin(), s.end());
- std::wstring::size_type pos;
- pos = wmsg.find(L"%0");
- if (pos != std::wstring::npos) {
- wmsg.replace(pos, 2, toBasicString<wchar_t>(code_));
- }
- if (count_ > 0) {
- pos = wmsg.find(L"%1");
- if (pos != std::wstring::npos) {
- wmsg.replace(pos, 2, arg1_);
- }
- }
- if (count_ > 1) {
- pos = wmsg.find(L"%2");
- if (pos != std::wstring::npos) {
- wmsg.replace(pos, 2, arg2_);
- }
- }
- if (count_ > 2) {
- pos = wmsg.find(L"%3");
- if (pos != std::wstring::npos) {
- wmsg.replace(pos, 2, arg3_);
- }
- }
- wmsg_ = wmsg;
- msg_ = ws2s(wmsg);
- }
- template class EXIV2API BasicError<wchar_t>;
-#endif
const char* errMsg(int code)
{