blob: 45ad543b5d734b48084d22283861a6853d2597df (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/* ISC license. */
#include <skalibs/config.h>
#include <skalibs/bytestr.h>
#ifndef SKALIBS_FLAG_REPLACE_LIBC
#include <string.h>
unsigned int byte_chr (char const *s, unsigned int n, int c)
{
register void *p = memchr(s, c, n) ;
return p ? (unsigned int)((char *)p - s) : n ;
}
#else
unsigned int byte_chr (char const *s, unsigned int n, int c)
{
register unsigned int i = 0 ;
register char ch = c ;
for (; i < n && *s++ != ch ; i++) ;
return i ;
}
#endif
|