Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,5 +1,5 @@
V crc_table = [0] * 256
L(i) 256
L(i) 0.<256
UInt32 rem = i
L 8
I rem [&] 1 != 0

View file

@ -32,7 +32,7 @@ PROC update_crc = (BITS crc, STRING buf) BITS:
PROC hex = (BITS x) STRING :
BEGIN
PROC hexdig = (BITS x) CHAR: REPR (IF ABS x 9 THEN ABS x + ABS "0"
PROC hexdig = (BITS x) CHAR: REPR (IF ABS x <= 9 THEN ABS x + ABS "0"
ELSE ABS x - 10 + ABS "a"
FI);
STRING h := "";
@ -40,7 +40,7 @@ PROC update_crc = (BITS crc, STRING buf) BITS:
h := "0"
ELSE
BITS n := x;
WHILE h := hexdig (n AND 16rf) + h; n 16r0 DO
WHILE h := hexdig (n AND 16rf) + h; n /= 16r0 DO
n := n SHR 4
OD
FI;

View file

@ -1,14 +0,0 @@
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.CRC32; use GNAT.CRC32;
with Interfaces; use Interfaces;
procedure TestCRC is
package IIO is new Ada.Text_IO.Modular_IO (Unsigned_32);
crc : CRC32;
num : Unsigned_32;
str : String := "The quick brown fox jumps over the lazy dog";
begin
Initialize (crc);
Update (crc, str);
num := Get_Value (crc);
IIO.Put (num, Base => 16); New_Line;
end TestCRC;

View file

@ -1,37 +0,0 @@
*> tectonics: cobc -xj crc32-zlib.cob -lz
identification division.
program-id. rosetta-crc32.
environment division.
configuration section.
repository.
function all intrinsic.
data division.
working-storage section.
01 crc32-initial usage binary-c-long.
01 crc32-result usage binary-c-long unsigned.
01 crc32-input.
05 value "The quick brown fox jumps over the lazy dog".
01 crc32-hex usage pointer.
procedure division.
crc32-main.
*> libz crc32
call "crc32" using
by value crc32-initial
by reference crc32-input
by value length(crc32-input)
returning crc32-result
on exception
display "error: no crc32 zlib linkage" upon syserr
end-call
call "printf" using "checksum: %lx" & x"0a" by value crc32-result
*> GnuCOBOL pointers are displayed in hex by default
set crc32-hex up by crc32-result
display 'crc32 of "' crc32-input '" is ' crc32-hex
goback.
end program rosetta-crc32.

View file

@ -1,4 +1,5 @@
func crc32 buf$[] .
global table[] .
proc mktable .
for i = 0 to 0xff
rem = i
for j to 8
@ -10,13 +11,15 @@ func crc32 buf$[] .
.
table[] &= rem
.
.
func crc32 s$ .
crc = 0xffffffff
for c$ in buf$[]
for c$ in strchars s$
c = strcode c$
crb = bitxor bitand crc 0xff c
crc = bitxor (bitshift crc -8) table[crb + 1]
.
return bitnot crc
return bitand bitnot crc 0xffffffff
.
s$ = "The quick brown fox jumps over the lazy dog"
print crc32 strchars s$
mktable
print crc32 "The quick brown fox jumps over the lazy dog"

View file

@ -1,9 +0,0 @@
using StringTools;
class Main {
static function main() {
var data = haxe.io.Bytes.ofString("The quick brown fox jumps over the lazy dog");
var crc = haxe.crypto.Crc32.make(data);
Sys.println(crc.hex());
}
}

View file

@ -1,31 +1,31 @@
function crc32(crc::Int, str::String)
table = zeros(UInt32, 256)
table = zeros(UInt32, 256)
for i in 0:255
tmp = i
for j in 0:7
if tmp & 1 == 1
tmp >>= 1
tmp ⊻= 0xedb88320
else
tmp >>= 1
end
end
for i in 0:255
tmp = i
for j in 0:7
if tmp & 1 == 1
tmp >>= 1
tmp ⊻= 0xedb88320
else
tmp >>= 1
end
end
table[i + 1] = tmp
end
table[i+1] = tmp
end
crc ⊻= 0xffffffff
crc ⊻= 0xffffffff
for i in UInt32.(collect(str))
crc = (crc >> 8) table[(crc & 0xff) i + 1]
end
for i in UInt32.(collect(str))
crc = (crc >> 8) table[(crc&0xff)i+1]
end
crc 0xffffffff
crc 0xffffffff
end
str = "The quick brown fox jumps over the lazy dog"
crc = crc32(0, str)
assert(crc == 0x414fa339)
@assert(crc == 0x414fa339)
println("Message: ", str)
println("Checksum: ", hex(crc))
println("Checksum: ", string(crc, base = 16))

View file

@ -1,8 +1,8 @@
>>> s = 'The quick brown fox jumps over the lazy dog'
>>> import zlib
>>> hex(zlib.crc32(s))
>>> hex(zlib.crc32(s.encode()))
'0x414fa339'
>>> import binascii
>>> hex(binascii.crc32(s))
>>> hex(binascii.crc32(s.encode()))
'0x414fa339'

View file

@ -1,32 +0,0 @@
dim crctbl(255)
const crcc =&hEDB88320
sub gencrctable
for i= 0 to 255
k=i
for j=1 to 8
if k and 1 then
k=(k and &h7fffffff)\2 or (&h40000000 and ((k and &h80000000)<>0))
k=k xor crcc
else
k=(k and &h7fffffff)\2 or (&h40000000 and ((k and &h80000000)<>0))
end if
next ' j
crctbl(i)=k
next
end sub
function crc32 (buf)
dim r,r1,i
r=&hffffffff
for i=1 to len(buf)
r1=(r and &h7fffffff)\&h100 or (&h800000 and (r and &h80000000)<>0)
r=r1 xor crctbl((asc(mid(buf,i,1))xor r) and 255)
next
crc32=r xor &hffffffff
end function
'414FA339
gencrctable
wscript.stdout.writeline hex(crc32("The quick brown fox jumps over the lazy dog"))