Embedded Artistry libc
C Standard Library Support for Bare-metal Systems
strchrnul.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

char * __strchrnul (const char *s, int c)
 

Function Documentation

◆ __strchrnul()

char* __strchrnul ( const char *  s,
int  c 
)

Definition at line 13 of file strchrnul.c.

14 {
15  const size_t* w;
16  size_t k;
17  c = (unsigned char)c;
18 
19  if(!c)
20  {
21  return (char*)(uintptr_t)s + strlen(s);
22  }
23 
24  for(; (uintptr_t)s % ALIGN; s++)
25  {
26  if(!*s || *(const unsigned char*)s == c)
27  {
28  return (char*)(uintptr_t)s;
29  }
30  }
31 
32  k = ONES * (unsigned long)c;
33 
34  for(w = (const void*)s; !HASZERO(*w) && !HASZERO(*w ^ k); w++)
35  {
36  {
37  ;
38  }
39  }
40  for(s = (const void*)w; *s && *(const unsigned char*)s != c; s++)
41  {
42  {
43  ;
44  }
45  }
46 
47  return (char*)(uintptr_t)s;
48 }
#define HASZERO(x)
Definition: strchrnul.c:11
#define ONES
Definition: strchrnul.c:9
size_t strlen(const char *str)
Returns the length of the given null-terminated byte string.
Definition: strlen.c:77
#define ALIGN
Definition: strchrnul.c:8

References ALIGN, HASZERO, ONES, and strlen().