- if (xflags & XFLG_WORD_SPLIT) {
- /* Count how many tokens we need to add. Also looks for
- * the special "!" token, which clears the list up through
- * that token. */
- for (add_cnt = 0, cp = pattern; ; cp += pat_len, add_cnt++) {
- cp = get_exclude_tok(cp, &pat_len, xflags);
- if (!pat_len)
- break;
- if (pat_len == 1 && *cp == '!') {
- free_exclude_list(listp);
- add_cnt = -1; /* Will increment to 0. */
- pattern = cp + 1;
- }
- }
- if (!add_cnt)
- return;
- cp = get_exclude_tok(pattern, &pat_len, xflags);
- } else {
- add_cnt = 1;
- cp = pattern;
- pat_len = strlen(pattern);
-
- if (pat_len == 1 && *cp == '!') {
+ cp = pattern;
+ pat_len = 0;
+ while (1) {
+ cp = get_exclude_tok(cp + pat_len, &pat_len, &incl, xflags);
+ if (!pat_len)
+ break;
+ /* If we got the special "!" token, clear the list. */
+ if (incl < 0)