Index: subversion/include/svn_utf.h =================================================================== --- subversion/include/svn_utf.h (revision 19222) +++ subversion/include/svn_utf.h (working copy) @@ -81,11 +81,22 @@ apr_pool_t *pool); -/** Set @a *dest to a utf8-encoded C string from @a frompage C string - * @a src; allocate @a *dest in @a pool. Use @a convset_key as the - * cache key for the charset converter; if it's NULL, don't cache the - * converter. +/** Set @a *dest to a utf8 encoded C string from @a frompage encoded C + * string @a src; allocate @a *dest in @a pool. + * + * @since New in 1.4. */ +svn_error_t *svn_utf_cstring_to_utf8_ex2(const char **dest, + const char *src, + const char *frompage, + apr_pool_t *pool); + + +/** Like svn_utf_cstring_to_utf8_ex2() but with @a convset_key which is + * ignored. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ svn_error_t *svn_utf_cstring_to_utf8_ex(const char **dest, const char *src, const char *frompage, @@ -117,11 +128,22 @@ apr_pool_t *pool); -/** Set @a *dest to a @a topage encoded C string from utf8 C string - * @a src; allocate @a *dest in @a pool. Use @a convset_key as the - * cache key for the charset converter; if it's NULL, don't cache the - * converter. +/** Set @a *dest to a @a topage encoded C string from utf8 encoded C string + * @a src; allocate @a *dest in @a pool. + * + * @since New in 1.4. */ +svn_error_t *svn_utf_cstring_from_utf8_ex2(const char **dest, + const char *src, + const char *topage, + apr_pool_t *pool); + + +/** Like svn_utf_cstring_from_utf8_ex2() but with @a convset_key which is + * ignored. + * + * @deprecated Provided for backward compatibility with the 1.3 API. + */ svn_error_t *svn_utf_cstring_from_utf8_ex(const char **dest, const char *src, const char *topage, Index: subversion/libsvn_client/diff.c =================================================================== --- subversion/libsvn_client/diff.c (revision 19222) +++ subversion/libsvn_client/diff.c (working copy) @@ -73,8 +73,8 @@ buf = apr_pvsprintf(apr_file_pool_get(fptr), format, ap); va_end(ap); - SVN_ERR(svn_utf_cstring_from_utf8_ex(&buf_apr, buf, encoding, NULL, - apr_file_pool_get(fptr))); + SVN_ERR(svn_utf_cstring_from_utf8_ex2(&buf_apr, buf, encoding, + apr_file_pool_get(fptr))); return svn_io_file_write_full(fptr, buf_apr, strlen(buf_apr), NULL, apr_file_pool_get(fptr)); Index: subversion/libsvn_diff/diff_file.c =================================================================== --- subversion/libsvn_diff/diff_file.c (revision 19222) +++ subversion/libsvn_diff/diff_file.c (working copy) @@ -1013,12 +1013,12 @@ && ! had_cr) { const char *out_str; - SVN_ERR(svn_utf_cstring_from_utf8_ex + SVN_ERR(svn_utf_cstring_from_utf8_ex2 (&out_str, apr_psprintf(baton->pool, _("%s\\ No newline at end of file%s"), APR_EOL_STR, APR_EOL_STR), - baton->header_encoding, NULL, baton->pool)); + baton->header_encoding, baton->pool)); svn_stringbuf_appendcstr(baton->hunk, out_str); } @@ -1230,12 +1230,12 @@ baton.path[1] = modified_path; baton.hunk = svn_stringbuf_create("", pool); - SVN_ERR(svn_utf_cstring_from_utf8_ex(&baton.context_str, " ", - header_encoding, NULL, pool)); - SVN_ERR(svn_utf_cstring_from_utf8_ex(&baton.delete_str, "-", - header_encoding, NULL, pool)); - SVN_ERR(svn_utf_cstring_from_utf8_ex(&baton.insert_str, "+", - header_encoding, NULL, pool)); + SVN_ERR(svn_utf_cstring_from_utf8_ex2(&baton.context_str, " ", + header_encoding, pool)); + SVN_ERR(svn_utf_cstring_from_utf8_ex2(&baton.delete_str, "-", + header_encoding, pool)); + SVN_ERR(svn_utf_cstring_from_utf8_ex2(&baton.insert_str, "+", + header_encoding, pool)); for (i = 0; i < 2; i++) { Index: subversion/libsvn_repos/hooks.c =================================================================== --- subversion/libsvn_repos/hooks.c (revision 19222) +++ subversion/libsvn_repos/hooks.c (working copy) @@ -199,10 +199,9 @@ /* Convert UTF-8 args to EBCDIC for use by spawn(). */ for (i = 0; args[i] != NULL; i++) { - SVN_ERR(svn_utf_cstring_from_utf8_ex((const char**)(&(native_args[i])), - args[i], (const char *)0, - "svn-repos-utoe-xlate-handle", - pool)); + SVN_ERR(svn_utf_cstring_from_utf8_ex2((const char**)(&(native_args[i])), + args[i], (const char *)0, + pool)); } /* Make the last element in the array a NULL pointer as required @@ -327,11 +326,9 @@ if (!svn_stringbuf_isempty(script_output)) { /* OS400 scripts produce EBCDIC stderr, so convert it. */ - SVN_ERR(svn_utf_cstring_to_utf8_ex(&script_stderr_utf8, - script_output->data, - (const char*)0, - "svn-repos-etou-xlate-handle", - pool)); + SVN_ERR(svn_utf_cstring_to_utf8_ex2(&script_stderr_utf8, + script_output->data, + (const char*)0, pool)); } if (WIFEXITED(exitcode)) Index: subversion/libsvn_subr/cmdline.c =================================================================== --- subversion/libsvn_subr/cmdline.c (revision 19222) +++ subversion/libsvn_subr/cmdline.c (working copy) @@ -43,13 +43,6 @@ #include "svn_private_config.h" -#define SVN_UTF_CONTOU_XLATE_HANDLE "svn-utf-contou-xlate-handle" -#define SVN_UTF_UTOCON_XLATE_HANDLE "svn-utf-utocon-xlate-handle" - -#ifdef AS400_UTF8 -#define SVN_UTF_ETOU_XLATE_HANDLE "svn-utf-etou-xlate-handle" -#endif - /* The stdin encoding. If null, it's the same as the native encoding. */ static const char *input_encoding = NULL; @@ -195,8 +188,7 @@ if (output_encoding == NULL) return svn_utf_cstring_from_utf8(dest, src, pool); else - return svn_utf_cstring_from_utf8_ex(dest, src, output_encoding, - SVN_UTF_UTOCON_XLATE_HANDLE, pool); + return svn_utf_cstring_from_utf8_ex2(dest, src, output_encoding, pool); } @@ -217,8 +209,7 @@ if (input_encoding == NULL) return svn_utf_cstring_to_utf8(dest, src, pool); else - return svn_utf_cstring_to_utf8_ex(dest, src, input_encoding, - SVN_UTF_CONTOU_XLATE_HANDLE, pool); + return svn_utf_cstring_to_utf8_ex2(dest, src, input_encoding, pool); } @@ -473,10 +464,8 @@ for (i = 0; i < argc; ++i) { char *arg_utf8; - SVN_ERR(svn_utf_cstring_to_utf8_ex(&arg_utf8, argv[i], - (const char *)0, - SVN_UTF_ETOU_XLATE_HANDLE, - pool)); + SVN_ERR(svn_utf_cstring_to_utf8_ex2(&arg_utf8, argv[i], + (const char *)0, pool)); argv[i] = arg_utf8; } #endif Index: subversion/libsvn_subr/io.c =================================================================== --- subversion/libsvn_subr/io.c (revision 19222) +++ subversion/libsvn_subr/io.c (working copy) @@ -51,11 +51,6 @@ #include "svn_utf.h" #include "svn_config.h" #include "svn_private_config.h" - -#ifdef AS400 -#define SVN_UTF_ETOU_XLATE_HANDLE "svn-utf-etou-xlate-handle" -#define SVN_UTF_UTOE_XLATE_HANDLE "svn-utf-utoe-xlate-handle" -#endif /* Windows is 'aided' by a number of types of applications that @@ -442,10 +437,8 @@ #ifdef AS400_UTF8 /* On OS400 with UTF support a native cstring is UTF-8, but * symlink() *really* needs EBCDIC paths. */ - SVN_ERR(svn_utf_cstring_from_utf8_ex(&dest_apr_ebcdic, dest_apr, - (const char*)0, - SVN_UTF_UTOE_XLATE_HANDLE, - pool)); + SVN_ERR(svn_utf_cstring_from_utf8_ex2(&dest_apr_ebcdic, dest_apr, + (const char*)0, pool)); dest_apr = dest_apr_ebcdic; #endif @@ -479,10 +472,8 @@ #else /* On OS400 with UTF support a native cstring is UTF-8, * but symlink() *really* needs an EBCDIC path. */ - SVN_ERR(svn_utf_cstring_from_utf8_ex(&unique_name_apr, unique_name, - (const char*)0, - SVN_UTF_UTOE_XLATE_HANDLE, - pool)); + SVN_ERR(svn_utf_cstring_from_utf8_ex2(&unique_name_apr, unique_name, + (const char*)0, pool)); #endif do { @@ -554,9 +545,8 @@ #else /* On OS400 with UTF support a native cstring is UTF-8, but * readlink() *really* needs an EBCDIC path. */ - SVN_ERR(svn_utf_cstring_from_utf8_ex(&path_apr, path, (const char*)0, - SVN_UTF_UTOE_XLATE_HANDLE, - pool)); + SVN_ERR(svn_utf_cstring_from_utf8_ex2(&path_apr, path, (const char*)0, + pool)); #endif do { rv = readlink(path_apr, buf, sizeof(buf) - 1); @@ -577,9 +567,8 @@ #else /* The buf filled by readline() is ebcdic encoded * despite V5R4's UTF support. */ - SVN_ERR(svn_utf_cstring_to_utf8_ex(&buf_utf8, dest_apr.data, - (const char *)0, - SVN_UTF_ETOU_XLATE_HANDLE, pool)); + SVN_ERR(svn_utf_cstring_to_utf8_ex2(&buf_utf8, dest_apr.data, + (const char *)0, pool)); *dest = svn_string_create(buf_utf8, pool); #endif Index: subversion/libsvn_subr/stream.c =================================================================== --- subversion/libsvn_subr/stream.c (revision 19222) +++ subversion/libsvn_subr/stream.c (working copy) @@ -151,8 +151,8 @@ message = apr_pvsprintf(pool, fmt, ap); va_end(ap); - SVN_ERR(svn_utf_cstring_from_utf8_ex(&translated, message, encoding, - NULL, pool)); + SVN_ERR(svn_utf_cstring_from_utf8_ex2(&translated, message, encoding, + pool)); len = strlen(translated); Index: subversion/libsvn_subr/subst.c =================================================================== --- subversion/libsvn_subr/subst.c (revision 19222) +++ subversion/libsvn_subr/subst.c (working copy) @@ -1694,8 +1694,8 @@ if (encoding) { - SVN_ERR(svn_utf_cstring_to_utf8_ex(&val_utf8, value->data, - encoding, NULL, pool)); + SVN_ERR(svn_utf_cstring_to_utf8_ex2(&val_utf8, value->data, + encoding, pool)); } else { Index: subversion/libsvn_subr/utf.c =================================================================== --- subversion/libsvn_subr/utf.c (revision 19222) +++ subversion/libsvn_subr/utf.c (working copy) @@ -131,6 +131,37 @@ } } +/* Return a unique string key based on TOPAGE and FROMPAGE. TOPAGE and + * FROMPAGE can be any valid arguments of the same name to + * apr_xlate_open(). Allocate the returned string in POOL. */ +static const char* +get_xlate_key(const char *topage, + const char *frompage, + apr_pool_t *pool) +{ +#ifndef AS400 + /* In the cases of SVN_APR_LOCALE_CHARSET and SVN_APR_DEFAULT_CHARSET + * topage/frompage is really an int, not a valid string. So generate a + * unique key accordingly. */ + if (frompage == SVN_APR_LOCALE_CHARSET) + frompage = "APR_LOCALE_CHARSET"; + else if (frompage == SVN_APR_DEFAULT_CHARSET) + frompage = "APR_DEFAULT_CHARSET"; + + if (topage == SVN_APR_LOCALE_CHARSET) + topage = "APR_LOCALE_CHARSET"; + else if (topage == SVN_APR_DEFAULT_CHARSET) + topage = "APR_DEFAULT_CHARSET"; + + return apr_pstrcat(pool, "svn-utf-", frompage, "to", topage, + "-xlate-handle", NULL); +#else + /* OS400 code pages are always ints. */ + return apr_psprintf(pool, "svn-utf-%dto%d-xlate-handle", (int)frompage, + (int)topage); +#endif +} + /* Set *RET to a handle node for converting from FROMPAGE to TOPAGE, creating the handle node if it doesn't exist in USERDATA_KEY. If a node is not cached and apr_xlate_open() returns APR_EINVAL or @@ -720,14 +751,15 @@ svn_error_t * -svn_utf_cstring_to_utf8_ex(const char **dest, - const char *src, - const char *frompage, - const char *convset_key, - apr_pool_t *pool) +svn_utf_cstring_to_utf8_ex2(const char **dest, + const char *src, + const char *frompage, + apr_pool_t *pool) { xlate_handle_node_t *node; svn_error_t *err; + const char *convset_key = get_xlate_key(SVN_APR_UTF8_CHARSET, frompage, + pool); SVN_ERR(get_xlate_handle_node(&node, SVN_APR_UTF8_CHARSET, frompage, convset_key, pool)); @@ -741,6 +773,17 @@ svn_error_t * +svn_utf_cstring_to_utf8_ex(const char **dest, + const char *src, + const char *frompage, + const char *convset_key, + apr_pool_t *pool) +{ + return svn_utf_cstring_to_utf8_ex2(dest, src, frompage, pool); +} + + +svn_error_t * svn_utf_stringbuf_from_utf8(svn_stringbuf_t **dest, const svn_stringbuf_t *src, apr_pool_t *pool) @@ -821,14 +864,15 @@ svn_error_t * -svn_utf_cstring_from_utf8_ex(const char **dest, - const char *src, - const char *topage, - const char *convset_key, - apr_pool_t *pool) +svn_utf_cstring_from_utf8_ex2(const char **dest, + const char *src, + const char *topage, + apr_pool_t *pool) { xlate_handle_node_t *node; svn_error_t *err; + const char *convset_key = get_xlate_key(topage, SVN_APR_UTF8_CHARSET, + pool); SVN_ERR(check_utf8(src, strlen(src), pool)); @@ -841,6 +885,17 @@ } +svn_error_t * +svn_utf_cstring_from_utf8_ex(const char **dest, + const char *src, + const char *topage, + const char *convset_key, + apr_pool_t *pool) +{ + return svn_utf_cstring_from_utf8_ex2(dest, src, topage, pool); +} + + const char * svn_utf__cstring_from_utf8_fuzzy(const char *src, apr_pool_t *pool, Index: subversion/svn/util.c =================================================================== --- subversion/svn/util.c (revision 19222) +++ subversion/svn/util.c (working copy) @@ -145,9 +145,8 @@ NULL, FALSE, pool)); translated_contents = svn_string_create("", pool); if (encoding) - SVN_ERR(svn_utf_cstring_from_utf8_ex(&translated_contents->data, - translated, encoding, NULL, - pool)); + SVN_ERR(svn_utf_cstring_from_utf8_ex2(&translated_contents->data, + translated, encoding, pool)); else SVN_ERR(svn_utf_cstring_from_utf8(&translated_contents->data, translated, pool));