git-svn: trunk@5039
Tomasz Kojm authored on 2009/04/12 19:10:32... | ... |
@@ -1,3 +1,8 @@ |
1 |
+Sun Apr 12 12:07:36 CEST 2009 (tk) |
|
2 |
+---------------------------------- |
|
3 |
+ * shared/optparser.c: regexes are now case insensitive by default (this can |
|
4 |
+ be changed with FLAG_REG_CASE) |
|
5 |
+ |
|
1 | 6 |
Sat Apr 11 11:40:38 CEST 2009 (tk) |
2 | 7 |
---------------------------------- |
3 | 8 |
* freshclam: fix calls to execute() (bb#1560) |
... | ... |
@@ -50,15 +50,16 @@ |
50 | 50 |
#define MAX(a,b) (a > b ? a : b) |
51 | 51 |
|
52 | 52 |
#define MATCH_NUMBER "^[0-9]+$" |
53 |
-#define MATCH_SIZE "^[0-9]+[kKmM]?$" |
|
54 |
-#define MATCH_BOOL "^([yY]es|[tT]rue|1|[nN]o|[fF]alse|0)$" |
|
53 |
+#define MATCH_SIZE "^[0-9]+[KM]?$" |
|
54 |
+#define MATCH_BOOL "^(yes|true|1|no|false|0)$" |
|
55 | 55 |
|
56 | 56 |
#define FLAG_MULTIPLE 1 /* option can be used multiple times */ |
57 | 57 |
#define FLAG_REQUIRED 2 /* arg is required, even if there's a default value */ |
58 | 58 |
#define FLAG_HIDDEN 4 /* don't print in clamconf --generate-config */ |
59 |
+#define FLAG_REG_CASE 8 /* case-sensitive regex matching */ |
|
59 | 60 |
|
60 | 61 |
const struct clam_option clam_options[] = { |
61 |
- /* name, longopt, sopt, argtype, regex, num, str, mul, owner, description, suggested */ |
|
62 |
+ /* name, longopt, sopt, argtype, regex, num, str, flags, owner, description, suggested */ |
|
62 | 63 |
|
63 | 64 |
/* cmdline only */ |
64 | 65 |
{ 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 |
637 | 637 |
char shortopts[MAXCMDOPTS]; |
638 | 638 |
regex_t regex; |
639 | 639 |
unsigned long int lnumarg; |
640 |
+ int regflags = REG_EXTENDED | REG_NOSUB; |
|
640 | 641 |
|
641 | 642 |
|
642 | 643 |
if(oldopts) |
... | ... |
@@ -858,7 +860,10 @@ struct optstruct *optparse(const char *cfgfile, int argc, char **argv, int verbo |
858 | 858 |
if(!cfgfile && !arg && optentry->argtype == TYPE_BOOL) { |
859 | 859 |
arg = "yes"; /* default to yes */ |
860 | 860 |
} else if(optentry->regex) { |
861 |
- if(cli_regcomp(®ex, optentry->regex, REG_EXTENDED | REG_NOSUB)) { |
|
861 |
+ if(!(optentry->flags & FLAG_REG_CASE)) |
|
862 |
+ regflags |= REG_ICASE; |
|
863 |
+ |
|
864 |
+ if(cli_regcomp(®ex, optentry->regex, regflags)) { |
|
862 | 865 |
fprintf(stderr, "ERROR: optparse: Can't compile regular expression %s for option %s\n", optentry->regex, name); |
863 | 866 |
err = 1; |
864 | 867 |
break; |