diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2020-06-30 23:56:34 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2020-06-30 23:56:34 -0700 |
commit | 4e6f86a1ce67142c3f21ac60fdddcbc6fb6c3a22 (patch) | |
tree | 392e2dbf5b7ff1b4ea8f7c2dfe88bb53bbff5ec5 /txr.1 | |
parent | f9258408cb85cdc2fecfe19fbd3e5c902bd907ba (diff) | |
download | txr-4e6f86a1ce67142c3f21ac60fdddcbc6fb6c3a22.tar.gz txr-4e6f86a1ce67142c3f21ac60fdddcbc6fb6c3a22.tar.bz2 txr-4e6f86a1ce67142c3f21ac60fdddcbc6fb6c3a22.zip |
crc32: add optional initial crc argument.
This allows a CRC-32 calculation over multiple objects in
multiple steps.
* chksum.c (crc32_stream, crc32_buf, crc32_str, crc32): Take
additional argument.
(chksum_init): Add optional argument to registration of
crc32-stream and crc32 intrinsics.
* chksum.h (crc32_stream, crc32): Declarations updated.
* txr.1: Doc updated; two examples added.
Diffstat (limited to 'txr.1')
-rw-r--r-- | txr.1 | 38 |
1 files changed, 34 insertions, 4 deletions
@@ -55574,7 +55574,7 @@ savings time). .coNP Function @ crc32-stream .synb -.mets (crc32-stream < stream <> [ nbytes ]) +.mets (crc32-stream < stream >> [ nbytes <> [ crc-prev ]]) .syne .desc The @@ -55590,11 +55590,19 @@ integer. It gives the number of bytes which should be read and included in the sum. If the argument is omitted, then bytes are read until the end of the stream. -The CRC-32 is returned as a non-negative integer. +The optional +.meta crc-prev +argument defaults to zero. It is fully documented under the +.code crc32 +function. + +The +.code crc32-stream +functions returns the calculated CRC-32 as a non-negative integer. .coNP Function @ crc32 .synb -.mets (crc32 << obj ) +.mets (crc32 < obj <> [ crc-prev ]) .syne .desc The @@ -55613,7 +55621,29 @@ If is a character string, then the sum is calculated over the bytes which constitute its UTF-8 representation. -The CRC-32 is returned as a non-negative integer. +The optional +.meta crc-prev +argument defaults to zero. If specified, it should be a nonnegative integer in +the 32 bit range. This argument is useful when a single CRC-32 must be +calculated in multiple operations over several objects. The first call should +specify a value of zero, or omit the argument. To continue the checksum, +each subsequent call to the function should pass as the +.meta crc-prev +argument the CRC-32 obtained from the previous call. + +The +.code crc32 +function returns the calculated CRC-32 as a non-negative integer. + +.TP* Examples: + +.mono + ;; Single operation + (crc32 "ABCD") --> 3675725989 + + ;; In two steps, demonstrating crc-prev argument: + (crc32 "CD" (crc32 "AB")) -> 3675725989 +.onom .coNP Functions @ sha256-stream and @ md5-stream .synb |