[Pkg-clamav-commits] [SCM] Debian repository for ClamAV branch, debian/unstable, updated. debian/0.95+dfsg-1-167-g4319a8f

tkojm tkojm at 77e5149b-7576-45b1-b177-96237e5ba77b
Fri Jun 12 19:11:12 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit b6821267451962a6b9bb4e1d5cbdae215a1d769a
Author: tkojm <tkojm at 77e5149b-7576-45b1-b177-96237e5ba77b>
Date:   Sun Apr 12 10:10:32 2009 +0000

    shared/optparser.c: regexes are now case insensitive by default (this can be changed with FLAG_REG_CASE)
    
    
    git-svn-id: http://svn.clamav.net/svn/clamav-devel/trunk@5039 77e5149b-7576-45b1-b177-96237e5ba77b

diff --git a/ChangeLog b/ChangeLog
index 4f435bb..2c26756 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sun Apr 12 12:07:36 CEST 2009 (tk)
+----------------------------------
+ * shared/optparser.c: regexes are now case insensitive by default (this can
+		       be changed with FLAG_REG_CASE)
+
 Sat Apr 11 11:40:38 CEST 2009 (tk)
 ----------------------------------
  * freshclam: fix calls to execute() (bb#1560)
diff --git a/shared/optparser.c b/shared/optparser.c
index 9a66022..70cec97 100644
--- a/shared/optparser.c
+++ b/shared/optparser.c
@@ -50,15 +50,16 @@
 #define MAX(a,b) (a > b ? a : b)
 
 #define MATCH_NUMBER "^[0-9]+$"
-#define MATCH_SIZE "^[0-9]+[kKmM]?$"
-#define MATCH_BOOL "^([yY]es|[tT]rue|1|[nN]o|[fF]alse|0)$"
+#define MATCH_SIZE "^[0-9]+[KM]?$"
+#define MATCH_BOOL "^(yes|true|1|no|false|0)$"
 
 #define FLAG_MULTIPLE	1 /* option can be used multiple times */
 #define FLAG_REQUIRED	2 /* arg is required, even if there's a default value */
 #define FLAG_HIDDEN	4 /* don't print in clamconf --generate-config */
+#define FLAG_REG_CASE	8 /* case-sensitive regex matching */
 
 const struct clam_option clam_options[] = {
-    /* name,   longopt, sopt, argtype, regex, num, str, mul, owner, description, suggested */
+    /* name,   longopt, sopt, argtype, regex, num, str, flags, owner, description, suggested */
 
     /* cmdline only */
     { NULL, "help", 'h', TYPE_BOOL, MATCH_BOOL, 0, NULL, 0, OPT_CLAMD | OPT_FRESHCLAM | OPT_CLAMSCAN | OPT_CLAMDSCAN | OPT_SIGTOOL | OPT_MILTER | OPT_CLAMCONF | OPT_CLAMDTOP, "", "" },
@@ -637,6 +638,7 @@ struct optstruct *optparse(const char *cfgfile, int argc, char **argv, int verbo
 	char shortopts[MAXCMDOPTS];
 	regex_t regex;
 	unsigned long int lnumarg;
+	int regflags = REG_EXTENDED | REG_NOSUB;
 
 
     if(oldopts)
@@ -858,7 +860,10 @@ struct optstruct *optparse(const char *cfgfile, int argc, char **argv, int verbo
 	if(!cfgfile && !arg && optentry->argtype == TYPE_BOOL) {
 	    arg = "yes"; /* default to yes */
 	} else if(optentry->regex) {
-	    if(cli_regcomp(&regex, optentry->regex, REG_EXTENDED | REG_NOSUB)) {
+	    if(!(optentry->flags & FLAG_REG_CASE))
+		regflags |= REG_ICASE;
+
+	    if(cli_regcomp(&regex, optentry->regex, regflags)) {
 		fprintf(stderr, "ERROR: optparse: Can't compile regular expression %s for option %s\n", optentry->regex, name);
 		err = 1;
 		break;

-- 
Debian repository for ClamAV



More information about the Pkg-clamav-commits mailing list