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