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.

296 lines
10 KiB

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