summaryrefslogtreecommitdiff
path: root/src/libstddjb/str_chr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstddjb/str_chr.c')
-rw-r--r--src/libstddjb/str_chr.c32
1 files changed, 5 insertions, 27 deletions
diff --git a/src/libstddjb/str_chr.c b/src/libstddjb/str_chr.c
index ed55e50..a415de6 100644
--- a/src/libstddjb/str_chr.c
+++ b/src/libstddjb/str_chr.c
@@ -1,33 +1,11 @@
/* ISC license. */
-#include <skalibs/config.h>
-#include <skalibs/bytestr.h>
-
-#ifndef SKALIBS_FLAG_REPLACE_LIBC
-
+#include <sys/types.h>
#include <string.h>
+#include <skalibs/bytestr.h>
-unsigned int str_chr (register char const *s, int c)
-{
- register char *p = strchr(s, c) ;
- return p ? (unsigned int)(p - s) : strlen(s) ;
-}
-
-#else
-
-unsigned int str_chr (register char const *s, int c)
+size_t str_chr (char const *s, int c)
{
- register char ch = c ;
- register char const *t = s ;
-
- for (;;)
- {
- if (!*t) break; if (*t == ch) break; ++t;
- if (!*t) break; if (*t == ch) break; ++t;
- if (!*t) break; if (*t == ch) break; ++t;
- if (!*t) break; if (*t == ch) break; ++t;
- }
- return t - s ;
+ char *p = strchr(s, c) ;
+ return p ? p - s : strlen(s) ;
}
-
-#endif