..wayne..
---- exclude.c 27 Apr 2004 01:36:06 -0000 1.75
-+++ exclude.c 8 May 2004 18:38:51 -0000
-@@ -30,32 +30,65 @@ extern int verbose;
+--- exclude.c 14 May 2004 21:23:41 -0000 1.76
++++ exclude.c 15 May 2004 00:36:36 -0000
+@@ -30,32 +30,58 @@ extern int verbose;
extern int eol_nulls;
extern int list_only;
extern int recurse;
-struct exclude_list_struct exclude_list = { 0, 0, "" };
-struct exclude_list_struct local_exclude_list = { 0, 0, "per-dir .cvsignore " };
-struct exclude_list_struct server_exclude_list = { 0, 0, "server " };
-+struct exclude_list_struct exclude_list = { 0, 0, 0, 0, "" };
-+struct exclude_list_struct server_exclude_list = { 0, 0, 0, 0, "server " };
++struct exclude_list_struct exclude_list = { 0, 0, 0, "" };
++struct exclude_list_struct server_exclude_list = { 0, 0, 0, "server " };
char *exclude_path_prefix = NULL;
+struct exclude_list_root {
+
+static char dirbuf[MAXPATHLEN];
+static unsigned int dirbuf_offset = 0;
-+
-+static void clear_exclude_list(struct exclude_list_struct *listp,
-+ struct exclude_struct *extra)
-+{
-+ listp->head = listp->extra = extra;
-+ listp->tail = NULL;
-+}
+
/** Build an exclude structure given a exclude pattern */
-static void make_exclude(struct exclude_list_struct *listp, const char *pattern,
ex_len = strlen(exclude_path_prefix);
else
ex_len = 0;
-@@ -64,33 +97,52 @@ static void make_exclude(struct exclude_
+@@ -64,33 +90,51 @@ static void make_exclude(struct exclude_
out_of_memory("make_exclude");
if (ex_len)
memcpy(ret->pattern, exclude_path_prefix, ex_len);
for (cp = ret->pattern; (cp = strchr(cp, '/')) != NULL; cp++)
ret->slash_cnt++;
-+ ret->next = listp->extra;
-+
- if (!listp->tail)
+- if (!listp->tail)
++ if (!listp->tail) {
++ ret->next = listp->head;
listp->head = listp->tail = ret;
- else {
- listp->tail->next = ret;
- listp->tail = ret;
- }
+- else {
+- listp->tail->next = ret;
+- listp->tail = ret;
++ } else {
++ ret->next = listp->tail->next;
++ listp->tail->next = listp->tail = ret;
++ }
+
+ if (mflags & MATCHFLG_MERGE_FILE) {
+ struct exclude_list_struct *lp;
+ if (!local_lists.head)
+ out_of_memory("make_exclude");
+ lp = &local_lists.head[ndx];
-+ clear_exclude_list(lp, NULL);
++ lp->head = lp->tail = NULL;
+ if (asprintf(&lp->debug_type, "per-dir %s ", ret->pattern) < 0)
+ out_of_memory("make_exclude");
+ lp->parent = ret;
+ ret->slash_cnt = ndx;
-+ }
+ }
+
+ ret->match_flags = mflags;
}
static void free_exclude(struct exclude_struct *ex)
-@@ -99,13 +151,15 @@ static void free_exclude(struct exclude_
+@@ -99,18 +143,90 @@ static void free_exclude(struct exclude_
free(ex);
}
-void free_exclude_list(struct exclude_list_struct *listp)
+static void free_exclude_list(struct exclude_list_struct *listp)
{
- struct exclude_struct *ent, *next;
-
-- if (verbose > 2) {
-- rprintf(FINFO, "[%s] clearing %sexclude list\n",
-- who_am_i(), listp->debug_type);
-+ if (listp->extra) {
-+ if (listp->tail)
-+ listp->tail->next = NULL;
-+ else
-+ listp->head = NULL;
+- struct exclude_struct *ent, *next;
+-
+- for (ent = listp->head; ent; ent = next) {
+- next = ent->next;
+- free_exclude(ent);
++ if (listp->tail) {
++ struct exclude_struct *ent, *next;
++ /* Truncate any extra parent items from local list. */
++ listp->tail->next = NULL;
++ for (ent = listp->head; ent; ent = next) {
++ next = ent->next;
++ free_exclude(ent);
++ }
}
- for (ent = listp->head; ent; ent = next) {
-@@ -113,7 +167,78 @@ void free_exclude_list(struct exclude_li
- free_exclude(ent);
- }
+ listp->head = listp->tail = NULL;
+ }
-- listp->head = listp->tail = NULL;
-+ clear_exclude_list(listp, NULL);
-+}
-+
+void *push_local_excludes(char *fname, unsigned int offset)
+{
+ int i;
+
+ for (i = 0; i < local_lists.cnt; i++) {
+ struct exclude_list_struct *listp = &local_lists.head[i];
-+ struct exclude_struct *extra;
+ char *file = listp->parent->pattern;
+ int flags;
+
+ }
+ if (listp->parent->match_flags & MATCHFLG_CVSIGNORE) {
+ flags = XFLG_WORD_SPLIT | XFLG_WORDS_ONLY;
-+ extra = NULL;
++ listp->head = NULL; /* Subdirs don't get our rules. */
+ } else {
+ flags = listp->parent->match_flags & MATCHFLG_INCLUDE
+ ? XFLG_DEF_INCLUDE : 0;
-+ extra = listp->head; /* Subdirs inherit our rules. */
+ }
-+ clear_exclude_list(listp, extra);
++ listp->tail = NULL;
+ if (strlcpy(fname + offset, file, MAXPATHLEN - offset)
+ < MAXPATHLEN - offset)
+ add_exclude_file(listp, fname, flags);
+ free(local_lists.head);
+ local_lists = *(struct exclude_list_root*)mem;
+ free(mem);
- }
-
++}
++
static int check_one_exclude(char *name, struct exclude_struct *ex,
-@@ -139,7 +264,8 @@ static int check_one_exclude(char *name,
+ int name_is_dir)
+ {
+@@ -134,7 +250,8 @@ static int check_one_exclude(char *name,
if (!name[0]) return 0;
if (*pattern == '/') {
match_start = 1;
-@@ -206,9 +332,11 @@ static void report_exclude_result(char c
+@@ -201,9 +318,11 @@ static void report_exclude_result(char c
if (verbose >= 2) {
rprintf(FINFO, "[%s] %scluding %s %s because of %spattern %s%s\n",
}
}
-@@ -222,10 +350,18 @@ int check_exclude(struct exclude_list_st
+@@ -217,10 +336,18 @@ int check_exclude(struct exclude_list_st
struct exclude_struct *ent;
for (ent = listp->head; ent; ent = ent->next) {
}
}
-@@ -241,11 +377,11 @@ int check_exclude(struct exclude_list_st
+@@ -236,11 +363,11 @@ int check_exclude(struct exclude_list_st
* *incl_ptr value will be 1 for an include, 0 for an exclude, and -1 for
* the list-clearing "!" token.
*/
if (xflags & XFLG_WORD_SPLIT) {
/* Skip over any initial whitespace. */
-@@ -255,13 +391,19 @@ static const char *get_exclude_tok(const
+@@ -250,13 +377,19 @@ static const char *get_exclude_tok(const
p = (const char *)s;
}
if (xflags & XFLG_WORD_SPLIT) {
const unsigned char *cp = s;
-@@ -273,9 +415,10 @@ static const char *get_exclude_tok(const
+@@ -268,9 +401,10 @@ static const char *get_exclude_tok(const
len = strlen(s);
if (*p == '!' && len == 1 && !(xflags & XFLG_WORDS_ONLY))
return (const char *)s;
}
-@@ -283,7 +426,7 @@ static const char *get_exclude_tok(const
+@@ -278,7 +412,7 @@ static const char *get_exclude_tok(const
void add_exclude(struct exclude_list_struct *listp, const char *pattern,
int xflags)
{
const char *cp;
if (!pattern)
-@@ -292,22 +435,48 @@ void add_exclude(struct exclude_list_str
+@@ -287,27 +421,49 @@ void add_exclude(struct exclude_list_str
cp = pattern;
pat_len = 0;
while (1) {
if (!pat_len)
break;
- /* If we got the special "!" token, clear the list. */
-- if (incl < 0)
-- free_exclude_list(listp);
-- else {
-- make_exclude(listp, cp, pat_len, incl);
--
+- if (incl < 0) {
+ if (mflags & MATCHFLG_CLEAR_LIST) {
if (verbose > 2) {
+ rprintf(FINFO,
+ "[%s] clearing %sexclude list\n",
+ who_am_i(), listp->debug_type);
+ }
+ free_exclude_list(listp);
+- } else {
+- make_exclude(listp, cp, pat_len, incl);
+-
+- if (verbose > 2) {
- rprintf(FINFO, "[%s] add_exclude(%.*s, %s%s)\n",
- who_am_i(), pat_len, cp,
- listp->debug_type,
- incl ? "include" : "exclude");
-+ rprintf(FINFO, "[%s] clearing %sexclude list\n",
-+ who_am_i(), listp->debug_type);
-+ }
-+ free_exclude_list(listp);
+ continue;
+ }
+ if (mflags & MATCHFLG_MERGE_FILE) {
}
}
-@@ -383,15 +552,19 @@ void send_exclude_list(int f)
+@@ -383,15 +539,19 @@ void send_exclude_list(int f)
l = strlcpy(p, ent->pattern, sizeof p);
if (l == 0 || l >= MAXPATHLEN)
continue;
write_int(f, l + 2);
write_buf(f, "- ", 2);
} else
-@@ -432,6 +605,7 @@ void add_cvs_excludes(void)
+@@ -432,6 +592,7 @@ void add_cvs_excludes(void)
char fname[MAXPATHLEN];
char *p;
add_exclude(&exclude_list, default_cvsignore,
XFLG_WORD_SPLIT | XFLG_WORDS_ONLY);
---- flist.c 3 May 2004 01:24:10 -0000 1.220
-+++ flist.c 8 May 2004 18:38:52 -0000
+--- flist.c 14 May 2004 21:23:41 -0000 1.222
++++ flist.c 15 May 2004 00:36:36 -0000
@@ -39,8 +39,6 @@ extern int module_id;
extern int ignore_errors;
extern int numeric_ids;
extern int recurse;
extern char curr_dir[MAXPATHLEN];
extern char *files_from;
-@@ -66,7 +64,6 @@ extern int write_batch;
+@@ -65,7 +63,6 @@ extern int write_batch;
extern struct exclude_list_struct exclude_list;
extern struct exclude_list_struct server_exclude_list;
int io_error;
-@@ -211,8 +208,6 @@ int link_stat(const char *path, STRUCT_S
+@@ -210,8 +207,6 @@ int link_stat(const char *path, STRUCT_S
*/
static int check_exclude_file(char *fname, int is_dir, int exclude_level)
{
#if 0 /* This currently never happens, so avoid a useless compare. */
if (exclude_level == NO_EXCLUDES)
return 0;
-@@ -234,10 +229,7 @@ static int check_exclude_file(char *fnam
+@@ -233,10 +228,7 @@ static int check_exclude_file(char *fnam
if (exclude_level != ALL_EXCLUDES)
return 0;
if (exclude_list.head
return 1;
return 0;
}
-@@ -947,11 +939,7 @@ void send_file_name(int f, struct file_l
+@@ -946,15 +938,7 @@ void send_file_name(int f, struct file_l
if (recursive && S_ISDIR(file->mode)
&& !(file->flags & FLAG_MOUNT_POINT)) {
- struct exclude_list_struct last_list = local_exclude_list;
- local_exclude_list.head = local_exclude_list.tail = NULL;
send_directory(f, flist, f_name_to(file, fbuf));
+- if (verbose > 2) {
+- rprintf(FINFO, "[%s] popping %sexclude list\n",
+- who_am_i(), local_exclude_list.debug_type);
+- }
- free_exclude_list(&local_exclude_list);
- local_exclude_list = last_list;
}
}
-@@ -962,6 +950,7 @@ static void send_directory(int f, struct
+@@ -965,6 +949,7 @@ static void send_directory(int f, struct
struct dirent *di;
char fname[MAXPATHLEN];
unsigned int offset;
char *p;
d = opendir(dir);
-@@ -986,18 +975,7 @@ static void send_directory(int f, struct
+@@ -989,18 +974,7 @@ static void send_directory(int f, struct
offset++;
}
for (errno = 0, di = readdir(d); di; errno = 0, di = readdir(d)) {
char *dname = d_name(di);
-@@ -1018,6 +996,8 @@ static void send_directory(int f, struct
+@@ -1021,6 +995,8 @@ static void send_directory(int f, struct
rprintf(FERROR, "readdir(%s): (%d) %s\n",
dir, errno, strerror(errno));
}
closedir(d);
}
---- rsync.h 2 May 2004 16:34:33 -0000 1.200
-+++ rsync.h 8 May 2004 18:38:52 -0000
-@@ -490,18 +490,21 @@ struct map_struct {
+--- rsync.h 13 May 2004 18:51:22 -0000 1.203
++++ rsync.h 15 May 2004 00:36:36 -0000
+@@ -493,18 +493,21 @@ struct map_struct {
#define MATCHFLG_WILD2 (1<<1) /* pattern has '**' */
#define MATCHFLG_WILD2_PREFIX (1<<2) /* pattern starts with '**' */
#define MATCHFLG_ABS_PATH (1<<3) /* path-match on absolute path */
- struct exclude_struct *head;
- struct exclude_struct *tail;
+ struct exclude_struct *head, *tail;
-+ struct exclude_struct *extra, *parent;
++ struct exclude_struct *parent;
char *debug_type;
};
--- rsync.yo 7 May 2004 00:18:37 -0000 1.169
-+++ rsync.yo 8 May 2004 18:38:53 -0000
++++ rsync.yo 15 May 2004 00:36:37 -0000
@@ -1075,6 +1075,72 @@ itemize(
it would be excluded by the "*")
)