diff options
author | Jeremy Allison <jra@samba.org> | 2003-09-13 22:41:21 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2003-09-13 22:41:21 +0000 |
commit | f23acb4ca5feac8ad2acfa1baf7df31283aba3ea (patch) | |
tree | 24114a8649d8b3faaee7a1232642bfb490d92dd1 /source/lib/util_str.c | |
parent | f23c9d36b0cd4083722012e4a94df8295f29d04c (diff) | |
download | samba-f23acb4ca5feac8ad2acfa1baf7df31283aba3ea.tar.gz samba-f23acb4ca5feac8ad2acfa1baf7df31283aba3ea.tar.xz samba-f23acb4ca5feac8ad2acfa1baf7df31283aba3ea.zip |
Fix for MacOS/X which uses STUPID BROKEN UNICODE COMPOSE CHARACTERS !
(rant off :-). Inspired by work from Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>.
Also add MacOSX/Darwin configure fixes.
Jerry - can we put this in 3.0 release ? :-).
Jeremy.
Diffstat (limited to 'source/lib/util_str.c')
-rw-r--r-- | source/lib/util_str.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/source/lib/util_str.c b/source/lib/util_str.c index c065bfe9db6..15ac1639a9a 100644 --- a/source/lib/util_str.c +++ b/source/lib/util_str.c @@ -382,6 +382,10 @@ void string_replace(pstring s,char oldc,char newc) return; /* Slow (mb) path. */ +#ifdef BROKEN_UNICODE_COMPOSE_CHARACTERS + /* With compose characters we must restart from the beginning. JRA. */ + p = s; +#endif push_ucs2(NULL, tmpbuf, p, sizeof(tmpbuf), STR_TERMINATE); string_replace_w(tmpbuf, UCS2_CHAR(oldc), UCS2_CHAR(newc)); pull_ucs2(NULL, p, tmpbuf, -1, sizeof(tmpbuf), STR_TERMINATE); @@ -1175,26 +1179,31 @@ char *string_truncate(char *s, unsigned int length) We convert via ucs2 for now. **/ -char *strchr_m(const char *s, char c) +char *strchr_m(const char *src, char c) { wpstring ws; pstring s2; smb_ucs2_t *p; + const char *s; /* this is quite a common operation, so we want it to be fast. We optimise for the ascii case, knowing that all our supported multi-byte character sets are ascii-compatible (ie. they match for the first 128 chars) */ - while (*s && !(((unsigned char)s[0]) & 0x80)) { + for (s = src; *s && !(((unsigned char)s[0]) & 0x80); s++) { if (*s == c) return s; - s++; } if (!*s) return NULL; +#ifdef BROKEN_UNICODE_COMPOSE_CHARACTERS + /* With compose characters we must restart from the beginning. JRA. */ + s = src; +#endif + push_ucs2(NULL, ws, s, sizeof(ws), STR_TERMINATE); p = strchr_w(ws, UCS2_CHAR(c)); if (!p) |