Browse code

use cli_regcomp(), instead of regcomp(). [patch idea approved by TK]

git-svn: trunk@3235

Török Edvin authored on 2007/09/21 07:03:53
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Fri Sep 21 00:18:08 EEST 2007(edwin)
2
+------------------------------------
3
+ * clamscan/others.c: use cli_regcomp(), instead of regcomp().
4
+
1 5
 Fri Sep 21 00:13:32 EEST 2007(edwin)
2 6
 ------------------------------------
3 7
   * configure, configure.in: add check to detect certain compiler bugs that
... ...
@@ -43,9 +43,7 @@
43 43
 #include <signal.h>
44 44
 #include <target.h>
45 45
 
46
-#ifdef HAVE_REGEX_H
47
-#include <regex.h>
48
-#endif
46
+#include "regex/regex.h"
49 47
 
50 48
 #include "shared/output.h"
51 49
 #include "others.h"
... ...
@@ -130,22 +128,18 @@ int checkaccess(const char *path, const char *username, int mode)
130 130
 
131 131
 int match_regex(const char *filename, const char *pattern)
132 132
 {
133
-#ifdef HAVE_REGEX_H
134 133
 	regex_t reg;
135 134
 	int match, flags;
136 135
 #if !defined(C_CYGWIN) && !defined(C_OS2)
137 136
 	flags = REG_EXTENDED;
138 137
 #else
139 138
 	flags = REG_EXTENDED | REG_ICASE; /* case insensitive on Windows */
140
-#endif	
141
-	if(regcomp(&reg, pattern, flags) != 0) {
139
+#endif
140
+	if(cli_regcomp(&reg, pattern, flags) != 0) {
142 141
 	    logg("!%s: Could not parse regular expression %s.\n", filename, pattern);
143 142
 		return 2;
144 143
 	}
145
-	match = (regexec(&reg, filename, 0, NULL, 0) == REG_NOMATCH) ? 0 : 1;
146
-	regfree(&reg);
144
+	match = (cli_regexec(&reg, filename, 0, NULL, 0) == REG_NOMATCH) ? 0 : 1;
145
+	cli_regfree(&reg);
147 146
 	return match;
148
-#else /* HAVE_REGEX_H */
149
-	return strstr(filename, pattern) ? 1 : 0;
150
-#endif
151 147
 }