gzip: don't assume C99, and don't assume overlapping memcpy should work
authorPaul R. Eggert <eggert@cs.ucla.edu>
Mon, 19 Jul 2010 17:22:10 +0000 (10:22 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 19 Jul 2010 17:23:48 +0000 (10:23 -0700)
* tailor.h (NOMEMCPY): Remove.  memcpy is entitled to not work
on overlapping blocks.
* inflate.c (inflate_codes): Don't put decl after statement.
Omit NOMEMCPY.

inflate.c
tailor.h

index 5f2f30377e4fa250dd9f426d5ac807947e447495..012bcb9254e1f16a0dff2e7f2feb8149cbeacf42 100644 (file)
--- a/inflate.c
+++ b/inflate.c
@@ -588,16 +588,15 @@ int bl, bd;             /* number of bits decoded by tl[] and td[] */
       /* do the copy */
       do {
         n -= (e = (e = WSIZE - ((d &= WSIZE-1) > w ? d : w)) > n ? n : e);
-#if !defined(NOMEMCPY) && !defined(DEBUG)
-        unsigned int delta = w > d ? w - d : d - w;
-        if (delta >= e)
+#ifndef DEBUG
+        if (e <= (d < w ? w - d : d - w))
         {
           memcpy(slide + w, slide + d, e);
           w += e;
           d += e;
         }
         else                      /* do it slow to avoid memcpy() overlap */
-#endif /* !NOMEMCPY */
+#endif
           do {
             slide[w++] = slide[d++];
             Tracevv((stderr, "%c", slide[w-1]));
index 4fe0da0de15e9b977104f8b0bb8f545bcbc7bab8..cc150ef8a040af1643154882a6b9c8f3d893095a 100644 (file)
--- a/tailor.h
+++ b/tailor.h
 #  endif
 #endif
 
-#if defined(pyr) && !defined(NOMEMCPY) /* Pyramid */
-#  define NOMEMCPY /* problem with overlapping copies */
-#endif
-
 #ifdef TOPS20
 #  define OS_CODE  0x0a
 #endif