Skip to content

Commit b5e539f

Browse files
committed
Use documentation to extract 2 more .h lists
- Change default_cvsignore char[] into a define. - Make the DEFAULT_DONT_COMPRESS and DEFAULT_CVSIGNORE defines get set based on their info in rsync.1.md. - Add a few more don't-compress suffixes from Simon Matter.
1 parent 88c18ef commit b5e539f

7 files changed

+88
-21
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ aclocal.m4
1919
/rsync*.5
2020
/rsync*.html
2121
/help-rsync*.h
22+
/default-cvsignore.h
23+
/default-dont-compress.h
2224
/.md2man-works
2325
/autom4te*.cache
2426
/confdefs.h

Makefile.in

+6-1
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,16 @@ rsync$(EXEEXT): $(OBJS)
100100
$(OBJS): $(HEADERS)
101101
$(CHECK_OBJS): $(HEADERS)
102102
options.o: latest-year.h help-rsync.h help-rsyncd.h
103+
exclude.o: default-cvsignore.h
104+
loadparm.o: default-dont-compress.h
103105

104106
flist.o: rounding.h
105107

108+
default-cvsignore.h default-dont-compress.h: rsync.1.md define-from-md.awk
109+
awk -f $(srcdir)/define-from-md.awk -v hfile=$@ $(srcdir)/rsync.1.md
110+
106111
help-rsync.h help-rsyncd.h: rsync.1.md help-from-md.awk
107-
awk -f $(srcdir)/help-from-md.awk -v helpfile=$@ $(srcdir)/rsync.1.md
112+
awk -f $(srcdir)/help-from-md.awk -v hfile=$@ $(srcdir)/rsync.1.md
108113

109114
rounding.h: rounding.c rsync.h proto.h
110115
@for r in 0 1 3; do \

