[Pkg-owncloud-commits] [owncloud-client] 115/484: csync_exclude: Use PathMatchSpecA instead of PathMatchSpecW
Sandro Knauß
hefee-guest at moszumanska.debian.org
Wed Dec 16 00:37:24 UTC 2015
This is an automated email from the git hooks/post-receive script.
hefee-guest pushed a commit to branch master
in repository owncloud-client.
commit 71827549d6bc8083baa61d8c2a5f3f3198526002
Author: Olivier Goffart <ogoffart at woboq.com>
Date: Tue Oct 20 17:06:32 2015 +0200
csync_exclude: Use PathMatchSpecA instead of PathMatchSpecW
So we avoid lots of memory allocation.
We can work with char* directly since both the pattern and the file
name are in UTF-8 and there is no need to understand unicode for
such pattern.
(In fact, '?' would not match anyore non-ascii characters, but I
don't think that's a problem. I don't think anyone use '?' in its
exclude list. And the two allocations per call to csync_fnmatch are
really worth getting rid of)
---
csync/src/csync_misc.c | 13 +++----------
csync/tests/csync_tests/check_csync_exclude.c | 16 ++++++++++++++++
2 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/csync/src/csync_misc.c b/csync/src/csync_misc.c
index 824e054..a93d422 100644
--- a/csync/src/csync_misc.c
+++ b/csync/src/csync_misc.c
@@ -57,20 +57,13 @@ int csync_fnmatch(__const char *__pattern, __const char *__name, int __flags) {
#else /* HAVE_FNMATCH */
#include <shlwapi.h>
-int csync_fnmatch(__const char *__pattern, __const char *__name, int __flags) {
- wchar_t *pat = NULL;
- wchar_t *name = NULL;
+int csync_fnmatch(const char *pattern, const char *name, int flags) {
BOOL match;
- (void) __flags;
-
- name = c_utf8_string_to_locale(__name);
- pat = c_utf8_string_to_locale(__pattern);
+ (void) flags;
- match = PathMatchSpecW(name, pat);
+ match = PathMatchSpecA(name, pattern);
- c_free_locale_string(pat);
- c_free_locale_string(name);
if(match)
return 0;
else
diff --git a/csync/tests/csync_tests/check_csync_exclude.c b/csync/tests/csync_tests/check_csync_exclude.c
index c73fe5f..797542f 100644
--- a/csync/tests/csync_tests/check_csync_exclude.c
+++ b/csync/tests/csync_tests/check_csync_exclude.c
@@ -48,6 +48,12 @@ static void setup_init(void **state) {
rc = csync_exclude_load(EXCLUDE_LIST_FILE, &(csync->excludes));
assert_int_equal(rc, 0);
+ /* and add some unicode stuff */
+ rc = _csync_exclude_add(&(csync->excludes), "*.💩");
+ assert_int_equal(rc, 0);
+ rc = _csync_exclude_add(&(csync->excludes), "пятницы.*");
+ assert_int_equal(rc, 0);
+
*state = csync;
}
@@ -145,6 +151,16 @@ static void check_csync_excluded(void **state)
rc = csync_excluded(csync, ".netscape/cache", CSYNC_FTW_TYPE_FILE);
assert_int_equal(rc, CSYNC_NOT_EXCLUDED);
+ /* Not excluded */
+ rc = csync_excluded(csync, "unicode/中文.hé", CSYNC_FTW_TYPE_FILE);
+ assert_int_equal(rc, CSYNC_NOT_EXCLUDED);
+ /* excluded */
+ rc = csync_excluded(csync, "unicode/пятницы.txt", CSYNC_FTW_TYPE_FILE);
+ assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
+ rc = csync_excluded(csync, "unicode/中文.💩", CSYNC_FTW_TYPE_FILE);
+ assert_int_equal(rc, CSYNC_FILE_EXCLUDE_LIST);
+
+
}
static void check_csync_excluded_traversal(void **state)
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud-client.git
More information about the Pkg-owncloud-commits
mailing list