From 9a9124b08760a6235059f517b9a138337754cd02 Mon Sep 17 00:00:00 2001 From: Andrew Bartlett Date: Fri, 29 Apr 2011 13:19:41 +1000 Subject: lib/util/charset Move strstr_m() to the top level --- source3/lib/util_str.c | 81 -------------------------------------------------- 1 file changed, 81 deletions(-) (limited to 'source3') diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 88a3d703f4..554f6a689b 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -904,87 +904,6 @@ char *strnrchr_m(const char *s, char c, unsigned int n) return ret; } -/*********************************************************************** - strstr_m - We convert via ucs2 for now. -***********************************************************************/ - -char *strstr_m(const char *src, const char *findstr) -{ - smb_ucs2_t *p; - smb_ucs2_t *src_w, *find_w; - const char *s; - char *s2; - char *retp; - - size_t converted_size, findstr_len = 0; - - /* for correctness */ - if (!findstr[0]) { - return (char*)src; - } - - /* Samba does single character findstr calls a *lot*. */ - if (findstr[1] == '\0') - return strchr_m(src, *findstr); - - /* 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 (s = src; *s && !(((unsigned char)s[0]) & 0x80); s++) { - if (*s == *findstr) { - if (!findstr_len) - findstr_len = strlen(findstr); - - if (strncmp(s, findstr, findstr_len) == 0) { - return (char *)s; - } - } - } - - if (!*s) - return NULL; - -#if 1 /* def BROKEN_UNICODE_COMPOSE_CHARACTERS */ - /* 'make check' fails unless we do this */ - - /* With compose characters we must restart from the beginning. JRA. */ - s = src; -#endif - - if (!push_ucs2_talloc(talloc_tos(), &src_w, src, &converted_size)) { - DEBUG(0,("strstr_m: src malloc fail\n")); - return NULL; - } - - if (!push_ucs2_talloc(talloc_tos(), &find_w, findstr, &converted_size)) { - TALLOC_FREE(src_w); - DEBUG(0,("strstr_m: find malloc fail\n")); - return NULL; - } - - p = strstr_w(src_w, find_w); - - if (!p) { - TALLOC_FREE(src_w); - TALLOC_FREE(find_w); - return NULL; - } - - *p = 0; - if (!pull_ucs2_talloc(talloc_tos(), &s2, src_w, &converted_size)) { - TALLOC_FREE(src_w); - TALLOC_FREE(find_w); - DEBUG(0,("strstr_m: dest malloc fail\n")); - return NULL; - } - retp = (char *)(s+strlen(s2)); - TALLOC_FREE(src_w); - TALLOC_FREE(find_w); - TALLOC_FREE(s2); - return retp; -} - static bool unix_strlower(const char *src, size_t srclen, char *dest, size_t destlen) { size_t size; -- cgit