123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- #include <string.h>
- typedef unsigned chartype;
- char *strstr (const char *phaystack, const char *pneedle)
- {
- const unsigned char *haystack, *needle;
- chartype b;
- const unsigned char *rneedle;
- haystack = (const unsigned char *) phaystack;
- if ((b = *(needle = (const unsigned char *) pneedle)))
- {
- chartype c;
- haystack--;
- {
- chartype a;
- do
- if (!(a = *++haystack))
- goto ret0;
- while (a != b);
- }
- if (!(c = *++needle))
- goto foundneedle;
- ++needle;
- goto jin;
- for (;;)
- {
- {
- chartype a;
- if (0)
- jin:{
- if ((a = *++haystack) == c)
- goto crest;
- }
- else
- a = *++haystack;
- do
- {
- for (; a != b; a = *++haystack)
- {
- if (!a)
- goto ret0;
- if ((a = *++haystack) == b)
- break;
- if (!a)
- goto ret0;
- }
- }
- while ((a = *++haystack) != c);
- }
- crest:
- {
- chartype a;
- {
- const unsigned char *rhaystack;
- if (*(rhaystack = haystack-- + 1) == (a = *(rneedle = needle)))
- do
- {
- if (!a)
- goto foundneedle;
- if (*++rhaystack != (a = *++needle))
- break;
- if (!a)
- goto foundneedle;
- }
- while (*++rhaystack == (a = *++needle));
- needle = rneedle;
- }
- if (!a)
- break;
- }
- }
- }
- foundneedle:
- return (char *) haystack;
- ret0:
- return 0;
- }
- libc_hidden_def(strstr)
|