From 284f5af19260e9ae52f077f7fabe5a925800aa85 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 18 Oct 2020 13:17:37 +0200 Subject: [PATCH 1/5] Add ANSI wxGTK Travis CI build Make sure this build is not broken again for as long as it's still supported. --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index ad25d52dd8..9a463b3f16 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,6 +34,10 @@ jobs: compiler: gcc env: wxGTK_VERSION=3 wxTOOLSET=cmake wxCMAKE_GENERATOR="Unix Makefiles" name: wxGTK 3 CMake Ubuntu 18.04 + - dist: focal + compiler: gcc + env: wxCONFIGURE_FLAGS="--disable-compat30 --disable-optimise --disable-unicode" + name: wxGTK ANSI Ubuntu 20.04 - os: osx osx_image: xcode7.3 compiler: clang From 7ed0d831d3f3847e2a01e4a82413e93d850606cd Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 18 Oct 2020 17:37:24 +0200 Subject: [PATCH 2/5] Declare variable unused in ANSI build inside #if wxUSE_UNICODE This avoids gcc -Wunused-variable about it in the ANSI build. --- src/gtk/app.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gtk/app.cpp b/src/gtk/app.cpp index a13b90f959..e4db864b01 100644 --- a/src/gtk/app.cpp +++ b/src/gtk/app.cpp @@ -339,9 +339,10 @@ bool wxApp::Initialize(int& argc_, wxChar **argv_) bool init_result; - int i; #if wxUSE_UNICODE + int i; + // gtk_init() wants UTF-8, not wchar_t, so convert char **argvGTK = new char *[argc_ + 1]; for ( i = 0; i < argc_; i++ ) From 577656a7d7700c9c772386127561085c73d7fa01 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 18 Oct 2020 20:14:27 +0200 Subject: [PATCH 3/5] Don't build samples in ANSI Travis CI build We don't need to waste build time on this and it's not really a problem if some samples don't compile without Unicode anyhow. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9a463b3f16..909d62a2c4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -36,7 +36,7 @@ jobs: name: wxGTK 3 CMake Ubuntu 18.04 - dist: focal compiler: gcc - env: wxCONFIGURE_FLAGS="--disable-compat30 --disable-optimise --disable-unicode" + env: wxCONFIGURE_FLAGS="--disable-compat30 --disable-optimise --disable-unicode" wxSKIP_SAMPLES=1 name: wxGTK ANSI Ubuntu 20.04 - os: osx osx_image: xcode7.3 From 9824d3bef32ae1ce37915dc60c349a99fe856501 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 18 Oct 2020 20:15:14 +0200 Subject: [PATCH 4/5] Don't try testing wxNO_IMPLICIT_WXSTRING_ENCODING in ANSI build This doesn't work and this won't change. --- tests/allheaders.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/allheaders.cpp b/tests/allheaders.cpp index 34629bd524..575d38fbfb 100644 --- a/tests/allheaders.cpp +++ b/tests/allheaders.cpp @@ -423,7 +423,10 @@ GCC_TURN_OFF(padded) #endif // gcc >= 4.6 -#if !wxUSE_UTF8_LOCALE_ONLY +// ANSI build hasn't been updated to work without implicit wxString encoding +// and never will be, as it will be removed soon anyhow. And in UTF-8-only +// build we actually want to use implicit encoding (UTF-8). +#if wxUSE_UNICODE && !wxUSE_UTF8_LOCALE_ONLY #define wxNO_IMPLICIT_WXSTRING_ENCODING #endif From 9e4d51dfcae583ef2d8857e6eada48dec8b3c137 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 18 Oct 2020 23:47:29 +0200 Subject: [PATCH 5/5] Disable tests not working in ANSI build Most of them can't be expected to work, e.g. non-ASCII file names can't be supported without Unicode support. Some others, e.g. test for NULs in wxDataOutputStream, are questionable, as it seems that it might be possible to fix them in ANSI build too, but for now just do the simplest thing to make the tests pass on Travis. --- tests/file/filefn.cpp | 22 ++++++++++++++++++++++ tests/streams/datastreamtest.cpp | 2 ++ tests/streams/sstream.cpp | 3 ++- tests/strings/stdstrings.cpp | 2 ++ tests/strings/strings.cpp | 2 ++ 5 files changed, 30 insertions(+), 1 deletion(-) diff --git a/tests/file/filefn.cpp b/tests/file/filefn.cpp index 4207545835..c347639d75 100644 --- a/tests/file/filefn.cpp +++ b/tests/file/filefn.cpp @@ -86,7 +86,9 @@ private: const wxString& destFilePath); wxString m_fileNameASCII; +#if wxUSE_UNICODE wxString m_fileNameNonASCII; +#endif // wxUSE_UNICODE wxString m_fileNameWork; wxDECLARE_NO_COPY_CLASS(FileFunctionsTestCase); @@ -110,10 +112,12 @@ void FileFunctionsTestCase::setUp() wxFileName fn1(wxFileName::GetTempDir(), wxT("wx_file_mask.txt")); m_fileNameASCII = fn1.GetFullPath(); +#if wxUSE_UNICODE // This file name is 'wx_file_mask.txt' in Russian. wxFileName fn2(wxFileName::GetTempDir(), wxT("wx_\u043C\u0430\u0441\u043A\u0430_\u0444\u0430\u0439\u043B\u0430.txt")); m_fileNameNonASCII = fn2.GetFullPath(); +#endif // wxUSE_UNICODE wxFileName fn3(wxFileName::GetTempDir(), wxT("wx_test_copy")); m_fileNameWork = fn3.GetFullPath(); @@ -126,10 +130,12 @@ void FileFunctionsTestCase::tearDown() { wxRemoveFile(m_fileNameASCII); } +#if wxUSE_UNICODE if ( wxFileExists(m_fileNameNonASCII) ) { wxRemoveFile(m_fileNameNonASCII); } +#endif // wxUSE_UNICODE if ( wxFileExists(m_fileNameWork) ) { wxRemoveFile(m_fileNameWork); @@ -176,8 +182,10 @@ void FileFunctionsTestCase::CreateFile() { // Create file name containing ASCII characters only. DoCreateFile(m_fileNameASCII); +#if wxUSE_UNICODE // Create file name containing non-ASCII characters. DoCreateFile(m_fileNameNonASCII); +#endif // wxUSE_UNICODE } void FileFunctionsTestCase::DoCreateFile(const wxString& filePath) @@ -199,8 +207,10 @@ void FileFunctionsTestCase::FileExists() // Check file name containing ASCII characters only. DoFileExists(m_fileNameASCII); +#if wxUSE_UNICODE // Check file name containing non-ASCII characters. DoFileExists(m_fileNameNonASCII); +#endif // wxUSE_UNICODE } void FileFunctionsTestCase::DoFileExists(const wxString& filePath) @@ -223,8 +233,10 @@ void FileFunctionsTestCase::FindFile() { // Find file name containing ASCII characters only. DoFindFile(m_fileNameASCII); +#if wxUSE_UNICODE // Find file name containing non-ASCII characters. DoFindFile(m_fileNameNonASCII); +#endif // wxUSE_UNICODE } void FileFunctionsTestCase::DoFindFile(const wxString& filePath) @@ -283,8 +295,10 @@ void FileFunctionsTestCase::RemoveFile() { // Create & remove file with name containing ASCII characters only. DoRemoveFile(m_fileNameASCII); +#if wxUSE_UNICODE // Create & remove file with name containing non-ASCII characters. DoRemoveFile(m_fileNameNonASCII); +#endif // wxUSE_UNICODE } void FileFunctionsTestCase::DoRemoveFile(const wxString& filePath) @@ -305,6 +319,7 @@ void FileFunctionsTestCase::RenameFile() { // Verify renaming file with/without overwriting // when new file already exist/don't exist. +#if wxUSE_UNICODE DoRenameFile(m_fileNameASCII, m_fileNameNonASCII, false, false); DoRenameFile(m_fileNameASCII, m_fileNameNonASCII, false, true); DoRenameFile(m_fileNameASCII, m_fileNameNonASCII, true, false); @@ -313,6 +328,7 @@ void FileFunctionsTestCase::RenameFile() DoRenameFile(m_fileNameNonASCII, m_fileNameASCII, false, true); DoRenameFile(m_fileNameNonASCII, m_fileNameASCII, true, false); DoRenameFile(m_fileNameNonASCII, m_fileNameASCII, true, true); +#endif // wxUSE_UNICODE } void @@ -378,8 +394,10 @@ FileFunctionsTestCase::DoRenameFile(const wxString& oldFilePath, void FileFunctionsTestCase::ConcatenateFiles() { +#if wxUSE_UNICODE DoConcatFile(m_fileNameASCII, m_fileNameNonASCII, m_fileNameWork); DoConcatFile(m_fileNameNonASCII, m_fileNameASCII, m_fileNameWork); +#endif // wxUSE_UNICODE } void FileFunctionsTestCase::DoConcatFile(const wxString& filePath1, @@ -525,21 +543,25 @@ void FileFunctionsTestCase::PathOnly() // Rmdir fails on them on Linux. See ticket #17644. void FileFunctionsTestCase::Mkdir() { +#if wxUSE_UNICODE wxString dirname = wxString::FromUTF8("__wxMkdir_test_dir_with_\xc3\xb6"); const std::string msg = wxString::Format("Dir: %s", dirname).ToStdString(); CPPUNIT_ASSERT_MESSAGE( msg, wxMkdir(dirname) ); CPPUNIT_ASSERT_MESSAGE( msg, wxDirExists(dirname) ); CPPUNIT_ASSERT_MESSAGE( msg, wxRmdir(dirname) ); +#endif // wxUSE_UNICODE } void FileFunctionsTestCase::Rmdir() { +#if wxUSE_UNICODE wxString dirname = wxString::FromUTF8("__wxRmdir_test_dir_with_\xc3\xb6"); const std::string msg = wxString::Format("Dir: %s", dirname).ToStdString(); CPPUNIT_ASSERT_MESSAGE( msg, wxMkdir(dirname) ); CPPUNIT_ASSERT_MESSAGE( msg, wxRmdir(dirname) ); CPPUNIT_ASSERT_MESSAGE( msg, !wxDirExists(dirname) ); +#endif // wxUSE_UNICODE } /* diff --git a/tests/streams/datastreamtest.cpp b/tests/streams/datastreamtest.cpp index a98c3af3ed..27bf25aa92 100644 --- a/tests/streams/datastreamtest.cpp +++ b/tests/streams/datastreamtest.cpp @@ -248,9 +248,11 @@ void DataStreamTestCase::StringRW() wxString s(wxT("Test1")); CPPUNIT_ASSERT_EQUAL( TestRW(s), s ); +#if wxUSE_UNICODE s.append(2, wxT('\0')); s.append(wxT("Test2")); CPPUNIT_ASSERT_EQUAL( TestRW(s), s ); +#endif // wxUSE_UNICODE s = wxString::FromUTF8("\xc3\xbc"); // U+00FC LATIN SMALL LETTER U WITH DIAERESIS CPPUNIT_ASSERT_EQUAL( TestRW(s), s ); diff --git a/tests/streams/sstream.cpp b/tests/streams/sstream.cpp index 1bff584180..a17640c3e8 100644 --- a/tests/streams/sstream.cpp +++ b/tests/streams/sstream.cpp @@ -131,7 +131,7 @@ TEST_CASE("wxStringOutputStream::Tell", "[stream]") wxString str(s); CHECK( wxStringOutputStream(&str).TellO() == len ); - +#if wxUSE_UNICODE wxMBConvUTF16 convUTF16; wxStringOutputStream ss16(NULL, convUTF16); CHECK( ss16.TellO() == 0 ); @@ -144,4 +144,5 @@ TEST_CASE("wxStringOutputStream::Tell", "[stream]") // The U+2070D character is represented by a surrogate pair in UTF-16. wxString u2070D = wxString::FromUTF8("\xF0\xA0\x9C\x8D"); CHECK( wxStringOutputStream(&u2070D, convUTF16).TellO() == 4 ); +#endif // wxUSE_UNICODE } diff --git a/tests/strings/stdstrings.cpp b/tests/strings/stdstrings.cpp index 550684f5da..1f9a6b3d66 100644 --- a/tests/strings/stdstrings.cpp +++ b/tests/strings/stdstrings.cpp @@ -636,9 +636,11 @@ void StdStringTestCase::StdConversion() wxStdWideString s8(s4); CPPUNIT_ASSERT( s8 == "hello" ); +#if wxUSE_UNICODE std::string s9("\xF0\x9F\x90\xB1\0\xE7\x8C\xAB", 9); /* U+1F431 U+0000 U+732B */ wxString s10 = wxString::FromUTF8(s9); CPPUNIT_ASSERT_EQUAL( s9, s10.ToStdString(wxConvUTF8) ); +#endif // wxUSE_UNICODE std::string s11("xyz\0\xFF", 5); /* an invalid UTF-8 sequence */ CPPUNIT_ASSERT_EQUAL( wxString::FromUTF8(s11), "" ); diff --git a/tests/strings/strings.cpp b/tests/strings/strings.cpp index be7215905c..8bbe9d69ad 100644 --- a/tests/strings/strings.cpp +++ b/tests/strings/strings.cpp @@ -260,7 +260,9 @@ void StringTestCase::StaticConstructors() CPPUNIT_ASSERT_EQUAL( "Hello", wxString::FromUTF8("Hello", 5) ); CPPUNIT_ASSERT_EQUAL( "Hello", wxString::FromUTF8("Hello") ); +#if wxUSE_UNICODE CPPUNIT_ASSERT_EQUAL( 2, wxString::FromUTF8("h\xc3\xa9llo", 3).length() ); +#endif // wxUSE_UNICODE //CPPUNIT_ASSERT_EQUAL( 1, wxString::FromUTF8("", 1).length() );