From: Bdale Garbee Date: Tue, 11 Jun 2013 14:48:11 +0000 (-0600) Subject: Merge tag 'upstream/1.6' X-Git-Tag: debian/1.6-1~14 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=d738e90e8360e101b94fca8c79147f59565f62d8;hp=-c;p=debian%2Fgzip Merge tag 'upstream/1.6' Upstream version 1.6 Conflicts: gzip.1 gzip.c zdiff.1 --- d738e90e8360e101b94fca8c79147f59565f62d8 diff --combined deflate.c index 4a0f3d3,f0f2394..8e539d2 --- a/deflate.c +++ b/deflate.c @@@ -1,6 -1,6 +1,6 @@@ /* deflate.c -- compress data using the deflation algorithm - Copyright (C) 1999, 2006, 2009-2012 Free Software Foundation, Inc. + Copyright (C) 1999, 2006, 2009-2013 Free Software Foundation, Inc. Copyright (C) 1992-1993 Jean-loup Gailly This program is free software; you can redistribute it and/or modify @@@ -131,14 -131,6 +131,14 @@@ #endif /* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ +#ifndef RSYNC_WIN +# define RSYNC_WIN 8192 +#endif +/* Size of rsync window, must be < MAX_DIST */ + +#define RSYNC_SUM_MATCH(sum) (((sum) & (RSYNC_WIN - 1)) == 0) +/* Whether window sum matches magic value */ + /* =========================================================================== * Local data used by the "longest match" routines. */ @@@ -220,8 -212,6 +220,8 @@@ local int compr_level unsigned good_match; /* Use a faster search when the previous match is longer than this */ +local ulg rsync_sum; /* rolling sum of rsync window */ +local ulg rsync_chunk_end; /* next rsync sequence point */ /* Values for max_lazy_match, good_match and max_chain_length, depending on * the desired pack level (0..9). The values given below have been tuned to @@@ -324,10 -314,6 +324,10 @@@ void lm_init (pack_level, flags #endif /* prev will be initialized on the fly */ + /* rsync params */ + rsync_chunk_end = 0xFFFFFFFFUL; + rsync_sum = 0; + /* Set the default configuration parameters: */ max_lazy_match = configuration_table[pack_level].max_lazy; @@@ -345,7 -331,6 +345,7 @@@ strstart = 0; block_start = 0L; + rsync_chunk_end = 0xFFFFFFFFUL; #ifdef ASMV match_init(); /* initialize the asm code */ #endif @@@ -565,8 -550,6 +565,8 @@@ local void fill_window( memcpy((char*)window, (char*)window+WSIZE, (unsigned)WSIZE); match_start -= WSIZE; strstart -= WSIZE; /* we now have strstart >= MAX_DIST: */ + if (rsync_chunk_end != 0xFFFFFFFFUL) + rsync_chunk_end -= WSIZE; block_start -= (long) WSIZE; @@@ -596,39 -579,6 +596,39 @@@ } } +local void rsync_roll(start, num) + unsigned start; + unsigned num; +{ + unsigned i; + + if (start < RSYNC_WIN) { + /* before window fills. */ + for (i = start; i < RSYNC_WIN; i++) { + if (i == start + num) return; + rsync_sum += (ulg)window[i]; + } + num -= (RSYNC_WIN - start); + start = RSYNC_WIN; + } + + /* buffer after window full */ + for (i = start; i < start+num; i++) { + /* New character in */ + rsync_sum += (ulg)window[i]; + /* Old character out */ + rsync_sum -= (ulg)window[i - RSYNC_WIN]; + if (rsync_chunk_end == 0xFFFFFFFFUL && RSYNC_SUM_MATCH(rsync_sum)) + rsync_chunk_end = i; + } +} + +/* =========================================================================== + * Set rsync_chunk_end if window sum matches magic value. + */ +#define RSYNC_ROLL(s, n) \ + do { if (rsync) rsync_roll((s), (n)); } while(0) + /* =========================================================================== * Flush the current block, with given end-of-file flag. * IN assertion: strstart is set to the end of the current match. @@@ -676,8 -626,7 +676,8 @@@ local off_t deflate_fast( lookahead -= match_length; - /* Insert new strings in the hash table only if the match length + RSYNC_ROLL(strstart, match_length); + /* Insert new strings in the hash table only if the match length * is not too large. This saves time but degrades compression. */ if (match_length <= max_insert_length) { @@@ -705,18 -654,9 +705,18 @@@ /* No match, output a literal byte */ Tracevv((stderr,"%c",window[strstart])); flush = ct_tally (0, window[strstart]); + RSYNC_ROLL(strstart, 1); lookahead--; strstart++; } + if (rsync && strstart > rsync_chunk_end) { + ush attr = 0; /* ascii/binary flag */ + + flush = 1; + /* Reset huffman tree */ + ct_init(&attr, &method); + rsync_chunk_end = 0xFFFFFFFFUL; + } if (flush) FLUSH_BLOCK(0), block_start = strstart; /* Make sure that we always have enough lookahead, except @@@ -790,7 -730,6 +790,7 @@@ off_t deflate( */ lookahead -= prev_length-1; prev_length -= 2; + RSYNC_ROLL(strstart, prev_length+1); do { strstart++; INSERT_STRING(strstart, hash_head); @@@ -803,51 -742,24 +803,51 @@@ match_available = 0; match_length = MIN_MATCH-1; strstart++; - if (flush) FLUSH_BLOCK(0), block_start = strstart; + if (rsync && strstart > rsync_chunk_end) { + ush attr = 0; /* ascii/binary flag */ + + /* Reset huffman tree */ + ct_init(&attr, &method); + rsync_chunk_end = 0xFFFFFFFFUL; + flush = 1; + } + if (flush) FLUSH_BLOCK(0), block_start = strstart; } else if (match_available) { /* If there was no match at the previous position, output a * single literal. If there was a match but the current match * is longer, truncate the previous match to a single literal. */ Tracevv((stderr,"%c",window[strstart-1])); - if (ct_tally (0, window[strstart-1])) { - FLUSH_BLOCK(0), block_start = strstart; - } + flush = ct_tally (0, window[strstart-1]); + if (rsync && strstart > rsync_chunk_end) { + ush attr = 0; /* ascii/binary flag */ + + /* Reset huffman tree */ + ct_init(&attr, &method); + rsync_chunk_end = 0xFFFFFFFFUL; + + flush = 1; + } + if (flush) FLUSH_BLOCK(0), block_start = strstart; + RSYNC_ROLL(strstart, 1); strstart++; lookahead--; } else { /* There is no previous match to compare with, wait for * the next step to decide. */ + if (rsync && strstart > rsync_chunk_end) { + ush attr = 0; /* ascii/binary flag */ + + /* Reset huffman tree */ + ct_init(&attr, &method); + rsync_chunk_end = 0xFFFFFFFFUL; + + FLUSH_BLOCK(0), block_start = strstart; + } match_available = 1; + RSYNC_ROLL(strstart, 1); strstart++; lookahead--; } diff --combined doc/gzip.texi index ffe20b4,3de3063..7ff37ad --- a/doc/gzip.texi +++ b/doc/gzip.texi @@@ -11,7 -11,7 +11,7 @@@ This manual is for GNU Gzi (version @value{VERSION}, @value{UPDATED}), and documents commands for compressing and decompressing data. - Copyright @copyright{} 1998-1999, 2001-2002, 2006-2007, 2009-2012 Free Software + Copyright @copyright{} 1998-1999, 2001-2002, 2006-2007, 2009-2013 Free Software Foundation, Inc. Copyright @copyright{} 1992, 1993 Jean-loup Gailly @@@ -171,10 -171,10 +171,10 @@@ ownership and time stamps of files whe The @command{gzip} file format is specified in P. Deutsch, @sc{gzip} file format specification version 4.3, - @uref{ftp://ftp.isi.edu/in-notes/rfc1952.txt, Internet @abbr{RFC} 1952} (May + @uref{http://www.ietf.org/rfc/rfc1952.txt, Internet @abbr{RFC} 1952} (May 1996). The @command{zip} deflation format is specified in P. Deutsch, @sc{deflate} Compressed Data Format Specification version 1.3, - @uref{ftp://ftp.isi.edu/in-notes/rfc1951.txt, Internet @abbr{RFC} 1951} (May + @uref{http://www.ietf.org/rfc/rfc1951.txt, Internet @abbr{RFC} 1951} (May 1996). @node Sample @@@ -195,6 -195,7 +195,7 @@@ Mandatory arguments to long options ar -d, --decompress decompress -f, --force force overwrite of output file and compress links -h, --help give this help + -k, --keep keep (don't delete) input files -l, --list list compressed file contents -L, --license display software license -n, --no-name do not save or restore the original name and time stamp @@@ -207,7 -208,6 +208,7 @@@ -V, --version display version number -1, --fast compress faster -9, --best compress better + --rsyncable Make rsync-friendly archive With no FILE, or when FILE is -, read standard input. @@@ -277,6 -277,10 +278,10 @@@ whether an existing file should be over @itemx -h Print an informative help message describing the options then quit. + @item --keep + @itemx -k + Keep (don't delete) input files during compression or decompression. + @item --list @itemx -l For each compressed file, list the following fields: @@@ -354,30 -358,6 +359,30 @@@ specified on the command line are direc into the directory and compress all the files it finds there (or decompress them in the case of @command{gunzip}). +@item --rsyncable +While compressing, synchronize the output occasionally based on the +input. This can reduce the compression slightly in some cases, but +means that the @code{rsync} program can take advantage of similarities +in the uncompressed input when syncronizing two files compressed with +this flag. @code{gunzip} cannot tell the difference between a +compressed file created with this option, and one created without it. + +@item --rsyncable +While compressing, synchronize the output occasionally based on +the input. This increases size by less than 1 percent most +cases, but means that the @command{rsync} program can much more efficiently +synchronize files compressed with this flag. @command{gunzip} +cannot tell the difference between a compressed file created +with this option, and one created without it. + +@item --rsyncable +While compressing, synchronize the output occasionally based on the +input. This can reduce the compression slightly in some cases, but +means that the @code{rsync} program can take advantage of similarities +in the uncompressed input when syncronizing two files compressed with +this flag. @code{gunzip} cannot tell the difference between a +compressed file created with this option, and one created without it. + @item --suffix @var{suf} @itemx -S @var{suf} Use suffix @var{suf} instead of @samp{.gz}. Any suffix can be diff --combined gzip.c index 5fc6ded,93cc738..cceb420 --- a/gzip.c +++ b/gzip.c @@@ -1,6 -1,6 +1,6 @@@ /* gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface - Copyright (C) 1999, 2001-2002, 2006-2007, 2009-2012 Free Software + Copyright (C) 1999, 2001-2002, 2006-2007, 2009-2013 Free Software Foundation, Inc. Copyright (C) 1992-1993 Jean-loup Gailly @@@ -74,6 -74,7 +74,7 @@@ static char const *const license_msg[] #include "ignore-value.h" #include "stat-time.h" #include "version.h" + #include "yesno.h" /* configuration */ @@@ -166,6 -167,7 +167,7 @@@ static int ascii = 0; /* conver int to_stdout = 0; /* output to stdout (-c) */ static int decompress = 0; /* decompress (-d) */ static int force = 0; /* don't ask questions, compress links (-f) */ + static int keep = 0; /* keep (don't delete) input files */ static int no_name = -1; /* don't save or restore the original file name */ static int no_time = -1; /* don't save or restore the original file time */ static int recursive = 0; /* recurse through directories (-r) */ @@@ -213,7 -215,6 +215,7 @@@ int ofd; /* output fi unsigned insize; /* valid bytes in inbuf */ unsigned inptr; /* index of next byte to be processed in inbuf */ unsigned outcnt; /* bytes in output buffer */ +int rsync = 0; /* make ryncable chunks */ static int handled_sig[] = { @@@ -223,7 -224,7 +225,7 @@@ #ifdef SIGHUP , SIGHUP #endif - #ifdef SIGPIPE + #if SIGPIPE , SIGPIPE #endif #ifdef SIGTERM @@@ -256,6 -257,7 +258,7 @@@ static const struct option longopts[] {"force", 0, 0, 'f'}, /* force overwrite of output file */ {"help", 0, 0, 'h'}, /* give help */ /* {"pkzip", 0, 0, 'k'}, force output in pkzip format */ + {"keep", 0, 0, 'k'}, /* keep (don't delete) input files */ {"list", 0, 0, 'l'}, /* list .gz file contents */ {"license", 0, 0, 'L'}, /* display software license */ {"no-name", 0, 0, 'n'}, /* don't save or restore original name & time */ @@@ -273,7 -275,7 +276,7 @@@ {"best", 0, 0, '9'}, /* compress better */ {"lzw", 0, 0, 'Z'}, /* make output compatible with old compress */ {"bits", 1, 0, 'b'}, /* max number of bits per code (implies -Z) */ - + {"rsyncable", 0, 0, 'R'}, /* make rsync-friendly archive */ { 0, 0, 0, 0 } }; @@@ -334,6 -336,7 +337,7 @@@ local void help( " -f, --force force overwrite of output file and compress links", " -h, --help give this help", /* -k, --pkzip force output in pkzip format */ + " -k, --keep keep (don't delete) input files", " -l, --list list compressed file contents", " -L, --license display software license", #ifdef UNDOCUMENTED @@@ -356,7 -359,6 +360,7 @@@ " -Z, --lzw produce output compatible with old compress", " -b, --bits=BITS max number of bits per code (implies -Z)", #endif + " --rsyncable Make rsync-friendly archive", "", "With no FILE, or when FILE is -, read standard input.", "", @@@ -438,7 -440,7 +442,7 @@@ int main (int argc, char **argv z_suffix = Z_SUFFIX; z_len = strlen(z_suffix); - while ((optc = getopt_long (argc, argv, "ab:cdfhH?lLmMnNqrS:tvVZ123456789", + while ((optc = getopt_long (argc, argv, "ab:cdfhH?klLmMnNqrS:tvVZ123456789", longopts, (int *)0)) != -1) { switch (optc) { case 'a': @@@ -461,6 -463,8 +465,8 @@@ force++; break; case 'h': case 'H': help(); do_exit(OK); break; + case 'k': + keep = 1; break; case 'l': list = decompress = to_stdout = 1; break; case 'L': @@@ -485,11 -489,8 +491,11 @@@ #else recursive = 1; #endif - break; - case 'S': + break; + case 'R': + rsync = 1; break; + + case 'S': #ifdef NO_MULTIPLE_DOTS if (*optarg == '.') optarg++; #endif @@@ -556,11 -557,7 +562,11 @@@ ALLOC(ush, tab_prefix1, 1L<<(BITS-1)); #endif +#ifdef SIGPIPE exiting_signal = quiet ? SIGPIPE : 0; +#else + exiting_signal = 0; +#endif install_signal_handlers (); /* And get to work */ @@@ -859,25 -856,29 +865,29 @@@ local void treat_file(iname if (!to_stdout) { - sigset_t oldset; - int unlink_errno; copy_stat (&istat); if (close (ofd) != 0) write_error (); - sigprocmask (SIG_BLOCK, &caught_signals, &oldset); - remove_ofname_fd = -1; - unlink_errno = xunlink (ifname) == 0 ? 0 : errno; - sigprocmask (SIG_SETMASK, &oldset, NULL); - - if (unlink_errno) + if (!keep) { - WARN ((stderr, "%s: ", program_name)); - if (!quiet) + sigset_t oldset; + int unlink_errno; + + sigprocmask (SIG_BLOCK, &caught_signals, &oldset); + remove_ofname_fd = -1; + unlink_errno = xunlink (ifname) == 0 ? 0 : errno; + sigprocmask (SIG_SETMASK, &oldset, NULL); + + if (unlink_errno) { - errno = unlink_errno; - perror (ifname); + WARN ((stderr, "%s: ", program_name)); + if (!quiet) + { + errno = unlink_errno; + perror (ifname); + } } } } diff --combined gzip.h index 711ff66,648073e..70ccaa9 --- a/gzip.h +++ b/gzip.h @@@ -1,6 -1,6 +1,6 @@@ /* gzip.h -- common declarations for all gzip modules - Copyright (C) 1997-1999, 2001, 2006-2007, 2009-2012 Free Software + Copyright (C) 1997-1999, 2001, 2006-2007, 2009-2013 Free Software Foundation, Inc. Copyright (C) 1992-1993 Jean-loup Gailly. @@@ -140,7 -140,6 +140,7 @@@ EXTERN(uch, window); /* Slidin extern unsigned insize; /* valid bytes in inbuf */ extern unsigned inptr; /* index of next byte to be processed in inbuf */ extern unsigned outcnt; /* bytes in output buffer */ +extern int rsync; /* deflate into rsyncable chunks */ extern off_t bytes_in; /* number of input bytes */ extern off_t bytes_out; /* number of output bytes */ @@@ -322,6 -321,3 +322,3 @@@ extern void fprint_off (FILE *, off_ /* in inflate.c */ extern int inflate (void); - - /* in yesno.c */ - extern int yesno (void); diff --combined zdiff.1 index 3b0ace5,0c826c3..d1b1235 --- a/zdiff.1 +++ b/zdiff.1 @@@ -10,7 -10,6 +10,7 @@@ zcmp, zdiff \- compare compressed file [ diff_options ] file1 [ file2 ] .SH DESCRIPTION +.P .I Zcmp and .I zdiff @@@ -24,14 -23,15 +24,15 @@@ All options specified are passed direct .I cmp or .IR diff "." - If only one file is specified, then it is compared to a file with the same name - without the - .I ".gz" - extension. If two files are specified, then they are uncompressed if necessary - and fed to + If only + .I file1 + is specified, it is compared to the uncompressed contents of + .IR file1 ".gz." + If two files are specified, their contents (uncompressed if necessary) are fed to .I cmp or .IR diff "." + The input files are not modified. The exit status from .I cmp or @@@ -44,4 -44,5 +45,5 @@@ Messages from th .I cmp or .I diff - programs refer to temporary filenames instead of those specified. + programs may refer to file names such as "\-" instead of to the file + names specified.