]> git.sur5r.net Git - openldap/commitdiff
Rename filter entry's strcpy_special() to strcpy_regex() to better
authorKurt Zeilenga <kurt@openldap.org>
Tue, 24 Aug 1999 01:13:30 +0000 (01:13 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Tue, 24 Aug 1999 01:13:30 +0000 (01:13 +0000)
reflect its purpose.  Modify switch to support REG_EXTENDED expressions.
Use REG_EXTENDED instead of REG_BASIC everywhere.
Modify <ac/regex.h> to support <gnuregex.h> for testing purposes.
Requires: env CPPFLAGS="-DHAVE_GNUREGEX_H=1" LIBS=-lgnuregex ./configure

include/ac/regex.h
libraries/libldap/getfilter.c
servers/slapd/filterentry.c

index 99afaec3d8756a9aaf485ba7e7136006713815d5..30a348235934dc6841b950a71af479668123dbf2 100644 (file)
        For NT: http://people.delphi.com/gjc/hs_regex.html
 */
 #error "No POSIX REGEX available."
+
+#elif HAVE_GNUREGEX_H
+       /* system has GNU gnuregex.h */ 
+#      include <gnuregex.h>
 #else
        /* have regex.h, assume it's POSIX compliant */
 #      include <regex.h>
index b0a181a8ef4185c57739d7936da8dd1ebcc9f5bd..2c06810ab69b21ac237f446972781f670c73fa6d 100644 (file)
@@ -253,7 +253,7 @@ ldap_getfirstfilter(
                        continue;
 
                /* compile flp->ifl_pattern, continue if we fail */
-               if (regcomp(&re, flp->lfl_pattern, 0) != 0)
+               if (regcomp(&re, flp->lfl_pattern, REG_EXTENDED) != 0)
                        continue;
 
                /* match ifl_pattern and lfd_curval, continue if we fail */
index dd6da92f64142f76849be1a3e248402e353e6352..f65c8472a80ff7fc1ec022d76715f3e9ae5f71c2 100644 (file)
@@ -283,18 +283,24 @@ test_filter_list(
 }
 
 static void
-strcpy_special( char *d, char *s )
+strcpy_regex( char *d, char *s )
 {
        for ( ; *s; s++ ) {
                switch ( *s ) {
+               case '^':
                case '.':
-               case '\\':
                case '[':
-               case ']':
+               case ']': /* ? */
+               case '$':
+               case '(':
+               case ')': /* ? */
+               case '|':
                case '*':
                case '+':
-               case '^':
-               case '$':
+               case '?':
+               case '{':
+               case '}': /* ? */
+               case '\\':
                        *d++ = '\\';
                        /* FALL */
                default:
@@ -356,7 +362,7 @@ test_substring_filter(
                            0, 0, 0 );
                        return( -1 );
                }
-               strcpy_special( p, f->f_sub_initial );
+               strcpy_regex( p, f->f_sub_initial );
                p = strchr( p, '\0' );
        }
        if ( f->f_sub_any != NULL ) {
@@ -369,7 +375,7 @@ test_substring_filter(
                        }
                        strcpy( p, ".*" );
                        p = strchr( p, '\0' );
-                       strcpy_special( p, f->f_sub_any[i] );
+                       strcpy_regex( p, f->f_sub_any[i] );
                        p = strchr( p, '\0' );
                }
        }
@@ -382,7 +388,7 @@ test_substring_filter(
                }
                strcpy( p, ".*" );
                p = strchr( p, '\0' );
-               strcpy_special( p, f->f_sub_final );
+               strcpy_regex( p, f->f_sub_final );
                p = strchr( p, '\0' );
                strcpy( p, "$" );
        }
@@ -390,7 +396,7 @@ test_substring_filter(
        /* compile the regex */
        Debug( LDAP_DEBUG_FILTER, "test_substring_filter: regcomp pat: %s\n",
                pat, 0, 0 );
-       if ((rc = regcomp(&re, pat, 0))) {
+       if ((rc = regcomp(&re, pat, REG_EXTENDED))) {
                char error[512];
 
                regerror(rc, &re, error, sizeof(error));