- int len=0;
- if (list && *list)
- for (; (*list)[len]; len++) ;
-
- if (strcmp(pattern,"!") == 0) {
- if (verbose > 2)
- rprintf(FINFO,"clearing exclude list\n");
- while ((len)--) {
- free_exclude((*list)[len]);
+ const unsigned char *s = (const unsigned char *)p;
+ int len;
+
+ if (xflags & XFLG_WORD_SPLIT) {
+ /* Skip over any initial whitespace. */
+ while (isspace(*s))
+ s++;
+ /* Update for "!" check. */
+ p = (const char *)s;
+ }
+
+ /* Is this a '+' or '-' followed by a space (not whitespace)? */
+ if (!(xflags & XFLG_NO_PREFIXES)
+ && (*s == '-' || *s == '+') && s[1] == ' ') {
+ *incl_ptr = *s == '+';
+ s += 2;
+ } else
+ *incl_ptr = xflags & XFLG_DEF_INCLUDE;
+
+ if (xflags & XFLG_WORD_SPLIT) {
+ const unsigned char *cp = s;
+ /* Token ends at whitespace or the end of the string. */
+ while (!isspace(*cp) && *cp != '\0')
+ cp++;
+ len = cp - s;
+ } else
+ len = strlen(s);
+
+ if (*p == '!' && len == 1 && !(xflags & XFLG_NO_PREFIXES))
+ *incl_ptr = -1;
+
+ *len_ptr = len;
+ return (const char *)s;
+}
+
+
+void add_exclude(struct exclude_struct ***listp, const char *pattern, int xflags)
+{
+ struct exclude_struct **list = *listp;
+ int pat_len, list_len = 0;
+ int incl, add_cnt = 1;
+ const char *cp;
+
+ if (!pattern)
+ return;
+
+ if (xflags & XFLG_WORD_SPLIT) {
+ int add = 0;
+ /* Count maximum extra tokens we might encounter. */
+ for (cp = pattern; *cp; cp++) {
+ if (isspace(*(unsigned char *)cp)) {
+ add_cnt += add;
+ add = 0;
+ } else
+ add = 1;