]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/lib/bregex.c
ebl use tokyocabinet by default instead of htable
[bacula/bacula] / bacula / src / lib / bregex.c
index acba19730cd64f1f894db74e191a10ba78faf854..65fe8884aea6eb06e73fc000d54bffc782b2b101 100644 (file)
@@ -37,7 +37,7 @@
 /*
    Bacula® - The Network Backup Solution
 
-   Copyright (C) 2006-2006 Free Software Foundation Europe e.V.
+   Copyright (C) 2006-2008 Free Software Foundation Europe e.V.
 
    The main author of Bacula is Kern Sibbald, with contributions from
    many others, a complete list can be found in the file AUTHORS.
@@ -1466,7 +1466,7 @@ int regcomp(regex_t * bufp, const char *regex, int cflags)
    if (bufp->cflags & REG_ICASE) {
       char *p, *lcase = bstrdup(regex);
       for( p = lcase; *p ; p++) {
-        *p = tolower(*p);
+         *p = tolower(*p);
       } 
       re_compile_pattern(bufp, (unsigned char *)lcase);
       bfree(lcase);
@@ -1480,8 +1480,8 @@ int regcomp(regex_t * bufp, const char *regex, int cflags)
 }
 
 void re_registers_to_regmatch(regexp_registers_t old_regs, 
-                             regmatch_t pmatch[], 
-                             size_t nmatch)
+                              regmatch_t pmatch[], 
+                              size_t nmatch)
 {
    size_t i=0;
    
@@ -1502,7 +1502,9 @@ int regexec(regex_t * preg, const char *string, size_t nmatch,
    int len = strlen(string);
    struct re_registers regs;
    stat = re_search(preg, (unsigned char *)string, len, 0, len, &regs);
-   re_registers_to_regmatch(&regs, pmatch, nmatch);
+   if (stat >= 0) {
+      re_registers_to_regmatch(&regs, pmatch, nmatch);
+   }
    /* stat is the start position in the string base 0 where       
     *  the pattern was found or negative if not found.
     */
@@ -1939,12 +1941,12 @@ int re_search(regex_t * bufp, unsigned char *str, int size, int pos,
    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);
+         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++ = tolower(*string++);
       }
       *dst = '\0';
       string = (unsigned char *)bufp->lcase;