MCPcopy Create free account
hub / github.com/F-Stack/f-stack / strspn

Function strspn

freebsd/libkern/strspn.c:39–73  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37#define BIT(c) ((u_long)1 << ((u_char)(c) % LONG_BIT))
38
39size_t
40strspn(const char *s, const char *charset)
41{
42 /*
43 * NB: idx and bit are temporaries whose use causes gcc 3.4.2 to
44 * generate better code. Without them, gcc gets a little confused.
45 */
46 const char *s1;
47 u_long bit;
48 u_long tbl[(UCHAR_MAX + 1) / LONG_BIT];
49 int idx;
50
51 if(*s == '\0')
52 return (0);
53
54#if LONG_BIT == 64 /* always better to unroll on 64-bit architectures */
55 tbl[3] = tbl[2] = tbl[1] = tbl[0] = 0;
56#else
57 for (idx = 0; idx < sizeof(tbl) / sizeof(tbl[0]); idx++)
58 tbl[idx] = 0;
59#endif
60 for (; *charset != '\0'; charset++) {
61 idx = IDX(*charset);
62 bit = BIT(*charset);
63 tbl[idx] |= bit;
64 }
65
66 for(s1 = s; ; s1++) {
67 idx = IDX(*s1);
68 bit = BIT(*s1);
69 if ((tbl[idx] & bit) == 0)
70 break;
71 }
72 return (s1 - s);
73}

Callers 9

isDISPFunction · 0.85
xo_set_optionsFunction · 0.85
get_mac_addr_maskFunction · 0.85
luaB_tonumberFunction · 0.85
nvpair_value_match_regexFunction · 0.85
mainFunction · 0.85
LibAliasProxyRuleFunction · 0.85
vdpa_dynamic_major_numFunction · 0.85
parse_pci_hardware_idFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected