mirror of
https://github.com/samba-team/samba.git
synced 2024-12-27 03:21:53 +03:00
7d32679e96
The motivation for this change was to avoid having to convert to/from
ucs2 strings for so many operations. Doing that was slow, used many
static buffers, and was also incorrect as it didn't cope properly with
unicode codepoints above 65536 (which could not be represented
correctly as smb_ucs2_t chars)
The two core functions that allowed this change are next_codepoint()
and push_codepoint(). These functions allow you to correctly walk a
arbitrary multi-byte string a character at a time without converting
the whole string to ucs2.
While doing this cleanup I also fixed several ucs2 string handling
bugs. See the commit for details.
The following code (which counts the number of occuraces of 'c' in a
string) shows how to use the new interface:
size_t count_chars(const char *s, char c)
{
size_t count = 0;
while (*s) {
size_t size;
codepoint_t c2 = next_codepoint(s, &size);
if (c2 == c) count++;
s += size;
}
return count;
}
(This used to be commit
|
||
---|---|---|
.. | ||
ads_ldap.c | ||
ads_status.c | ||
ads_struct.c | ||
config.m4 | ||
disp_sec.c | ||
krb5_setpw.c | ||
ldap_printer.c | ||
ldap_user.c | ||
ldap_utils.c | ||
ldap.c | ||
sasl.c | ||
util.c |