| 2212 | } |
| 2213 | |
| 2214 | static int |
| 2215 | xo_set_options_simple (xo_handle_t *xop, const char *input) |
| 2216 | { |
| 2217 | xo_xof_flags_t new_flag; |
| 2218 | char *cp, *ep, *vp, *np, *bp; |
| 2219 | ssize_t len = strlen(input) + 1; |
| 2220 | |
| 2221 | bp = alloca(len); |
| 2222 | memcpy(bp, input, len); |
| 2223 | |
| 2224 | for (cp = bp, ep = cp + len - 1; cp && cp < ep; cp = np) { |
| 2225 | np = strchr(cp, ','); |
| 2226 | if (np) |
| 2227 | *np++ = '\0'; |
| 2228 | |
| 2229 | vp = strchr(cp, '='); |
| 2230 | if (vp) |
| 2231 | *vp++ = '\0'; |
| 2232 | |
| 2233 | if (xo_streq("colors", cp)) { |
| 2234 | xo_set_color_map(xop, vp); |
| 2235 | continue; |
| 2236 | } |
| 2237 | |
| 2238 | new_flag = xo_name_lookup(xo_xof_simple_names, cp, -1); |
| 2239 | if (new_flag != 0) { |
| 2240 | XOF_SET(xop, new_flag); |
| 2241 | } else if (xo_streq(cp, "no-color")) { |
| 2242 | XOF_CLEAR(xop, XOF_COLOR_ALLOWED); |
| 2243 | } else { |
| 2244 | xo_failure(xop, "unknown simple option: %s", cp); |
| 2245 | return -1; |
| 2246 | } |
| 2247 | } |
| 2248 | |
| 2249 | return 0; |
| 2250 | } |
| 2251 | |
| 2252 | /** |
| 2253 | * Set the options for a handle using a string of options |
no test coverage detected