aboutsummaryrefslogtreecommitdiffstats
path: root/misc/mc/files/patch-regex
blob: 187dc029f42155ac8f0aa4adef64e72c1526c28c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
--- src/cmd.c.orig  2009-02-03 18:49:42.000000000 +0800
+++ src/cmd.c   2009-02-03 18:50:16.000000000 +0800
@@ -513,7 +513,7 @@
        continue;
    }
    c = regexp_match (reg_exp_t, current_panel->dir.list[i].fname,
-             match_file);
+             match_file, 0);
    if (c == -1) {
        message (1, MSG_ERROR, _("  Malformed regular expression  "));
        g_free (reg_exp);
--- src/dir.c.orig  2009-02-03 18:51:43.000000000 +0800
+++ src/dir.c   2009-02-03 18:51:57.000000000 +0800
@@ -327,7 +327,7 @@
        *stale_link = 1;
     }
     if (!(S_ISDIR (buf1->st_mode) || *link_to_dir) && filter
-   && !regexp_match (filter, dp->d_name, match_file))
+   && !regexp_match (filter, dp->d_name, match_file, 0))
    return 0;
 
     /* Need to grow the *list? */
--- src/ext.c.orig  2009-02-03 18:52:36.000000000 +0800
+++ src/ext.c   2009-02-03 18:53:11.000000000 +0800
@@ -395,7 +395,7 @@
     }
 
     if (content_string[0]
-   && regexp_match (ptr, content_string + content_shift, match_regex)) {
+   && regexp_match (ptr, content_string + content_shift, match_regex, 0)) {
    found = 1;
     }
 
@@ -519,11 +519,11 @@
        /* Do not transform shell patterns, you can use shell/ for
         * that
         */
-       if (regexp_match (p, filename, match_regex))
+       if (regexp_match (p, filename, match_regex, 0))
            found = 1;
        } else if (!strncmp (p, "directory/", 10)) {
        if (S_ISDIR (mystat.st_mode)
-           && regexp_match (p + 10, filename, match_regex))
+           && regexp_match (p + 10, filename, match_regex, 0))
            found = 1;
        } else if (!strncmp (p, "shell/", 6)) {
        p += 6;
--- src/find.c.orig 2009-02-03 18:54:16.000000000 +0800
+++ src/find.c  2009-02-03 18:56:56.000000000 +0800
@@ -615,6 +615,7 @@
     struct stat tmp_stat;
     static int pos;
     static int subdirs_left = 0;
+   int cflags = 0;
 
     if (!h) { /* someone forces me to close dirp */
    if (dirp) {
@@ -626,6 +627,9 @@
         dp = 0;
    return 1;
     }
+
+   if (case_sensitive == 0)
+       cflags |= REG_ICASE;
  do_search_begin:
     while (!dp){
    
@@ -702,7 +706,7 @@
    g_free (tmp_name);
     }
 
-    if (regexp_match (find_pattern, dp->d_name, match_file)){
+    if (regexp_match (find_pattern, dp->d_name, match_file, cflags)){
    if (content_pattern) {
        if (search_content (h, directory, dp->d_name)) {
        return 1;
--- src/user.c.orig 2009-02-03 18:57:38.000000000 +0800
+++ src/user.c  2009-02-03 18:58:17.000000000 +0800
@@ -416,18 +416,18 @@
        break;
    case 'f': /* file name pattern */
        p = extract_arg (p, arg, sizeof (arg));
-       *condition = panel && regexp_match (arg, panel->dir.list [panel->selected].fname, match_file);
+       *condition = panel && regexp_match (arg, panel->dir.list [panel->selected].fname, match_file, 0);
        break;
    case 'y': /* syntax pattern */
             if (edit_widget && edit_widget->syntax_type) {
            p = extract_arg (p, arg, sizeof (arg));
            *condition = panel &&
-                    regexp_match (arg, edit_widget->syntax_type, match_normal);
+                    regexp_match (arg, edit_widget->syntax_type, match_normal, 0);
        }
             break;
    case 'd':
        p = extract_arg (p, arg, sizeof (arg));
-       *condition = panel && regexp_match (arg, panel->cwd, match_file);
+       *condition = panel && regexp_match (arg, panel->cwd, match_file, 0);
        break;
    case 't':
        p = extract_arg (p, arg, sizeof (arg));
--- src/util.c.orig 2009-02-03 18:58:31.000000000 +0800
+++ src/util.c  2009-02-03 19:00:41.000000000 +0800
@@ -586,25 +586,28 @@
 }
 
 int
-regexp_match (const char *pattern, const char *string, int match_type)
+regexp_match (const char *pattern, const char *string, int match_type, int cflags)
 {
     static regex_t r;
     static char *old_pattern = NULL;
     static int old_type;
+   static int old_cflags;
     int    rval;
     char *my_pattern;
 
-    if (!old_pattern || STRCOMP (old_pattern, pattern) || old_type != match_type){
+    if (!old_pattern || STRCOMP (old_pattern, pattern) ||
+           old_type != match_type || cflags != old_cflags){
    if (old_pattern){
        regfree (&r);
        g_free (old_pattern);
        old_pattern = NULL;
    }
    my_pattern = convert_pattern (pattern, match_type, 0);
-   if (regcomp (&r, my_pattern, REG_EXTENDED|REG_NOSUB|MC_ARCH_FLAGS)) {
+   if (regcomp (&r, my_pattern, REG_EXTENDED|REG_NOSUB|MC_ARCH_FLAGS|cflags)) {
        g_free (my_pattern);
        return -1;
    }
+   old_cflags = cflags;
    old_pattern = my_pattern;
    old_type = match_type;
     }
--- src/util.h.orig 2009-02-03 19:00:50.000000000 +0800
+++ src/util.h  2009-02-03 19:01:21.000000000 +0800
@@ -125,7 +125,7 @@
 
 extern int easy_patterns;
 char *convert_pattern (const char *pattern, int match_type, int do_group);
-int regexp_match (const char *pattern, const char *string, int match_type);
+int regexp_match (const char *pattern, const char *string, int match_type, int cflags);
 
 /* Error pipes */
 void open_error_pipe (void);