* 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 <sav@bcs.zp.ua>
This commit is contained in:
Pavel Roskin 2003-06-07 00:37:28 +00:00
parent bd9c9343eb
commit f55e75b70a
4 changed files with 16 additions and 9 deletions

View File

@ -1,5 +1,11 @@
2003-06-06 Pavel Roskin <proski@gnu.org>
* 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 <sav@bcs.zp.ua>
* view.c (get_byte): Fix off-by-one error. Found by Valgrind.
* command.c (command_new): Fix memory leak.

View File

@ -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;

View File

@ -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)

View File

@ -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);