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",
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;
}
return(NULL);
/* Skip over any initial spaces */
- while(isspace((int) *s))
+ while (isspace(* (unsigned char *) s))
s++;
/* Are we at the end of the string? */
s+=2;
/* Skip to the next space or the end of the string */
- while(!isspace((int) *s) && *s != '\0')
+ while (!isspace(* (unsigned char *) s) && *s != '\0')
s++;
} else {
t=NULL;
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)