1 diff -u -r gzip-1.5/deflate.c /home/bdale/debian/gzip/deflate.c
2 --- gzip-1.5/deflate.c 2012-04-24 10:25:28.000000000 -0600
3 +++ /home/bdale/debian/gzip/deflate.c 2012-06-19 14:01:41.885498670 -0600
6 /* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
9 +# define RSYNC_WIN 8192
11 +/* Size of rsync window, must be < MAX_DIST */
13 +#define RSYNC_SUM_MATCH(sum) (((sum) & (RSYNC_WIN - 1)) == 0)
14 +/* Whether window sum matches magic value */
16 /* ===========================================================================
17 * Local data used by the "longest match" routines.
21 /* Use a faster search when the previous match is longer than this */
23 +local ulg rsync_sum; /* rolling sum of rsync window */
24 +local ulg rsync_chunk_end; /* next rsync sequence point */
26 /* Values for max_lazy_match, good_match and max_chain_length, depending on
27 * the desired pack level (0..9). The values given below have been tuned to
30 /* prev will be initialized on the fly */
33 + rsync_chunk_end = 0xFFFFFFFFUL;
36 /* Set the default configuration parameters:
38 max_lazy_match = configuration_table[pack_level].max_lazy;
43 + rsync_chunk_end = 0xFFFFFFFFUL;
45 match_init(); /* initialize the asm code */
48 memcpy((char*)window, (char*)window+WSIZE, (unsigned)WSIZE);
50 strstart -= WSIZE; /* we now have strstart >= MAX_DIST: */
51 + if (rsync_chunk_end != 0xFFFFFFFFUL)
52 + rsync_chunk_end -= WSIZE;
54 block_start -= (long) WSIZE;
60 +local void rsync_roll(start, num)
66 + if (start < RSYNC_WIN) {
67 + /* before window fills. */
68 + for (i = start; i < RSYNC_WIN; i++) {
69 + if (i == start + num) return;
70 + rsync_sum += (ulg)window[i];
72 + num -= (RSYNC_WIN - start);
76 + /* buffer after window full */
77 + for (i = start; i < start+num; i++) {
78 + /* New character in */
79 + rsync_sum += (ulg)window[i];
80 + /* Old character out */
81 + rsync_sum -= (ulg)window[i - RSYNC_WIN];
82 + if (rsync_chunk_end == 0xFFFFFFFFUL && RSYNC_SUM_MATCH(rsync_sum))
83 + rsync_chunk_end = i;
87 +/* ===========================================================================
88 + * Set rsync_chunk_end if window sum matches magic value.
90 +#define RSYNC_ROLL(s, n) \
91 + do { if (rsync) rsync_roll((s), (n)); } while(0)
93 /* ===========================================================================
94 * Flush the current block, with given end-of-file flag.
95 * IN assertion: strstart is set to the end of the current match.
98 lookahead -= match_length;
100 - /* Insert new strings in the hash table only if the match length
101 + RSYNC_ROLL(strstart, match_length);
102 + /* Insert new strings in the hash table only if the match length
103 * is not too large. This saves time but degrades compression.
105 if (match_length <= max_insert_length) {
107 /* No match, output a literal byte */
108 Tracevv((stderr,"%c",window[strstart]));
109 flush = ct_tally (0, window[strstart]);
110 + RSYNC_ROLL(strstart, 1);
114 + if (rsync && strstart > rsync_chunk_end) {
115 + ush attr = 0; /* ascii/binary flag */
118 + /* Reset huffman tree */
119 + ct_init(&attr, &method);
120 + rsync_chunk_end = 0xFFFFFFFFUL;
122 if (flush) FLUSH_BLOCK(0), block_start = strstart;
124 /* Make sure that we always have enough lookahead, except
127 lookahead -= prev_length-1;
129 + RSYNC_ROLL(strstart, prev_length+1);
132 INSERT_STRING(strstart, hash_head);
133 @@ -742,24 +803,51 @@
135 match_length = MIN_MATCH-1;
137 - if (flush) FLUSH_BLOCK(0), block_start = strstart;
139 + if (rsync && strstart > rsync_chunk_end) {
140 + ush attr = 0; /* ascii/binary flag */
142 + /* Reset huffman tree */
143 + ct_init(&attr, &method);
144 + rsync_chunk_end = 0xFFFFFFFFUL;
147 + if (flush) FLUSH_BLOCK(0), block_start = strstart;
148 } else if (match_available) {
149 /* If there was no match at the previous position, output a
150 * single literal. If there was a match but the current match
151 * is longer, truncate the previous match to a single literal.
153 Tracevv((stderr,"%c",window[strstart-1]));
154 - if (ct_tally (0, window[strstart-1])) {
155 - FLUSH_BLOCK(0), block_start = strstart;
157 + flush = ct_tally (0, window[strstart-1]);
158 + if (rsync && strstart > rsync_chunk_end) {
159 + ush attr = 0; /* ascii/binary flag */
161 + /* Reset huffman tree */
162 + ct_init(&attr, &method);
163 + rsync_chunk_end = 0xFFFFFFFFUL;
167 + if (flush) FLUSH_BLOCK(0), block_start = strstart;
168 + RSYNC_ROLL(strstart, 1);
172 /* There is no previous match to compare with, wait for
173 * the next step to decide.
175 + if (rsync && strstart > rsync_chunk_end) {
176 + ush attr = 0; /* ascii/binary flag */
178 + /* Reset huffman tree */
179 + ct_init(&attr, &method);
180 + rsync_chunk_end = 0xFFFFFFFFUL;
182 + FLUSH_BLOCK(0), block_start = strstart;
185 + RSYNC_ROLL(strstart, 1);
189 diff -u -r gzip-1.5/doc/gzip.texi /home/bdale/debian/gzip/doc/gzip.texi
190 --- gzip-1.5/doc/gzip.texi 2012-01-01 01:53:58.000000000 -0700
191 +++ /home/bdale/debian/gzip/doc/gzip.texi 2012-06-19 14:09:36.041559612 -0600
193 -V, --version display version number
194 -1, --fast compress faster
195 -9, --best compress better
196 + --rsyncable Make rsync-friendly archive
198 With no FILE, or when FILE is -, read standard input.
201 into the directory and compress all the files it finds there (or
202 decompress them in the case of @command{gunzip}).
205 +While compressing, synchronize the output occasionally based on the
206 +input. This can reduce the compression slightly in some cases, but
207 +means that the @code{rsync} program can take advantage of similarities
208 +in the uncompressed input when syncronizing two files compressed with
209 +this flag. @code{gunzip} cannot tell the difference between a
210 +compressed file created with this option, and one created without it.
213 +While compressing, synchronize the output occasionally based on
214 +the input. This increases size by less than 1 percent most
215 +cases, but means that the @command{rsync} program can much more efficiently
216 +synchronize files compressed with this flag. @command{gunzip}
217 +cannot tell the difference between a compressed file created
218 +with this option, and one created without it.
221 +While compressing, synchronize the output occasionally based on the
222 +input. This can reduce the compression slightly in some cases, but
223 +means that the @code{rsync} program can take advantage of similarities
224 +in the uncompressed input when syncronizing two files compressed with
225 +this flag. @code{gunzip} cannot tell the difference between a
226 +compressed file created with this option, and one created without it.
228 @item --suffix @var{suf}
230 Use suffix @var{suf} instead of @samp{.gz}. Any suffix can be
231 --- gzip-1.5/gzip.c 2012-04-24 10:25:28.000000000 -0600
232 +++ /home/bdale/debian/gzip/gzip.c 2012-06-19 14:00:43.283873180 -0600
234 unsigned insize; /* valid bytes in inbuf */
235 unsigned inptr; /* index of next byte to be processed in inbuf */
236 unsigned outcnt; /* bytes in output buffer */
237 +int rsync = 0; /* make ryncable chunks */
239 static int handled_sig[] =
242 {"best", 0, 0, '9'}, /* compress better */
243 {"lzw", 0, 0, 'Z'}, /* make output compatible with old compress */
244 {"bits", 1, 0, 'b'}, /* max number of bits per code (implies -Z) */
246 + {"rsyncable", 0, 0, 'R'}, /* make rsync-friendly archive */
251 " -Z, --lzw produce output compatible with old compress",
252 " -b, --bits=BITS max number of bits per code (implies -Z)",
254 + " --rsyncable Make rsync-friendly archive",
256 "With no FILE, or when FILE is -, read standard input.",
269 #ifdef NO_MULTIPLE_DOTS
270 if (*optarg == '.') optarg++;
272 diff -u -r gzip-1.5/gzip.h /home/bdale/debian/gzip/gzip.h
273 --- gzip-1.5/gzip.h 2012-01-01 01:53:58.000000000 -0700
274 +++ /home/bdale/debian/gzip/gzip.h 2012-06-19 13:57:36.833883093 -0600
276 extern unsigned insize; /* valid bytes in inbuf */
277 extern unsigned inptr; /* index of next byte to be processed in inbuf */
278 extern unsigned outcnt; /* bytes in output buffer */
279 +extern int rsync; /* deflate into rsyncable chunks */
281 extern off_t bytes_in; /* number of input bytes */
282 extern off_t bytes_out; /* number of output bytes */