diff --git a/src/attr.c b/src/attr.c index 3fe76d124..fa1a4f121 100644 --- a/src/attr.c +++ b/src/attr.c @@ -232,7 +232,7 @@ int git_attr_cache__push_file( file = git_hashtable_lookup(cache->files, filename); if (file == NULL && git_futils_exists(filename) == GIT_SUCCESS) { if ((error = git_attr_file__new(&file)) == GIT_SUCCESS) - error = (*loader)(repo, filename, file); + error = loader(repo, filename, file); add_to_cache = (error == GIT_SUCCESS); } diff --git a/src/attr_file.c b/src/attr_file.c index f6eaad69d..4303c7667 100644 --- a/src/attr_file.c +++ b/src/attr_file.c @@ -363,8 +363,18 @@ int git_attr_fnmatch__parse( *base = git__next_line(pattern); return GIT_ENOMEM; } else { - /* remove '\' that might have be used for internal whitespace */ - spec->length = git__removechar(spec->pattern, '\\'); + /* strip '\' that might have be used for internal whitespace */ + char *to = spec->pattern; + for (scan = spec->pattern; *scan; to++, scan++) { + if (*scan == '\\') + scan++; /* skip '\' but include next char */ + if (to != scan) + *to = *scan; + } + if (to != scan) { + *to = '\0'; + spec->length = (to - spec->pattern); + } } return GIT_SUCCESS; diff --git a/src/util.c b/src/util.c index f47de9e53..1ca9d850c 100644 --- a/src/util.c +++ b/src/util.c @@ -156,23 +156,6 @@ void git__strtolower(char *str) git__strntolower(str, strlen(str)); } -size_t git__removechar(char *str, char remove) -{ - char *from = str, *to = str; - - while (*from) { - if (*from == remove) - from++; - if (to != from) - *to = *from; - to++; - from++; - } - *to = '\0'; - - return (to - str); -} - int git__prefixcmp(const char *str, const char *prefix) { for (;;) { diff --git a/src/util.h b/src/util.h index 818e6f0f2..6c929cf0a 100644 --- a/src/util.h +++ b/src/util.h @@ -102,8 +102,6 @@ extern char *git__strtok(char **end, const char *sep); extern void git__strntolower(char *str, size_t len); extern void git__strtolower(char *str); -extern size_t git__removechar(char *str, char remove); - GIT_INLINE(const char *) git__next_line(const char *s) { while (*s && *s != '\n') s++;