Embedded Artistry libc
C Standard Library Support for Bare-metal Systems
strcspn.c File Reference
#include "strchrnul.h"
#include <stdint.h>
#include <string.h>
Include dependency graph for strcspn.c:

Go to the source code of this file.

Macros

#define BITOP(a, b, op)   ((a)[(size_t)(b) / (8 * sizeof *(a))] op(size_t) 1 << ((size_t)(b) % (8 * sizeof *(a))))
 

Functions

size_t strcspn (const char *s, const char *c)
 

Macro Definition Documentation

◆ BITOP

#define BITOP (   a,
  b,
  op 
)    ((a)[(size_t)(b) / (8 * sizeof *(a))] op(size_t) 1 << ((size_t)(b) % (8 * sizeof *(a))))

Definition at line 5 of file strcspn.c.

Function Documentation

◆ strcspn()

size_t strcspn ( const char *  s,
const char *  c 
)

Definition at line 8 of file strcspn.c.

9 {
10  const char* a = s;
11  size_t byteset[32 / sizeof(size_t)];
12 
13  if(!c[0] || !c[1])
14  {
15  return (uintptr_t)(__strchrnul(s, *c) - (uintptr_t)a);
16  }
17 
18  memset(byteset, 0, sizeof byteset);
19  for(; *c && BITOP(byteset, *(const unsigned char*)c, |=); c++)
20  {
21  {
22  ;
23  }
24  }
25  for(; *s && !BITOP(byteset, *(const unsigned char*)s, &); s++)
26  {
27  {
28  ;
29  }
30  }
31  return (uintptr_t)s - (uintptr_t)a;
32 }
char * __strchrnul(const char *, int)
Definition: strchrnul.c:13
#define BITOP(a, b, op)
Definition: strcspn.c:5
void * memset(void *dest, int c, size_t n)
Copies the value c into each of the first n characters of the object pointed to by dest.

References __strchrnul(), BITOP, and memset().

Referenced by strpbrk().

Here is the caller graph for this function: