[perl-Compress-LZF] Initial import (#1074129).

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



commit 16cb2fda049ad020c1f707da7171cd22629bd10c
Author: David Dick <ddick@xxxxxxxx>
Date:   Wed Apr 16 19:05:15 2014 +1000

    Initial import (#1074129).

 .gitignore                  |    1 +
 compress_lzf_unbundle.patch | 1073 +++++++++++++++++++++++++++++++++++++++++++
 perl-Compress-LZF.spec      |   50 ++
 sources                     |    1 +
 4 files changed, 1125 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e69de29..1124518 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/Compress-LZF-3.7.tar.gz
diff --git a/compress_lzf_unbundle.patch b/compress_lzf_unbundle.patch
new file mode 100644
index 0000000..4af62c1
--- /dev/null
+++ b/compress_lzf_unbundle.patch
@@ -0,0 +1,1073 @@
+diff -Naur old/lzf_c_best.c new/lzf_c_best.c
+--- old/lzf_c_best.c	2013-08-26 04:03:41.000000000 +1000
++++ new/lzf_c_best.c	1970-01-01 10:00:00.000000000 +1000
+@@ -1,207 +0,0 @@
+-/*
+- * Copyright (c) 2000-2012 Marc Alexander Lehmann <schmorp@xxxxxxxxxx>
+- *
+- * Redistribution and use in source and binary forms, with or without modifica-
+- * tion, are permitted provided that the following conditions are met:
+- *
+- *   1.  Redistributions of source code must retain the above copyright notice,
+- *       this list of conditions and the following disclaimer.
+- *
+- *   2.  Redistributions in binary form must reproduce the above copyright
+- *       notice, this list of conditions and the following disclaimer in the
+- *       documentation and/or other materials provided with the distribution.
+- *
+- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
+- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
+- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
+- * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
+- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+- * OF THE POSSIBILITY OF SUCH DAMAGE.
+- *
+- * Alternatively, the contents of this file may be used under the terms of
+- * the GNU General Public License ("GPL") version 2 or any later version,
+- * in which case the provisions of the GPL are applicable instead of
+- * the above. If you wish to allow the use of your version of this file
+- * only under the terms of the GPL and not to allow others to use your
+- * version of this file under the BSD license, indicate your decision
+- * by deleting the provisions above and replace them with the notice
+- * and other provisions required by the GPL. If you do not delete the
+- * provisions above, a recipient may use your version of this file under
+- * either the BSD or the GPL.
+- */
+-
+-#include "lzfP.h"
+-
+-#define HASH(p) (p[0] << 6) ^ (p[1] << 3) ^ p[2]
+-
+-#define        MAX_LIT        (1 <<  5)
+-#define        MAX_OFF        (1 << 13)
+-#define        MAX_REF        ((1 << 8) + (1 << 3))
+-
+-#if __GNUC__ >= 3
+-# define expect(expr,value)         __builtin_expect ((expr),(value))
+-# define inline                     inline
+-#else
+-# define expect(expr,value)         (expr)
+-# define inline                     static
+-#endif
+-
+-#define expect_false(expr) expect ((expr) != 0, 0)
+-#define expect_true(expr)  expect ((expr) != 0, 1)
+-
+-/*
+- * compressed format
+- *
+- * 000LLLLL <L+1>    ; literal, L+1=1..33 octets
+- * LLLooooo oooooooo ; backref L+1=1..7 octets, o+1=1..4096 offset
+- * 111ooooo LLLLLLLL oooooooo ; backref L+8 octets, o+1=1..4096 offset
+- *
+- */
+-
+-unsigned int
+-lzf_compress_best (const void *const in_data, unsigned int in_len,
+-	           void *out_data, unsigned int out_len)
+-{
+-  const u8 *ip = (const u8 *)in_data;
+-        u8 *op = (u8 *)out_data;
+-  const u8 *in_end  = ip + in_len;
+-        u8 *out_end = op + out_len;
+-
+-  const u8 *first [1 << (6+8)]; /* most recent occurance of a match */
+-  u16 prev [MAX_OFF]; /* how many bytes to go backwards for te next match */
+-
+-  int lit;
+-
+-  if (!in_len || !out_len)
+-    return 0;
+-
+-  lit = 0; op++; /* start run */
+-
+-  lit++; *op++ = *ip++;
+-
+-  while (ip < in_end - 2)
+-    {
+-      int best_l = 0;
+-      const u8 *best_p;
+-      int e = (in_end - ip < MAX_REF ? in_end - ip : MAX_REF) - 1;
+-      unsigned int res = ((unsigned int)ip) & (MAX_OFF - 1);
+-      u16 hash = HASH (ip);
+-      u16 diff;
+-      const u8 *b = ip < (u8 *)in_data + MAX_OFF ? in_data : ip - MAX_OFF;
+-      const u8 *p = first [hash];
+-      prev [res] = ip - p; /* update ptr to previous hash match */
+-      first [hash] = ip; /* first hash match is here */
+-
+-      if (p < ip)
+-      while (p >= b)
+-        {
+-          if (p[2] == ip[2]) /* first two bytes almost always match */
+-            if (p[best_l] == ip[best_l]) /* new match must be longer than the old one to qualify */
+-              if (p[1] == ip[1] && p[0] == ip[0]) /* just to be sure */
+-                {
+-                  int l = 3;
+-
+-                  while (p[l] == ip[l] && l < e)
+-                    ++l;
+-
+-                  if (l >= best_l)
+-                    {
+-                      best_p = p;
+-                      best_l = l;
+-                    }
+-                }
+-
+-          diff = prev [((unsigned int)p) & (MAX_OFF - 1)];
+-          p = diff ? p - diff : 0;
+-        }
+-
+-      if (best_l)
+-        {
+-          int len = best_l;
+-          int off = ip - best_p - 1;
+-
+-          if (expect_false (op + 3 + 1 >= out_end)) /* first a faster conservative test */
+-            if (op - !lit + 3 + 1 >= out_end) /* second the exact but rare test */
+-              return 0;
+-
+-          op [- lit - 1] = lit - 1; /* stop run */
+-          op -= !lit; /* undo run if length is zero */
+-
+-          len -= 2; /* len is now #octets - 1 */
+-          ip++;
+-
+-          if (len < 7)
+-            {
+-              *op++ = (off >> 8) + (len << 5);
+-            }
+-          else
+-            {
+-              *op++ = (off >> 8) + (  7 << 5);
+-              *op++ = len - 7;
+-            }
+-
+-          *op++ = off;
+-
+-          lit = 0; op++; /* start run */
+-
+-          ip += len + 1;
+-
+-          if (expect_false (ip >= in_end - 2))
+-            break;
+-
+-          ip -= len + 1;
+-
+-          //printf (" fill %p for %d\n", ip, len);//D
+-          do
+-            {
+-              u16 hash = HASH (ip);
+-              res = ((unsigned int)ip) & (MAX_OFF - 1);
+-
+-              p = first [hash];
+-              prev [res] = ip - p; /* update ptr to previous hash match */
+-              first [hash] = ip; /* first hash match is here */
+-
+-              ip++;
+-            }
+-          while (len--);
+-        }
+-      else
+-        {
+-          /* one more literal byte we must copy */
+-          if (expect_false (op >= out_end))
+-            return 0;
+-
+-          lit++; *op++ = *ip++;
+-
+-          if (expect_false (lit == MAX_LIT))
+-            {
+-              op [- lit - 1] = lit - 1; /* stop run */
+-              lit = 0; op++; /* start run */
+-            }
+-        }
+-    }
+-
+-  if (op + 3 > out_end) /* at most 3 bytes can be missing here */
+-    return 0;
+-
+-  while (ip < in_end)
+-    {
+-      lit++; *op++ = *ip++;
+-
+-      if (expect_false (lit == MAX_LIT))
+-        {
+-          op [- lit - 1] = lit - 1; /* stop run */
+-          lit = 0; op++; /* start run */
+-        }
+-    }
+-
+-  op [- lit - 1] = lit - 1; /* end run */
+-  op -= !lit; /* undo run if length is zero */
+-
+-  return op - (u8 *)out_data;
+-}
+-
+diff -Naur old/lzf_c.c new/lzf_c.c
+--- old/lzf_c.c	2013-08-26 03:51:51.000000000 +1000
++++ new/lzf_c.c	1970-01-01 10:00:00.000000000 +1000
+@@ -1,296 +0,0 @@
+-/*
+- * Copyright (c) 2000-2010,2012 Marc Alexander Lehmann <schmorp@xxxxxxxxxx>
+- *
+- * Redistribution and use in source and binary forms, with or without modifica-
+- * tion, are permitted provided that the following conditions are met:
+- *
+- *   1.  Redistributions of source code must retain the above copyright notice,
+- *       this list of conditions and the following disclaimer.
+- *
+- *   2.  Redistributions in binary form must reproduce the above copyright
+- *       notice, this list of conditions and the following disclaimer in the
+- *       documentation and/or other materials provided with the distribution.
+- *
+- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
+- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
+- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
+- * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
+- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+- * OF THE POSSIBILITY OF SUCH DAMAGE.
+- *
+- * Alternatively, the contents of this file may be used under the terms of
+- * the GNU General Public License ("GPL") version 2 or any later version,
+- * in which case the provisions of the GPL are applicable instead of
+- * the above. If you wish to allow the use of your version of this file
+- * only under the terms of the GPL and not to allow others to use your
+- * version of this file under the BSD license, indicate your decision
+- * by deleting the provisions above and replace them with the notice
+- * and other provisions required by the GPL. If you do not delete the
+- * provisions above, a recipient may use your version of this file under
+- * either the BSD or the GPL.
+- */
+-
+-#include "lzfP.h"
+-
+-#define HSIZE (1 << (HLOG))
+-
+-/*
+- * don't play with this unless you benchmark!
+- * the data format is not dependent on the hash function.
+- * the hash function might seem strange, just believe me,
+- * it works ;)
+- */
+-#ifndef FRST
+-# define FRST(p) (((p[0]) << 8) | p[1])
+-# define NEXT(v,p) (((v) << 8) | p[2])
+-# if MULTIPLICATION_IS_SLOW
+-#  if ULTRA_FAST
+-#   define IDX(h) ((( h             >> (3*8 - HLOG)) - h  ) & (HSIZE - 1))
+-#  elif VERY_FAST
+-#   define IDX(h) ((( h             >> (3*8 - HLOG)) - h*5) & (HSIZE - 1))
+-#  else
+-#   define IDX(h) ((((h ^ (h << 5)) >> (3*8 - HLOG)) - h*5) & (HSIZE - 1))
+-#  endif
+-# else
+-/* this one was developed with sesse,
+- * and is very similar to the one in snappy.
+- * it does need a modern enough cpu with a fast multiplication.
+- */
+-#  define IDX(h) (((h * 0x1e35a7bdU) >> (32 - HLOG - 8)) & (HSIZE - 1))
+-# endif
+-#endif
+-
+-#if 0
+-/* original lzv-like hash function, much worse and thus slower */
+-# define FRST(p) (p[0] << 5) ^ p[1]
+-# define NEXT(v,p) ((v) << 5) ^ p[2]
+-# define IDX(h) ((h) & (HSIZE - 1))
+-#endif
+-
+-#define        MAX_LIT        (1 <<  5)
+-#define        MAX_OFF        (1 << 13)
+-#define        MAX_REF        ((1 << 8) + (1 << 3))
+-
+-#if __GNUC__ >= 3
+-# define expect(expr,value)         __builtin_expect ((expr),(value))
+-# define inline                     inline
+-#else
+-# define expect(expr,value)         (expr)
+-# define inline                     static
+-#endif
+-
+-#define expect_false(expr) expect ((expr) != 0, 0)
+-#define expect_true(expr)  expect ((expr) != 0, 1)
+-
+-/*
+- * compressed format
+- *
+- * 000LLLLL <L+1>    ; literal, L+1=1..33 octets
+- * LLLooooo oooooooo ; backref L+1=1..7 octets, o+1=1..4096 offset
+- * 111ooooo LLLLLLLL oooooooo ; backref L+8 octets, o+1=1..4096 offset
+- *
+- */
+-
+-unsigned int
+-lzf_compress (const void *const in_data, unsigned int in_len,
+-	      void *out_data, unsigned int out_len
+-#if LZF_STATE_ARG
+-              , LZF_STATE htab
+-#endif
+-              )
+-{
+-#if !LZF_STATE_ARG
+-  LZF_STATE htab;
+-#endif
+-  const u8 *ip = (const u8 *)in_data;
+-        u8 *op = (u8 *)out_data;
+-  const u8 *in_end  = ip + in_len;
+-        u8 *out_end = op + out_len;
+-  const u8 *ref;
+-
+-  /* off requires a type wide enough to hold a general pointer difference.
+-   * ISO C doesn't have that (size_t might not be enough and ptrdiff_t only
+-   * works for differences within a single object). We also assume that
+-   * no bit pattern traps. Since the only platform that is both non-POSIX
+-   * and fails to support both assumptions is windows 64 bit, we make a
+-   * special workaround for it.
+-   */
+-#if defined (_WIN32) && defined (_M_X64)
+-  /* workaround for missing POSIX compliance */
+-  #if __GNUC__
+-    unsigned long long off;
+-  #else
+-    unsigned __int64 off;
+-  #endif
+-#else
+-  unsigned long off;
+-#endif
+-  unsigned int hval;
+-  int lit;
+-
+-  if (!in_len || !out_len)
+-    return 0;
+-
+-#if INIT_HTAB
+-  memset (htab, 0, sizeof (htab));
+-#endif
+-
+-  lit = 0; op++; /* start run */
+-
+-  hval = FRST (ip);
+-  while (ip < in_end - 2)
+-    {
+-      LZF_HSLOT *hslot;
+-
+-      hval = NEXT (hval, ip);
+-      hslot = htab + IDX (hval);
+-      ref = *hslot + LZF_HSLOT_BIAS; *hslot = ip - LZF_HSLOT_BIAS;
+-
+-      if (1
+-#if INIT_HTAB
+-          && ref < ip /* the next test will actually take care of this, but this is faster */
+-#endif
+-          && (off = ip - ref - 1) < MAX_OFF
+-          && ref > (u8 *)in_data
+-          && ref[2] == ip[2]
+-#if STRICT_ALIGN
+-          && ((ref[1] << 8) | ref[0]) == ((ip[1] << 8) | ip[0])
+-#else
+-          && *(u16 *)ref == *(u16 *)ip
+-#endif
+-        )
+-        {
+-          /* match found at *ref++ */
+-          unsigned int len = 2;
+-          unsigned int maxlen = in_end - ip - len;
+-          maxlen = maxlen > MAX_REF ? MAX_REF : maxlen;
+-
+-          if (expect_false (op + 3 + 1 >= out_end)) /* first a faster conservative test */
+-            if (op - !lit + 3 + 1 >= out_end) /* second the exact but rare test */
+-              return 0;
+-
+-          op [- lit - 1] = lit - 1; /* stop run */
+-          op -= !lit; /* undo run if length is zero */
+-
+-          for (;;)
+-            {
+-              if (expect_true (maxlen > 16))
+-                {
+-                  len++; if (ref [len] != ip [len]) break;
+-                  len++; if (ref [len] != ip [len]) break;
+-                  len++; if (ref [len] != ip [len]) break;
+-                  len++; if (ref [len] != ip [len]) break;
+-
+-                  len++; if (ref [len] != ip [len]) break;
+-                  len++; if (ref [len] != ip [len]) break;
+-                  len++; if (ref [len] != ip [len]) break;
+-                  len++; if (ref [len] != ip [len]) break;
+-
+-                  len++; if (ref [len] != ip [len]) break;
+-                  len++; if (ref [len] != ip [len]) break;
+-                  len++; if (ref [len] != ip [len]) break;
+-                  len++; if (ref [len] != ip [len]) break;
+-
+-                  len++; if (ref [len] != ip [len]) break;
+-                  len++; if (ref [len] != ip [len]) break;
+-                  len++; if (ref [len] != ip [len]) break;
+-                  len++; if (ref [len] != ip [len]) break;
+-                }
+-
+-              do
+-                len++;
+-              while (len < maxlen && ref[len] == ip[len]);
+-
+-              break;
+-            }
+-
+-          len -= 2; /* len is now #octets - 1 */
+-          ip++;
+-
+-          if (len < 7)
+-            {
+-              *op++ = (off >> 8) + (len << 5);
+-            }
+-          else
+-            {
+-              *op++ = (off >> 8) + (  7 << 5);
+-              *op++ = len - 7;
+-            }
+-
+-          *op++ = off;
+-
+-          lit = 0; op++; /* start run */
+-
+-          ip += len + 1;
+-
+-          if (expect_false (ip >= in_end - 2))
+-            break;
+-
+-#if ULTRA_FAST || VERY_FAST
+-          --ip;
+-# if VERY_FAST && !ULTRA_FAST
+-          --ip;
+-# endif
+-          hval = FRST (ip);
+-
+-          hval = NEXT (hval, ip);
+-          htab[IDX (hval)] = ip - LZF_HSLOT_BIAS;
+-          ip++;
+-
+-# if VERY_FAST && !ULTRA_FAST
+-          hval = NEXT (hval, ip);
+-          htab[IDX (hval)] = ip - LZF_HSLOT_BIAS;
+-          ip++;
+-# endif
+-#else
+-          ip -= len + 1;
+-
+-          do
+-            {
+-              hval = NEXT (hval, ip);
+-              htab[IDX (hval)] = ip - LZF_HSLOT_BIAS;
+-              ip++;
+-            }
+-          while (len--);
+-#endif
+-        }
+-      else
+-        {
+-          /* one more literal byte we must copy */
+-          if (expect_false (op >= out_end))
+-            return 0;
+-
+-          lit++; *op++ = *ip++;
+-
+-          if (expect_false (lit == MAX_LIT))
+-            {
+-              op [- lit - 1] = lit - 1; /* stop run */
+-              lit = 0; op++; /* start run */
+-            }
+-        }
+-    }
+-
+-  if (op + 3 > out_end) /* at most 3 bytes can be missing here */
+-    return 0;
+-
+-  while (ip < in_end)
+-    {
+-      lit++; *op++ = *ip++;
+-
+-      if (expect_false (lit == MAX_LIT))
+-        {
+-          op [- lit - 1] = lit - 1; /* stop run */
+-          lit = 0; op++; /* start run */
+-        }
+-    }
+-
+-  op [- lit - 1] = lit - 1; /* end run */
+-  op -= !lit; /* undo run if length is zero */
+-
+-  return op - (u8 *)out_data;
+-}
+-
+diff -Naur old/lzf_d.c new/lzf_d.c
+--- old/lzf_d.c	2013-08-26 03:51:51.000000000 +1000
++++ new/lzf_d.c	1970-01-01 10:00:00.000000000 +1000
+@@ -1,185 +0,0 @@
+-/*
+- * Copyright (c) 2000-2010 Marc Alexander Lehmann <schmorp@xxxxxxxxxx>
+- *
+- * Redistribution and use in source and binary forms, with or without modifica-
+- * tion, are permitted provided that the following conditions are met:
+- *
+- *   1.  Redistributions of source code must retain the above copyright notice,
+- *       this list of conditions and the following disclaimer.
+- *
+- *   2.  Redistributions in binary form must reproduce the above copyright
+- *       notice, this list of conditions and the following disclaimer in the
+- *       documentation and/or other materials provided with the distribution.
+- *
+- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
+- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
+- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
+- * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
+- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+- * OF THE POSSIBILITY OF SUCH DAMAGE.
+- *
+- * Alternatively, the contents of this file may be used under the terms of
+- * the GNU General Public License ("GPL") version 2 or any later version,
+- * in which case the provisions of the GPL are applicable instead of
+- * the above. If you wish to allow the use of your version of this file
+- * only under the terms of the GPL and not to allow others to use your
+- * version of this file under the BSD license, indicate your decision
+- * by deleting the provisions above and replace them with the notice
+- * and other provisions required by the GPL. If you do not delete the
+- * provisions above, a recipient may use your version of this file under
+- * either the BSD or the GPL.
+- */
+-
+-#include "lzfP.h"
+-
+-#if AVOID_ERRNO
+-# define SET_ERRNO(n)
+-#else
+-# include <errno.h>
+-# define SET_ERRNO(n) errno = (n)
+-#endif
+-
+-#if USE_REP_MOVSB /* small win on amd, big loss on intel */
+-#if (__i386 || __amd64) && __GNUC__ >= 3
+-# define lzf_movsb(dst, src, len)                \
+-   asm ("rep movsb"                              \
+-        : "=D" (dst), "=S" (src), "=c" (len)     \
+-        :  "0" (dst),  "1" (src),  "2" (len));
+-#endif
+-#endif
+-
+-unsigned int 
+-lzf_decompress (const void *const in_data,  unsigned int in_len,
+-                void             *out_data, unsigned int out_len)
+-{
+-  u8 const *ip = (const u8 *)in_data;
+-  u8       *op = (u8 *)out_data;
+-  u8 const *const in_end  = ip + in_len;
+-  u8       *const out_end = op + out_len;
+-
+-  do
+-    {
+-      unsigned int ctrl = *ip++;
+-
+-      if (ctrl < (1 << 5)) /* literal run */
+-        {
+-          ctrl++;
+-
+-          if (op + ctrl > out_end)
+-            {
+-              SET_ERRNO (E2BIG);
+-              return 0;
+-            }
+-
+-#if CHECK_INPUT
+-          if (ip + ctrl > in_end)
+-            {
+-              SET_ERRNO (EINVAL);
+-              return 0;
+-            }
+-#endif
+-
+-#ifdef lzf_movsb
+-          lzf_movsb (op, ip, ctrl);
+-#else
+-          switch (ctrl)
+-            {
+-              case 32: *op++ = *ip++; case 31: *op++ = *ip++; case 30: *op++ = *ip++; case 29: *op++ = *ip++;
+-              case 28: *op++ = *ip++; case 27: *op++ = *ip++; case 26: *op++ = *ip++; case 25: *op++ = *ip++;
+-              case 24: *op++ = *ip++; case 23: *op++ = *ip++; case 22: *op++ = *ip++; case 21: *op++ = *ip++;
+-              case 20: *op++ = *ip++; case 19: *op++ = *ip++; case 18: *op++ = *ip++; case 17: *op++ = *ip++;
+-              case 16: *op++ = *ip++; case 15: *op++ = *ip++; case 14: *op++ = *ip++; case 13: *op++ = *ip++;
+-              case 12: *op++ = *ip++; case 11: *op++ = *ip++; case 10: *op++ = *ip++; case  9: *op++ = *ip++;
+-              case  8: *op++ = *ip++; case  7: *op++ = *ip++; case  6: *op++ = *ip++; case  5: *op++ = *ip++;
+-              case  4: *op++ = *ip++; case  3: *op++ = *ip++; case  2: *op++ = *ip++; case  1: *op++ = *ip++;
+-            }
+-#endif
+-        }
+-      else /* back reference */
+-        {
+-          unsigned int len = ctrl >> 5;
+-
+-          u8 *ref = op - ((ctrl & 0x1f) << 8) - 1;
+-
+-#if CHECK_INPUT
+-          if (ip >= in_end)
+-            {
+-              SET_ERRNO (EINVAL);
+-              return 0;
+-            }
+-#endif
+-          if (len == 7)
+-            {
+-              len += *ip++;
+-#if CHECK_INPUT
+-              if (ip >= in_end)
+-                {
+-                  SET_ERRNO (EINVAL);
+-                  return 0;
+-                }
+-#endif
+-            }
+-
+-          ref -= *ip++;
+-
+-          if (op + len + 2 > out_end)
+-            {
+-              SET_ERRNO (E2BIG);
+-              return 0;
+-            }
+-
+-          if (ref < (u8 *)out_data)
+-            {
+-              SET_ERRNO (EINVAL);
+-              return 0;
+-            }
+-
+-#ifdef lzf_movsb
+-          len += 2;
+-          lzf_movsb (op, ref, len);
+-#else
+-          switch (len)
+-            {
+-              default:
+-                len += 2;
+-
+-                if (op >= ref + len)
+-                  {
+-                    /* disjunct areas */
+-                    memcpy (op, ref, len);
+-                    op += len;
+-                  }
+-                else
+-                  {
+-                    /* overlapping, use octte by octte copying */
+-                    do
+-                      *op++ = *ref++;
+-                    while (--len);
+-                  }
+-
+-                break;
+-
+-              case 9: *op++ = *ref++;
+-              case 8: *op++ = *ref++;
+-              case 7: *op++ = *ref++;
+-              case 6: *op++ = *ref++;
+-              case 5: *op++ = *ref++;
+-              case 4: *op++ = *ref++;
+-              case 3: *op++ = *ref++;
+-              case 2: *op++ = *ref++;
+-              case 1: *op++ = *ref++;
+-              case 0: *op++ = *ref++; /* two octets more */
+-                      *op++ = *ref++;
+-            }
+-#endif
+-        }
+-    }
+-  while (ip < in_end);
+-
+-  return op - (u8 *)out_data;
+-}
+-
+diff -Naur old/lzfP.h new/lzfP.h
+--- old/lzfP.h	2013-08-26 03:51:51.000000000 +1000
++++ new/lzfP.h	1970-01-01 10:00:00.000000000 +1000
+@@ -1,204 +0,0 @@
+-/*
+- * Copyright (c) 2000-2007 Marc Alexander Lehmann <schmorp@xxxxxxxxxx>
+- *
+- * Redistribution and use in source and binary forms, with or without modifica-
+- * tion, are permitted provided that the following conditions are met:
+- *
+- *   1.  Redistributions of source code must retain the above copyright notice,
+- *       this list of conditions and the following disclaimer.
+- *
+- *   2.  Redistributions in binary form must reproduce the above copyright
+- *       notice, this list of conditions and the following disclaimer in the
+- *       documentation and/or other materials provided with the distribution.
+- *
+- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
+- * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MER-
+- * CHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
+- * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPE-
+- * CIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTH-
+- * ERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+- * OF THE POSSIBILITY OF SUCH DAMAGE.
+- *
+- * Alternatively, the contents of this file may be used under the terms of
+- * the GNU General Public License ("GPL") version 2 or any later version,
+- * in which case the provisions of the GPL are applicable instead of
+- * the above. If you wish to allow the use of your version of this file
+- * only under the terms of the GPL and not to allow others to use your
+- * version of this file under the BSD license, indicate your decision
+- * by deleting the provisions above and replace them with the notice
+- * and other provisions required by the GPL. If you do not delete the
+- * provisions above, a recipient may use your version of this file under
+- * either the BSD or the GPL.
+- */
+-
+-#ifndef LZFP_h
+-#define LZFP_h
+-
+-#define STANDALONE 1 /* at the moment, this is ok. */
+-
+-#ifndef STANDALONE
+-# include "lzf.h"
+-#endif
+-
+-/*
+- * Size of hashtable is (1 << HLOG) * sizeof (char *)
+- * decompression is independent of the hash table size
+- * the difference between 15 and 14 is very small
+- * for small blocks (and 14 is usually a bit faster).
+- * For a low-memory/faster configuration, use HLOG == 13;
+- * For best compression, use 15 or 16 (or more, up to 22).
+- */
+-#ifndef HLOG
+-# define HLOG 16
+-#endif
+-
+-/*
+- * Sacrifice very little compression quality in favour of compression speed.
+- * This gives almost the same compression as the default code, and is
+- * (very roughly) 15% faster. This is the preferred mode of operation.
+- */
+-#ifndef VERY_FAST
+-# define VERY_FAST 1
+-#endif
+-
+-/*
+- * Sacrifice some more compression quality in favour of compression speed.
+- * (roughly 1-2% worse compression for large blocks and
+- * 9-10% for small, redundant, blocks and >>20% better speed in both cases)
+- * In short: when in need for speed, enable this for binary data,
+- * possibly disable this for text data.
+- */
+-#ifndef ULTRA_FAST
+-# define ULTRA_FAST 0
+-#endif
+-
+-/*
+- * Unconditionally aligning does not cost very much, so do it if unsure
+- */
+-#ifndef STRICT_ALIGN
+-# define STRICT_ALIGN !(defined(__i386) || defined (__amd64))
+-#endif
+-
+-/*
+- * You may choose to pre-set the hash table (might be faster on some
+- * modern cpus and large (>>64k) blocks, and also makes compression
+- * deterministic/repeatable when the configuration otherwise is the same).
+- */
+-#ifndef INIT_HTAB
+-# define INIT_HTAB 1
+-#endif
+-
+-/*
+- * Avoid assigning values to errno variable? for some embedding purposes
+- * (linux kernel for example), this is necessary. NOTE: this breaks
+- * the documentation in lzf.h. Avoiding errno has no speed impact.
+- */
+-#ifndef AVOID_ERRNO
+-# define AVOID_ERRNO 0
+-#endif
+-
+-/*
+- * Whether to pass the LZF_STATE variable as argument, or allocate it
+- * on the stack. For small-stack environments, define this to 1.
+- * NOTE: this breaks the prototype in lzf.h.
+- */
+-#ifndef LZF_STATE_ARG
+-# define LZF_STATE_ARG 0
+-#endif
+-
+-/*
+- * Whether to add extra checks for input validity in lzf_decompress
+- * and return EINVAL if the input stream has been corrupted. This
+- * only shields against overflowing the input buffer and will not
+- * detect most corrupted streams.
+- * This check is not normally noticeable on modern hardware
+- * (<1% slowdown), but might slow down older cpus considerably.
+- */
+-#ifndef CHECK_INPUT
+-# define CHECK_INPUT 1
+-#endif
+-
+-/*
+- * Whether the target CPU has a slow multiplication. This affects
+- * the default hash function for the compressor, and enables a slightly
+- * worse hash function that needs only shifts.
+- */
+-#ifndef MULTIPLICATION_IS_SLOW
+-# define MULTIPLICATION_IS_SLOW 0
+-#endif
+-
+-/*
+- * If defined, then this data type will be used for storing offsets.
+- * This can be useful if you want to use a huge hashtable, want to
+- * conserve memory, or both, and your data fits into e.g. 64kb.
+- * If instead you want to compress data > 4GB, then it's better to
+- * to "#define LZF_USE_OFFSETS 0" instead.
+- */
+-/*#define LZF_HSLOT unsigned short*/
+-
+-/*
+- * Whether to store pointers or offsets inside the hash table. On
+- * 64 bit architetcures, pointers take up twice as much space,
+- * and might also be slower. Default is to autodetect.
+- */
+-/*#define LZF_USE_OFFSETS autodetect */
+-
+-/*****************************************************************************/
+-/* nothing should be changed below */
+-
+-#ifdef __cplusplus
+-# include <cstring>
+-# include <climits>
+-using namespace std;
+-#else
+-# include <string.h>
+-# include <limits.h>
+-#endif
+-
+-#ifndef LZF_USE_OFFSETS
+-# ifdef _WIN32
+-#  define LZF_USE_OFFSETS defined(_M_X64)
+-# else
+-#  if __cplusplus > 199711L
+-#   include <cstdint>
+-#  else
+-#   include <stdint.h>
+-#  endif
+-#  define LZF_USE_OFFSETS (UINTPTR_MAX > 0xffffffffU)
+-# endif
+-#endif
+-
+-typedef unsigned char u8;
+-
+-#ifdef LZF_HSLOT
+-# define LZF_HSLOT_BIAS ((const u8 *)in_data)
+-#else
+-# if LZF_USE_OFFSETS
+-#  define LZF_HSLOT_BIAS ((const u8 *)in_data)
+-   typedef unsigned int LZF_HSLOT;
+-# else
+-#  define LZF_HSLOT_BIAS 0
+-   typedef const u8 *LZF_HSLOT;
+-# endif
+-#endif
+-
+-typedef LZF_HSLOT LZF_STATE[1 << (HLOG)];
+-
+-#if USHRT_MAX == 65535
+-   typedef unsigned short u16;
+-#elif UINT_MAX == 65535
+-   typedef unsigned int u16;
+-#else
+-# undef STRICT_ALIGN
+-# define STRICT_ALIGN 1
+-#endif
+-
+-#if ULTRA_FAST
+-# undef VERY_FAST
+-#endif
+-
+-#endif
+-
+diff -Naur old/LZF.xs new/LZF.xs
+--- old/LZF.xs	2013-08-26 04:08:35.000000000 +1000
++++ new/LZF.xs	2014-04-10 20:14:09.423267181 +1000
+@@ -5,10 +5,6 @@
+ #define LZF_STANDALONE 1
+ #define LZF_STATE_ARG 1
+ 
+-#include "lzf_c.c"
+-#include "lzf_d.c"
+-#include "lzf_c_best.c"
+-
+ /* we re-use the storable header for our purposes */
+ #define MAGIC_LO	0
+ #define MAGIC_U		0 /* uncompressed data follows */
+@@ -33,9 +29,8 @@
+ #endif
+ 
+ static SV *
+-compress_sv (SV *data, char cprepend, int uprepend, int best)
++compress_sv (SV *data, char cprepend, int uprepend)
+ {
+-  LZF_STATE *state;
+   STRLEN usize, csize;
+   char *src = (char *)SvPVbyte (data, usize);
+ 
+@@ -93,16 +88,8 @@
+       else
+         croak ("compress can only compress up to %ld bytes", 0x7fffffffL);
+ 
+-      New (0, state, 1, LZF_STATE);
+-      if (!state)
+-        croak ("Compress::LZF unable to allocate memory for compression state");
+-
+       /* 11 bytes is the smallest compressible string */
+-      csize = usize < 11 ? 0 :
+-              (best ? lzf_compress_best (src, usize, dst + skip, usize - skip)
+-                    : lzf_compress (src, usize, dst + skip, usize - skip, *state));
+-
+-      Safefree (state);
++      csize = usize < 11 ? 0 : lzf_compress (src, usize, dst + skip, usize - skip);
+ 
+       if (csize)
+         {
+@@ -253,11 +240,9 @@
+ void
+ compress(data)
+         SV *	data
+-        ALIAS:
+-        compress_best = 1
+         PROTOTYPE: $
+         PPCODE:
+-        XPUSHs (sv_2mortal (compress_sv (data, 0, MAGIC_U, ix)));
++        XPUSHs (sv_2mortal (compress_sv (data, 0, MAGIC_U)));
+ 
+ void
+ decompress(data)
+@@ -273,15 +258,9 @@
+         sfreeze         = 0
+         sfreeze_cr      = 1
+         sfreeze_c       = 2
+-        sfreeze_best    = 4
+-        sfreeze_cr_best = 5
+-        sfreeze_c_best  = 6
+         PROTOTYPE: $
+         PPCODE:
+ {
+-	int best = ix & 4;
+-        ix &= 3;
+-
+         SvGETMAGIC (sv);
+ 
+         if (!SvOK (sv))
+@@ -336,14 +315,14 @@
+               }
+ 
+             if (ix) /* compress */
+-              sv = sv_2mortal (compress_sv (sv, deref ? MAGIC_CR_deref : MAGIC_CR, -1, best));
++              sv = sv_2mortal (compress_sv (sv, deref ? MAGIC_CR_deref : MAGIC_CR, -1));
+ 
+             XPUSHs (sv);
+           }
+         else if (SvPOKp (sv) && IN_RANGE (SvPVX (sv)[0], MAGIC_LO, MAGIC_HI))
+-          XPUSHs (sv_2mortal (compress_sv (sv, MAGIC_C, MAGIC_U, best))); /* need to prefix only */
++          XPUSHs (sv_2mortal (compress_sv (sv, MAGIC_C, MAGIC_U))); /* need to prefix only */
+         else if (ix == 2) /* compress always */
+-          XPUSHs (sv_2mortal (compress_sv (sv, MAGIC_C, -1, best)));
++          XPUSHs (sv_2mortal (compress_sv (sv, MAGIC_C, -1)));
+         else if (SvNIOK (sv)) /* don't compress */
+           {
+             STRLEN len;
+diff -Naur old/Makefile.PL new/Makefile.PL
+--- old/Makefile.PL	2010-06-01 13:31:02.000000000 +1000
++++ new/Makefile.PL	2014-04-10 20:10:18.746011784 +1000
+@@ -10,7 +10,7 @@
+ 	           },
+     'NAME'	=> 'Compress::LZF',
+     'VERSION_FROM' => 'LZF.pm',
+-    'LIBS'	=> [''],
++    'LIBS'	=> ['-llzf'],
+     'DEFINE'	=> '',
+     'INC'	=> '',
+ );
+diff -Naur old/t/03_freeze_best.t new/t/03_freeze_best.t
+--- old/t/03_freeze_best.t	2013-08-26 04:09:36.000000000 +1000
++++ new/t/03_freeze_best.t	1970-01-01 10:00:00.000000000 +1000
+@@ -1,59 +0,0 @@
+-BEGIN {
+-   eval "use Storable; 1" or do {
+-      print "1..0 # skip Storable module unavailable\n";
+-      exit;
+-   };
+-}
+-
+-BEGIN { $| = 1; print "1..1959\n"; }
+-
+-END {print "not ok 1\n" unless $loaded;}
+-use Compress::LZF ':freeze';
+-use Storable;
+-$loaded = 1;
+-print "ok 1\n";
+-
+-$tst = 0;
+-
+-sub ok {
+-   print (($_[0] ? "ok " : "not ok "), 1+ ++$tst, "\n");
+-}
+-
+-sub chk {
+-   my $s = shift;
+-   my $n  = sfreeze_best    $s; ok(1);
+-   my $nr = sfreeze_cr_best $s; ok(1);
+-   my $nc = sfreeze_c_best  $s; ok(1);
+-   my $r  = sfreeze_best   \$s; ok(1);
+-   my $rr = sfreeze_cr_best\$s; ok(1);
+-   my $rc = sfreeze_c_best \$s; ok(1);
+-
+-   ok (length ($n) >= length ($nc));
+-   ok (length ($n) <= length ($r));
+-   ok (length ($r) >= length ($rr));
+-   ok ($rr eq $rc);
+-   ok (length ($r) >= length ($rr));
+-
+-   #print unpack("H*", $s), " => ", unpack("H*", $rc), "\n";
+-
+-   ok ($s eq sthaw $n);
+-   ok ($s eq sthaw $nr);
+-   ok ($s eq sthaw $nc);
+-   ok ($s eq ${sthaw $r});
+-   ok ($s eq ${sthaw $rr});
+-   ok ($s eq ${sthaw $rc});
+-}
+-
+-for my $pfx (0, 1, 4, 6, 7, 40, ord('x'), 240..255) {
+-   chk $pfx;
+-   $pfx =~ /(.*)/;
+-   chk $1;
+-   chk chr($pfx)."x";
+-   chk chr($pfx)."xxxxxxxxxxxxx";
+-   chk chr($pfx)."abcdefghijklm";
+-}
+-
+-ok (eval {sthaw undef; 1});
+-ok (!eval {sthaw "\x07"; 1});
+-ok (!defined sthaw sfreeze_best undef);
+-
diff --git a/perl-Compress-LZF.spec b/perl-Compress-LZF.spec
new file mode 100644
index 0000000..6d59234
--- /dev/null
+++ b/perl-Compress-LZF.spec
@@ -0,0 +1,50 @@
+Name:           perl-Compress-LZF
+Version:        3.7
+Release:        1%{?dist}
+Summary:        Extremely light-weight Lempel-Ziv-Free compression
+License:        GPL+ or Artistic
+# patch to address https://fedoraproject.org/wiki/Common_Rpmlint_issues#incorrect-fsf-address has been sent upstream at https://rt.cpan.org/Ticket/Display.html?id=93643
+Group:          Development/Libraries
+URL:            http://search.cpan.org/dist/Compress-LZF/
+Source0:        http://www.cpan.org/modules/by-module/Compress/Compress-LZF-%{version}.tar.gz
+Patch1:         compress_lzf_unbundle.patch
+BuildRequires:  liblzf-devel
+BuildRequires:  perl
+BuildRequires:  perl(DynaLoader)
+BuildRequires:  perl(Exporter)
+BuildRequires:  perl(ExtUtils::MakeMaker)
+BuildRequires:  perl(Storable)
+Requires:       perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
+
+%description
+This is Perl binding to the LZF compression library.
+
+%prep
+%setup -q -n Compress-LZF-%{version}
+
+%patch1 -p1
+
+%build
+%{__perl} Makefile.PL INSTALLDIRS=vendor OPTIMIZE="$RPM_OPT_FLAGS"
+make %{?_smp_mflags}
+
+%install
+make pure_install PERL_INSTALL_ROOT=$RPM_BUILD_ROOT
+
+find $RPM_BUILD_ROOT -type f -name .packlist -exec rm -f {} \;
+find $RPM_BUILD_ROOT -type f -name '*.bs' -size 0 -exec rm -f {} \;
+
+%{_fixperms} $RPM_BUILD_ROOT/*
+
+%check
+make test
+
+%files
+%doc Changes COPYING COPYING.Artistic COPYING.GNU README
+%{perl_vendorarch}/auto/*
+%{perl_vendorarch}/Compress*
+%{_mandir}/man3/*
+
+%changelog
+* Sat Mar 8 2014 David Dick <ddick@xxxxxxxx> - 3.7-1
+- Initial release
diff --git a/sources b/sources
index e69de29..56cdd04 100644
--- a/sources
+++ b/sources
@@ -0,0 +1 @@
+a23ffab4875d4cff4795023c95a5360f  Compress-LZF-3.7.tar.gz
--
Fedora Extras Perl SIG
http://www.fedoraproject.org/wiki/Extras/SIGs/Perl
perl-devel mailing list
perl-devel@xxxxxxxxxxxxxxxxxxxxxxx
https://admin.fedoraproject.org/mailman/listinfo/perl-devel





[Index of Archives]     [Fedora Announce]     [Fedora Kernel]     [Fedora Testing]     [Fedora Legacy Announce]     [Fedora PHP Devel]     [Kernel Devel]     [Fedora Legacy]     [Fedora Maintainers]     [Fedora Desktop]     [PAM]     [Red Hat Development]     [Big List of Linux Books]     [Gimp]     [Yosemite Information]
  Powered by Linux