diff options
author | Andrew Bartlett <abartlet@samba.org> | 2011-04-29 13:19:41 +1000 |
---|---|---|
committer | Andrew Bartlett <abartlet@samba.org> | 2011-04-29 16:38:14 +1000 |
commit | 9a9124b08760a6235059f517b9a138337754cd02 (patch) | |
tree | d986cc4347bdd1cf85a6b6d096de77a257f71351 /source3/lib/util_str.c | |
parent | 67905b41a97fb7c0a7f4c7070e837f1fcb8bfbb4 (diff) | |
download | samba-9a9124b08760a6235059f517b9a138337754cd02.tar.gz |
lib/util/charset Move strstr_m() to the top level
Diffstat (limited to 'source3/lib/util_str.c')
-rw-r--r-- | source3/lib/util_str.c | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index 88a3d703f4d..554f6a689be 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; |