diff --git a/src/ChangeLog b/src/ChangeLog index 71a0f5084..385fd1d22 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,11 @@ 2003-06-06 Pavel Roskin + * util.h: Add new match_type - match_regex. + * ext.c: Use it everywhere. + (regex_command): Don't change easy_patterns - it affects the + panel filters. + Reported by Andrew V. Samoilov + * view.c (get_byte): Fix off-by-one error. Found by Valgrind. * command.c (command_new): Fix memory leak. diff --git a/src/ext.c b/src/ext.c index 44fd1a3e4..8845063aa 100644 --- a/src/ext.c +++ b/src/ext.c @@ -457,7 +457,7 @@ regex_check_type (char *filename, int file_len, char *ptr, int *have_type) if (content_string && content_string[0] && regexp_match (ptr, content_string + content_shift, - match_normal)) { + match_regex)) { found = 1; } @@ -484,7 +484,6 @@ regex_command (char *filename, char *action, int *move_dir) int found = 0; int error_flag = 0; int ret = 0; - int old_patterns; struct stat mystat; int view_at_line_number; char *include_target; @@ -566,8 +565,6 @@ regex_command (char *filename, char *action, int *move_dir) } mc_stat (filename, &mystat); - old_patterns = easy_patterns; - easy_patterns = 0; /* Real regular expressions are needed :) */ include_target = NULL; include_target_len = 0; for (p = data; *p; p++) { @@ -600,11 +597,11 @@ regex_command (char *filename, char *action, int *move_dir) /* Do not transform shell patterns, you can use shell/ for * that */ - if (regexp_match (p, filename, match_normal)) + if (regexp_match (p, filename, match_regex)) found = 1; } else if (!strncmp (p, "directory/", 10)) { if (S_ISDIR (mystat.st_mode) - && regexp_match (p + 10, filename, match_normal)) + && regexp_match (p + 10, filename, match_regex)) found = 1; } else if (!strncmp (p, "shell/", 6)) { p += 6; @@ -690,7 +687,6 @@ regex_command (char *filename, char *action, int *move_dir) break; } } - easy_patterns = old_patterns; if (error_flag) return -1; return ret; diff --git a/src/util.c b/src/util.c index dc8a39a4c..5637bb9d8 100644 --- a/src/util.c +++ b/src/util.c @@ -496,7 +496,7 @@ char *convert_pattern (char *pattern, int match_type, int do_group) char *new_pattern; int was_wildcard = 0; - if (easy_patterns){ + if ((match_type != match_regex) && easy_patterns){ new_pattern = g_malloc (MC_MAXPATHLEN); d = new_pattern; if (match_type == match_file) diff --git a/src/util.h b/src/util.h index f22947ab5..6f40c6ea3 100644 --- a/src/util.h +++ b/src/util.h @@ -62,7 +62,12 @@ char *_icase_search (char *text, char *data, int *lng); #define icase_search(T,D) _icase_search((T), (D), NULL) /* Matching */ -enum { match_file, match_normal }; +enum { + match_file, /* match a filename, use easy_patterns */ + match_normal, /* match pattern, use easy_patterns */ + match_regex, /* match pattern, force using regex */ +}; + extern int easy_patterns; char *convert_pattern (char *pattern, int match_type, int do_group); int regexp_match (char *pattern, char *string, int match_type);