| 3241 | |
| 3242 | |
| 3243 | void |
| 3244 | parseautocomplete(char *autocomplete, boolean condition) |
| 3245 | { |
| 3246 | struct ext_func_tab *efp; |
| 3247 | char *autoc; |
| 3248 | |
| 3249 | /* break off first autocomplete from the rest; parse the rest */ |
| 3250 | if ((autoc = strchr(autocomplete, ',')) != 0 |
| 3251 | || (autoc = strchr(autocomplete, ':')) != 0) { |
| 3252 | *autoc++ = '\0'; |
| 3253 | parseautocomplete(autoc, condition); |
| 3254 | } |
| 3255 | |
| 3256 | /* strip leading and trailing white space */ |
| 3257 | autocomplete = trimspaces(autocomplete); |
| 3258 | |
| 3259 | if (!*autocomplete) |
| 3260 | return; |
| 3261 | |
| 3262 | /* take off negation */ |
| 3263 | if (*autocomplete == '!') { |
| 3264 | /* unlike most options, a leading "no" might actually be a part of |
| 3265 | * the extended command. Thus you have to use ! */ |
| 3266 | autocomplete++; |
| 3267 | autocomplete = trimspaces(autocomplete); |
| 3268 | condition = !condition; |
| 3269 | } |
| 3270 | |
| 3271 | /* find and modify the extended command */ |
| 3272 | for (efp = extcmdlist; efp->ef_txt; efp++) { |
| 3273 | if (!strcmp(autocomplete, efp->ef_txt)) { |
| 3274 | if (condition == ((efp->flags & AUTOCOMPLETE) ? FALSE : TRUE)) { |
| 3275 | if ((efp->flags & AUTOCOMP_ADJ)) |
| 3276 | efp->flags &= ~AUTOCOMP_ADJ; |
| 3277 | else |
| 3278 | efp->flags |= AUTOCOMP_ADJ; |
| 3279 | } |
| 3280 | if (condition) |
| 3281 | efp->flags |= AUTOCOMPLETE; |
| 3282 | else |
| 3283 | efp->flags &= ~AUTOCOMPLETE; |
| 3284 | return; |
| 3285 | } |
| 3286 | } |
| 3287 | |
| 3288 | /* not a real extended command */ |
| 3289 | raw_printf("Bad autocomplete: invalid extended command '%s'.", |
| 3290 | autocomplete); |
| 3291 | wait_synch(); |
| 3292 | } |
| 3293 | |
| 3294 | /* add changed autocompletions to the string buffer in config file format */ |
| 3295 | void |
no test coverage detected