Add an option to filter by object hash
Implement a new --filter-hash option to filter by object identifiers. Each object having an identifier that has the specified pattern as a prefix is matched. Patterns starting with an exclamation mark (!) are interpreted as negative patterns. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
12
src/utils.c
12
src/utils.c
@@ -1641,3 +1641,15 @@ int starts_with_ci(const char *s, const char *p)
|
||||
for (; *p && tolower(*p) == tolower(*s); s++, p++);
|
||||
return (*p == '\0');
|
||||
}
|
||||
|
||||
int hash_matches(const char *pattern, const char *hash)
|
||||
{
|
||||
int invert = 0;
|
||||
|
||||
if (pattern[0] == '!') {
|
||||
invert = 1;
|
||||
pattern++;
|
||||
}
|
||||
|
||||
return (starts_with(hash, pattern) != invert);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user