Got rid of "extra" pointer out of exclude_list_struct (we can get
authorWayne Davison <wayned@samba.org>
Sat, 15 May 2004 00:53:47 +0000 (00:53 +0000)
committerWayne Davison <wayned@samba.org>
Sat, 15 May 2004 00:53:47 +0000 (00:53 +0000)
that info from tail->next).  Modified to apply to the latest CVS
source.

filter.diff

index 12b9343..d5de412 100644 (file)
@@ -28,9 +28,9 @@ for the current dir because its name contained a slash.
 
 ..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;
@@ -42,8 +42,8 @@ for the current dir because its name contained a slash.
 -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 {
@@ -53,13 +53,6 @@ for the current dir because its name contained a slash.
 +
 +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,
@@ -105,7 +98,7 @@ for the current dir because its name contained a slash.
                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);
@@ -135,14 +128,17 @@ for the current dir because its name contained a slash.
        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;
@@ -152,45 +148,42 @@ for the current dir because its name contained a slash.
 +              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;
@@ -214,7 +207,6 @@ for the current dir because its name contained a slash.
 +
 +      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;
 +
@@ -224,13 +216,12 @@ for the current dir because its name contained a slash.
 +              }
 +              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);
@@ -260,10 +251,12 @@ for the current dir because its name contained a slash.
 +      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;
  
@@ -273,7 +266,7 @@ for the current dir because its name contained a slash.
  
        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",
@@ -287,7 +280,7 @@ for the current dir because its name contained a slash.
        }
  }
  
-@@ -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) {
@@ -307,7 +300,7 @@ for the current dir because its name contained a slash.
                }
        }
  
-@@ -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.
   */
@@ -321,7 +314,7 @@ for the current dir because its name contained a slash.
  
        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;
        }
  
@@ -346,7 +339,7 @@ for the current dir because its name contained a slash.
  
        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))
@@ -358,7 +351,7 @@ for the current dir because its name contained a slash.
        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)
  {
@@ -367,7 +360,7 @@ for the current dir because its name contained a slash.
        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) {
@@ -376,21 +369,22 @@ for the current dir because its name contained a slash.
                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) {
@@ -427,7 +421,7 @@ for the current dir because its name contained a slash.
        }
  }
  
-@@ -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;
@@ -450,7 +444,7 @@ for the current dir because its name contained a slash.
                        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;
  
@@ -458,8 +452,8 @@ for the current dir because its name contained a slash.
        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;
@@ -469,7 +463,7 @@ for the current dir because its name contained a slash.
  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;
@@ -477,7 +471,7 @@ for the current dir because its name contained a slash.
  
  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)
  {
@@ -486,7 +480,7 @@ for the current dir because its name contained a slash.
  #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
@@ -498,19 +492,23 @@ for the current dir because its name contained a slash.
                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;
@@ -518,7 +516,7 @@ for the current dir because its name contained a slash.
        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++;
        }
  
@@ -538,7 +536,7 @@ for the current dir because its name contained a slash.
  
        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));
        }
@@ -547,9 +545,9 @@ for the current dir because its name contained a slash.
  
        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 */
@@ -571,12 +569,12 @@ for the current dir because its name contained a slash.
 -      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 "*")
  )