Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
liblongpath-rsync
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
liblongpath
liblongpath-rsync
Commits
a61ec6b1
Commit
a61ec6b1
authored
May 23, 2009
by
Wayne Davison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved a couple variable names.
parent
7b6c5c77
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
54 deletions
+42
-54
exclude.c
exclude.c
+42
-54
No files found.
exclude.c
View file @
a61ec6b1
...
...
@@ -155,7 +155,7 @@ static void free_filters(filter_rule *head)
static
void
add_rule
(
filter_rule_list
*
listp
,
const
char
*
pat
,
unsigned
int
pat_len
,
uint32
rflags
,
int
xflags
)
{
filter_rule
*
r
et
;
filter_rule
*
r
ule
;
const
char
*
cp
;
unsigned
int
pre_len
,
suf_len
,
slash_cnt
=
0
;
...
...
@@ -180,7 +180,7 @@ static void add_rule(filter_rule_list *listp, const char *pat,
}
}
if
(
!
(
r
et
=
new0
(
filter_rule
)))
if
(
!
(
r
ule
=
new0
(
filter_rule
)))
out_of_memory
(
"add_rule"
);
if
(
pat_len
>
1
&&
pat
[
pat_len
-
1
]
==
'/'
)
{
...
...
@@ -212,35 +212,35 @@ static void add_rule(filter_rule_list *listp, const char *pat,
}
else
suf_len
=
0
;
if
(
!
(
r
et
->
pattern
=
new_array
(
char
,
pre_len
+
pat_len
+
suf_len
+
1
)))
if
(
!
(
r
ule
->
pattern
=
new_array
(
char
,
pre_len
+
pat_len
+
suf_len
+
1
)))
out_of_memory
(
"add_rule"
);
if
(
pre_len
)
{
memcpy
(
r
et
->
pattern
,
dirbuf
+
module_dirlen
,
pre_len
);
for
(
cp
=
r
et
->
pattern
;
cp
<
ret
->
pattern
+
pre_len
;
cp
++
)
{
memcpy
(
r
ule
->
pattern
,
dirbuf
+
module_dirlen
,
pre_len
);
for
(
cp
=
r
ule
->
pattern
;
cp
<
rule
->
pattern
+
pre_len
;
cp
++
)
{
if
(
*
cp
==
'/'
)
slash_cnt
++
;
}
}
strlcpy
(
r
et
->
pattern
+
pre_len
,
pat
,
pat_len
+
1
);
strlcpy
(
r
ule
->
pattern
+
pre_len
,
pat
,
pat_len
+
1
);
pat_len
+=
pre_len
;
if
(
suf_len
)
{
memcpy
(
r
et
->
pattern
+
pat_len
,
SLASH_WILD3_SUFFIX
,
suf_len
+
1
);
memcpy
(
r
ule
->
pattern
+
pat_len
,
SLASH_WILD3_SUFFIX
,
suf_len
+
1
);
pat_len
+=
suf_len
;
slash_cnt
++
;
}
if
(
strpbrk
(
r
et
->
pattern
,
"*[?"
))
{
if
(
strpbrk
(
r
ule
->
pattern
,
"*[?"
))
{
rflags
|=
FILTRULE_WILD
;
if
((
cp
=
strstr
(
r
et
->
pattern
,
"**"
))
!=
NULL
)
{
if
((
cp
=
strstr
(
r
ule
->
pattern
,
"**"
))
!=
NULL
)
{
rflags
|=
FILTRULE_WILD2
;
/* If the pattern starts with **, note that. */
if
(
cp
==
r
et
->
pattern
)
if
(
cp
==
r
ule
->
pattern
)
rflags
|=
FILTRULE_WILD2_PREFIX
;
/* If the pattern ends with ***, note that. */
if
(
pat_len
>=
3
&&
r
et
->
pattern
[
pat_len
-
3
]
==
'*'
&&
r
et
->
pattern
[
pat_len
-
2
]
==
'*'
&&
r
et
->
pattern
[
pat_len
-
1
]
==
'*'
)
&&
r
ule
->
pattern
[
pat_len
-
3
]
==
'*'
&&
r
ule
->
pattern
[
pat_len
-
2
]
==
'*'
&&
r
ule
->
pattern
[
pat_len
-
1
]
==
'*'
)
rflags
|=
FILTRULE_WILD3_SUFFIX
;
}
}
...
...
@@ -250,10 +250,10 @@ static void add_rule(filter_rule_list *listp, const char *pat,
unsigned
int
len
;
int
i
;
if
((
cp
=
strrchr
(
r
et
->
pattern
,
'/'
))
!=
NULL
)
if
((
cp
=
strrchr
(
r
ule
->
pattern
,
'/'
))
!=
NULL
)
cp
++
;
else
cp
=
r
et
->
pattern
;
cp
=
r
ule
->
pattern
;
/* If the local merge file was already mentioned, don't
* add it again. */
...
...
@@ -265,9 +265,8 @@ static void add_rule(filter_rule_list *listp, const char *pat,
else
s
=
ex
->
pattern
;
len
=
strlen
(
s
);
if
(
len
==
pat_len
-
(
cp
-
ret
->
pattern
)
&&
memcmp
(
s
,
cp
,
len
)
==
0
)
{
free_filter
(
ret
);
if
(
len
==
pat_len
-
(
cp
-
rule
->
pattern
)
&&
memcmp
(
s
,
cp
,
len
)
==
0
)
{
free_filter
(
rule
);
return
;
}
}
...
...
@@ -277,7 +276,7 @@ static void add_rule(filter_rule_list *listp, const char *pat,
lp
->
head
=
lp
->
tail
=
lp
->
parent_dirscan_head
=
NULL
;
if
(
asprintf
(
&
lp
->
debug_type
,
" [per-dir %s]"
,
cp
)
<
0
)
out_of_memory
(
"add_rule"
);
r
et
->
u
.
mergelist
=
lp
;
r
ule
->
u
.
mergelist
=
lp
;
if
(
mergelist_cnt
==
mergelist_size
)
{
mergelist_size
+=
5
;
...
...
@@ -291,19 +290,19 @@ static void add_rule(filter_rule_list *listp, const char *pat,
rprintf
(
FINFO
,
"[%s] activating mergelist #%d%s
\n
"
,
who_am_i
(),
mergelist_cnt
,
lp
->
debug_type
);
}
mergelist_parents
[
mergelist_cnt
++
]
=
r
et
;
mergelist_parents
[
mergelist_cnt
++
]
=
r
ule
;
}
else
r
et
->
u
.
slash_cnt
=
slash_cnt
;
r
ule
->
u
.
slash_cnt
=
slash_cnt
;
r
et
->
rflags
=
rflags
;
r
ule
->
rflags
=
rflags
;
if
(
!
listp
->
tail
)
{
r
et
->
next
=
listp
->
head
;
listp
->
head
=
listp
->
tail
=
r
et
;
r
ule
->
next
=
listp
->
head
;
listp
->
head
=
listp
->
tail
=
r
ule
;
}
else
{
r
et
->
next
=
listp
->
tail
->
next
;
listp
->
tail
->
next
=
r
et
;
listp
->
tail
=
r
et
;
r
ule
->
next
=
listp
->
tail
->
next
;
listp
->
tail
->
next
=
r
ule
;
listp
->
tail
=
r
ule
;
}
}
...
...
@@ -712,7 +711,6 @@ static int rule_matches(const char *fname, filter_rule *ex, int name_is_dir)
return
!
ret_match
;
}
static
void
report_filter_result
(
enum
logcode
code
,
char
const
*
name
,
filter_rule
const
*
ent
,
int
name_is_dir
,
const
char
*
type
)
...
...
@@ -732,11 +730,8 @@ static void report_filter_result(enum logcode code, char const *name,
}
}
/*
* Return -1 if file "name" is defined to be excluded by the specified
* exclude list, 1 if it is included, and 0 if it was not matched.
*/
/* Return -1 if file "name" is defined to be excluded by the specified
* exclude list, 1 if it is included, and 0 if it was not matched. */
int
check_filter
(
filter_rule_list
*
listp
,
enum
logcode
code
,
const
char
*
name
,
int
name_is_dir
)
{
...
...
@@ -1007,7 +1002,6 @@ static const char *parse_rule_tok(const char *p, uint32 rflags, int xflags,
return
(
const
char
*
)
s
;
}
static
char
default_cvsignore
[]
=
/* These default ignored items come from the CVS manual. */
"RCS SCCS CVS CVS.adm RCSLOG cvslog.* tags TAGS"
...
...
@@ -1038,29 +1032,25 @@ static void get_cvs_excludes(uint32 rflags)
parse_rule
(
&
cvs_filter_list
,
getenv
(
"CVSIGNORE"
),
rflags
,
0
);
}
void
parse_rule
(
filter_rule_list
*
listp
,
const
char
*
pattern
,
uint32
rflags
,
int
xflags
)
void
parse_rule
(
filter_rule_list
*
listp
,
const
char
*
pattern
,
uint32
rflags
,
int
xflags
)
{
const
char
*
pat
;
unsigned
int
pat_len
;
uint32
new_rflags
;
const
char
*
cp
,
*
p
;
if
(
!
pattern
)
return
;
while
(
1
)
{
/* Remember that the returned string is NOT '\0' terminated! */
cp
=
parse_rule_tok
(
pattern
,
rflags
,
xflags
,
&
pat_len
,
&
new_rflags
);
if
(
!
cp
)
if
(
!
(
pat
=
parse_rule_tok
(
pattern
,
rflags
,
xflags
,
&
pat_len
,
&
new_rflags
)))
break
;
pattern
=
cp
+
pat_len
;
pattern
=
pat
+
pat_len
;
if
(
pat_len
>=
MAXPATHLEN
)
{
rprintf
(
FERROR
,
"discarding over-long filter: %.*s
\n
"
,
(
int
)
pat_len
,
cp
);
(
int
)
pat_len
,
pat
);
continue
;
}
...
...
@@ -1077,28 +1067,27 @@ void parse_rule(filter_rule_list *listp, const char *pattern,
if
(
new_rflags
&
FILTRULE_MERGE_FILE
)
{
unsigned
int
len
;
if
(
!
pat_len
)
{
cp
=
".cvsignore"
;
pat
=
".cvsignore"
;
pat_len
=
10
;
}
len
=
pat_len
;
if
(
new_rflags
&
FILTRULE_EXCLUDE_SELF
)
{
const
char
*
name
=
cp
+
len
;
while
(
name
>
cp
&&
name
[
-
1
]
!=
'/'
)
name
--
;
len
-=
name
-
cp
;
add_rule
(
listp
,
name
,
len
,
0
,
0
);
const
char
*
name
=
pat
+
len
;
while
(
name
>
pat
&&
name
[
-
1
]
!=
'/'
)
name
--
;
add_rule
(
listp
,
name
,
len
-
(
name
-
pat
),
0
,
0
);
new_rflags
&=
~
FILTRULE_EXCLUDE_SELF
;
len
=
pat_len
;
}
if
(
new_rflags
&
FILTRULE_PERDIR_MERGE
)
{
if
(
parent_dirscan
)
{
if
(
!
(
p
=
parse_merge_name
(
cp
,
&
len
,
module_dirlen
)))
const
char
*
p
;
if
(
!
(
p
=
parse_merge_name
(
pat
,
&
len
,
module_dirlen
)))
continue
;
add_rule
(
listp
,
p
,
len
,
new_rflags
,
0
);
continue
;
}
}
else
{
if
(
!
(
p
=
parse_merge_name
(
cp
,
&
len
,
0
)))
const
char
*
p
;
if
(
!
(
p
=
parse_merge_name
(
pat
,
&
len
,
0
)))
continue
;
parse_filter_file
(
listp
,
p
,
new_rflags
,
XFLG_FATAL_ERRORS
);
...
...
@@ -1106,7 +1095,7 @@ void parse_rule(filter_rule_list *listp, const char *pattern,
}
}
add_rule
(
listp
,
cp
,
pat_len
,
new_rflags
,
xflags
);
add_rule
(
listp
,
pat
,
pat_len
,
new_rflags
,
xflags
);
if
(
new_rflags
&
FILTRULE_CVS_IGNORE
&&
!
(
new_rflags
&
FILTRULE_MERGE_FILE
))
...
...
@@ -1114,7 +1103,6 @@ void parse_rule(filter_rule_list *listp, const char *pattern,
}
}
void
parse_filter_file
(
filter_rule_list
*
listp
,
const
char
*
fname
,
uint32
rflags
,
int
xflags
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment