Commit d555f18 for gzip
commit d555f189a65fd2f0c527b57df86afd861a4149f4
Author: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu Nov 12 17:59:40 2026 -0800
gzip: tell other modules about buffer size
* gzip.h (WSIZE): Move up.
(inbuf, outbuf, d_buf, window, tab_prefix):
Declare with size, to help the compiler in some cases.
(BITS): Move here ...
* lzw.h: ... from here.
diff --git a/gzip.h b/gzip.h
index 724b46c..97ba182 100644
--- a/gzip.h
+++ b/gzip.h
@@ -83,6 +83,14 @@ extern int method; /* compression method */
# define DIST_BUFSIZE 0x8000 /* buffer for distances, see trees.c */
#endif
+/* Maximum number of bits per LZW code. Must be at least 16 to decompress
+ classic .Z files; unlzw.c would break if it exceeded 16. */
+#define BITS 16
+
+/* Window size. Must be a power of 2. RFC 1951 specifies 2**15,
+ and deflate.c would break if it were any other value. */
+#define WSIZE (1 << 15)
+
/* With IBM_Z_DFLTCC, DEFLATE COMPRESSION works faster with
page-aligned input and output buffers, and requires page-aligned
windows; the alignment requirement is 4096. On other platforms
@@ -97,22 +105,22 @@ extern int method; /* compression method */
/* Global buffers. */
/* Input buffer. */
-extern uch BUFFER_ALIGNED inbuf[];
+extern uch BUFFER_ALIGNED inbuf[INBUFSIZ + INBUF_EXTRA];
/* Output buffer. */
-extern uch BUFFER_ALIGNED outbuf[];
+extern uch BUFFER_ALIGNED outbuf[OUTBUFSIZ + OUTBUF_EXTRA];
/* Buffer for distances; see trees.c. */
-extern ush d_buf[];
+extern ush d_buf[DIST_BUFSIZE];
/* Sliding window and suffix table (unlzw). */
-extern uch BUFFER_ALIGNED window[];
+extern uch BUFFER_ALIGNED window[2 * WSIZE];
#define tab_suffix window
#define tab_prefix prev /* hash link (see deflate.c) */
#define head (prev + WSIZE) /* hash head (see deflate.c) */
/* prefix code (see unlzw.c) */
-extern ush tab_prefix[];
+extern ush tab_prefix[1 << BITS];
extern unsigned insize; /* valid bytes in inbuf */
extern unsigned inptr; /* index of next byte to be processed in inbuf */
@@ -156,10 +164,6 @@ typedef int file_t; /* Do not use stdio */
#define BINARY 0
#define ASCII 1
-#ifndef WSIZE
-# define WSIZE 0x8000 /* window size--must be a power of two, and */
-#endif /* at least 32K for zip's deflate method */
-
#define MIN_MATCH 3
#define MAX_MATCH 258
/* The minimum and maximum match lengths */
diff --git a/lzw.h b/lzw.h
index 71113fb..fc26538 100644
--- a/lzw.h
+++ b/lzw.h
@@ -16,9 +16,6 @@
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. */
-#ifndef BITS
-# define BITS 16
-#endif
#define INIT_BITS 9 /* Initial number of bits per code */
#define LZW_MAGIC "\037\235" /* Magic header for lzw files, 1F 9D. */