From: Olivier Goffart Date: Mon, 3 Jul 2017 14:15:42 +0000 (+0200) Subject: csync: Remove iconv depedency X-Git-Tag: archive/raspbian/3.16.7-1_deb13u1+rpi1~1^2~704^2^2~40 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=20f1257e883180a89d01412d34460ee0af736a93;p=nextcloud-desktop.git csync: Remove iconv depedency We use iconv to normalize the string on mac. But the iconv version on mac does not support full unicode. So we will use Qt to normalize the string --- diff --git a/cmake/modules/FindIconv.cmake b/cmake/modules/FindIconv.cmake deleted file mode 100644 index 46d99f058..000000000 --- a/cmake/modules/FindIconv.cmake +++ /dev/null @@ -1,82 +0,0 @@ -# - Try to find Iconv -# Once done this will define -# -# ICONV_FOUND - system has Iconv -# ICONV_INCLUDE_DIRS - the Iconv include directory -# ICONV_LIBRARIES - Link these to use Iconv -# ICONV_DEFINITIONS - Compiler switches required for using Iconv -# -# Copyright (c) 2013 Andreas Schneider -# -# Redistribution and use is allowed according to the terms of the New -# BSD license. -# For details see the accompanying COPYING-CMAKE-SCRIPTS file. -# - -include(CheckIncludeFile) -include(CheckFunctionExists) -include(CheckLibraryExists) -include(CheckPrototypeDefinition) - -find_path(ICONV_INCLUDE_DIR - NAMES - iconv.h sys/iconv.h -) - -set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) -check_include_file(iconv.h HAVE_ICONV_H) -check_include_file(sys/iconv.h HAVE_SYS_ICONV_H) -set(CMAKE_REQUIRED_INCLUDES) - -find_library(ICONV_LIBRARY - NAMES - iconv - libiconv - PATHS -) - -if (ICONV_LIBRARY) - get_filename_component(_ICONV_NAME ${ICONV_LIBRARY} NAME) - get_filename_component(_ICONV_PATH ${ICONV_LIBRARY} PATH) - check_library_exists(${_ICONV_NAME} iconv ${_ICONV_PATH} HAVE_ICONV) -else() - check_function_exists(iconv HAVE_ICONV) -endif() - -if (HAVE_ICONV_H OR HAVE_SYS_ICONV_H) - if (HAVE_ICONV_H) - set(_ICONV_PROTO_INCLUDE "iconv.h") - endif (HAVE_ICONV_H) - if (HAVE_SYS_ICONV_H) - set(_ICONV_PROTO_INCLUDE "sys/iconv.h") - endif (HAVE_SYS_ICONV_H) - - set(CMAKE_REQUIRED_INCLUDES ${ICONV_INCLUDE_DIR}) - check_prototype_definition(iconv - "size_t iconv(iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)" - "-1" - ${_ICONV_PROTO_INCLUDE} - HAVE_ICONV_CONST) - set(CMAKE_REQUIRED_INCLUDES) -endif (HAVE_ICONV_H OR HAVE_SYS_ICONV_H) - -set(ICONV_INCLUDE_DIRS - ${ICONV_INCLUDE_DIR} -) - -if (ICONV_LIBRARY) - set(ICONV_LIBRARIES - ${ICONV_LIBRARIES} - ${ICONV_LIBRARY} - ) -endif (ICONV_LIBRARY) - -include(FindPackageHandleStandardArgs) -if (ICONV_LIBRARIES) - find_package_handle_standard_args(Iconv DEFAULT_MSG ICONV_LIBRARIES ICONV_INCLUDE_DIRS) -else() - find_package_handle_standard_args(Iconv DEFAULT_MSG ICONV_INCLUDE_DIRS) -endif() - -# show the ICONV_INCLUDE_DIRS and ICONV_LIBRARIES variables only in the advanced view -mark_as_advanced(ICONV_INCLUDE_DIRS ICONV_LIBRARIES) diff --git a/csync/CMakeLists.txt b/csync/CMakeLists.txt index 2d4b94f2a..d5be43a29 100644 --- a/csync/CMakeLists.txt +++ b/csync/CMakeLists.txt @@ -18,10 +18,6 @@ include(DefineInstallationPaths) include(MacroAddPlugin) include(MacroCopyFile) -if (NOT WIN32) - find_package(Iconv) -endif (NOT WIN32) - find_package(SQLite3 3.8.0 REQUIRED) include(ConfigureChecks.cmake) diff --git a/csync/DefineOptions.cmake b/csync/DefineOptions.cmake index 9ba14800d..485e18322 100644 --- a/csync/DefineOptions.cmake +++ b/csync/DefineOptions.cmake @@ -1,5 +1,2 @@ -if ( NOT WIN32 ) - option(WITH_ICONV "Build csync with iconv support" ON) -endif() option(UNIT_TESTING "Build with unit tests" OFF) option(MEM_NULL_TESTS "Enable NULL memory testing" OFF) diff --git a/csync/config_csync.h.cmake b/csync/config_csync.h.cmake index 155329bbd..f5c9f09b2 100644 --- a/csync/config_csync.h.cmake +++ b/csync/config_csync.h.cmake @@ -9,19 +9,14 @@ #cmakedefine HAVE_CLOCK_GETTIME #cmakedefine WITH_LOG4C 1 -#cmakedefine WITH_ICONV 1 #cmakedefine HAVE_ARGP_H 1 -#cmakedefine HAVE_ICONV_H 1 -#cmakedefine HAVE_SYS_ICONV_H 1 #cmakedefine HAVE_TIMEGM 1 #cmakedefine HAVE_STRERROR_R 1 #cmakedefine HAVE_UTIMES 1 #cmakedefine HAVE_LSTAT 1 #cmakedefine HAVE_FNMATCH 1 -#cmakedefine HAVE_ICONV 1 -#cmakedefine HAVE_ICONV_CONST 1 #cmakedefine HAVE___MINGW_ASPRINTF 1 #cmakedefine HAVE_ASPRINTF 1 diff --git a/csync/src/CMakeLists.txt b/csync/src/CMakeLists.txt index cb07377e9..8bce5f418 100644 --- a/csync/src/CMakeLists.txt +++ b/csync/src/CMakeLists.txt @@ -28,11 +28,6 @@ set(CSYNC_LINK_LIBRARIES ${SQLITE3_LIBRARIES} ) -if(HAVE_ICONV AND WITH_ICONV) - list(APPEND CSYNC_PRIVATE_INCLUDE_DIRS ${ICONV_INCLUDE_DIR}) - list(APPEND CSYNC_LINK_LIBRARIES ${ICONV_LIBRARIES}) -endif() - # Specific option for builds tied to servers that do not support renaming extensions set(NO_RENAME_EXTENSION 0 CACHE BOOL "Do not issue rename if the extension changes") if(NO_RENAME_EXTENSION) diff --git a/csync/src/csync.c b/csync/src/csync.c index 9af6f0fcf..1f75ac3bd 100644 --- a/csync/src/csync.c +++ b/csync/src/csync.c @@ -33,13 +33,6 @@ #include #include -#ifdef HAVE_ICONV_H -#include -#endif -#ifdef HAVE_SYS_ICONV_H -#include -#endif - #include "c_lib.h" #include "csync_private.h" #include "csync_exclude.h" @@ -569,10 +562,6 @@ int csync_destroy(CSYNC *ctx) { SAFE_FREE(ctx->local.uri); SAFE_FREE(ctx->error_string); -#ifdef WITH_ICONV - c_close_iconv(); -#endif - SAFE_FREE(ctx); return rc; @@ -626,19 +615,6 @@ const char *csync_get_status_string(CSYNC *ctx) return csync_vio_get_status_string(ctx); } -#ifdef WITH_ICONV -int csync_set_iconv_codec(const char *from) -{ - c_close_iconv(); - - if (from != NULL) { - c_setup_iconv(from); - } - - return 0; -} -#endif - void csync_request_abort(CSYNC *ctx) { if (ctx != NULL) { diff --git a/csync/src/csync.h b/csync/src/csync.h index 949c9efd2..b35d4601c 100644 --- a/csync/src/csync.h +++ b/csync/src/csync.h @@ -479,17 +479,6 @@ int OCSYNC_EXPORT csync_walk_remote_tree(CSYNC *ctx, csync_treewalk_visit_func * */ const char OCSYNC_EXPORT *csync_get_status_string(CSYNC *ctx); -#ifdef WITH_ICONV -/** - * @brief Set iconv source codec for filenames. - * - * @param from Source codec. - * - * @return 0 on success, or an iconv error number. - */ -int OCSYNC_EXPORT csync_set_iconv_codec(const char *from); -#endif - /** * @brief Aborts the current sync run as soon as possible. Can be called from another thread. * diff --git a/csync/src/csync_private.h b/csync/src/csync_private.h index 11775f345..2edc26019 100644 --- a/csync/src/csync_private.h +++ b/csync/src/csync_private.h @@ -42,17 +42,6 @@ #include "csync.h" #include "csync_misc.h" -#ifdef WITH_ICONV -#include -#endif - -#ifdef HAVE_ICONV_H -#include -#endif -#ifdef HAVE_SYS_ICONV_H -#include -#endif - #include "csync_macros.h" /** @@ -130,12 +119,6 @@ struct csync_s { } remote; -#if defined(HAVE_ICONV) && defined(WITH_ICONV) - struct { - iconv_t iconv_cd; - } options; -#endif - /* replica we are currently walking */ enum csync_replica_e current; diff --git a/csync/src/std/CMakeLists.txt b/csync/src/std/CMakeLists.txt index 91b8843a8..39b1fd550 100644 --- a/csync/src/std/CMakeLists.txt +++ b/csync/src/std/CMakeLists.txt @@ -5,10 +5,6 @@ set(CSTDLIB_PUBLIC_INCLUDE_DIRS CACHE INTERNAL "cstdlib public include directories" ) -set(CSTDLIB_PRIVATE_INCLUDE_DIRS - ${ICONV_INCLUDE_DIR} -) - set(CSTDLIB_LIBRARY cstdlib CACHE INTERNAL "cstdlib library" @@ -34,7 +30,6 @@ endif() include_directories( ${CSTDLIB_PUBLIC_INCLUDE_DIRS} - ${CSTDLIB_PRIVATE_INCLUDE_DIRS} ) add_library(${CSTDLIB_LIBRARY} STATIC ${cstdlib_SRCS}) diff --git a/csync/src/std/c_private.h b/csync/src/std/c_private.h index 09c1ea36b..26bba70db 100644 --- a/csync/src/std/c_private.h +++ b/csync/src/std/c_private.h @@ -159,13 +159,6 @@ typedef char mbchar_t; #define _tgetcwd getcwd #endif -#ifdef WITH_ICONV -/** @internal */ -int c_setup_iconv(const char* to); -/** @internal */ -int c_close_iconv(void); -#endif - /* FIXME: Implement TLS for OS X */ #if defined(__GNUC__) && !defined(__APPLE__) # define CSYNC_THREAD __thread diff --git a/csync/src/std/c_string.c b/csync/src/std/c_string.c index e21d4374e..6bf2d7723 100644 --- a/csync/src/std/c_string.c +++ b/csync/src/std/c_string.c @@ -40,97 +40,6 @@ #include #endif -#if defined(HAVE_ICONV) && defined(WITH_ICONV) -# ifdef HAVE_ICONV_H -# include -# endif -# ifdef HAVE_SYS_ICONV_H -# include -# endif - -typedef struct { - iconv_t to; - iconv_t from; -} iconv_conversions; - -CSYNC_THREAD iconv_conversions _iconvs = { NULL, NULL }; - -int c_setup_iconv(const char* to) { - _iconvs.to = iconv_open(to, "UTF-8"); - _iconvs.from = iconv_open("UTF-8", to); - - if (_iconvs.to == (iconv_t)-1 || _iconvs.from == (iconv_t)-1) - return -1; - - return 0; -} - -int c_close_iconv() { - int ret_to = 0; - int ret_from = 0; - if( _iconvs.to != (iconv_t) NULL ) { - ret_to = iconv_close(_iconvs.to); - } - if( _iconvs.from != (iconv_t) NULL ) { - ret_from = iconv_close(_iconvs.from); - } - - if (ret_to == -1 || ret_from == -1) - return -1; - - _iconvs.to = (iconv_t) 0; - _iconvs.from = (iconv_t) 0; - - return 0; -} - -enum iconv_direction { iconv_from_native, iconv_to_native }; - -static char *c_iconv(const char* str, enum iconv_direction dir) -{ -#ifdef HAVE_ICONV_CONST - const char *in = str; -#else - char *in = discard_const(str); -#endif - size_t size; - size_t outsize; - char *out; - char *out_in; - size_t ret; - - if (str == NULL) { - return NULL; - } - - if(_iconvs.from == NULL && _iconvs.to == NULL) { -#ifdef __APPLE__ - c_setup_iconv("UTF-8-MAC"); -#else - return c_strdup(str); -#endif - } - - size = strlen(in); - outsize = size*2; - out = c_malloc(outsize); - out_in = out; - - if (dir == iconv_to_native) { - ret = iconv(_iconvs.to, &in, &size, &out, &outsize); - } else { - ret = iconv(_iconvs.from, &in, &size, &out, &outsize); - } - - if (ret == (size_t)-1) { - SAFE_FREE(out_in); - return NULL; - } - - return out_in; -} -#endif /* defined(HAVE_ICONV) && defined(WITH_ICONV) */ - int c_strncasecmp(const char *a, const char *b, size_t n) { #ifdef _WIN32 return _strnicmp(a, b, n); @@ -285,11 +194,7 @@ char* c_utf8_from_locale(const mbchar_t *wstr) dst = mdst; } #else -#ifdef WITH_ICONV - dst = c_iconv(wstr, iconv_from_native); -#else - dst = (char*) wstr; -#endif + dst = c_strdup(wstr); #endif return dst; } @@ -317,11 +222,7 @@ mbchar_t* c_utf8_string_to_locale(const char *str) MultiByteToWideChar(CP_UTF8, 0, str, -1, dst, size_needed); } #else -#ifdef WITH_ICONV - dst = c_iconv(str, iconv_to_native); -#else - dst = (_TCHAR*) str; -#endif + dst = c_strdup(str); #endif return dst; } diff --git a/csync/src/std/c_string.h b/csync/src/std/c_string.h index 60bc010da..304c598a2 100644 --- a/csync/src/std/c_string.h +++ b/csync/src/std/c_string.h @@ -194,8 +194,6 @@ void c_strlist_destroy(c_strlist_t *strlist); */ mbchar_t* c_utf8_string_to_locale(const char *wstr); -#if defined(_WIN32) || defined(WITH_ICONV) - /** * @brief Free buffer malloced by c_utf8_from_locale or c_utf8_to_locale(). * @@ -214,9 +212,7 @@ mbchar_t* c_utf8_string_to_locale(const char *wstr); * */ #define c_free_locale_string(x) SAFE_FREE(x) -#else -#define c_free_locale_string(x) (void)x -#endif + /** * }@