Skip to content

Instantly share code, notes, and snippets.

@tholu
Created July 2, 2013 20:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tholu/5912705 to your computer and use it in GitHub Desktop.
Save tholu/5912705 to your computer and use it in GitHub Desktop.
svn_diff_xp_utf8_patch
Index: subversion/libsvn_subr/path.c
===================================================================
--- subversion/libsvn_subr/path.c (revision 1499077)
+++ subversion/libsvn_subr/path.c (working copy)
@@ -40,6 +40,9 @@
#include "dirent_uri.h"
+#if defined(DARWIN)
+#include <CoreFoundation/CoreFoundation.h>
+#endif /* DARWIN */
/* The canonical empty path. Can this be changed? Well, change the empty
test below and the path library will work, not so sure about the fs/wc
@@ -1100,7 +1103,6 @@ svn_path_get_absolute(const char **pabsolute,
}
-#if !defined(WIN32) && !defined(DARWIN)
/** Get APR's internal path encoding. */
static svn_error_t *
get_path_encoding(svn_boolean_t *path_is_utf8, apr_pool_t *pool)
@@ -1119,7 +1121,6 @@ get_path_encoding(svn_boolean_t *path_is_utf8, apr
*path_is_utf8 = (encoding_style == APR_FILEPATH_ENCODING_UTF8);
return SVN_NO_ERROR;
}
-#endif
svn_error_t *
@@ -1148,19 +1149,48 @@ svn_path_cstring_to_utf8(const char **path_utf8,
const char *path_apr,
apr_pool_t *pool)
{
-#if !defined(WIN32) && !defined(DARWIN)
+ svn_error_t *err;
+#if !defined(WIN32)
svn_boolean_t path_is_utf8;
+#endif
+#if defined(DARWIN)
+ /*
+ Compose decomposed unicode characters out of precomposed ones.
+ This will solve the problem that the 'svn status' command sometimes
+ cannot recognize a file if it contains composed characters, like
+ Umlaut in some European languages
+ */
+ CFMutableStringRef cfmsr = CFStringCreateMutable(NULL, 0);
+ CFStringAppendCString(cfmsr, path_apr, kCFStringEncodingUTF8);
+ CFStringNormalize(cfmsr, kCFStringNormalizationFormC);
+ CFIndex path_buff_size = 1 + CFStringGetMaximumSizeForEncoding(
+ CFStringGetLength(cfmsr), kCFStringEncodingUTF8);
+ char *path = apr_palloc(pool, path_buff_size);
+ CFStringGetCString(cfmsr, path, path_buff_size, kCFStringEncodingUTF8);
+#endif
+#if !defined(WIN32)
SVN_ERR(get_path_encoding(&path_is_utf8, pool));
if (path_is_utf8)
#endif
{
+#if defined(DARWIN)
+ *path_utf8 = apr_pstrdup(pool, path);
+#else
*path_utf8 = apr_pstrdup(pool, path_apr);
- return SVN_NO_ERROR;
+#endif
+ err = SVN_NO_ERROR;
}
-#if !defined(WIN32) && !defined(DARWIN)
- else
- return svn_utf_cstring_to_utf8(path_utf8, path_apr, pool);
+#if !defined(WIN32)
+ else {
+#if defined(DARWIN)
+ err = svn_utf_cstring_to_utf8(path_utf8, path_apr, pool);
+ CFRelease(cfmsr);
+#else
+ err = svn_utf_cstring_to_utf8(path_utf8, path_apr, pool);
#endif
+ }
+#endif
+ return err;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment