You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-08 14:02:17 +03:00
Added build option WITH_ICONV.
Default is OFF, which means MariaDB Connector/C will be built without iconv support. If set to OFF The API function mariadb_convert_string will always return -1 and errorcode ENOTSUP.
This commit is contained in:
@@ -24,7 +24,7 @@ get_directory_property(IS_SUBPROJECT PARENT_DIRECTORY)
|
||||
# do not inherit include directories from the parent project
|
||||
SET_PROPERTY(DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
|
||||
FOREACH(V WITH_MYSQLCOMPAT WITH_MSI WITH_SIGNCODE WITH_RTC WITH_UNIT_TESTS
|
||||
WITH_DYNCOL WITH_EXTERNAL_ZLIB WITH_CURL WITH_SQLITE WITH_SSL
|
||||
WITH_DYNCOL WITH_EXTERNAL_ZLIB WITH_CURL WITH_SQLITE WITH_SSL WITH_ICONV
|
||||
INSTALL_LAYOUT WITH_TEST_SRCPKG)
|
||||
SET(${V} ${${OPT}${V}})
|
||||
ENDFOREACH()
|
||||
@@ -57,6 +57,7 @@ ELSE()
|
||||
ADD_OPTION(WITH_MSI "Build MSI installation package" OFF)
|
||||
ADD_OPTION(WITH_SIGNCODE "digitally sign files" OFF)
|
||||
ADD_OPTION(WITH_RTC "enables run time checks for debug builds" OFF)
|
||||
ADD_OPTION(WITH_ICONV "enables character set conversion" OFF)
|
||||
ENDIF()
|
||||
|
||||
ADD_OPTION(WITH_UNIT_TESTS "build test suite" ON)
|
||||
@@ -343,9 +344,11 @@ ELSEIF (NOT ENABLED_LOCAL_INFILE MATCHES "^(ON|OFF|AUTO)$")
|
||||
MESSAGE(FATAL_ERROR "ENABLED_LOCAL_INFILE must be one of OFF, ON, AUTO")
|
||||
ENDIF()
|
||||
|
||||
IF(WITH_ICONV)
|
||||
IF(NOT WIN32)
|
||||
INCLUDE(${CC_SOURCE_DIR}/cmake/FindIconv.cmake)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
CONFIGURE_FILE(${CC_SOURCE_DIR}/include/ma_config.h.in
|
||||
${CC_BINARY_DIR}/include/ma_config.h)
|
||||
|
@@ -58,6 +58,7 @@ if (ICONV_FOUND)
|
||||
return 0;
|
||||
}
|
||||
" ICONV_SECOND_ARGUMENT_IS_CONST )
|
||||
ADD_DEFINITIONS(-DHAVE_ICONV)
|
||||
endif (ICONV_FOUND)
|
||||
|
||||
set (CMAKE_REQUIRED_INCLUDES)
|
||||
|
@@ -53,11 +53,13 @@
|
||||
#include <mariadb_ctype.h>
|
||||
#include <ma_string.h>
|
||||
|
||||
#ifdef HAVE_ICONV
|
||||
#ifdef _WIN32
|
||||
#include "../win-iconv/iconv.h"
|
||||
#else
|
||||
#include <iconv.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(HAVE_NL_LANGINFO) && defined(HAVE_SETLOCALE)
|
||||
@@ -1385,7 +1387,7 @@ int madb_get_windows_cp(const char *charset)
|
||||
#endif
|
||||
/* }}} */
|
||||
|
||||
|
||||
#ifdef HAVE_ICONV
|
||||
/* {{{ map_charset_name
|
||||
Changing charset name into something iconv understands, if necessary.
|
||||
Another purpose it to avoid BOMs in result string, adding BE if necessary
|
||||
@@ -1413,6 +1415,7 @@ static void map_charset_name(const char *cs_name, my_bool target_cs, char *buffe
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
#endif
|
||||
|
||||
/* {{{ mariadb_convert_string
|
||||
Converts string from one charset to another, and writes converted string to given buffer
|
||||
@@ -1426,9 +1429,17 @@ static void map_charset_name(const char *cs_name, my_bool target_cs, char *buffe
|
||||
|
||||
@return -1 in case of error, bytes used in the "to" buffer, otherwise
|
||||
*/
|
||||
size_t STDCALL mariadb_convert_string(const char *from, size_t *from_len, MARIADB_CHARSET_INFO *from_cs,
|
||||
char *to, size_t *to_len, MARIADB_CHARSET_INFO *to_cs, int *errorcode)
|
||||
size_t STDCALL mariadb_convert_string(const char *from __attribute__((unused)),
|
||||
size_t *from_len __attribute__((unused)),
|
||||
MARIADB_CHARSET_INFO *from_cs __attribute__((unused)),
|
||||
char *to __attribute__((unused)),
|
||||
size_t *to_len __attribute__((unused)),
|
||||
MARIADB_CHARSET_INFO *to_cs __attribute__((unused)), int *errorcode)
|
||||
{
|
||||
#ifndef HAVE_ICONV
|
||||
*errorcode= ENOTSUP;
|
||||
return -1;
|
||||
#else
|
||||
iconv_t conv= 0;
|
||||
size_t rc= -1;
|
||||
size_t save_len= *to_len;
|
||||
@@ -1462,6 +1473,7 @@ error:
|
||||
if (conv != (iconv_t)-1)
|
||||
iconv_close(conv);
|
||||
return rc;
|
||||
#endif
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
@@ -661,6 +661,10 @@ static int test_bug_54100(MYSQL *mysql)
|
||||
|
||||
static int test_utf16_utf32_noboms(MYSQL *mysql __attribute__((unused)))
|
||||
{
|
||||
#ifndef HAVE_ICONV
|
||||
diag("MariaDB Connector/C was built without iconv support");
|
||||
return SKIP;
|
||||
#else
|
||||
const char *csname[]= {"utf16", "utf16le", "utf32", "utf8"};
|
||||
MARIADB_CHARSET_INFO *csinfo[sizeof(csname)/sizeof(char*)];
|
||||
|
||||
@@ -724,6 +728,7 @@ static int test_utf16_utf32_noboms(MYSQL *mysql __attribute__((unused)))
|
||||
}
|
||||
|
||||
return OK;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int charset_auto(MYSQL *my __attribute__((unused)))
|
||||
|
Reference in New Issue
Block a user