File exiv2_setMsg.patch of Package mingw32-exiv2
diff -rupN exiv2-trunk/include/exiv2/error.hpp exiv2-trunk-new/include/exiv2/error.hpp
--- exiv2-trunk/include/exiv2/error.hpp 2017-03-16 19:13:12.000000000 +0100
+++ exiv2-trunk-new/include/exiv2/error.hpp 2018-07-29 00:52:00.175217226 +0200
@@ -185,6 +185,9 @@ namespace Exiv2 {
//! Return the error code.
virtual int code() const throw() =0;
//@}
+
+ protected:
+ std::string localizedErrMsg(int code);
}; // AnyError
//! %AnyError output operator
@@ -238,7 +241,7 @@ namespace Exiv2 {
//! @name Manipulators
//@{
//! Assemble the error message from the arguments
- EXIV2API void setMsg();
+ EXV_DLLLOCAL void setMsg();
//@}
// DATA
@@ -327,6 +330,76 @@ namespace Exiv2 {
return wmsg_.c_str();
}
#endif
+
+ //! @cond IGNORE
+ 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
+ }
+ //! @endcond
+
+#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);
+ }
+#endif
+
#ifdef _MSC_VER
# pragma warning( default : 4275 )
#endif
diff -rupN exiv2-trunk/src/error.cpp exiv2-trunk-new/src/error.cpp
--- exiv2-trunk/src/error.cpp 2017-03-08 21:42:28.000000000 +0100
+++ exiv2-trunk-new/src/error.cpp 2018-07-29 00:52:00.175217226 +0200
@@ -133,74 +133,10 @@ namespace Exiv2 {
{
}
- //! @cond IGNORE
- 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));
}
- //! @endcond
-
-#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);
- }
-#endif
const char* errMsg(int code)
{