char *out, *outtmp, *s;
unsigned long *ucs, *p, *ucsout;
+ static unsigned char mask[] = {
+ 0, 0x7f, 0x1f, 0x0f, 0x07, 0x03, 0x01 };
+
unsigned casefold = flags & LDAP_UTF8_CASEFOLD;
unsigned approx = flags & LDAP_UTF8_APPROX;
- static unsigned char mask[] = {
- 0, 0x7f, 0x1f, 0x0f, 0x07, 0x03, 0x01 };
if ( bv == NULL ) {
return NULL;
return ber_dupbv_x( newbv, bv, ctx );
}
- /* FIXME: Should first check to see if string is already in
- * proper normalized form. This is almost as time consuming
- * as the normalization though.
+ /* Should first check to see if string is already in proper
+ * normalized form. This is almost as time consuming as
+ * the normalization though.
*/
/* finish off everything up to character before first non-ascii */
out[outpos++] = TOLOWER( s[i-1] );
}
if ( i == len ) {
- out[outpos++] = TOLOWER( s[len - 1] );
+ out[outpos++] = TOLOWER( s[len-1] );
out[outpos] = '\0';
return ber_str2bv( out, outpos, 0, newbv);
}
/* convert character before first non-ascii to ucs-4 */
if ( i > 0 ) {
- *p = casefold ? TOLOWER( s[i - 1] ) : s[i - 1];
+ *p = casefold ? TOLOWER( s[i-1] ) : s[i-1];
p++;
}
*p = uctolower( *p );
}
p++;
- }
+ }
/* normalize ucs of length p - ucs */
uccompatdecomp( ucs, p - ucs, &ucsout, &ucsoutlen, ctx );
if ( approx ) {
out[outpos++] = casefold ? TOLOWER( s[i-1] ) : s[i-1];
}
if ( i == len ) {
- out[outpos++] = casefold ? TOLOWER( s[len - 1] ) : s[len - 1];
+ out[outpos++] = casefold ? TOLOWER( s[len-1] ) : s[len-1];
break;
}
/* convert character before next non-ascii to ucs-4 */
- *ucs = casefold ? TOLOWER( s[i - 1] ) : s[i - 1];
+ *ucs = casefold ? TOLOWER( s[i-1] ) : s[i-1];
p = ucs + 1;
- }
+ }
+
free( ucs );
out[outpos] = '\0';
return ber_str2bv( out, outpos, 0, newbv );
int i, l1, l2, len, ulen, res = 0;
char *s1, *s2, *done;
unsigned long *ucs, *ucsout1, *ucsout2;
+
unsigned casefold = flags & LDAP_UTF8_CASEFOLD;
unsigned norm1 = flags & LDAP_UTF8_ARG1NFC;
unsigned norm2 = flags & LDAP_UTF8_ARG2NFC;
if (bv1 == NULL) {
return bv2 == NULL ? 0 : -1;
+
} else if (bv2 == NULL) {
return 1;
}
if (casefold) {
char c1 = TOLOWER(*s1);
char c2 = TOLOWER(*s2);
- res = c1 - c2;
+ res = c1 - c2;
} else {
res = *s1 - *s2;
}
break;
}
} else if (((len < l1) && !LDAP_UTF8_ISASCII(s1)) ||
- ((len < l2) && !LDAP_UTF8_ISASCII(s2))) {
+ ((len < l2) && !LDAP_UTF8_ISASCII(s2)))
+ {
break;
}
return res;
l2 -= i - 1;
}
- /* FIXME: Should first check to see if strings are already in
+ /* Should first check to see if strings are already in
* proper normalized form.
*/
-
ucs = malloc( ( ( norm1 || l1 > l2 ) ? l1 : l2 ) * sizeof(*ucs) );
if ( ucs == NULL ) {
return l1 > l2 ? 1 : -1; /* what to do??? */
/* convert and normalize 1st string */
for ( i = 0, ulen = 0; i < l1; i += len, ulen++ ) {
- ucs[ulen] = ldap_x_utf8_to_ucs4( s1 + i );
- if ( ucs[ulen] == LDAP_UCS4_INVALID ) {
+ ucs[ulen] = ldap_x_utf8_to_ucs4( s1 + i );
+ if ( ucs[ulen] == LDAP_UCS4_INVALID ) {
free( ucs );
- return -1; /* what to do??? */
- }
+ return -1; /* what to do??? */
+ }
len = LDAP_UTF8_CHARLEN( s1 + i );
}
/* convert and normalize 2nd string */
for ( i = 0, ulen = 0; i < l2; i += len, ulen++ ) {
- ucs[ulen] = ldap_x_utf8_to_ucs4( s2 + i );
- if ( ucs[ulen] == LDAP_UCS4_INVALID ) {
+ ucs[ulen] = ldap_x_utf8_to_ucs4( s2 + i );
+ if ( ucs[ulen] == LDAP_UCS4_INVALID ) {
free( ucsout1 );
free( ucs );
- return 1; /* what to do??? */
- }
+ return 1; /* what to do??? */
+ }
len = LDAP_UTF8_CHARLEN( s2 + i );
}