Skip to content

Instantly share code, notes, and snippets.

@tholu
Last active December 18, 2015 18:39
Show Gist options
  • Save tholu/5827651 to your computer and use it in GitHub Desktop.
Save tholu/5827651 to your computer and use it in GitHub Desktop.
UTF8 patch for Subversion 1.8.0
--- subversion/libsvn_subr/path.c.original 2013-07-02 23:04:31.000000000 +0200
+++ subversion/libsvn_subr/path.c 2013-07-02 23:29:30.000000000 +0200
@@ -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 @@
}
-#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 @@
*path_is_utf8 = (encoding_style == APR_FILEPATH_ENCODING_UTF8);
return SVN_NO_ERROR;
}
-#endif
svn_error_t *
@@ -1127,19 +1128,15 @@
const char *path_utf8,
apr_pool_t *pool)
{
-#if !defined(WIN32) && !defined(DARWIN)
svn_boolean_t path_is_utf8;
SVN_ERR(get_path_encoding(&path_is_utf8, pool));
if (path_is_utf8)
-#endif
{
*path_apr = apr_pstrdup(pool, path_utf8);
return SVN_NO_ERROR;
}
-#if !defined(WIN32) && !defined(DARWIN)
else
return svn_utf_cstring_from_utf8(path_apr, path_utf8, pool);
-#endif
}
@@ -1148,16 +1145,43 @@
const char *path_apr,
apr_pool_t *pool)
{
-#if !defined(WIN32) && !defined(DARWIN)
svn_boolean_t path_is_utf8;
+#if defined(DARWIN)
+ svn_error_t *err;
+ /*
+ Compose any decomposed unicode characters precomposed one.
+ This will solve the problem that the 'svn status' command sometime
+ cannot recognize as same file when files suppose to be comtain
+ comopsed characters, like umlaut in some European language or
+ 'Daku-ten' in Japanese, and the files are added on windows machines
+ then you use svn on Mac OS X checking out the files.
+ */
+ 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);
+
SVN_ERR(get_path_encoding(&path_is_utf8, pool));
+
if (path_is_utf8)
-#endif
- {
- *path_utf8 = apr_pstrdup(pool, path_apr);
- return SVN_NO_ERROR;
- }
-#if !defined(WIN32) && !defined(DARWIN)
+ {
+ *path_utf8 = apr_pstrdup(pool, path);
+ err = SVN_NO_ERROR;
+ }
+ else
+ err = svn_utf_cstring_to_utf8(path_utf8, path, pool);
+ CFRelease(cfmsr);
+ return err;
+#else
+ SVN_ERR(get_path_encoding(&path_is_utf8, pool));
+ if (path_is_utf8)
+ {
+ *path_utf8 = apr_pstrdup(pool, path_apr);
+ return SVN_NO_ERROR;
+ }
else
return svn_utf_cstring_to_utf8(path_utf8, path_apr, pool);
#endif
@tholu
Copy link
Author

tholu commented Jun 20, 2013

Does apply and svn stats runs with no direct error but does not fix the utf8 issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment