Commit 83bfbdf5 by Russell Belfer

Remove poor git__removechar function

Going back over this, the git__removechar function was not
needed (only invoked once) and is actually mislabeled.  As
implemented, it really only made sense for removing backslash
characters, since two of the "removed" characters in a row
would include the second one -- i.e. it really implements
stripping backslash-escaped strings where a backslash allows
internal whitespace in a word.
parent a51cd8e6
......@@ -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);
}
......
......@@ -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;
......
......@@ -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 (;;) {
......
......@@ -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++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment