A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 45 lines 990 B view raw
1/* 2FUNCTION 3 <<strcspn>>---count characters not in string 4INDEX 5 strcspn 6ANSI_SYNOPSIS 7 size_t strcspn(const char *<[s1]>, const char *<[s2]>); 8TRAD_SYNOPSIS 9 size_t strcspn(<[s1]>, <[s2]>) 10 char *<[s1]>; 11 char *<[s2]>; 12DESCRIPTION 13 This function computes the length of the initial part of 14 the string pointed to by <[s1]> which consists entirely of 15 characters <[NOT]> from the string pointed to by <[s2]> 16 (excluding the terminating null character). 17RETURNS 18 <<strcspn>> returns the length of the substring found. 19PORTABILITY 20<<strcspn>> is ANSI C. 21<<strcspn>> requires no supporting OS subroutines. 22 */ 23#include <string.h> 24#include "_ansi.h" /* for _DEFUN */ 25 26size_t 27_DEFUN (strcspn, (s1, s2), 28 _CONST char *s1 _AND 29 _CONST char *s2) 30{ 31 _CONST char *s = s1; 32 _CONST char *c; 33 while (*s1) 34 { 35 for (c = s2; *c; c++) 36 { 37 if (*s1 == *c) 38 break; 39 } 40 if (*c) 41 break; 42 s1++; 43 } 44 return s1 - s; 45}