Author: brane Date: Mon Oct 21 12:08:32 2013 New Revision: 1534118 URL: http://svn.apache.org/r1534118 Log: Move the new Win32-specific UTF-8 <-> UTF-16 conversion functions to the svn_utf namespace.
* subversion/include/private/svn_subr_private.h (svn_subr__win32_utf8_to_utf16, svn_subr__win32_utf16_to_utf8): Move prototypes from here to ... * subversion/include/private/svn_utf_private.h (svn_utf__win32_utf8_to_utf16, svn_utf__win32_utf16_to_utf8): ... here. * subversion/libsvn_subr/win32_xlate.c (svn_subr__win32_utf8_to_utf16, svn_subr__win32_utf16_to_utf8): Move implementation from here to ... * subversion/libsvn_subr/utf.c (svn_utf__win32_utf8_to_utf16, svn_utf__win32_utf16_to_utf8): ... here. * subversion/bindings/javahl/native/JNIUtil.cpp, subversion/libsvn_subr/cmdline.c, subversion/libsvn_subr/config_win.c, subversion/libsvn_subr/nls.c: Update uses. Include svn_utf_private.h instead of svn_subr_private.h for svn_utf__win32_utf8_to_utf16 and svn_utf__win32_utf16_to_utf8. Modified: subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp subversion/trunk/subversion/include/private/svn_subr_private.h subversion/trunk/subversion/include/private/svn_utf_private.h subversion/trunk/subversion/libsvn_subr/cmdline.c subversion/trunk/subversion/libsvn_subr/config_win.c subversion/trunk/subversion/libsvn_subr/nls.c subversion/trunk/subversion/libsvn_subr/utf.c subversion/trunk/subversion/libsvn_subr/win32_xlate.c Modified: subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp?rev=1534118&r1=1534117&r2=1534118&view=diff ============================================================================== --- subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp (original) +++ subversion/trunk/subversion/bindings/javahl/native/JNIUtil.cpp Mon Oct 21 12:08:32 2013 @@ -54,6 +54,7 @@ #include "svn_path.h" #include "svn_cache_config.h" #include "private/svn_atomic.h" +#include "private/svn_utf_private.h" #include "svn_private_config.h" #include "SVNBase.h" @@ -312,7 +313,7 @@ bool JNIUtil::JNIGlobalInit(JNIEnv *env) HINSTANCE moduleHandle = GetModuleHandle("libsvnjavahl-1"); GetModuleFileNameW(moduleHandle, ucs2_path, sizeof(ucs2_path) / sizeof(ucs2_path[0])); - err = svn_subr__win32_utf16_to_utf8(&utf8_path, ucs2_path, pool); + err = svn_utf__win32_utf16_to_utf8(&utf8_path, ucs2_path, pool); if (err) { if (stderr) Modified: subversion/trunk/subversion/include/private/svn_subr_private.h URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_subr_private.h?rev=1534118&r1=1534117&r2=1534118&view=diff ============================================================================== --- subversion/trunk/subversion/include/private/svn_subr_private.h (original) +++ subversion/trunk/subversion/include/private/svn_subr_private.h Mon Oct 21 12:08:32 2013 @@ -474,27 +474,6 @@ void svn_config__set_read_only(svn_confi /** @} */ -#if defined(WIN32) || defined(DOXYGEN) -/** - * @defgroup svn_win32_private Private Windows-specific API - * @{ - */ - -/* On Windows: Convert the UTF-8 string SRC to UTF-16. */ -svn_error_t * -svn_subr__win32_utf8_to_utf16(const WCHAR **result, - const char *src, - apr_pool_t *result_pool); - -/* On Windows: Convert the UTF-18 string SRC to UTF-8. */ -svn_error_t * -svn_subr__win32_utf16_to_utf8(const char **result, - const WCHAR *src, - apr_pool_t *result_pool); - -/** @} */ -#endif /* WIN32 || DOXYGEN*/ - #ifdef __cplusplus } #endif /* __cplusplus */ Modified: subversion/trunk/subversion/include/private/svn_utf_private.h URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/include/private/svn_utf_private.h?rev=1534118&r1=1534117&r2=1534118&view=diff ============================================================================== --- subversion/trunk/subversion/include/private/svn_utf_private.h (original) +++ subversion/trunk/subversion/include/private/svn_utf_private.h Mon Oct 21 12:08:32 2013 @@ -93,6 +93,22 @@ svn_utf__cstring_from_utf8_fuzzy(const c const char *, apr_pool_t *)); + +#if defined(WIN32) +/* On Windows: Convert the UTF-8 string SRC to UTF-16. */ +svn_error_t * +svn_utf__win32_utf8_to_utf16(const WCHAR **result, + const char *src, + apr_pool_t *result_pool); + +/* On Windows: Convert the UTF-18 string SRC to UTF-8. */ +svn_error_t * +svn_utf__win32_utf16_to_utf8(const char **result, + const WCHAR *src, + apr_pool_t *result_pool); +#endif /* WIN32*/ + + /* A constant used for many length parameters in the utf8proc wrappers * to indicate that the length of a string is unknonw. */ #define SVN_UTF__UNKNOWN_LENGTH ((apr_size_t) -1) Modified: subversion/trunk/subversion/libsvn_subr/cmdline.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/cmdline.c?rev=1534118&r1=1534117&r2=1534118&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_subr/cmdline.c (original) +++ subversion/trunk/subversion/libsvn_subr/cmdline.c Mon Oct 21 12:08:32 2013 @@ -65,7 +65,6 @@ #include "private/svn_cmdline_private.h" #include "private/svn_utf_private.h" #include "private/svn_string_private.h" -#include "private/svn_subr_private.h" #include "win32_crashrpt.h" @@ -407,7 +406,7 @@ svn_cmdline_fputs(const char *string, FI SVN_ERR(svn_cmdline_fflush(stream)); /* Flush existing output */ - SVN_ERR(svn_subr__win32_utf8_to_utf16(&result, string, pool)); + SVN_ERR(svn_utf__win32_utf8_to_utf16(&result, string, pool)); if (_cputws(result)) { Modified: subversion/trunk/subversion/libsvn_subr/config_win.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/config_win.c?rev=1534118&r1=1534117&r2=1534118&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_subr/config_win.c (original) +++ subversion/trunk/subversion/libsvn_subr/config_win.c Mon Oct 21 12:08:32 2013 @@ -44,7 +44,7 @@ #include "svn_path.h" #include "svn_pools.h" #include "svn_utf.h" -#include "private/svn_subr_private.h" +#include "private/svn_utf_private.h" svn_error_t * svn_config__win_config_path(const char **folder, int system_path, @@ -65,8 +65,8 @@ svn_config__win_config_path(const char * ? "Can't determine the system config path" : "Can't determine the user's config path")); - return svn_error_trace(svn_subr__win32_utf16_to_utf8(folder, folder_ucs2, - result_pool)); + return svn_error_trace(svn_utf__win32_utf16_to_utf8(folder, folder_ucs2, + result_pool)); } Modified: subversion/trunk/subversion/libsvn_subr/nls.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/nls.c?rev=1534118&r1=1534117&r2=1534118&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_subr/nls.c (original) +++ subversion/trunk/subversion/libsvn_subr/nls.c Mon Oct 21 12:08:32 2013 @@ -37,7 +37,7 @@ #include "svn_pools.h" #include "svn_path.h" -#include "private/svn_subr_private.h" +#include "private/svn_utf_private.h" #include "svn_private_config.h" @@ -70,8 +70,8 @@ svn_nls_init(void) } if (! err) - err = svn_subr__win32_utf16_to_utf8(&utf8_path, ucs2_path, - scratch_pool); + err = svn_utf__win32_utf16_to_utf8(&utf8_path, ucs2_path, + scratch_pool); if (! err) { Modified: subversion/trunk/subversion/libsvn_subr/utf.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/utf.c?rev=1534118&r1=1534117&r2=1534118&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_subr/utf.c (original) +++ subversion/trunk/subversion/libsvn_subr/utf.c Mon Oct 21 12:08:32 2013 @@ -1020,3 +1020,74 @@ svn_utf_cstring_from_utf8_string(const c return err; } + + +#ifdef WIN32 + + +svn_error_t * +svn_utf__win32_utf8_to_utf16(const WCHAR **result, + const char *src, + apr_pool_t *result_pool) +{ + const int utf8_count = strlen(src); + WCHAR *wide_str; + int wide_count; + + if (!utf8_count) + { + *result = L""; + return SVN_NO_ERROR; + } + + wide_count = MultiByteToWideChar(CP_UTF8, 0, src, utf8_count, NULL, 0); + if (wide_count == 0) + return svn_error_wrap_apr(apr_get_os_error(), + _("Conversion to UTF-16 failed")); + + wide_str = apr_palloc(result_pool, (wide_count + 1) * sizeof(*wide_str)); + if (0 == MultiByteToWideChar(CP_UTF8, 0, src, utf8_count, + wide_str, wide_count)) + return svn_error_wrap_apr(apr_get_os_error(), + _("Conversion to UTF-16 failed")); + + wide_str[wide_count] = 0; + *result = wide_str; + + return SVN_NO_ERROR; +} + +svn_error_t * +svn_utf__win32_utf16_to_utf8(const char **result, + const WCHAR *src, + apr_pool_t *result_pool) +{ + const int wide_count = lstrlenW(src); + char *utf8_str; + int utf8_count; + + if (!wide_count) + { + *result = ""; + return SVN_NO_ERROR; + } + + utf8_count = WideCharToMultiByte(CP_UTF8, 0, src, wide_count, + NULL, 0, NULL, FALSE); + if (utf8_count == 0) + return svn_error_wrap_apr(apr_get_os_error(), + _("Conversion from UTF-16 failed")); + + utf8_str = apr_palloc(result_pool, (utf8_count + 1) * sizeof(*utf8_str)); + if (0 == WideCharToMultiByte(CP_UTF8, 0, src, wide_count, + utf8_str, utf8_count, NULL, FALSE)) + return svn_error_wrap_apr(apr_get_os_error(), + _("Conversion from UTF-16 failed")); + + utf8_str[utf8_count] = 0; + *result = utf8_str; + + return SVN_NO_ERROR; +} + +#endif /* WIN32 */ Modified: subversion/trunk/subversion/libsvn_subr/win32_xlate.c URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_subr/win32_xlate.c?rev=1534118&r1=1534117&r2=1534118&view=diff ============================================================================== --- subversion/trunk/subversion/libsvn_subr/win32_xlate.c (original) +++ subversion/trunk/subversion/libsvn_subr/win32_xlate.c Mon Oct 21 12:08:32 2013 @@ -238,69 +238,4 @@ svn_subr__win32_xlate_to_stringbuf(win32 return APR_SUCCESS; } -svn_error_t * -svn_subr__win32_utf8_to_utf16(const WCHAR **result, - const char *src, - apr_pool_t *result_pool) -{ - const int utf8_count = strlen(src); - WCHAR *wide_str; - int wide_count; - - if (!utf8_count) - { - *result = L""; - return SVN_NO_ERROR; - } - - wide_count = MultiByteToWideChar(CP_UTF8, 0, src, utf8_count, NULL, 0); - if (wide_count == 0) - return svn_error_wrap_apr(apr_get_os_error(), - _("Conversion to UTF-16 failed")); - - wide_str = apr_palloc(result_pool, (wide_count + 1) * sizeof(*wide_str)); - if (0 == MultiByteToWideChar(CP_UTF8, 0, src, utf8_count, - wide_str, wide_count)) - return svn_error_wrap_apr(apr_get_os_error(), - _("Conversion to UTF-16 failed")); - - wide_str[wide_count] = 0; - *result = wide_str; - - return SVN_NO_ERROR; -} - -svn_error_t * -svn_subr__win32_utf16_to_utf8(const char **result, - const WCHAR *src, - apr_pool_t *result_pool) -{ - const int wide_count = lstrlenW(src); - char *utf8_str; - int utf8_count; - - if (!wide_count) - { - *result = ""; - return SVN_NO_ERROR; - } - - utf8_count = WideCharToMultiByte(CP_UTF8, 0, src, wide_count, - NULL, 0, NULL, FALSE); - if (utf8_count == 0) - return svn_error_wrap_apr(apr_get_os_error(), - _("Conversion from UTF-16 failed")); - - utf8_str = apr_palloc(result_pool, (utf8_count + 1) * sizeof(*utf8_str)); - if (0 == WideCharToMultiByte(CP_UTF8, 0, src, wide_count, - utf8_str, utf8_count, NULL, FALSE)) - return svn_error_wrap_apr(apr_get_os_error(), - _("Conversion from UTF-16 failed")); - - utf8_str[utf8_count] = 0; - *result = utf8_str; - - return SVN_NO_ERROR; -} - #endif /* WIN32 */