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

Function acl_argv_quote_split4

lib_acl/src/stdlib/common/acl_argv_split.c:118–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116}
117
118ACL_ARGV *acl_argv_quote_split4(const char *str, const char *delim,
119 ACL_DBUF_POOL *dbuf) {
120 ACL_ARGV *argvp = acl_argv_alloc2(1, dbuf);
121 int ch, quote = 0, backslash = 0;
122 ACL_VSTRING *buf = acl_vstring_dbuf_alloc(dbuf, 128);
123
124#define ADDCH ACL_VSTRING_ADDCH
125#define TERM ACL_VSTRING_TERMINATE
126#define LEN ACL_VSTRING_LEN
127#define STR acl_vstring_str
128#define RESET ACL_VSTRING_RESET
129
130 while ((ch = (unsigned char) *str) != 0) {
131 if (quote) {
132 if (backslash) {
133 ADDCH(buf, ch);
134 TERM(buf);
135 backslash = 0;
136 } else if (ch == '\\')
137 backslash = 1;
138 else if (ch == quote) {
139 quote = 0;
140 if (LEN(buf) > 0) {
141 acl_argv_add(argvp, STR(buf), NULL);
142 RESET(buf);
143 }
144 } else {
145 ADDCH(buf, ch);
146 TERM(buf);
147 }
148 } else if (backslash) {
149 ADDCH(buf, ch);
150 TERM(buf);
151 backslash = 0;
152 } else if (ch == '\\')
153 backslash = 1;
154 else if (ch == '\'' || ch == '\"')
155 quote = ch;
156 else if (strchr(delim, ch) != NULL) {
157 if (LEN(buf) > 0) {
158 acl_argv_add(argvp, STR(buf), NULL);
159 RESET(buf);
160 }
161 } else {
162 ADDCH(buf, ch);
163 TERM(buf);
164 }
165
166 str++;;
167 }
168
169 if (LEN(buf) > 0) {
170 acl_argv_add(argvp, STR(buf), NULL);
171 }
172
173 acl_argv_terminate(argvp);
174 acl_vstring_free(buf);
175 return argvp;

Callers 1

acl_argv_quote_splitFunction · 0.85

Calls 5

acl_argv_alloc2Function · 0.85
acl_vstring_dbuf_allocFunction · 0.85
acl_argv_addFunction · 0.85
acl_argv_terminateFunction · 0.85
acl_vstring_freeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…