From: <man...@us...> - 2013-09-09 10:17:25
|
Revision: 2669 http://sourceforge.net/p/modplug/code/2669 Author: manxorist Date: 2013-09-09 10:17:13 +0000 (Mon, 09 Sep 2013) Log Message: ----------- [Ref] libopenmpt: Build with UNICODE on windows. [Fix] in_openmpt: Correct charset handling. [Fix] Make testcases compile without and with UNICODE. [Fix] xmp-openmpt: Correct charset handling in aboud dialog. [Ref] xmp-openmpt: Assume UNICODE. [Ref] in_openmpt: Assume UNICODE. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp trunk/OpenMPT/test/test.cpp Modified: trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2013-09-09 10:14:49 UTC (rev 2668) +++ trunk/OpenMPT/libopenmpt/libopenmpt.vcxproj 2013-09-09 10:17:13 UTC (rev 2669) @@ -50,58 +50,58 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> - <CharacterSet>NotSet</CharacterSet> + <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> - <CharacterSet>NotSet</CharacterSet> + <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugStatic|Win32'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> - <CharacterSet>NotSet</CharacterSet> + <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='DebugStatic|x64'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> - <CharacterSet>NotSet</CharacterSet> + <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>false</WholeProgramOptimization> - <CharacterSet>NotSet</CharacterSet> + <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Test|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>false</WholeProgramOptimization> - <CharacterSet>NotSet</CharacterSet> + <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>DynamicLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>false</WholeProgramOptimization> - <CharacterSet>NotSet</CharacterSet> + <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Test|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>false</WholeProgramOptimization> - <CharacterSet>NotSet</CharacterSet> + <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseStatic|Win32'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>false</WholeProgramOptimization> - <CharacterSet>NotSet</CharacterSet> + <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseStatic|x64'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>false</WholeProgramOptimization> - <CharacterSet>NotSet</CharacterSet> + <CharacterSet>Unicode</CharacterSet> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> Modified: trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp 2013-09-09 10:14:49 UTC (rev 2668) +++ trunk/OpenMPT/libopenmpt/libopenmpt_winamp.cpp 2013-09-09 10:17:13 UTC (rev 2669) @@ -75,9 +75,9 @@ int samplerate; int channels; std::string cached_filename; - std::string cached_title; + std::wstring cached_title; int cached_length; - std::string cached_infotext; + std::wstring cached_infotext; std::int64_t decode_position_frames; openmpt::module * mod; HANDLE PlayThread; @@ -100,9 +100,9 @@ samplerate = settings.samplerate; channels = settings.channels; cached_filename = ""; - cached_title = ""; + cached_title = std::wstring(); cached_length = 0; - cached_infotext = ""; + cached_infotext = std::wstring(); decode_position_frames = 0; mod = 0; PlayThread = 0; @@ -135,13 +135,13 @@ static DWORD WINAPI DecodeThread( LPVOID ); -static std::string generate_infotext( const std::string & filename, const openmpt::module & mod ) { - std::ostringstream str; - str << "filename: " << filename << std::endl; - str << "duration: " << mod.get_duration_seconds() << "seconds" << std::endl; +static std::wstring generate_infotext( const std::string & filename, const openmpt::module & mod ) { + std::wostringstream str; + str << L"filename: " << StringDecode( filename, CP_ACP ) << std::endl; + str << L"duration: " << mod.get_duration_seconds() << L"seconds" << std::endl; std::vector<std::string> metadatakeys = mod.get_metadata_keys(); for ( std::vector<std::string>::iterator key = metadatakeys.begin(); key != metadatakeys.end(); ++key ) { - str << *key << ": " << mod.get_metadata(*key) << std::endl; + str << StringDecode( *key, CP_UTF8 ) << L": " << StringDecode( mod.get_metadata(*key), CP_UTF8 ) << std::endl; } return str.str(); } @@ -151,7 +151,7 @@ openmpt::settings::edit( self->settings, hwndParent, SHORT_TITLE ); apply_options(); } else { - MessageBox( hwndParent, "libopenmpt_settings.dll failed to load. Please check if it is in the same folder as in_openmpt.dll and that .NET framework v4.0 is installed.", SHORT_TITLE, MB_ICONERROR ); + MessageBox( hwndParent, TEXT("libopenmpt_settings.dll failed to load. Please check if it is in the same folder as in_openmpt.dll and that .NET framework v4.0 is installed."), TEXT(SHORT_TITLE), MB_ICONERROR ); } } @@ -164,17 +164,17 @@ about << openmpt::string::get( openmpt::string::contact ) << std::endl; about << std::endl; about << "Show full credits?" << std::endl; - if ( MessageBox( hwndParent, StringEncode( StringDecode( about.str(), CP_UTF8 ), CP_ACP ).c_str(), SHORT_TITLE, MB_ICONINFORMATION | MB_YESNOCANCEL | MB_DEFBUTTON1 ) != IDYES ) { + if ( MessageBox( hwndParent, StringDecode( about.str(), CP_UTF8 ).c_str(), TEXT(SHORT_TITLE), MB_ICONINFORMATION | MB_YESNOCANCEL | MB_DEFBUTTON1 ) != IDYES ) { return; } std::ostringstream credits; credits << openmpt::string::get( openmpt::string::credits ); - MessageBox( hwndParent, StringEncode( StringDecode( credits.str(), CP_UTF8 ), CP_ACP ).c_str(), SHORT_TITLE, MB_ICONINFORMATION ); + MessageBox( hwndParent, StringDecode( credits.str(), CP_UTF8 ).c_str(), TEXT(SHORT_TITLE), MB_ICONINFORMATION ); } static void init() { if ( !settings_dll ) { - settings_dll = LoadLibrary( "libopenmpt_settings.dll" ); + settings_dll = LoadLibrary( TEXT("libopenmpt_settings.dll") ); } if ( !self ) { self = new self_winamp_t(); @@ -206,7 +206,7 @@ std::ifstream s( fn, std::ios::binary ); self->mod = new openmpt::module( s ); self->cached_filename = fn; - self->cached_title = self->mod->get_metadata( "title" ); + self->cached_title = StringDecode( self->mod->get_metadata( "title" ), CP_UTF8 ); self->cached_length = static_cast<int>( self->mod->get_duration_seconds() * 1000.0 ); self->cached_infotext = generate_infotext( self->cached_filename, *self->mod ); apply_options(); @@ -285,11 +285,11 @@ try { std::ifstream s( fn, std::ios::binary ); openmpt::module mod( s ); - MessageBox( hWndParent, generate_infotext( fn, mod ).c_str(), SHORT_TITLE, 0 ); + MessageBox( hWndParent, generate_infotext( fn, mod ).c_str(), TEXT(SHORT_TITLE), 0 ); } catch ( ... ) { } } else { - MessageBox( hWndParent, self->cached_infotext.c_str(), SHORT_TITLE, 0 ); + MessageBox( hWndParent, self->cached_infotext.c_str(), TEXT(SHORT_TITLE), 0 ); } return 0; } @@ -300,7 +300,7 @@ *length_in_ms = self->cached_length; } if ( title ) { - strcpy( title, self->cached_title.c_str() ); + strcpy( title, StringEncode( self->cached_title, CP_ACP ).c_str() ); } } else { try { @@ -310,7 +310,7 @@ *length_in_ms = static_cast<int>( mod.get_duration_seconds() * 1000.0 ); } if ( title ) { - strcpy( title, mod.get_metadata("title").c_str() ); + strcpy( title, StringEncode( StringDecode( mod.get_metadata("title"), CP_UTF8 ), CP_ACP ).c_str() ); } } catch ( ... ) { } Modified: trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp 2013-09-09 10:14:49 UTC (rev 2668) +++ trunk/OpenMPT/libopenmpt/libopenmpt_xmplay.cpp 2013-09-09 10:17:13 UTC (rev 2669) @@ -264,12 +264,12 @@ about << openmpt::string::get( openmpt::string::contact ) << std::endl; about << std::endl; about << "Show full credits?" << std::endl; - if ( MessageBox( win, StringEncode( StringDecode( about.str(), CP_UTF8 ), CP_ACP ).c_str(), SHORT_TITLE, MB_ICONINFORMATION | MB_YESNOCANCEL | MB_DEFBUTTON1 ) != IDYES ) { + if ( MessageBox( win, StringDecode( about.str(), CP_UTF8 ).c_str(), TEXT(SHORT_TITLE), MB_ICONINFORMATION | MB_YESNOCANCEL | MB_DEFBUTTON1 ) != IDYES ) { return; } std::ostringstream credits; credits << openmpt::string::get( openmpt::string::credits ); - MessageBox( win, StringEncode( StringDecode( credits.str(), CP_UTF8 ), CP_ACP ).c_str(), SHORT_TITLE, MB_ICONINFORMATION ); + MessageBox( win, StringDecode( credits.str(), CP_UTF8 ).c_str(), TEXT(SHORT_TITLE), MB_ICONINFORMATION ); } static void WINAPI openmpt_Config( HWND win ) { @@ -277,7 +277,7 @@ openmpt::settings::edit( self->settings, win, SHORT_TITLE ); apply_and_save_options(); } else { - MessageBox( win, "libopenmpt_settings.dll failed to load. Please check if it is in the same folder as xmp-openmpt.dll and that .NET framework v4.0 is installed.", SHORT_TITLE, MB_ICONERROR ); + MessageBox( win, TEXT("libopenmpt_settings.dll failed to load. Please check if it is in the same folder as xmp-openmpt.dll and that .NET framework v4.0 is installed."), TEXT(SHORT_TITLE), MB_ICONERROR ); } } @@ -955,7 +955,7 @@ } else { xmpin.exts = xmp_openmpt_default_exts; } - settings_dll = LoadLibrary( "libopenmpt_settings.dll" ); + settings_dll = LoadLibrary( TEXT("libopenmpt_settings.dll") ); self = new self_xmplay_t(); } Modified: trunk/OpenMPT/test/test.cpp =================================================================== --- trunk/OpenMPT/test/test.cpp 2013-09-09 10:14:49 UTC (rev 2668) +++ trunk/OpenMPT/test/test.cpp 2013-09-09 10:17:13 UTC (rev 2669) @@ -483,21 +483,21 @@ VERIFY_EQUAL(ModCommand::IsPcNote(NOTE_PC), true); VERIFY_EQUAL(ModCommand::IsPcNote(NOTE_PCS), true); - VERIFY_EQUAL(CModSpecifications::ExtensionToType(_T(".mod")), MOD_TYPE_MOD); - VERIFY_EQUAL(CModSpecifications::ExtensionToType(_T("mod")), MOD_TYPE_MOD); - VERIFY_EQUAL(CModSpecifications::ExtensionToType(_T(".s3m")), MOD_TYPE_S3M); - VERIFY_EQUAL(CModSpecifications::ExtensionToType(_T("s3m")), MOD_TYPE_S3M); - VERIFY_EQUAL(CModSpecifications::ExtensionToType(_T(".xm")), MOD_TYPE_XM); - VERIFY_EQUAL(CModSpecifications::ExtensionToType(_T("xm")), MOD_TYPE_XM); - VERIFY_EQUAL(CModSpecifications::ExtensionToType(_T(".it")), MOD_TYPE_IT); - VERIFY_EQUAL(CModSpecifications::ExtensionToType(_T("it")), MOD_TYPE_IT); - VERIFY_EQUAL(CModSpecifications::ExtensionToType(_T(".itp")), MOD_TYPE_IT); - VERIFY_EQUAL(CModSpecifications::ExtensionToType(_T("itp")), MOD_TYPE_IT); - VERIFY_EQUAL(CModSpecifications::ExtensionToType(_T("mptm")), MOD_TYPE_MPT); - VERIFY_EQUAL(CModSpecifications::ExtensionToType(_T("invalidExtension")), MOD_TYPE_NONE); - VERIFY_EQUAL(CModSpecifications::ExtensionToType(_T("ita")), MOD_TYPE_NONE); - VERIFY_EQUAL(CModSpecifications::ExtensionToType(_T("s2m")), MOD_TYPE_NONE); - VERIFY_EQUAL(CModSpecifications::ExtensionToType(_T("")), MOD_TYPE_NONE); + VERIFY_EQUAL(CModSpecifications::ExtensionToType(".mod"), MOD_TYPE_MOD); + VERIFY_EQUAL(CModSpecifications::ExtensionToType("mod"), MOD_TYPE_MOD); + VERIFY_EQUAL(CModSpecifications::ExtensionToType(".s3m"), MOD_TYPE_S3M); + VERIFY_EQUAL(CModSpecifications::ExtensionToType("s3m"), MOD_TYPE_S3M); + VERIFY_EQUAL(CModSpecifications::ExtensionToType(".xm"), MOD_TYPE_XM); + VERIFY_EQUAL(CModSpecifications::ExtensionToType("xm"), MOD_TYPE_XM); + VERIFY_EQUAL(CModSpecifications::ExtensionToType(".it"), MOD_TYPE_IT); + VERIFY_EQUAL(CModSpecifications::ExtensionToType("it"), MOD_TYPE_IT); + VERIFY_EQUAL(CModSpecifications::ExtensionToType(".itp"), MOD_TYPE_IT); + VERIFY_EQUAL(CModSpecifications::ExtensionToType("itp"), MOD_TYPE_IT); + VERIFY_EQUAL(CModSpecifications::ExtensionToType("mptm"), MOD_TYPE_MPT); + VERIFY_EQUAL(CModSpecifications::ExtensionToType("invalidExtension"), MOD_TYPE_NONE); + VERIFY_EQUAL(CModSpecifications::ExtensionToType("ita"), MOD_TYPE_NONE); + VERIFY_EQUAL(CModSpecifications::ExtensionToType("s2m"), MOD_TYPE_NONE); + VERIFY_EQUAL(CModSpecifications::ExtensionToType(""), MOD_TYPE_NONE); VERIFY_EQUAL( Util::Round(1.99), 2.0 ); VERIFY_EQUAL( Util::Round(1.5), 2.0 ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |