Commit d2de3af for gzip
commit d2de3afe1825a09da79a1d096cce4cad567d6246
Author: Paul Eggert <eggert@cs.ucla.edu>
Date: Thu Nov 12 12:56:08 2026 -0800
gzip: clean out old 16-bit code
gzip long ago stopped working on 16-bit MS-DOS, so remove code
needed only for it, code that gets in the way of maintenance.
* gzip.h (ALLOC, FREE): Remove now that they are always no-ops.
All uses removed.
* tailor.h (near, MAXSEG_64K, DYN_ALLOC, fcalloc, fcfree):
Remove. All uses removed.
(HAVE_SYS_UTIME_H): Remove; unused.
(off_t): Remove macro; defined only on 16-bit platforms.
* unlzw.c (tab_prefixof, tab_suffixof): Remove.
All uses replaced by tab_prefix and tab_suffix.
diff --git a/NEWS b/NEWS
index fb4307b..3b6b33a 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,12 @@ GNU gzip NEWS -*- outline -*-
* Noteworthy changes in release ?.? (????-??-??) [?]
+** Platforms no longer supported
+
+ Code has been removed that existed only for 16-bit MS-DOS platforms
+ like Turbo C.
+ [16-bit MS-DOS has not worked since gzip-1.3]
+
* Noteworthy changes in release 1.15 (2026-09-20) [stable]
diff --git a/deflate.c b/deflate.c
index a2f92e8..5db492d 100644
--- a/deflate.c
+++ b/deflate.c
@@ -107,10 +107,10 @@
* window with tab_suffix. Check that we can do this:
*/
#if (WSIZE<<1) > (1<<BITS)
- error: cannot overlay window with tab_suffix and prev with tab_prefix0
+# error "cannot overlay window with tab_suffix and prev with tab_prefix"
#endif
#if HASH_BITS > BITS-1
- error: cannot overlay head with tab_prefix1
+# error "cannot overlay head with tab_prefix"
#endif
#define HASH_SIZE (unsigned)(1<<HASH_BITS)
@@ -183,13 +183,13 @@ static unsigned ins_h; /* hash index of string to be inserted */
* H_SHIFT * MIN_MATCH >= HASH_BITS
*/
-unsigned int near prev_length;
+unsigned int prev_length;
/* Length of the best match at previous step. Matches not greater than this
* are discarded. This is used in the lazy match evaluation.
*/
-unsigned near strstart; /* start of string to insert */
-unsigned near match_start; /* start of matching string */
+unsigned strstart; /* start of string to insert */
+unsigned match_start; /* start of matching string */
static int eofile; /* Flag set at end of input file. */
static unsigned lookahead; /* Number of valid bytes ahead in window. */
@@ -305,11 +305,7 @@ lm_init (int pack_level)
if (pack_level < 1 || pack_level > 9) gzip_error ("bad pack level");
/* Initialize the hash table. */
-#if defined MAXSEG_64K && HASH_BITS == 15
- for (j = 0; j < HASH_SIZE; j++) head[j] = NIL;
-#else
memzero((char*)head, HASH_SIZE*sizeof(*head));
-#endif
/* prev will be initialized on the fly */
/* rsync params */
@@ -383,7 +379,7 @@ longest_match(IPos cur_match)
* It is easy to get rid of this optimization if necessary.
*/
#if HASH_BITS < 8 || MAX_MATCH != 258
- error: Code too clever
+# error "Code too clever"
#endif
#ifdef UNALIGNED_OK
diff --git a/deflate.h b/deflate.h
index 46b97ae..9004560 100644
--- a/deflate.h
+++ b/deflate.h
@@ -18,8 +18,8 @@
#include "tailor.h"
extern long block_start;
-extern unsigned int near prev_length;
-extern unsigned near strstart;
-extern unsigned near match_start;
+extern unsigned int prev_length;
+extern unsigned strstart;
+extern unsigned match_start;
extern unsigned max_chain_length;
extern unsigned good_match;
diff --git a/dfltcc.c b/dfltcc.c
index 6730cbf..ebb43ea 100644
--- a/dfltcc.c
+++ b/dfltcc.c
@@ -27,10 +27,6 @@
#include "tailor.h"
#include "gzip.h"
-#ifdef DYN_ALLOC
-# error "DYN_ALLOC is not supported by DFLTCC"
-#endif
-
/* ===========================================================================
* C wrappers for the DEFLATE CONVERSION CALL instruction.
*/
diff --git a/gzip.c b/gzip.c
index 6c0af7f..7360f40 100644
--- a/gzip.c
+++ b/gzip.c
@@ -184,12 +184,7 @@ DECLARE(uch BUFFER_ALIGNED, inbuf, INBUFSIZ +INBUF_EXTRA);
DECLARE(uch BUFFER_ALIGNED, outbuf, OUTBUFSIZ+OUTBUF_EXTRA);
DECLARE(ush, d_buf, DIST_BUFSIZE);
DECLARE(uch BUFFER_ALIGNED, window, 2L*WSIZE);
-#ifndef MAXSEG_64K
- DECLARE(ush, tab_prefix, 1L<<BITS);
-#else
- DECLARE(ush, tab_prefix0, 1L<<(BITS-1));
- DECLARE(ush, tab_prefix1, 1L<<(BITS-1));
-#endif
+DECLARE(ush, tab_prefix, 1L << BITS);
/* local variables */
@@ -653,18 +648,6 @@ int main (int argc, char **argv)
do_exit(ERROR);
}
- /* Allocate all global buffers (for DYN_ALLOC option) */
- ALLOC(uch, inbuf, INBUFSIZ +INBUF_EXTRA);
- ALLOC(uch, outbuf, OUTBUFSIZ+OUTBUF_EXTRA);
- ALLOC(ush, d_buf, DIST_BUFSIZE);
- ALLOC(uch, window, 2L*WSIZE);
-#ifndef MAXSEG_64K
- ALLOC(ush, tab_prefix, 1L<<BITS);
-#else
- ALLOC(ush, tab_prefix0, 1L<<(BITS-1));
- ALLOC(ush, tab_prefix1, 1L<<(BITS-1));
-#endif
-
int stdopen_err = stdopen ();
if (stdopen_err)
{
@@ -2120,16 +2103,6 @@ do_exit (int exitcode)
in_exit = 1;
free(env);
env = NULL;
- FREE(inbuf);
- FREE(outbuf);
- FREE(d_buf);
- FREE(window);
-#ifndef MAXSEG_64K
- FREE(tab_prefix);
-#else
- FREE(tab_prefix0);
- FREE(tab_prefix1);
-#endif
exit(exitcode);
}
diff --git a/gzip.h b/gzip.h
index 7941e89..fd497e6 100644
--- a/gzip.h
+++ b/gzip.h
@@ -95,36 +95,17 @@ extern int method; /* compression method */
# endif
#endif
-#ifdef DYN_ALLOC
-# define EXTERN(type, array) extern type * near array
-# define DECLARE(type, array, size) type * near array
-# define ALLOC(type, array, size) { \
- array = (type*)fcalloc((size_t)(((size)+1L)/2), 2*sizeof(type)); \
- if (!array) xalloc_die (); \
- }
-# define FREE(array) {if (array != NULL) fcfree(array), array=NULL;}
-#else
-# define EXTERN(type, array) extern type array[]
-# define DECLARE(type, array, size) type array[size]
-# define ALLOC(type, array, size)
-# define FREE(array)
-#endif
+#define EXTERN(type, array) extern type array[]
+#define DECLARE(type, array, size) type array[size]
EXTERN(uch, inbuf); /* input buffer */
EXTERN(uch, outbuf); /* output buffer */
EXTERN(ush, d_buf); /* buffer for distances, see trees.c */
EXTERN(uch, window); /* Sliding window and suffix table (unlzw) */
#define tab_suffix window
-#ifndef MAXSEG_64K
-# define tab_prefix prev /* hash link (see deflate.c) */
-# define head (prev+WSIZE) /* hash head (see deflate.c) */
- EXTERN(ush, tab_prefix); /* prefix code (see unlzw.c) */
-#else
-# define tab_prefix0 prev
-# define head tab_prefix1
- EXTERN(ush, tab_prefix0); /* prefix for even codes */
- EXTERN(ush, tab_prefix1); /* prefix for odd codes */
-#endif
+#define tab_prefix prev /* hash link (see deflate.c) */
+#define head (prev + WSIZE) /* hash head (see deflate.c) */
+EXTERN (ush, tab_prefix); /* prefix code (see unlzw.c) */
extern unsigned insize; /* valid bytes in inbuf */
extern unsigned inptr; /* index of next byte to be processed in inbuf */
diff --git a/tailor.h b/tailor.h
index 8412dde..9a1c139 100644
--- a/tailor.h
+++ b/tailor.h
@@ -34,20 +34,6 @@
#endif
#ifdef MSDOS
-# ifdef __GNUC__
- /* DJGPP version 1.09+ on MS-DOS.
- * The DJGPP 1.09 stat() function must be upgraded before gzip will
- * fully work.
- */
-# define near
-# else
-# define MAXSEG_64K
-# ifdef __TURBOC__
-# define off_t long
-# else /* MSC */
-# define HAVE_SYS_UTIME_H
-# endif
-# endif
# define MAX_PATH_LEN 128
# define NO_MULTIPLE_DOTS
# define MAX_EXT_CHARS 3
@@ -61,8 +47,6 @@
# if !defined(NO_ASM) && !defined(ASMV)
# define ASMV
# endif
-#else
-# define near
#endif
#ifdef OS2
@@ -77,14 +61,7 @@
# include <io.h>
# define OS_CODE 0x06
# define SET_BINARY_MODE(fd) setmode(fd, O_BINARY)
-# ifdef _MSC_VER
-# define HAVE_SYS_UTIME_H
-# define MAXSEG_64K
-# undef near
-# define near _near
-# endif
# ifdef __EMX__
-# define HAVE_SYS_UTIME_H
# define EXPAND(argc,argv) \
{_response(&argc, &argv); _wildcard(&argc, &argv);}
# endif
@@ -97,7 +74,6 @@
#endif
#if defined WIN32 || defined _WIN32
-# define HAVE_SYS_UTIME_H
# define MAX_PATH_LEN 260
# define SET_BINARY_MODE(fd) setmode(fd, O_BINARY)
# define UNLINK_READONLY_BUG
@@ -112,27 +88,6 @@
# define OS_CODE 0x0b
#endif
-#ifdef MSDOS
-# ifdef __TURBOC__
-# include <alloc.h>
-# define DYN_ALLOC
- /* Turbo C 2.0 does not accept static allocations of large arrays */
- void * fcalloc (unsigned items, unsigned size);
- void fcfree (void *ptr);
-# else /* MSC */
-# include <malloc.h>
-# define fcalloc(nitems,itemsize) halloc((long)(nitems),(itemsize))
-# define fcfree(ptr) hfree(ptr)
-# endif
-#else
-# ifdef MAXSEG_64K
-# define fcalloc(items,size) calloc((items),(size))
-# else
-# define fcalloc(items,size) malloc((size_t)(items)*(size_t)(size))
-# endif
-# define fcfree(ptr) free(ptr)
-#endif
-
#if defined(ATARI) || defined(atarist)
# define OS_CODE 0x05
# ifdef TOSFS
diff --git a/trees.c b/trees.c
index 684d672..10c79a8 100644
--- a/trees.c
+++ b/trees.c
@@ -101,13 +101,13 @@
/* number of codes used to transfer the bit lengths */
-static int near extra_lbits[LENGTH_CODES] /* extra bits for each length code */
+static int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
= {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
-static int near extra_dbits[D_CODES] /* extra bits for each distance code */
+static int extra_dbits[D_CODES] /* extra bits for each distance code */
= {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
-static int near extra_blbits[BL_CODES]/* extra bits for each bit length code */
+static int extra_blbits[BL_CODES] /* extra bits for each bit length code */
= {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
#define STORED_BLOCK 0
@@ -186,61 +186,61 @@ typedef struct ct_data {
#define HEAP_SIZE (2*L_CODES+1)
/* maximum heap size */
-static ct_data near dyn_ltree[HEAP_SIZE]; /* literal and length tree */
-static ct_data near dyn_dtree[2*D_CODES+1]; /* distance tree */
+static ct_data dyn_ltree[HEAP_SIZE]; /* literal and length tree */
+static ct_data dyn_dtree[2*D_CODES+1]; /* distance tree */
-static ct_data near static_ltree[L_CODES+2];
+static ct_data static_ltree[L_CODES+2];
/* The static literal tree. Since the bit lengths are imposed, there is no
* need for the L_CODES extra codes used during heap construction. However
* The codes 286 and 287 are needed to build a canonical tree (see ct_init
* below).
*/
-static ct_data near static_dtree[D_CODES];
+static ct_data static_dtree[D_CODES];
/* The static distance tree. (Actually a trivial tree since all codes use
* 5 bits.)
*/
-static ct_data near bl_tree[2*BL_CODES+1];
+static ct_data bl_tree[2*BL_CODES+1];
/* Huffman tree for the bit lengths */
typedef struct tree_desc {
- ct_data near *dyn_tree; /* the dynamic tree */
- ct_data near *static_tree; /* corresponding static tree or NULL */
- int near *extra_bits; /* extra bits for each code or NULL */
+ ct_data *dyn_tree; /* the dynamic tree */
+ ct_data *static_tree; /* corresponding static tree or NULL */
+ int *extra_bits; /* extra bits for each code or NULL */
int extra_base; /* base index for extra_bits */
int elems; /* max number of elements in the tree */
int max_length; /* max bit length for the codes */
int max_code; /* largest code with non zero frequency */
} tree_desc;
-static tree_desc near l_desc =
+static tree_desc l_desc =
{dyn_ltree, static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS, 0};
-static tree_desc near d_desc =
+static tree_desc d_desc =
{dyn_dtree, static_dtree, extra_dbits, 0, D_CODES, MAX_BITS, 0};
-static tree_desc near bl_desc =
-{bl_tree, (ct_data near *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS, 0};
+static tree_desc bl_desc =
+{bl_tree, (ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS, 0};
-static ush near bl_count[MAX_BITS+1];
+static ush bl_count[MAX_BITS+1];
/* number of codes at each bit length for an optimal tree */
-static uch near bl_order[BL_CODES]
+static uch bl_order[BL_CODES]
= {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
/* The lengths of the bit length codes are sent in order of decreasing
* probability, to avoid transmitting the lengths for unused bit length codes.
*/
-static int near heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
+static int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
static int heap_len; /* number of elements in the heap */
static int heap_max; /* element of largest frequency */
/* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used.
* The same heap array is used to build all trees.
*/
-static uch near depth[2*L_CODES+1];
+static uch depth[2*L_CODES+1];
/* Depth of each subtree used as tie breaker for trees of equal frequency */
static uch length_code[MAX_MATCH-MIN_MATCH+1];
@@ -252,10 +252,10 @@ static uch dist_code[512];
* the 15 bit distances.
*/
-static int near base_length[LENGTH_CODES];
+static int base_length[LENGTH_CODES];
/* First normalized length for each code (0 = MIN_MATCH) */
-static int near base_dist[D_CODES];
+static int base_dist[D_CODES];
/* First normalized distance for each code (0 = distance of 1) */
#define l_buf inbuf
@@ -263,7 +263,7 @@ static int near base_dist[D_CODES];
/* DECLARE(ush, d_buf, DIST_BUFSIZE); buffer for distances */
-static uch near flag_buf[(LIT_BUFSIZE/8)];
+static uch flag_buf[(LIT_BUFSIZE/8)];
/* flag_buf is a bit array distinguishing literals from lengths in
* l_buf, thus indicating the presence or absence of a distance.
*/
@@ -294,22 +294,22 @@ extern off_t bits_sent; /* bit length of the compressed data */
#endif
extern long block_start; /* window offset of current block */
-extern unsigned near strstart; /* window offset of current string */
+extern unsigned strstart; /* window offset of current string */
/* ===========================================================================
* Local (static) routines in this file.
*/
static void init_block (void);
-static void pqdownheap (ct_data near *tree, int k);
-static void gen_bitlen (tree_desc near *desc);
-static void gen_codes (ct_data near *tree, int max_code);
-static void build_tree (tree_desc near *desc);
-static void scan_tree (ct_data near *tree, int max_code);
-static void send_tree (ct_data near *tree, int max_code);
+static void pqdownheap (ct_data *tree, int k);
+static void gen_bitlen (tree_desc *desc);
+static void gen_codes (ct_data *tree, int max_code);
+static void build_tree (tree_desc *desc);
+static void scan_tree (ct_data *tree, int max_code);
+static void send_tree (ct_data *tree, int max_code);
static int build_bl_tree (void);
static void send_all_trees (int lcodes, int dcodes, int blcodes);
-static void compress_block (ct_data near *ltree, ct_data near *dtree);
+static void compress_block (ct_data *ltree, ct_data *dtree);
static void set_file_type (void);
@@ -462,7 +462,7 @@ init_block ()
* K is the node to move down.
*/
static void
-pqdownheap (ct_data near *tree, int k)
+pqdownheap (ct_data *tree, int k)
{
int v = heap[k];
int j = k << 1; /* left son of k */
@@ -494,14 +494,14 @@ pqdownheap (ct_data near *tree, int k)
* DESC is the tree descriptor.
*/
static void
-gen_bitlen (tree_desc near *desc)
+gen_bitlen (tree_desc *desc)
{
- ct_data near *tree = desc->dyn_tree;
- int near *extra = desc->extra_bits;
+ ct_data *tree = desc->dyn_tree;
+ int *extra = desc->extra_bits;
int base = desc->extra_base;
int max_code = desc->max_code;
int max_length = desc->max_length;
- ct_data near *stree = desc->static_tree;
+ ct_data *stree = desc->static_tree;
int h; /* heap index */
int n, m; /* iterate over the tree elements */
int bits; /* bit length */
@@ -581,7 +581,7 @@ gen_bitlen (tree_desc near *desc)
* MAX_CODE is the largest code with non zero frequency.
*/
static void
-gen_codes (ct_data near *tree, int max_code)
+gen_codes (ct_data *tree, int max_code)
{
ush next_code[MAX_BITS+1]; /* next code value for each bit length */
ush code = 0; /* running code value */
@@ -623,10 +623,10 @@ gen_codes (ct_data near *tree, int max_code)
* DESC is the tree descriptor.
*/
static void
-build_tree(tree_desc near *desc)
+build_tree (tree_desc *desc)
{
- ct_data near *tree = desc->dyn_tree;
- ct_data near *stree = desc->static_tree;
+ ct_data *tree = desc->dyn_tree;
+ ct_data *stree = desc->static_tree;
int elems = desc->elems;
int n, m; /* iterate over heap elements */
int max_code = -1; /* largest code with non zero frequency */
@@ -712,7 +712,7 @@ build_tree(tree_desc near *desc)
* MAX_CODE is its largest code of non zero frequency.
*/
static void
-scan_tree (ct_data near *tree, int max_code)
+scan_tree (ct_data *tree, int max_code)
{
int n; /* iterates over all tree elements */
int prevlen = -1; /* last emitted length */
@@ -757,7 +757,7 @@ scan_tree (ct_data near *tree, int max_code)
* MAX_CODE is its largest code of non zero frequency.
*/
static void
-send_tree (ct_data near *tree, int max_code)
+send_tree (ct_data *tree, int max_code)
{
int n; /* iterates over all tree elements */
int prevlen = -1; /* last emitted length */
@@ -1033,7 +1033,7 @@ ct_tally (int dist, int lc)
* LTREE is the literal tree, DTREE the distance tree.
*/
static void
-compress_block (ct_data near *ltree, ct_data near *dtree)
+compress_block (ct_data *ltree, ct_data *dtree)
{
unsigned dist; /* distance of matched string */
int lc; /* match length or unmatched char (if dist == 0) */
diff --git a/unlzw.c b/unlzw.c
index 358add3..4f37fcd 100644
--- a/unlzw.c
+++ b/unlzw.c
@@ -69,21 +69,9 @@ union bytes
}
#endif
-#ifndef MAXSEG_64K
- /* DECLARE(ush, tab_prefix, (1<<BITS)); -- prefix code */
-# define tab_prefixof(i) tab_prefix[i]
-# define clear_tab_prefixof() memzero (tab_prefix, 256);
-#else
- /* DECLARE(ush, tab_prefix0, (1<<(BITS-1)); -- prefix for even codes */
- /* DECLARE(ush, tab_prefix1, (1<<(BITS-1)); -- prefix for odd codes */
- ush *tab_prefix[2];
-# define tab_prefixof(i) tab_prefix[(i)&1][(i)>>1]
-# define clear_tab_prefixof() \
- memzero(tab_prefix0, 128), \
- memzero(tab_prefix1, 128);
-#endif
+/* DECLARE (ush, tab_prefix, 1 << BITS); -- prefix code */
+#define clear_tab_prefixof() memzero (tab_prefix, 256);
#define de_stack ((char_type *)(&d_buf[DIST_BUFSIZE-1]))
-#define tab_suffixof(i) tab_suffix[i]
/* block compress mode -C compatible with 2.0 */
static int block_mode = BLOCK_MODE;
@@ -117,10 +105,6 @@ unlzw (int in, int out)
int n_bits;
int rsize;
-#ifdef MAXSEG_64K
- tab_prefix[0] = tab_prefix0;
- tab_prefix[1] = tab_prefix1;
-#endif
maxbits = get_byte();
block_mode = maxbits & BLOCK_MODE;
if ((maxbits & LZW_RESERVED) != 0) {
@@ -151,7 +135,7 @@ unlzw (int in, int out)
clear_tab_prefixof(); /* Initialize the first 256 entries in the table. */
for (code = 255 ; code >= 0 ; --code) {
- tab_suffixof(code) = (char_type)code;
+ tab_suffix[code] = (char_type)code;
}
do {
int i;
@@ -239,10 +223,11 @@ unlzw (int in, int out)
while ((cmp_code_int)code >= (cmp_code_int)256) {
/* Generate output characters in reverse order */
- *--stackp = tab_suffixof(code);
- code = tab_prefixof(code);
+ *--stackp = tab_suffix[code];
+ code = tab_prefix[code];
}
- *--stackp = (char_type) (finchar = tab_suffixof (code));
+ finchar = tab_suffix[code];
+ *--stackp = (char_type) finchar;
/* And put them out in forward order */
{
@@ -270,8 +255,8 @@ unlzw (int in, int out)
if ((code = free_ent) < maxmaxcode) { /* Generate the new entry. */
- tab_prefixof(code) = (unsigned short)oldcode;
- tab_suffixof(code) = (char_type)finchar;
+ tab_prefix[code] = (unsigned short)oldcode;
+ tab_suffix[code] = (char_type)finchar;
free_ent = code+1;
}
oldcode = incode; /* Remember previous code. */