mirror of
https://git.openldap.org/openldap/openldap.git
synced 2026-01-25 00:02:53 -05:00
Have the normalize routines process white space in the required way.
Code untested, but it is not used yet.
This commit is contained in:
parent
10eb260e9c
commit
5d8b65deb1
1 changed files with 48 additions and 4 deletions
|
|
@ -663,8 +663,32 @@ case_exact_normalize(
|
|||
)
|
||||
{
|
||||
struct berval *newval;
|
||||
char *p, *q;
|
||||
|
||||
newval = ber_bvdup( val );
|
||||
p = q = newval->bv_val;
|
||||
/* Ignore initial whitespace */
|
||||
while ( isspace( *p++ ) )
|
||||
;
|
||||
while ( *p ) {
|
||||
if ( isspace( *p ) ) {
|
||||
*q++ = *p++;
|
||||
/* Ignore the extra whitespace */
|
||||
while ( isspace(*p++) )
|
||||
;
|
||||
} else {
|
||||
*q++ = *p++;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* If the string ended in space, backup the pointer one
|
||||
* position. One is enough because the above loop collapsed
|
||||
* all whitespace to a single space.
|
||||
*/
|
||||
if ( p != newval->bv_val && isspace( *(p-1) ) ) {
|
||||
*(q-1) = '\0';
|
||||
}
|
||||
newval->bv_len = strlen( newval->bv_val );
|
||||
normalized = &newval;
|
||||
|
||||
return 0;
|
||||
|
|
@ -679,19 +703,39 @@ case_exact_compare(
|
|||
return strcmp( val1->bv_val, val2->bv_val );
|
||||
}
|
||||
|
||||
static int
|
||||
int
|
||||
case_ignore_normalize(
|
||||
struct berval *val,
|
||||
struct berval **normalized
|
||||
)
|
||||
{
|
||||
struct berval *newval;
|
||||
char *p;
|
||||
char *p, *q;
|
||||
|
||||
newval = ber_bvdup( val );
|
||||
for ( p = newval->bv_val; *p; p++ ) {
|
||||
*p = TOUPPER( *p );
|
||||
p = q = newval->bv_val;
|
||||
/* Ignore initial whitespace */
|
||||
while ( isspace( *p++ ) )
|
||||
;
|
||||
while ( *p ) {
|
||||
if ( isspace( *p ) ) {
|
||||
*q++ = *p++;
|
||||
/* Ignore the extra whitespace */
|
||||
while ( isspace(*p++) )
|
||||
;
|
||||
} else {
|
||||
*q++ = TOUPPER( *p++ );
|
||||
}
|
||||
}
|
||||
/*
|
||||
* If the string ended in space, backup the pointer one
|
||||
* position. One is enough because the above loop collapsed
|
||||
* all whitespace to a single space.
|
||||
*/
|
||||
if ( p != newval->bv_val && isspace( *(p-1) ) ) {
|
||||
*(q-1) = '\0';
|
||||
}
|
||||
newval->bv_len = strlen( newval->bv_val );
|
||||
normalized = &newval;
|
||||
|
||||
return 0;
|
||||
|
|
|
|||
Loading…
Reference in a new issue