]> git.gag.com Git - debian/gzip/commitdiff
gzip 1.3.5
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 25 Sep 2002 21:20:13 +0000 (21:20 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 25 Sep 2002 21:20:13 +0000 (21:20 +0000)
inflate.c
tailor.h

index c5fe4de3f70b6f651d49666c5daf06379b9e4539..a1c6cbcf244f4e9aa7f1d22190058a57c2db0c61 100644 (file)
--- a/inflate.c
+++ b/inflate.c
@@ -1,4 +1,23 @@
-/* inflate.c -- Not copyrighted 1992 by Mark Adler
+/* Inflate deflated data
+
+   Copyright (C) 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+   See the GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; see the file COPYING.
+   If not, write to the Free Software Foundation,
+   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+/* Not copyrighted 1992 by Mark Adler
    version c10p1, 10 January 1993 */
 
 /* You can do whatever you like with this source file, though I would
 static char rcsid[] = "$Id$";
 #endif
 
-#include <sys/types.h>
-
+#include <config.h>
 #include "tailor.h"
 
-#if defined(STDC_HEADERS) || !defined(NO_STDLIB_H)
+#if defined STDC_HEADERS || defined HAVE_STDLIB_H
 #  include <stdlib.h>
 #endif
 
@@ -185,6 +203,7 @@ static ush cpdext[] = {         /* Extra bits for distance codes */
    for the number of bits in b.  Normally, b and k are register
    variables for speed, and are initialized at the beginning of a
    routine that uses these macros from a global bit buffer and count.
+   The macros also use the variable w, which is a cached copy of wp.
 
    If we assume that EOB will be the longest code, then we will never
    ask for bits with NEEDBITS that are beyond the end of the stream.
@@ -212,12 +231,14 @@ ush mask_bits[] = {
     0x01ff, 0x03ff, 0x07ff, 0x0fff, 0x1fff, 0x3fff, 0x7fff, 0xffff
 };
 
+#define GETBYTE() (inptr < insize ? inbuf[inptr++] : (wp = w, fill_inbuf(0)))
+
 #ifdef CRYPT
   uch cc;
 #  define NEXTBYTE() \
-     (decrypt ? (cc = get_byte(), zdecode(cc), cc) : get_byte())
+     (decrypt ? (cc = GETBYTE(), zdecode(cc), cc) : GETBYTE())
 #else
-#  define NEXTBYTE()  (uch)get_byte()
+#  define NEXTBYTE()  (uch)GETBYTE()
 #endif
 #define NEEDBITS(n) {while(k<(n)){b|=((ulg)NEXTBYTE())<<k;k+=8;}}
 #define DUMPBITS(n) {b>>=(n);k-=(n);}
@@ -360,6 +381,7 @@ int *m;                 /* maximum lookup bits, returns actual */
     if ((j = *p++) != 0)
       v[x[j]++] = i;
   } while (++i < n);
+  n = x[g];                   /* set n to length of v */
 
 
   /* Generate the Huffman codes and for each, make the table entries */
@@ -390,12 +412,13 @@ int *m;                 /* maximum lookup bits, returns actual */
         {                       /* too few codes for k-w bit table */
           f -= a + 1;           /* deduct codes from patterns left */
           xp = c + k;
-          while (++j < z)       /* try smaller tables up to z bits */
-          {
-            if ((f <<= 1) <= *++xp)
-              break;            /* enough codes to use up j bits */
-            f -= *xp;           /* else deduct codes from patterns */
-          }
+         if (j < z)
+           while (++j < z)       /* try smaller tables up to z bits */
+           {
+             if ((f <<= 1) <= *++xp)
+               break;            /* enough codes to use up j bits */
+             f -= *xp;           /* else deduct codes from patterns */
+           }
         }
         z = 1 << j;             /* table entries for j-bit table */
 
@@ -708,6 +731,7 @@ int inflate_dynamic()
   unsigned l;           /* last length */
   unsigned m;           /* mask for bit lengths table */
   unsigned n;           /* number of lengths to get */
+  unsigned w;           /* current window position */
   struct huft *tl;      /* literal/length code table */
   struct huft *td;      /* distance code table */
   int bl;               /* lookup bits for tl */
@@ -727,6 +751,7 @@ int inflate_dynamic()
   /* make local bit buffer */
   b = bb;
   k = bk;
+  w = wp;
 
 
   /* read in table lengths */
@@ -767,6 +792,8 @@ int inflate_dynamic()
     return i;                   /* incomplete code set */
   }
 
+  if (tl == NULL)              /* Grrrhhh */
+       return 2;
 
   /* read in literal and distance code lengths */
   n = nl + nd;
