From 267d61c5bcbc69e8038c76d036d84c97de74058d Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Fri, 13 Jun 2003 19:52:46 +0000 Subject: [PATCH] Fixes for cygwin with libebml's new wchar string handling. --- common.cpp | 16 ++++++---------- mkvinfo.cpp | 18 ++++++++---------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/common.cpp b/common.cpp index c66945166..d31f573bc 100644 --- a/common.cpp +++ b/common.cpp @@ -362,9 +362,6 @@ void *_saferealloc(void *mem, size_t size, const char *file, int line) { */ UTFstring cstr_to_UTFstring(const char *c) { -#ifdef NO_WSTRING - return UTFstring(c); -#else wchar_t *new_string; char *old_locale; UTFstring u; @@ -383,25 +380,24 @@ UTFstring cstr_to_UTFstring(const char *c) { safefree(new_string); return u; -#endif } char *UTFstring_to_cstr(const UTFstring &u) { -#ifdef NO_WSTRING - return safestrdup(u.c_str()); -#else const wchar_t *sptr; - char *new_string; + char *new_string, *old_locale; int len; - len = u.size(); + len = u.length(); new_string = (char *)safemalloc(len * 4 + 1); memset(new_string, 0, len * 4 + 1); sptr = u.c_str(); + old_locale = safestrdup(setlocale(LC_CTYPE, NULL)); + setlocale(LC_CTYPE, ""); wcsrtombs(new_string, &sptr, len, NULL); + setlocale(LC_CTYPE, old_locale); + safefree(old_locale); return new_string; -#endif } #ifdef DEBUG diff --git a/mkvinfo.cpp b/mkvinfo.cpp index 16f428ef8..72ac48cc6 100644 --- a/mkvinfo.cpp +++ b/mkvinfo.cpp @@ -74,12 +74,6 @@ extern "C" { using namespace LIBMATROSKA_NAMESPACE; using namespace std; -#ifdef NO_WSTRING -#define WCHARMODIFIER -#else -#define WCHARMODIFIER "l" -#endif - typedef struct { unsigned int tnum, tuid; char type; @@ -319,16 +313,20 @@ bool process_file(const char *file_name) { float(duration) * tc_scale / 1000000000.0); } else if (EbmlId(*l2) == KaxMuxingApp::ClassInfos.GlobalId) { + char *str; KaxMuxingApp &muxingapp = *static_cast(l2); muxingapp.ReadData(es->I_O()); - show_element(l2, 2, "Muxing application: %" WCHARMODIFIER "s", - UTFstring(muxingapp).c_str()); + str = UTFstring_to_cstr(UTFstring(muxingapp)); + show_element(l2, 2, "Muxing application: %s", str); + safefree(str); } else if (EbmlId(*l2) == KaxWritingApp::ClassInfos.GlobalId) { + char *str; KaxWritingApp &writingapp = *static_cast(l2); writingapp.ReadData(es->I_O()); - show_element(l2, 2, "Writing application: %" WCHARMODIFIER "s", - UTFstring(writingapp).c_str()); + str = UTFstring_to_cstr(UTFstring(writingapp)); + show_element(l2, 2, "Writing application: %ls", str); + safefree(str); } else if (EbmlId(*l2) == KaxDateUTC::ClassInfos.GlobalId) { struct tm tmutc;