[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#73814: [PATCH] maint: Drop unused sample/makecrc.c.
From: |
Simon Josefsson |
Subject: |
bug#73814: [PATCH] maint: Drop unused sample/makecrc.c. |
Date: |
Tue, 15 Oct 2024 09:47:23 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) |
Hi. The makecrc.c is not longer particulary relevant since gzip uses
the gnulib crc module. The code is nice to preserve, and could be moved
to gnulib eventually (possibly rewritten), but it will still be in gzip
git forever, so doesn't have to be in the release archive. What do you
think?
/Simon
From 8d2f138b50bae43f1a208eb98ec4ebace41b0e53 Mon Sep 17 00:00:00 2001
From: Simon Josefsson <simon@josefsson.org>
Date: Tue, 15 Oct 2024 09:44:25 +0200
Subject: [PATCH] maint: Drop unused sample/makecrc.c.
---
Makefile.am | 2 +-
sample/makecrc.c | 61 ------------------------------------------------
2 files changed, 1 insertion(+), 62 deletions(-)
delete mode 100644 sample/makecrc.c
diff --git a/Makefile.am b/Makefile.am
index 1aaec82..c1fb1dd 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -47,7 +47,7 @@ EXTRA_DIST = $(ACINCLUDE_INPUTS) $(man_MANS) \
dist-check.mk \
algorithm.doc \
gunzip.in gzexe.in gzip.doc \
- revision.h sample/makecrc.c \
+ revision.h \
sample/ztouch sample/add.c sample/sub.c sample/zread.c sample/zfile \
tailor.h \
zcat.in zcmp.in zdiff.in \
diff --git a/sample/makecrc.c b/sample/makecrc.c
deleted file mode 100644
index bf789d3..0000000
--- a/sample/makecrc.c
+++ /dev/null
@@ -1,61 +0,0 @@
-/* Not copyrighted 1990 Mark Adler */
-
-#include <config.h>
-#include <stdio.h>
-
-int
-main ()
-/*
- Generate a table for a byte-wise 32-bit CRC calculation on the polynomial:
- x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1.
-
- Polynomials over GF(2) are represented in binary, one bit per coefficient,
- with the lowest powers in the most significant bit. Then adding polynomials
- is just exclusive-or, and multiplying a polynomial by x is a right shift by
- one. If we call the above polynomial p, and represent a byte as the
- polynomial q, also with the lowest power in the most significant bit (so the
- byte 0xb1 is the polynomial x^7+x^3+x+1), then the CRC is (q*x^32) mod p,
- where a mod b means the remainder after dividing a by b.
-
- This calculation is done using the shift-register method of multiplying and
- taking the remainder. The register is initialized to zero, and for each
- incoming bit, x^32 is added mod p to the register if the bit is a one (where
- x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by
- x (which is shifting right by one and adding x^32 mod p if the bit shifted
- out is a one). We start with the highest power (least significant bit) of
- q and repeat for all eight bits of q.
-
- The table is simply the CRC of all possible eight bit values. This is all
- the information needed to generate CRC's on data a byte at a time for all
- combinations of CRC register values and incoming bytes. The table is
- written to stdout as 256 long hexadecimal values in C language format.
-*/
-{
- unsigned long c; /* crc shift register */
- unsigned long e; /* polynomial exclusive-or pattern */
- int i; /* counter for all possible eight bit values */
- int k; /* byte being shifted into crc apparatus */
-
- /* terms of polynomial defining this crc (except x^32): */
- static int p[] = {0,1,2,4,5,7,8,10,11,12,16,22,23,26};
-
- /* Make exclusive-or pattern from polynomial (0xedb88320) */
- e = 0;
- for (i = 0; i < sizeof(p)/sizeof(int); i++)
- e |= 1L << (31 - p[i]);
-
- /* Compute and print table of CRC's, five per line */
- printf(" 0x00000000L");
- for (i = 1; i < 256; i++)
- {
- c = i;
- /* The idea to initialize the register with the byte instead of
- * zero was stolen from Haruhiko Okumura's ar002
- */
- for (k = 8; k; k--)
- c = c & 1 ? (c >> 1) ^ e : c >> 1;
- printf(i % 5 ? ", 0x%08lxL" : ",\n 0x%08lxL", c);
- }
- putchar('\n');
- return 0;
-}
--
2.46.0
signature.asc
Description: PGP signature
- bug#73814: [PATCH] maint: Drop unused sample/makecrc.c.,
Simon Josefsson <=