1 /* 2 * Copyright (C) 2002 Manuel Novoa III 3 * Copyright (C) 2000-2005 Erik Andersen <andersen@uclibc.org> 4 * 5 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. 6 */ 7 8 #include "_string.h" 9 10 #ifdef WANT_WIDE 11 # define Wstrstr wcsstr 12 #else 13 # define Wstrstr strstr 14 #endif 15 16 /* NOTE: This is the simple-minded O(len(s1) * len(s2)) worst-case approach. */ 17 Wstrstr(const Wchar * s1,const Wchar * s2)18Wchar *Wstrstr(const Wchar *s1, const Wchar *s2) 19 { 20 register const Wchar *s = s1; 21 register const Wchar *p = s2; 22 23 do { 24 if (!*p) { 25 return (Wchar *) s1; 26 } 27 if (*p == *s) { 28 ++p; 29 ++s; 30 } else { 31 p = s2; 32 if (!*s) { 33 return NULL; 34 } 35 s = ++s1; 36 } 37 } while (1); 38 } 39 #ifndef WANT_WIDE 40 libc_hidden_def(strstr) 41 #elif defined __UCLIBC_SUSV3_LEGACY__ 42 strong_alias(wcsstr,wcswcs) 43 #endif 44