{
success = false; /* use this.success to known if it's ok */
int flen = strlen(fname);
-#ifndef HAVE_REGEX_H
- int i;
- check_pool_memory_size(lcase, flen);
- for(i=0; fname[i] ; i++) {
- lcase[i] = tolower(fname[i]);
- }
- lcase[i] = '\0';
- int rc = re_search(&preg, (BREGEX_CAST char*) lcase, flen, 0, flen, ®s);
-#else
int rc = re_search(&preg, (BREGEX_CAST char*) fname, flen, 0, flen, ®s);
-#endif
if (rc < 0) {
Dmsg0(500, "bregexp: regex mismatch\n");
*
* This file modified to work with Bacula and C++ by
* Kern Sibbald, April 2006
+ *
+ * This file modified to work with REG_ICASE and Bacula by
+ * Eric Bollengier April 2007
*/
/*
Bacula® - The Network Backup Solution
memset(bufp, 0, sizeof(regex_t));
bufp->cflags = cflags;
if (bufp->cflags & REG_ICASE) {
- // ICI passer regex en lcase
+ char *p, *lcase = bstrdup(regex);
+ for( p = lcase; *p ; p++) {
+ *p = tolower(*p);
+ }
+ re_compile_pattern(bufp, (unsigned char *)lcase);
+ bfree(lcase);
+ } else {
+ re_compile_pattern(bufp, (unsigned char *)regex);
}
- re_compile_pattern(bufp, (unsigned char *)regex);
if (got_error) {
return -1;
}
{
int stat;
int len = strlen(string);
- // ICI passer string en lcase
struct re_registers regs;
stat = re_search(preg, (unsigned char *)string, len, 0, len, ®s);
/* stat is the start position in the string base 0 where
void regfree(regex_t * preg)
{
+ if (preg->lcase) {
+ free_pool_memory(preg->lcase);
+ preg->lcase = NULL;
+ }
}
int re_match(regex_t * bufp, unsigned char *string, int size, int pos,
#undef PREFETCH
#undef NEXTCHAR
-int re_search(regex_t * bufp, unsigned char *string, int size, int pos,
+int re_search(regex_t * bufp, unsigned char *str, int size, int pos,
int range, regexp_registers_t regs)
{
unsigned char *fastmap;
int dir;
int ret;
unsigned char anchor;
+ unsigned char *string = str;
+
+ if (bufp->cflags & REG_ICASE) { /* we must use string in lowercase */
+ int len = strlen((const char *)str);
+ if (!bufp->lcase) {
+ bufp->lcase = get_pool_memory(PM_FNAME);
+ }
+ check_pool_memory_size(bufp->lcase, len+1);
+ unsigned char *dst = (unsigned char *)bufp->lcase;
+ while (*string) {
+ *dst++ = tolower(*string++);
+ }
+ *dst = '\0';
+ string = (unsigned char *)bufp->lcase;
+ }
// assert(size >= 0 && pos >= 0);
// assert(pos + range >= 0 && pos + range <= size); /* Bugfix by ylo */