OpenSDE Packages Database (without history before r20070)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

295 lines
10 KiB

  1. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # T2 SDE: package/.../gzip/gzip-1.3-rsync.patch
  5. # Copyright (C) 2004 - 2006 The T2 SDE Project
  6. #
  7. # More information can be found in the files COPYING and README.
  8. #
  9. # This patch file is dual-licensed. It is available under the license the
  10. # patched project is licensed under, as long as it is an OpenSource license
  11. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  12. # of the GNU General Public License as published by the Free Software
  13. # Foundation; either version 2 of the License, or (at your option) any later
  14. # version.
  15. # --- T2-COPYRIGHT-NOTE-END ---
  16. Rsync friendly less changing compression - pulled from Fedora Core.
  17. - Rene Rebe <rene�@exactcode.de>
  18. --- gzip-1.3.2/deflate.c.rsync Fri Oct 8 08:46:28 1999
  19. +++ gzip-1.3.2/deflate.c Sun Mar 10 12:35:00 2002
  20. @@ -122,6 +122,14 @@
  21. #endif
  22. /* Matches of length 3 are discarded if their distance exceeds TOO_FAR */
  23. +#ifndef RSYNC_WIN
  24. +# define RSYNC_WIN 4096
  25. +#endif
  26. +/* Size of rsync window, must be < MAX_DIST */
  27. +
  28. +#define RSYNC_SUM_MATCH(sum) ((sum) % RSYNC_WIN == 0)
  29. +/* Whether window sum matches magic value */
  30. +
  31. /* ===========================================================================
  32. * Local data used by the "longest match" routines.
  33. */
  34. @@ -203,6 +211,8 @@
  35. unsigned near good_match;
  36. /* Use a faster search when the previous match is longer than this */
  37. +local ulg rsync_sum; /* rolling sum of rsync window */
  38. +local ulg rsync_chunk_end; /* next rsync sequence point */
  39. /* Values for max_lazy_match, good_match and max_chain_length, depending on
  40. * the desired pack level (0..9). The values given below have been tuned to
  41. @@ -301,6 +311,10 @@
  42. #endif
  43. /* prev will be initialized on the fly */
  44. + /* rsync params */
  45. + rsync_chunk_end = 0xFFFFFFFFUL;
  46. + rsync_sum = 0;
  47. +
  48. /* Set the default configuration parameters:
  49. */
  50. max_lazy_match = configuration_table[pack_level].max_lazy;
  51. @@ -537,6 +551,8 @@
  52. memcpy((char*)window, (char*)window+WSIZE, (unsigned)WSIZE);
  53. match_start -= WSIZE;
  54. strstart -= WSIZE; /* we now have strstart >= MAX_DIST: */
  55. + if (rsync_chunk_end != 0xFFFFFFFFUL)
  56. + rsync_chunk_end -= WSIZE;
  57. block_start -= (long) WSIZE;
  58. @@ -564,13 +580,46 @@
  59. }
  60. }
  61. +local void rsync_roll(start, num)
  62. + unsigned start;
  63. + unsigned num;
  64. +{
  65. + unsigned i;
  66. +
  67. + if (start < RSYNC_WIN) {
  68. + /* before window fills. */
  69. + for (i = start; i < RSYNC_WIN; i++) {
  70. + if (i == start + num) return;
  71. + rsync_sum += (ulg)window[i];
  72. + }
  73. + num -= (RSYNC_WIN - start);
  74. + start = RSYNC_WIN;
  75. + }
  76. +
  77. + /* buffer after window full */
  78. + for (i = start; i < start+num; i++) {
  79. + /* New character in */
  80. + rsync_sum += (ulg)window[i];
  81. + /* Old character out */
  82. + rsync_sum -= (ulg)window[i - RSYNC_WIN];
  83. + if (rsync_chunk_end == 0xFFFFFFFFUL && RSYNC_SUM_MATCH(rsync_sum))
  84. + rsync_chunk_end = i;
  85. + }
  86. +}
  87. +
  88. +/* ===========================================================================
  89. + * Set rsync_chunk_end if window sum matches magic value.
  90. + */
  91. +#define RSYNC_ROLL(s, n) \
  92. + do { if (rsync) rsync_roll((s), (n)); } while(0)
  93. +
  94. /* ===========================================================================
  95. * Flush the current block, with given end-of-file flag.
  96. * IN assertion: strstart is set to the end of the current match.
  97. */
  98. #define FLUSH_BLOCK(eof) \
  99. flush_block(block_start >= 0L ? (char*)&window[(unsigned)block_start] : \
  100. - (char*)NULL, (long)strstart - block_start, (eof))
  101. + (char*)NULL, (long)strstart - block_start, flush-1, (eof))
  102. /* ===========================================================================
  103. * Processes a new input file and return its compressed length. This
  104. @@ -581,7 +630,7 @@
  105. local off_t deflate_fast()
  106. {
  107. IPos hash_head; /* head of the hash chain */
  108. - int flush; /* set if current block must be flushed */
  109. + int flush; /* set if current block must be flushed, 2=>and padded */
  110. unsigned match_length = 0; /* length of best match */
  111. prev_length = MIN_MATCH-1;
  112. @@ -610,6 +659,7 @@
  113. lookahead -= match_length;
  114. + RSYNC_ROLL(strstart, match_length);
  115. /* Insert new strings in the hash table only if the match length
  116. * is not too large. This saves time but degrades compression.
  117. */
  118. @@ -638,9 +688,14 @@
  119. /* No match, output a literal byte */
  120. Tracevv((stderr,"%c",window[strstart]));
  121. flush = ct_tally (0, window[strstart]);
  122. + RSYNC_ROLL(strstart, 1);
  123. lookahead--;
  124. strstart++;
  125. }
  126. + if (rsync && strstart > rsync_chunk_end) {
  127. + rsync_chunk_end = 0xFFFFFFFFUL;
  128. + flush = 2;
  129. + }
  130. if (flush) FLUSH_BLOCK(0), block_start = strstart;
  131. /* Make sure that we always have enough lookahead, except
  132. @@ -713,6 +768,7 @@
  133. */
  134. lookahead -= prev_length-1;
  135. prev_length -= 2;
  136. + RSYNC_ROLL(strstart, prev_length+1);
  137. do {
  138. strstart++;
  139. INSERT_STRING(strstart, hash_head);
  140. @@ -725,24 +781,39 @@
  141. match_available = 0;
  142. match_length = MIN_MATCH-1;
  143. strstart++;
  144. - if (flush) FLUSH_BLOCK(0), block_start = strstart;
  145. + if (rsync && strstart > rsync_chunk_end) {
  146. + rsync_chunk_end = 0xFFFFFFFFUL;
  147. + flush = 2;
  148. + }
  149. + if (flush) FLUSH_BLOCK(0), block_start = strstart;
  150. } else if (match_available) {
  151. /* If there was no match at the previous position, output a
  152. * single literal. If there was a match but the current match
  153. * is longer, truncate the previous match to a single literal.
  154. */
  155. Tracevv((stderr,"%c",window[strstart-1]));
  156. - if (ct_tally (0, window[strstart-1])) {
  157. - FLUSH_BLOCK(0), block_start = strstart;
  158. - }
  159. + flush = ct_tally (0, window[strstart-1]);
  160. + if (rsync && strstart > rsync_chunk_end) {
  161. + rsync_chunk_end = 0xFFFFFFFFUL;
  162. + flush = 2;
  163. + }
  164. + if (flush) FLUSH_BLOCK(0), block_start = strstart;
  165. + RSYNC_ROLL(strstart, 1);
  166. strstart++;
  167. lookahead--;
  168. } else {
  169. /* There is no previous match to compare with, wait for
  170. * the next step to decide.
  171. */
  172. + if (rsync && strstart > rsync_chunk_end) {
  173. + /* Reset huffman tree */
  174. + rsync_chunk_end = 0xFFFFFFFFUL;
  175. + flush = 2;
  176. + FLUSH_BLOCK(0), block_start = strstart;
  177. + }
  178. match_available = 1;
  179. + RSYNC_ROLL(strstart, 1);
  180. strstart++;
  181. lookahead--;
  182. }
  183. --- gzip-1.3.2/gzip.c.rsync Mon Oct 1 07:28:16 2001
  184. +++ gzip-1.3.2/gzip.c Sun Mar 10 12:35:00 2002
  185. @@ -249,6 +249,7 @@
  186. unsigned insize; /* valid bytes in inbuf */
  187. unsigned inptr; /* index of next byte to be processed in inbuf */
  188. unsigned outcnt; /* bytes in output buffer */
  189. +int rsync = 0; /* make ryncable chunks */
  190. struct option longopts[] =
  191. {
  192. @@ -278,6 +279,7 @@
  193. {"best", 0, 0, '9'}, /* compress better */
  194. {"lzw", 0, 0, 'Z'}, /* make output compatible with old compress */
  195. {"bits", 1, 0, 'b'}, /* max number of bits per code (implies -Z) */
  196. + {"rsyncable", 0, 0, 'R'}, /* make rsync-friendly archive */
  197. { 0, 0, 0, 0 }
  198. };
  199. @@ -368,6 +370,7 @@
  200. " -Z --lzw produce output compatible with old compress",
  201. " -b --bits maxbits max number of bits per code (implies -Z)",
  202. #endif
  203. + " --rsyncable Make rsync-friendly archive",
  204. " file... files to (de)compress. If none given, use standard input.",
  205. "Report bugs to <bug-gzip@gnu.org>.",
  206. 0};
  207. @@ -546,6 +549,9 @@
  208. #else
  209. recursive = 1; break;
  210. #endif
  211. + case 'R':
  212. + rsync = 1; break;
  213. +
  214. case 'S':
  215. #ifdef NO_MULTIPLE_DOTS
  216. if (*optarg == '.') optarg++;
  217. --- gzip-1.3.2/gzip.h.rsync Mon Oct 1 07:24:52 2001
  218. +++ gzip-1.3.2/gzip.h Sun Mar 10 12:36:12 2002
  219. @@ -133,6 +133,7 @@
  220. extern unsigned insize; /* valid bytes in inbuf */
  221. extern unsigned inptr; /* index of next byte to be processed in inbuf */
  222. extern unsigned outcnt; /* bytes in output buffer */
  223. +extern int rsync; /* deflate into rsyncable chunks */
  224. extern off_t bytes_in; /* number of input bytes */
  225. extern off_t bytes_out; /* number of output bytes */
  226. @@ -281,7 +282,7 @@
  227. /* in trees.c */
  228. void ct_init OF((ush *attr, int *method));
  229. int ct_tally OF((int dist, int lc));
  230. -off_t flush_block OF((char *buf, ulg stored_len, int eof));
  231. +off_t flush_block OF((char *buf, ulg stored_len, int pad, int eof));
  232. /* in bits.c */
  233. void bi_init OF((file_t zipfile));
  234. --- gzip-1.3.2/gzip.texi.rsync Sun Nov 4 08:39:35 2001
  235. +++ gzip-1.3.2/gzip.texi Sun Mar 10 12:35:00 2002
  236. @@ -340,6 +340,14 @@
  237. into the directory and compress all the files it finds there (or
  238. decompress them in the case of @code{gunzip}).
  239. +@item --rsyncable
  240. +While compressing, synchronize the output occasionally based on the
  241. +input. This reduces compression by about 1 percent most cases, but
  242. +means that the @code{rsync} program can take advantage of similarities
  243. +in the uncompressed input when syncronizing two files compressed with
  244. +this flag. @code{gunzip} cannot tell the difference between a
  245. +compressed file created with this option, and one created without it.
  246. +
  247. @item --suffix @var{suf}
  248. @itemx -S @var{suf}
  249. Use suffix @samp{@var{suf}} instead of @samp{.gz}. Any suffix can be
  250. --- gzip-1.3.2/trees.c.rsync Wed Oct 6 07:00:00 1999
  251. +++ gzip-1.3.2/trees.c Sun Mar 10 12:37:05 2002
  252. @@ -847,9 +847,10 @@
  253. * trees or store, and output the encoded block to the zip file. This function
  254. * returns the total compressed length for the file so far.
  255. */
  256. -off_t flush_block(buf, stored_len, eof)
  257. +off_t flush_block(buf, stored_len, pad, eof)
  258. char *buf; /* input block, or NULL if too old */
  259. ulg stored_len; /* length of input block */
  260. + int pad; /* pad output to byte boundary */
  261. int eof; /* true if this is the last block for a file */
  262. {
  263. ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */
  264. @@ -941,6 +942,10 @@
  265. Assert (input_len == bytes_in, "bad input size");
  266. bi_windup();
  267. compressed_len += 7; /* align on byte boundary */
  268. + } else if (pad && (compressed_len % 8) != 0) {
  269. + send_bits((STORED_BLOCK<<1)+eof, 3); /* send block type */
  270. + compressed_len = (compressed_len + 3 + 7) & ~7L;
  271. + copy_block(buf, 0, 1); /* with header */
  272. }
  273. return compressed_len >> 3;