File rsync-both-compressions.patch of Package rsync

diff --git a/configure.ac b/configure.ac
index e01e124b..4ee4083e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -794,7 +794,8 @@ else
     AC_MSG_RESULT(no)
 fi
 
-# We default to using our zlib unless --with-included-zlib=no is given.
+# Always compile with system zlib but if --with-included-zlib=yes is given
+# or not specified at all compile in the support too.
 if test x"$with_included_zlib" != x"no"; then
     with_included_zlib=yes
 elif test x"$ac_cv_header_zlib_h" != x"yes"; then
@@ -810,7 +811,6 @@ if test x"$with_included_zlib" = x"yes"; then
     BUILD_ZLIB='$(zlib_OBJS)'
     CFLAGS="-I$srcdir/zlib $CFLAGS"
 else
-    AC_DEFINE(EXTERNAL_ZLIB, 1, [Define to 1 if using external zlib])
     AC_MSG_RESULT(no)
 fi
 
diff --git a/options.c b/options.c
index 64ec8b84..522875c5 100644
--- a/options.c
+++ b/options.c
@@ -1866,16 +1866,6 @@ int parse_arguments(int *argc_p, const char ***argv_p)
 			create_refuse_error(refused_compress);
 			return 0;
 		}
-#ifdef EXTERNAL_ZLIB
-		if (do_compression == 1) {
-			snprintf(err_buf, sizeof err_buf,
-				"This rsync lacks old-style --compress due to its external zlib.  Try -zz.\n");
-			if (am_server)
-				return 0;
-			fprintf(stderr, "%s" "Continuing without compression.\n\n", err_buf);
-			do_compression = 0;
-		}
-#endif
 	}
 
 #ifdef HAVE_SETVBUF
diff --git a/token.c b/token.c
index ad9b9bcd..34bc331f 100644
--- a/token.c
+++ b/token.c
@@ -23,6 +23,10 @@
 #include "itypes.h"
 #include <zlib.h>
 
+#ifndef Z_INSERT_ONLY
+#define Z_INSERT_ONLY Z_SYNC_FLUSH
+#endif
+
 extern int do_compression;
 extern int protocol_version;
 extern int module_id;
@@ -405,7 +409,6 @@ send_deflated_token(int f, int32 token, struct map_struct *buf, OFF_T offset,
 	} else if (token != -2 && do_compression == 1) {
 		/* Add the data in the current block to the compressor's
 		 * history and hash table. */
-#ifndef EXTERNAL_ZLIB
 		do {
 			/* Break up long sections in the same way that
 			 * see_deflate_token() does. */
@@ -424,11 +427,6 @@ send_deflated_token(int f, int32 token, struct map_struct *buf, OFF_T offset,
 				exit_cleanup(RERR_STREAMIO);
 			}
 		} while (toklen > 0);
-#else
-		toklen++;
-		rprintf(FERROR, "Impossible error in external-zlib code (1).\n");
-		exit_cleanup(RERR_STREAMIO);
-#endif
 	}
 }
 
@@ -579,7 +577,6 @@ static int32 recv_deflated_token(int f, char **data)
  */
 static void see_deflate_token(char *buf, int32 len)
 {
-#ifndef EXTERNAL_ZLIB
 	int r;
 	int32 blklen;
 	unsigned char hdr[5];
@@ -617,11 +614,6 @@ static void see_deflate_token(char *buf, int32 len)
 			exit_cleanup(RERR_STREAMIO);
 		}
 	} while (len || rx_strm.avail_out == 0);
-#else
-	buf++; len++;
-	rprintf(FERROR, "Impossible error in external-zlib code (2).\n");
-	exit_cleanup(RERR_STREAMIO);
-#endif
 }
 
 /**
openSUSE Build Service is sponsored by