This version hits error.c only, no new APIs. Sending as an attachment per
http://subversion.apache.org/docs/community-guide/general.html#patches
[[[ Produce readable error messages on non-ASCII systems.
* subversion/libsvn_subr/error.c:
print_error(): convert err->message and the message prefix to UTF-8
before calling svn_cmdline_printf.
svn_error_wrap_apr(): remove UTF-8 conversion of apr_strerror output
before storing it in err->message to avoid a double conversion
]]]
Greg
Index: subversion/libsvn_subr/error.c
===================================================================
--- subversion/libsvn_subr/error.c (revision 943729)
+++ subversion/libsvn_subr/error.c (working copy)
@@ -161,7 +161,7 @@
const char *fmt,
...)
{
- svn_error_t *err, *utf8_err;
+ svn_error_t *err;
va_list ap;
char errbuf[255];
const char *msg_apr, *msg;
@@ -172,10 +172,6 @@
{
/* Grab the APR error message. */
apr_strerror(status, errbuf, sizeof(errbuf));
- utf8_err = svn_utf_cstring_to_utf8(&msg_apr, errbuf, err->pool);
- if (utf8_err)
- msg_apr = NULL;
- svn_error_clear(utf8_err);
/* Append it to the formatted message. */
va_start(ap, fmt);
@@ -183,7 +179,7 @@
va_end(ap);
err->message = apr_psprintf(err->pool, "%s%s%s", msg,
(msg_apr) ? ": " : "",
- (msg_apr) ? msg_apr : "");
+ (msg_apr) ? errbuf : "");
}
return err;
@@ -380,7 +376,7 @@
print_error(svn_error_t *err, FILE *stream, const char *prefix)
{
char errbuf[256];
- const char *err_string;
+ const char *err_string, *prefix_utf8;
svn_error_t *temp_err = NULL; /* ensure initialized even if
err->file == NULL */
/* Pretty-print the error */
@@ -413,15 +409,21 @@
/* Skip it. We already printed the file-line coordinates. */
}
/* Only print the same APR error string once. */
- else if (err->message)
- {
- svn_error_clear(svn_cmdline_fprintf(stream, err->pool, "%s%s\n",
- prefix, err->message));
- }
else
{
+ if (err->message)
+ {
+ /* set ERR_STRING to a UTF-8 version of ERR->message */
+ temp_err = svn_utf_cstring_to_utf8(&err_string, err->message,
+ err->pool);
+ if (temp_err)
+ {
+ svn_error_clear(temp_err);
+ err_string = _("Can't recode error message");
+ }
+ }
/* Is this a Subversion-specific error code? */
- if ((err->apr_err > APR_OS_START_USEERR)
+ else if ((err->apr_err > APR_OS_START_USEERR)
&& (err->apr_err <= APR_OS_START_CANONERR))
err_string = svn_strerror(err->apr_err, errbuf, sizeof(errbuf));
/* Otherwise, this must be an APR error code. */
@@ -433,8 +435,14 @@
err_string = _("Can't recode error string from APR");
}
+ if (temp_err = svn_utf_cstring_to_utf8(&prefix_utf8, prefix, err->pool))
+ {
+ svn_error_clear(temp_err);
+ err_string = _("Can't recode message prefix");
+ }
+
svn_error_clear(svn_cmdline_fprintf(stream, err->pool,
- "%s%s\n", prefix, err_string));
+ "%s%s\n", prefix_utf8, err_string));
}
}