Implement case insensitive for shell keyword.

shell/i is used now for case-insensitive shell patterns.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2012-07-21 12:02:07 +04:00
parent cbcae18836
commit 81c3d80f4b
2 changed files with 15 additions and 2 deletions

View File

@ -12,6 +12,9 @@
# i.e. matches all the files *desc . Example: .tar matches *.tar;
# if it doesn't start with a dot, it matches only a file of that name)
#
# shell/i (desc is, when starting with a dot, any extension (no wildcars),
# The same as shell but with case insensitive.
#
# regex (desc is an extended regular expression)
# Please note that we are using the GNU regex library and thus
# \| matches the literal | and | has special meaning (or) and

View File

@ -880,15 +880,25 @@ regex_command (const vfs_path_t * filename_vpath, const char *action)
}
else if (strncmp (p, "shell/", 6) == 0)
{
gboolean case_insense;
int (*cmp_func) (const char *s1, const char *s2, size_t n) = strncmp;
p += 6;
case_insense = (strncmp (p, "i/", 2) == 0);
if (case_insense)
{
p += 2;
cmp_func = strncasecmp;
}
if (*p == '.' && file_len >= (size_t) (q - p))
{
if (strncmp (p, filename + file_len - (q - p), q - p) == 0)
if (cmp_func (p, filename + file_len - (q - p), q - p) == 0)
found = TRUE;
}
else
{
if ((size_t) (q - p) == file_len && strncmp (p, filename, q - p) == 0)
if ((size_t) (q - p) == file_len && cmp_func (p, filename, q - p) == 0)
found = TRUE;
}
}