diff --git a/CMakeLists.txt b/CMakeLists.txt index 5e0696d41..080d3b320 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1248,15 +1248,6 @@ endif() CHECK_INCLUDE_FILE_CXX(getopt.h HAVE_GETOPT_H) -find_package(ICONV) -if(ICONV_FOUND) - set(HAVE_ICONV true) - target_link_libraries(openclonk ${ICONV_LIBRARIES}) - if(ICONV_IS_CONST) - set(ICONV_CONST "const") - endif() -endif() - # TinyXML if(WITH_SYSTEM_TINYXML) pkg_search_module(TINYXML REQUIRED tinyxml) diff --git a/cmake/FindICONV.cmake b/cmake/FindICONV.cmake deleted file mode 100644 index ad8e9f74a..000000000 --- a/cmake/FindICONV.cmake +++ /dev/null @@ -1,62 +0,0 @@ -# - Try to find Iconv -# Once done this will define -# -# ICONV_FOUND - system has Iconv -# ICONV_INCLUDE_DIR - the Iconv include directory -# ICONV_LIBRARIES - Link these to use Iconv -# ICONV_IS_CONST - the second argument for iconv() is const -# -# This was mostly borrowed from Strigi. LyX also has a (quite -# different) FindICONV: the one in LyX does not check -# second_argument_is_const, but seems to have more fleshed-out support -# for WIN32. There may need to be some merging done. -# Tim Holy, 2008-05-07 - -include(CheckCXXSourceCompiles) - -IF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) - # Already in cache, be silent - SET(ICONV_FIND_QUIETLY TRUE) -ENDIF (ICONV_INCLUDE_DIR AND ICONV_LIBRARIES) - -FIND_PATH(ICONV_INCLUDE_DIR iconv.h - /Developer/SDKs/MacOSX10.4u.sdk/usr/include/iconv.h - /Developer/SDKs/MacOSX10.5.sdk/usr/include/iconv.h - /usr/include -) - -FIND_LIBRARY(ICONV_LIBRARIES NAMES iconv libiconv libiconv2 c - PATHS - /Developer/SDKs/MacOSX10.4u.sdk/usr/lib - /Developer/SDKs/MacOSX10.5.sdk/usr/lib - /usr/lib -) - -include(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(ICONV REQUIRED_VARS ICONV_LIBRARIES ICONV_INCLUDE_DIR) - -IF(ICONV_FOUND) - set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) - set(CMAKE_REQUIRED_LIBRARIES ${ICONV_LIBRARIES}) - check_cxx_source_compiles(" - #include - int main(){ - iconv_t conv = 0; - const char* in = 0; - size_t ilen = 0; - char* out = 0; - size_t olen = 0; - iconv(conv, &in, &ilen, &out, &olen); - return 0; - } -" ICONV_IS_CONST ) - set(CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_LIBRARIES) -ENDIF(ICONV_FOUND) - -MARK_AS_ADVANCED( - ICONV_INCLUDE_DIR - ICONV_LIBRARIES - ICONV_IS_CONST -) - diff --git a/config.h.cmake b/config.h.cmake index 2c40f049e..d4df94551 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -10,9 +10,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_HISTORY_H 1 -/* Define if you have the iconv() function. */ -#cmakedefine HAVE_ICONV 1 - /* Define to 1 if you have the header file. */ #cmakedefine HAVE_INTTYPES_H 1 @@ -117,9 +114,6 @@ /* Define to 1 if you have the header file. */ #cmakedefine HAVE_X11_KEYSYM_H 1 -/* Define as const if the declaration of iconv() needs const. */ -#define ICONV_CONST @ICONV_CONST@ - /* compile without debug options */ #cmakedefine NDEBUG 1 diff --git a/src/c4group/C4Language.cpp b/src/c4group/C4Language.cpp index 28b8b2ec2..3139cc426 100644 --- a/src/c4group/C4Language.cpp +++ b/src/c4group/C4Language.cpp @@ -31,15 +31,6 @@ #include #include -#ifdef HAVE_ICONV -#ifdef HAVE_LANGINFO_H -#include -#endif -#include -iconv_t C4Language::host_to_local = iconv_t(-1); -iconv_t C4Language::local_to_host = iconv_t(-1); -#endif - C4Language Languages; //char strLog[2048 + 1]; @@ -157,88 +148,8 @@ void C4Language::Clear() Infos = pNext; } Infos = NULL; -#ifdef HAVE_ICONV - if (local_to_host != iconv_t(-1)) - { - iconv_close(local_to_host); - local_to_host = iconv_t(-1); - } - if (host_to_local != iconv_t(-1)) - { - iconv_close(host_to_local); - host_to_local = iconv_t(-1); - } -#endif } -#ifdef HAVE_ICONV -StdStrBuf C4Language::Iconv(const char * string, iconv_t cd) -{ - if (cd == iconv_t(-1)) - { - return StdStrBuf(string, true); - } - StdStrBuf r; - if (!string) return r; - size_t inlen = strlen(string); - size_t outlen = strlen(string); - r.SetLength(inlen); - const char * inbuf = string; - char * outbuf = r.getMData(); - while (inlen > 0) - { - // Hope that iconv does not change the inbuf... - if ((size_t)(-1) == iconv(cd, const_cast(&inbuf), &inlen, &outbuf, &outlen)) - { - switch (errno) - { - // There is not sufficient room at *outbuf. - case E2BIG: - { - size_t done = outbuf - r.getMData(); - r.Grow(inlen * 2); - outbuf = r.getMData() + done; - outlen += inlen * 2; - break; - } - // An invalid multibyte sequence has been encountered in the input. - case EILSEQ: - ++inbuf; - --inlen; - break; - // An incomplete multibyte sequence has been encountered in the input. - case EINVAL: - default: - if (outlen) r.Shrink(outlen); - return r; - } - } - } - if (outlen) r.Shrink(outlen); - // StdStrBuf has taken care of the terminating zero - return r; -} -StdStrBuf C4Language::IconvSystem(const char * string) -{ - return Iconv(string, local_to_host); -} -StdStrBuf C4Language::IconvClonk(const char * string) -{ - return Iconv(string, host_to_local); -} -#else -StdStrBuf C4Language::IconvSystem(const char * string) -{ - // Just copy through - return StdStrBuf(string, true); -} -StdStrBuf C4Language::IconvClonk(const char * string) -{ - // Just copy through - return StdStrBuf(string, true); -} -#endif - int C4Language::GetPackCount() { return Packs.GetGroupCount(); @@ -533,19 +444,6 @@ bool C4Language::LoadStringTable(C4Group &hGroup, const char *strCode) // Load string table if (!C4LangStringTable::GetSystemStringTable().Load(hGroup, strEntry)) return false; - -#ifdef HAVE_ICONV -#ifdef HAVE_LANGINFO_H - const char * const to_set = nl_langinfo(CODESET); - if (local_to_host == iconv_t(-1)) - local_to_host = iconv_open (to_set ? to_set : "ASCII", "UTF-8"); - if (host_to_local == iconv_t(-1)) - host_to_local = iconv_open ("UTF-8", - to_set ? to_set : "ASCII"); -#else - const char * const to_set = ""; -#endif -#endif // Success return true; } diff --git a/src/c4group/C4Language.h b/src/c4group/C4Language.h index a34cdc6d0..2bbcb4ef3 100644 --- a/src/c4group/C4Language.h +++ b/src/c4group/C4Language.h @@ -23,10 +23,6 @@ #include "c4group/C4GroupSet.h" #include "c4group/C4LangStringTable.h" -#ifdef HAVE_ICONV -#include -#endif - const int C4MaxLanguageInfo = 1024; class C4LanguageInfo @@ -71,9 +67,6 @@ public: C4LanguageInfo *FindInfo(const char *strCode); // Loading of actual resource string table bool LoadLanguage(const char *strLanguages); - // Encoding conversion functions - static StdStrBuf IconvClonk(const char * string); - static StdStrBuf IconvSystem(const char * string); inline bool HasStringTable() const { return !C4LangStringTable::GetSystemStringTable().GetDataBuf().isNull(); } @@ -84,11 +77,6 @@ private: // Loading of actual resource string table bool InitStringTable(const char *strCode); bool LoadStringTable(C4Group &hGroup, const char *strCode); -#ifdef HAVE_ICONV - static iconv_t local_to_host; - static iconv_t host_to_local; - static StdStrBuf Iconv(const char * string, iconv_t cd); -#endif }; extern C4Language Languages; @@ -106,4 +94,4 @@ inline const char *LoadResStr(const char *id) } const char *LoadResStrNoAmp(const char *id); -#endif \ No newline at end of file +#endif diff --git a/src/gui/C4StartupMainDlg.cpp b/src/gui/C4StartupMainDlg.cpp index 1df5f69ea..9615c32e6 100644 --- a/src/gui/C4StartupMainDlg.cpp +++ b/src/gui/C4StartupMainDlg.cpp @@ -136,7 +136,7 @@ C4GUI::ContextMenu *C4StartupMainDlg::OnPlayerSelContextAdd(C4GUI::Element *pBtn if (*GetFilename(szFn) == '.') continue; if (!WildcardMatch(C4CFN_PlayerFiles, GetFilename(szFn))) continue; if (!SIsModule(Config.General.Participants, szFn, NULL, false)) - pCtx->AddItem(C4Language::IconvClonk(GetFilenameOnly(szFn)).getData(), "Let this player join in next game", C4GUI::Ico_Player, + pCtx->AddItem(GetFilenameOnly(szFn), "Let this player join in next game", C4GUI::Ico_Player, new C4GUI::CBMenuHandlerEx(this, &C4StartupMainDlg::OnPlayerSelContextAddPlr, StdCopyStrBuf(szFn)), NULL); } return pCtx; @@ -192,7 +192,7 @@ void C4StartupMainDlg::UpdateParticipants() for (int i = 0; SCopySegment(Config.General.Participants, i, &strPlayer[0], ';', 1024, true); i++) { if (i > 0) strPlayers.append(", "); - strPlayers.append(C4Language::IconvClonk(GetFilenameOnly(&strPlayer[0])).getData()); + strPlayers.append(GetFilenameOnly(&strPlayer[0])); } pParticipantsLbl->SetText(strPlayers.c_str()); } diff --git a/src/gui/C4StartupPlrSelDlg.cpp b/src/gui/C4StartupPlrSelDlg.cpp index 97b46425a..8c084080b 100644 --- a/src/gui/C4StartupPlrSelDlg.cpp +++ b/src/gui/C4StartupPlrSelDlg.cpp @@ -811,7 +811,7 @@ bool C4StartupPlrSelDlg::CheckPlayerName(const StdStrBuf &Playername, StdStrBuf return false; } // generate valid filename - Filename.Take(C4Language::IconvSystem(Playername.getData())); + Filename.Copy(Playername); // Slashes in Filenames are no good SReplaceChar(Filename.getMData(), '\\', '_'); SReplaceChar(Filename.getMData(), '/', '_'); diff --git a/src/gui/C4StartupScenSelDlg.cpp b/src/gui/C4StartupScenSelDlg.cpp index 9bbb277cd..4afb094b1 100644 --- a/src/gui/C4StartupScenSelDlg.cpp +++ b/src/gui/C4StartupScenSelDlg.cpp @@ -467,7 +467,6 @@ bool C4ScenarioListLoader::Entry::Load(C4Group *pFromGrp, const StdStrBuf *psFil char *szBuf = sName.GrabPointer(); RemoveExtension(szBuf); sName.Take(szBuf); - sName.Take(C4Language::IconvClonk(sName.getData())); // load entry specific stuff that's in the front of the group if (!LoadCustomPre(Group)) return false; diff --git a/src/lib/C4Log.cpp b/src/lib/C4Log.cpp index fa1f35458..09d9eb0de 100644 --- a/src/lib/C4Log.cpp +++ b/src/lib/C4Log.cpp @@ -119,23 +119,17 @@ bool LogSilent(const char *szMessage, bool fConsole) } *pDest++='\n'; *pDest = '\0'; -#ifdef HAVE_ICONV - StdStrBuf Line = Languages.IconvSystem(TimeMessage.getData()); -#else - const StdStrBuf &Line = TimeMessage; -#endif - // Save into log file if (C4LogFile) { - fputs(Line.getData(),C4LogFile); + fputs(TimeMessage.getData(),C4LogFile); fflush(C4LogFile); } // Save into record log file, if available if(Control.GetRecord()) { - Control.GetRecord()->GetLogFile()->Write(Line.getData(), strlen(Line.getData())); + Control.GetRecord()->GetLogFile()->Write(TimeMessage.getData(), TimeMessage.getLength()); #ifdef IMMEDIATEREC Control.GetRecord()->GetLogFile()->Flush(); #endif @@ -147,9 +141,9 @@ bool LogSilent(const char *szMessage, bool fConsole) { #if defined(_DEBUG) && defined(_WIN32) // debug: output to VC console - OutputDebugString(Line.GetWideChar()); + OutputDebugString(TimeMessage.GetWideChar()); #endif - fputs(Line.getData(),stdout); + fputs(TimeMessage.getData(),stdout); fflush(stdout); } diff --git a/tools/osx_bundle_libs b/tools/osx_bundle_libs index 2f49d4c97..ae97a4d81 100755 --- a/tools/osx_bundle_libs +++ b/tools/osx_bundle_libs @@ -1,7 +1,7 @@ #!/usr/bin/env ruby # Bundle all the libraries, no matter their potential existence on pristine OSX installations -$libs_to_bundle=".*?/lib(jpeg|GLEW|llvm|SDL|SDL_mixer|freetype|ogg|vorbis|vorbisfile|z\.|png[0-9]*|iconv|alut)\.[^ ]+\.dylib" +$libs_to_bundle=".*?/lib(jpeg|GLEW|llvm|SDL|SDL_mixer|freetype|ogg|vorbis|vorbisfile|z\.|png[0-9]*|alut)\.[^ ]+\.dylib" $executable_path = ENV['EXECUTABLE_PATH'] $frameworks_folder_path = ENV['FRAMEWORKS_FOLDER_PATH']