[hackers] [scc] [libc] Add strstr() || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Thu, 23 Feb 2017 16:16:26 +0100 (CET)

commit 1eab8918ca76c97dc01cb5f61b751bc148699e92
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Feb 23 15:16:38 2017 +0100
Commit: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
CommitDate: Thu Feb 23 16:16:08 2017 +0100

    [libc] Add strstr()

diff --git a/libc/src/strstr.c b/libc/src/strstr.c
index 7f000f3..bc3277a 100644
--- a/libc/src/strstr.c
+++ b/libc/src/strstr.c
_AT_@ -12,15 +12,16 @@ strstr(const char *s1, const char *s2)
         if (c == '\0')
                 return (char *) s1;
 
- for ( ; *s1; ++s1) {
- if (*s1 != c)
- continue;
- p = s1++;
- for (q = s2; *q && *s1 == *q; ++s1, ++q)
- /* nothing */;
- if (*q == '\0')
- return (char *) p;
- --s1;
+ while (*s1) {
+ if (*s1 != c) {
+ ++s;
+ } else {
+ p = s1++;
+ for (q = s2; *q && *s1 == *q; ++s1, ++q)
+ /* nothing */;
+ if (*q == '\0')
+ return (char *) p;
+ }
         }
         return NULL;
 }
Received on Thu Feb 23 2017 - 16:16:26 CET

This archive was generated by hypermail 2.3.0 : Thu Feb 23 2017 - 16:24:26 CET