MCPcopy Create free account
hub / github.com/acl-dev/acl / acl_split_nameval2

Function acl_split_nameval2

lib_acl/src/stdlib/string/acl_split_nameval.c:18–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18const char *acl_split_nameval2(char *buf, char **name, char **value, char sep)
19{
20 char *np; /* name substring */
21 char *vp; /* value substring */
22 char *cp;
23 char *ep;
24
25 /*
26 * Ugly macros to make complex expressions less unreadable.
27 */
28#define SKIP(start, var, cond) \
29 for (var = start; *var && (cond); var++) {}
30
31#define TRIM(s) { \
32 char *p; \
33 for (p = (s) + strlen(s); p > (s) && ACL_ISSPACE(p[-1]); p--) {} \
34 *p = 0; \
35}
36
37 SKIP(buf, np, ACL_ISSPACE(*np)); /* find name begin */
38 if (*np == 0) {
39 return "missing attribute name";
40 }
41 SKIP(np, ep, !ACL_ISSPACE(*ep) && *ep != sep); /* find name end */
42 SKIP(ep, cp, ACL_ISSPACE(*cp)); /* skip blanks before '=' */
43 if (*cp != sep) { /* need '=' */
44 return "missing '=' after attribute name";
45 }
46 *ep = 0; /* terminate name */
47 cp++; /* skip over '=' */
48 SKIP(cp, vp, ACL_ISSPACE(*vp)); /* skip leading blanks */
49 TRIM(vp); /* trim trailing blanks */
50 *name = np;
51 *value = vp;
52 return NULL;
53}
54

Callers 3

acl_split_namevalFunction · 0.85
string.cppFile · 0.85
acl_foreachFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…