Additional indexer normalization (need to check all Indexers)

This commit is contained in:
Kurt Zeilenga 2003-02-25 19:21:18 +00:00
parent c98ef452aa
commit 627de4de15

View File

@ -1390,11 +1390,11 @@ static int caseExactIgnoreSubstringsIndexer(
BerVarray values,
BerVarray *keysp )
{
unsigned casefold;
ber_len_t i, nkeys;
unsigned casefold, wasspace;
ber_len_t i, j, nkeys;
size_t slen, mlen;
BerVarray keys;
BerVarray nvalues;
BerVarray tvalues, nvalues;
HASH_CONTEXT HASHcontext;
unsigned char HASHdigest[HASH_BYTES];
@ -1414,10 +1414,39 @@ static int caseExactIgnoreSubstringsIndexer(
casefold = ( mr != caseExactSubstringsMatchingRule )
? LDAP_UTF8_CASEFOLD : LDAP_UTF8_NOCASEFOLD;
tvalues = ch_malloc( sizeof( struct berval ) * (i+1) );
nvalues = ch_malloc( sizeof( struct berval ) * (i+1) );
for( i=0; values[i].bv_val != NULL; i++ ) {
UTF8bvnormalize( &values[i], &nvalues[i], casefold );
UTF8bvnormalize( &values[i], &tvalues[i], casefold );
/* collapse spaces (in place) */
nvalues[i].bv_len = 0;
nvalues[i].bv_val = tvalues[i].bv_val;
wasspace=1;
for( j=0; j<tvalues[i].bv_len; j++) {
if ( ASCII_SPACE( tvalues[i].bv_val[j] )) {
if( wasspace++ == 0 ) {
nvalues[i].bv_val[nvalues[i].bv_len++] =
tvalues[i].bv_val[j];
}
} else {
wasspace = 0;
nvalues[i].bv_val[nvalues[i].bv_len++] = tvalues[i].bv_val[j];
}
}
if( nvalues[i].bv_len == 0 ) {
nvalues[i].bv_val = " ";
nvalues[i].bv_len = sizeof(" ")-1;
} else {
if( wasspace ) --nvalues[i].bv_len;
nvalues[i].bv_val[nvalues[i].bv_len] = '\0';
}
}
tvalues[i].bv_val = NULL;
nvalues[i].bv_val = NULL;
values = nvalues;
@ -1455,7 +1484,8 @@ static int caseExactIgnoreSubstringsIndexer(
if( nkeys == 0 ) {
/* no keys to generate */
*keysp = NULL;
ber_bvarray_free( nvalues );
ber_bvarray_free( tvalues );
ch_free( nvalues );
return LDAP_SUCCESS;
}
@ -1556,7 +1586,8 @@ static int caseExactIgnoreSubstringsIndexer(
*keysp = NULL;
}
ber_bvarray_free( nvalues );
ber_bvarray_free( tvalues );
ch_free( nvalues );
return LDAP_SUCCESS;
}