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
ec497df1
Commit
ec497df1
authored
Dec 30, 2005
by
Wayne Davison
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Optimized set_compression() to remove the per-file strdup(), strlower(),
and free() calls (it now uses iwildmatch()).
parent
8e744636
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
24 deletions
+34
-24
token.c
token.c
+34
-24
No files found.
token.c
View file @
ec497df1
...
...
@@ -24,48 +24,58 @@ extern int do_compression;
extern
int
module_id
;
extern
int
def_compress_level
;
static
int
compression_level
;
static
int
compression_level
,
per_file_default_level
;
/* determine the compression level based on a wildcard filename list */
void
set_compression
(
char
*
fname
)
{
char
*
don
t
;
char
*
tok
;
static
char
*
match_lis
t
;
char
*
s
;
if
(
!
do_compression
)
return
;
compression_level
=
def_compress_level
;
dont
=
lp_dont_compress
(
module_id
);
if
(
!
dont
||
!*
dont
)
return
;
if
(
dont
[
0
]
==
'*'
&&
!
dont
[
1
])
{
/* an optimization to skip the rest of this routine */
compression_level
=
0
;
return
;
if
(
!
match_list
)
{
char
*
t
,
*
f
=
lp_dont_compress
(
module_id
);
int
len
=
strlen
(
f
);
if
(
!
(
match_list
=
t
=
new_array
(
char
,
len
+
2
)))
out_of_memory
(
"set_compression"
);
while
(
*
f
)
{
if
(
*
f
==
' '
)
{
f
++
;
continue
;
}
do
{
if
(
isupper
(
*
(
unsigned
char
*
)
f
))
*
t
++
=
tolower
(
*
(
unsigned
char
*
)
f
);
else
*
t
++
=
*
f
;
}
while
(
*++
f
!=
' '
&&
*
f
);
*
t
++
=
'\0'
;
}
/* Optimize a match-string of "*". */
if
(
t
-
match_list
==
2
&&
match_list
[
0
]
==
'*'
)
{
t
=
match_list
;
per_file_default_level
=
0
;
}
else
per_file_default_level
=
def_compress_level
;
*
t
++
=
'\0'
;
}
if
((
tok
=
strrchr
(
fname
,
'/'
))
!=
NULL
)
fname
=
tok
+
1
;
compression_level
=
per_file_default_level
;
dont
=
strdup
(
dont
);
fname
=
strdup
(
fname
);
if
(
!
dont
||
!
fname
)
if
(
!*
match_list
)
return
;
strlower
(
dont
);
strlower
(
fname
)
;
if
((
s
=
strrchr
(
fname
,
'/'
))
!=
NULL
)
fname
=
s
+
1
;
for
(
tok
=
strtok
(
dont
,
" "
);
tok
;
tok
=
strtok
(
NULL
,
" "
)
)
{
if
(
wildmatch
(
tok
,
fname
))
{
for
(
s
=
match_list
;
*
s
;
s
+=
strlen
(
s
)
+
1
)
{
if
(
iwildmatch
(
s
,
fname
))
{
compression_level
=
0
;
break
;
}
}
free
(
dont
);
free
(
fname
);
}
/* non-compressing recv token */
...
...
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