@@ -869,6 +896,7 @@ int *e;                 /* last block flag */
 /* decompress an inflated block */
 {
   unsigned t;           /* block type */
+  unsigned w;           /* current window position */
   register ulg b;       /* bit buffer */
   register unsigned k;  /* number of bits in bit buffer */
 
@@ -876,6 +904,7 @@ int *e;                 /* last block flag */
   /* make local bit buffer */
   b = bb;
   k = bk;
+  w = wp;
 
 
   /* read in last block bit */
index daa48ca4ee2d01a2ee49f076979e23bb463b95c7..9a1cd1bafa90a3de1d0a607d322871412cd34382 100644 (file)
--- a/tailor.h
+++ b/tailor.h
      /* DJGPP version 1.09+ on MS-DOS.
       * The DJGPP 1.09 stat() function must be upgraded before gzip will
       * fully work.
-      * No need for DIRENT, since <unistd.h> defines POSIX_SOURCE which
-      * implies DIRENT.
+      * No need for HAVE_DIRENT_H, since <unistd.h> defines POSIX_SOURCE which
+      * implies HAVE_DIRENT_H.
       */
 #    define near
 #  else
 #    define MAXSEG_64K
 #    ifdef __TURBOC__
-#      define NO_OFF_T
+#      define off_t long
 #      ifdef __BORLANDC__
-#        define DIRENT
-#      else
-#        define NO_UTIME
+#        define HAVE_DIRENT_H
+#        define HAVE_UTIME
 #      endif
+#      define HAVE_UTIME_H
 #    else /* MSC */
 #      define HAVE_SYS_UTIME_H
-#      define NO_UTIME_H
 #    endif
 #  endif
 #  define PATH_SEP2 '\\'
 #  define NO_MULTIPLE_DOTS
 #  define MAX_EXT_CHARS 3
 #  define Z_SUFFIX "z"
-#  define NO_CHOWN
 #  define PROTO
 #  define STDC_HEADERS
 #  define NO_SIZE_CHECK
+#  define UNLINK_READONLY_BUG
 #  define casemap(c) tolow(c) /* Force file names to lower case */
 #  include <io.h>
 #  define OS_CODE  0x00
 #    define Z_SUFFIX "z"
 #    define casemap(c) tolow(c)
 #  endif
-#  define NO_CHOWN
 #  define PROTO
 #  define STDC_HEADERS
+#  define UNLINK_READONLY_BUG
 #  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 NO_UTIME_H
 #    define MAXSEG_64K
 #    undef near
 #    define near _near
 #  endif
 #  ifdef __EMX__
 #    define HAVE_SYS_UTIME_H
-#    define NO_UTIME_H
-#    define DIRENT
+#    define HAVE_DIRENT_H
 #    define EXPAND(argc,argv) \
        {_response(&argc, &argv); _wildcard(&argc, &argv);}
 #  endif
 #  ifdef __BORLANDC__
-#    define DIRENT
+#    define HAVE_DIRENT_H
+#    define HAVE_UTIME_H
 #  endif
 #  ifdef __ZTC__
-#    define NO_DIR
-#    define NO_UTIME_H
+#    define NO_DIR 1
 #    include <dos.h>
 #    define EXPAND(argc,argv) \
        {response_expand(&argc, &argv);}
 
 #ifdef WIN32 /* Windows NT */
 #  define HAVE_SYS_UTIME_H
-#  define NO_UTIME_H
 #  define PATH_SEP2 '\\'
 #  define PATH_SEP3 ':'
 #  define MAX_PATH_LEN  260
-#  define NO_CHOWN
 #  define PROTO
 #  define STDC_HEADERS
 #  define SET_BINARY_MODE(fd) setmode(fd, O_BINARY)
+#  define UNLINK_READONLY_BUG
 #  include <io.h>
 #  include <malloc.h>
 #  ifdef NTFAT
 #  define OS_CODE  0x02
 #  define OPTIONS_VAR "GZIP_OPT"
 #  define STDC_HEADERS
-#  define NO_UTIME
 #  define EXPAND(argc,argv) vms_expand_args(&argc,&argv);
 #  include <file.h>
 #  define unlink delete
 #  ifdef VAXC
-#    define NO_FCNTL_H
 #    include <unixio.h>
+#  else
+#    define HAVE_FCNTL_H
 #  endif
 #endif
 
 #  define OS_CODE  0x01
 #  define ASMV
 #  ifdef __GNUC__
-#    define DIRENT
+#    define HAVE_DIRENT_H
+#    define HAVE_FCNTL_H
 #    define HAVE_UNISTD_H
+#    define HAVE_CHOWN
+#    define HAVE_LSTAT
 #  else /* SASC */
 #    define NO_STDIN_FSTAT
-#    define SYSDIR
-#    define NO_SYMLINK
-#    define NO_CHOWN
-#    define NO_FCNTL_H
+#    define HAVE_SYS_DIR_H
 #    include <fcntl.h> /* for read() and write() */
 #    define direct dirent
      extern void _expand_args(int *argc, char ***argv);
 #  ifndef STDC_HEADERS
 #    define STDC_HEADERS
 #    define HAVE_UNISTD_H
-#    define DIRENT
+#    define HAVE_DIRENT_H
 #  endif
 #  define ASMV
 #  define OS_CODE  0x05
 #    define NO_MULTIPLE_DOTS
 #    define MAX_EXT_CHARS 3
 #    define Z_SUFFIX "z"
-#    define NO_CHOWN
 #    define casemap(c) tolow(c) /* Force file names to lower case */
-#    define NO_SYMLINK
 #  endif
 #endif
 
 #  define DYN_ALLOC
 #  define PROTO
 #  define NO_STDIN_FSTAT
-#  define NO_CHOWN
-#  define NO_UTIME
 #  define chmod(file, mode) (0)
 #  define OPEN(name, flags, mode) open(name, flags)
 #  define OS_CODE  0x07
 #ifdef __50SERIES /* Prime/PRIMOS */
 #  define PATH_SEP '>'
 #  define STDC_HEADERS
-#  define NO_MEMORY_H
-#  define NO_UTIME_H
-#  define NO_UTIME
-#  define NO_CHOWN 
 #  define NO_STDIN_FSTAT 
 #  define NO_SIZE_CHECK 
-#  define NO_SYMLINK
 #  define RECORD_IO  1
 #  define casemap(c)  tolow(c) /* Force file names to lower case */
 #  define put_char(c) put_byte((c) & 0x7F)