Fixes for cygwin with libebml's new wchar string handling.

This commit is contained in:
Moritz Bunkus 2003-06-13 19:52:46 +00:00
parent 4774d753d2
commit 267d61c5bc
2 changed files with 14 additions and 20 deletions

View File

@ -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

View File

@ -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<KaxMuxingApp *>(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<KaxWritingApp *>(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;