Remove tempname length problem and files-from from TODO.
[rsync/rsync.git] / exclude.c
index dc469e1..d5680ea 100644 (file)
--- a/exclude.c
+++ b/exclude.c
@@ -220,9 +220,16 @@ struct exclude_struct **make_exclude_list(const char *fname,
                                          int fatal, int include)
 {
        struct exclude_struct **list=list1;
-       FILE *f = fopen(fname,"r");
+       int fd;
        char line[MAXPATHLEN];
-       if (!f) {
+       char *eob = line + MAXPATHLEN - 1;
+       extern int eol_nulls;
+
+       if (strcmp(fname, "-") != 0)
+               fd = open(fname, O_RDONLY|O_BINARY);
+       else
+               fd = 0;
+       if (fd < 0) {
                if (fatal) {
                        rsyserr(FERROR, errno,
                                 "failed to open %s file %s",
@@ -233,18 +240,31 @@ struct exclude_struct **make_exclude_list(const char *fname,
                return list;
        }
 
-       while (fgets(line,MAXPATHLEN,f)) {
-               int l = strlen(line);
-               if (l && line[l-1] == '\n') l--;
-               line[l] = 0;
-               if (line[0] && (line[0] != ';') && (line[0] != '#')) {
+       while (1) {
+               char ch, *s = line;
+               int cnt;
+               while (1) {
+                       if ((cnt = read(fd, &ch, 1)) <= 0) {
+                               if (cnt < 0 && errno == EINTR)
+                                       continue;
+                               break;
+                       }
+                       if (eol_nulls? !ch : (ch == '\n' || ch == '\r'))
+                               break;
+                       if (s < eob)
+                               *s++ = ch;
+               }
+               *s = '\0';
+               if (*line && *line != ';' && *line != '#') {
                        /* Skip lines starting with semicolon or pound.
-                          It probably wouldn't cause any harm to not skip
-                            them but there's no need to save them. */
+                        * It probably wouldn't cause any harm to not skip
+                        * them but there's no need to save them. */
                        add_exclude_list(line,&list,include);
                }
+               if (cnt <= 0)
+                       break;
        }
-       fclose(f);
+       close(fd);
        return list;
 }
 
@@ -387,12 +407,11 @@ void add_include_line(char *p)
 
 
 static char *cvs_ignore_list[] = {
-  "RCS","SCCS","CVS","CVS.adm","RCSLOG","cvslog.*",
-  "tags","TAGS",".make.state",".nse_depinfo",
-  "*~", "#*", ".#*", ",*", "*.old", "*.bak", "*.BAK", "*.orig",
+  "RCS/", "SCCS/", "CVS/", ".svn/", "CVS.adm", "RCSLOG", "cvslog.*",
+  "tags", "TAGS", ".make.state", ".nse_depinfo",
+  "*~", "#*", ".#*", ", *", "*.old", "*.bak", "*.BAK", "*.orig",
   "*.rej", ".del-*", "*.a", "*.o", "*.obj", "*.so", "*.Z", "*.elc", "*.ln",
-  "core",NULL};
-
+  "core", NULL};
 
 
 void add_cvs_excludes(void)