define-from-md.awk

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/awk -f
2+
3+
# The caller must pass args: -v hfile=NAME rsync.1.md
4+
5+
BEGIN {
6+
heading = "/* DO NOT EDIT THIS FILE! It is auto-generated from a list of values in " ARGV[1] "! */"
7+
if (hfile ~ /compress/) {
8+
define = "#define DEFAULT_DONT_COMPRESS"
9+
prefix = "*."
10+
} else {
11+
define = "#define DEFAULT_CVSIGNORE"
12+
prefix = ""
13+
}
14+
value_list = ""
15+
}
16+
17+
/^ > [^ ]+$/ {
18+
gsub(/`/, "")
19+
if (value_list != "") value_list = value_list " "
20+
value_list = value_list prefix $2
21+
next
22+
}
23+
24+
value_list ~ /\.gz / && hfile ~ /compress/ {
25+
exit
26+
}
27+
28+
value_list ~ /SCCS / && hfile ~ /cvsignore/ {
29+
exit
30+
}
31+
32+
value_list = ""
33+
34+
END {
35+
if (value_list != "")
36+
print heading "\n\n" define " \"" value_list "\"" > hfile
37+
else {
38+
print "Failed to find a value list in " ARGV[1] " for " hfile
39+
exit 1
40+
}
41+
}

exclude.c

+2-11
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
*/
2222

2323
#include "rsync.h"
24+
#include "default-cvsignore.h"
2425

2526
extern int am_server;
2627
extern int am_sender;
@@ -1051,16 +1052,6 @@ static filter_rule *parse_rule_tok(const char **rulestr_ptr,
10511052
return rule;
10521053
}
10531054

1054-
static char default_cvsignore[] =
1055-
/* These default ignored items come from the CVS manual. */
1056-
"RCS SCCS CVS CVS.adm RCSLOG cvslog.* tags TAGS"
1057-
" .make.state .nse_depinfo *~ #* .#* ,* _$* *$"
1058-
" *.old *.bak *.BAK *.orig *.rej .del-*"
1059-
" *.a *.olb *.o *.obj *.so *.exe"
1060-
" *.Z *.elc *.ln core"
1061-
/* The rest we added to suit ourself. */
1062-
" .svn/ .git/ .hg/ .bzr/";
1063-
10641055
static void get_cvs_excludes(uint32 rflags)
10651056
{
10661057
static int initialized = 0;
@@ -1070,7 +1061,7 @@ static void get_cvs_excludes(uint32 rflags)
10701061
return;
10711062
initialized = 1;
10721063

1073-
parse_filter_str(&cvs_filter_list, default_cvsignore,
1064+
parse_filter_str(&cvs_filter_list, DEFAULT_CVSIGNORE,
10741065
rule_template(rflags | (protocol_version >= 30 ? FILTRULE_PERISHABLE : 0)),
10751066
0);
10761067

help-from-md.awk

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/awk -f
22

3-
# The caller must set -v helpfile=help-NAME.h and pass arg NAME.NUM.md
3+
# The caller must pass args: -v hfile=help-NAME.h NAME.NUM.md
44

55
BEGIN {
66
heading = "/* DO NOT EDIT THIS FILE! It is auto-generated from the option list in " ARGV[1] "! */"
7-
findcomment = helpfile
7+
findcomment = hfile
88
sub("\\.", "\\.", findcomment)
99
findcomment = "\\[comment\\].*" findcomment
1010
backtick_cnt = 0
@@ -32,9 +32,9 @@ $0 ~ findcomment {
3232

3333
END {
3434
if (foundcomment && backtick_cnt > 1)
35-
print heading "\n" prints > helpfile
35+
print heading "\n" prints > hfile
3636
else {
37-
print "Failed to find " helpfile " section in " ARGV[1]
37+
print "Failed to find " hfile " section in " ARGV[1]
3838
exit 1
3939
}
4040
}

loadparm.c

+1-5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242

4343
#include "rsync.h"
4444
#include "itypes.h"
45+
#include "default-dont-compress.h"
4546

4647
extern item_list dparam_list;
4748

@@ -52,11 +53,6 @@ extern item_list dparam_list;
5253
#define LOG_DAEMON 0
5354
#endif
5455

55-
#define DEFAULT_DONT_COMPRESS "*.gz *.zip *.z *.rpm *.deb *.iso *.bz2" \
56-
" *.t[gb]z *.7z *.mp[34] *.mov *.avi *.ogg *.jpg *.jpeg *.png" \
57-
" *.lzo *.rzip *.lzma *.rar *.ace *.gpg *.xz *.txz *.lz *.tlz" \
58-
" *.ogv *.web[mp] *.squashfs"
59-
6056
/* the following are used by loadparm for option lists */
6157
typedef enum {
6258
P_BOOL, P_BOOLREV, P_CHAR, P_INTEGER,

rsync.1.md

+32
Original file line numberDiff line numberDiff line change
@@ -1852,6 +1852,8 @@ your home directory (remove the '=' for that).
18521852
The exclude list is initialized to exclude the following items (these
18531853
initial items are marked as perishable -- see the FILTER RULES section):
18541854

1855+
[comment]: # (This list gets used for the default-cvsignore.h file.)
1856+
18551857
> `RCS`
18561858
> `SCCS`
18571859
> `CVS`
@@ -2335,38 +2337,68 @@ your home directory (remove the '=' for that).
23352337
The default file suffixes in the skip-compress list in this version of
23362338
rsync are:
23372339

2340+
[comment]: # (This list gets used for the default-dont-compress.h file.)
2341+
23382342
> 7z
23392343
> ace
2344+
> apk
23402345
> avi
23412346
> bz2
23422347
> deb
2348+
> flac
23432349
> gpg
23442350
> gz
23452351
> iso
2352+
> jar
23462353
> jpeg
23472354
> jpg
23482355
> lz
2356+
> lz4
23492357
> lzma
23502358
> lzo
2359+
> mkv
23512360
> mov
23522361
> mp3
23532362
> mp4
2363+
> odb
2364+
> odf
2365+
> odg
2366+
> odi
2367+
> odm
2368+
> odp
2369+
> ods
2370+
> odt
23542371
> ogg
23552372
> ogv
2373+
> opus
2374+
> otg
2375+
> oth
2376+
> otp
2377+
> ots
2378+
> ott
2379+
> oxt
23562380
> png
23572381
> rar
23582382
> rpm
2383+
> rz
23592384
> rzip
23602385
> squashfs
2386+
> sxc
2387+
> sxd
2388+
> sxg
2389+
> sxm
2390+
> sxw
23612391
> tbz
23622392
> tgz
23632393
> tlz
23642394
> txz
2395+
> tzo
23652396
> webm
23662397
> webp
23672398
> xz
23682399
> z
23692400
> zip
2401+
> zst
23702402

23712403
This list will be replaced by your `--skip-compress` list in all but one
23722404
situation: a copy from a daemon rsync will add your skipped suffixes to its

0 commit comments

Comments
 (0)