From 17ccff973a4136c6bffa2fce68eeb1be53add447 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 8 Apr 2011 13:04:26 +1000 Subject: lib/util: Make string_replace from s3 common The s4 implementation didn't do multibyte strings, so was only good for '/' which is known to be safe in all multibyte charsets. Andrew Bartlett Signed-off-by: Andrew Tridgell --- source3/lib/util_str.c | 43 ------------------------------------------- 1 file changed, 43 deletions(-) (limited to 'source3') diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index a710fcc35b..13aa78cc91 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -233,49 +233,6 @@ bool strisnormal(const char *s, int case_default) } -/** - String replace. - NOTE: oldc and newc must be 7 bit characters -**/ -void string_replace( char *s, char oldc, char newc ) -{ - char *p; - - /* 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) */ - - for (p = s; *p; p++) { - if (*p & 0x80) /* mb string - slow path. */ - break; - if (*p == oldc) { - *p = newc; - } - } - - if (!*p) - return; - - /* Slow (mb) path. */ -#ifdef BROKEN_UNICODE_COMPOSE_CHARACTERS - /* With compose characters we must restart from the beginning. JRA. */ - p = s; -#endif - - while (*p) { - size_t c_size; - next_codepoint(p, &c_size); - - if (c_size == 1) { - if (*p == oldc) { - *p = newc; - } - } - p += c_size; - } -} - /** * Skip past some strings in a buffer - old version - no checks. * **/ -- cgit