diff options
author | Tim Potter <tpot@samba.org> | 2003-09-15 05:02:12 +0000 |
---|---|---|
committer | Tim Potter <tpot@samba.org> | 2003-09-15 05:02:12 +0000 |
commit | d8231592bc4497fbec0a9ced20cd8cc84782bb9d (patch) | |
tree | 894c492318457cfeddd6911717f22a7dec5a8c02 /source3/lib/util_str.c | |
parent | a9cd4a6ae1709381f896605beb0c3e82c16b330e (diff) | |
download | samba-d8231592bc4497fbec0a9ced20cd8cc84782bb9d.tar.gz samba-d8231592bc4497fbec0a9ced20cd8cc84782bb9d.tar.bz2 samba-d8231592bc4497fbec0a9ced20cd8cc84782bb9d.zip |
Merge from Samba 3.0:
>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.
(This used to be commit 67acde75d3569b612f87646ff0740f8020e8fdcf)
Diffstat (limited to 'source3/lib/util_str.c')
-rw-r--r-- | source3/lib/util_str.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 82b312e241..15ac1639a9 100644 --- a/source3/lib/util_str.c +++ b/source3/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,18 +1179,19 @@ 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; } @@ -1194,6 +1199,11 @@ char *strchr_m(const char *s, char c) 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) |