]> gitweb.factorcode.org Git - factor.git/commitdiff
checksums.crc16: moving to basis from extra.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 16 Aug 2016 23:21:08 +0000 (16:21 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 16 Aug 2016 23:21:08 +0000 (16:21 -0700)
basis/checksums/crc16/authors.txt [new file with mode: 0644]
basis/checksums/crc16/crc16-docs.factor [new file with mode: 0644]
basis/checksums/crc16/crc16-tests.factor [new file with mode: 0644]
basis/checksums/crc16/crc16.factor [new file with mode: 0644]
basis/checksums/crc16/summary.txt [new file with mode: 0644]
extra/checksums/crc16/authors.txt [deleted file]
extra/checksums/crc16/crc16-docs.factor [deleted file]
extra/checksums/crc16/crc16-tests.factor [deleted file]
extra/checksums/crc16/crc16.factor [deleted file]
extra/checksums/crc16/summary.txt [deleted file]

diff --git a/basis/checksums/crc16/authors.txt b/basis/checksums/crc16/authors.txt
new file mode 100644 (file)
index 0000000..8e1955f
--- /dev/null
@@ -0,0 +1 @@
+Alexander Ilin
diff --git a/basis/checksums/crc16/crc16-docs.factor b/basis/checksums/crc16/crc16-docs.factor
new file mode 100644 (file)
index 0000000..81dcd24
--- /dev/null
@@ -0,0 +1,11 @@
+USING: help.markup help.syntax math ;
+IN: checksums.crc16
+
+HELP: crc16
+{ $class-description "The crc16 checksum algorithm." } ;
+
+ARTICLE: "checksums.crc16" "crc16 checksum"
+"The crc16 checksum algorithm provides a quick but unreliable way to detect changes in data. Also known as CRC-16 and CRC-16-ANSI. Used in Bisync, Modbus, USB, ANSI X3.28 and many other protocols."
+{ $subsections crc16 } ;
+
+ABOUT: "checksums.crc16"
diff --git a/basis/checksums/crc16/crc16-tests.factor b/basis/checksums/crc16/crc16-tests.factor
new file mode 100644 (file)
index 0000000..6ee242e
--- /dev/null
@@ -0,0 +1,13 @@
+! Copyright (C) 2016 Alexander Ilin.
+! See http://factorcode.org/license.txt for BSD license.
+USING: tools.test checksums checksums.crc16 ;
+IN: checksums.crc16.tests
+
+{ B{ 0xb8 0x80 } } [
+    B{ 0x01 0x04 0x02 0xFF 0xFF } crc16 checksum-bytes
+] unit-test
+
+{ B{ 0x21 0xc1 } } [
+    B{ 0x68 0x11 0x08 0x18 0x00 0x00 0x01 0x43 0x04 0x6e 0xda }
+    crc16 checksum-bytes
+] unit-test
diff --git a/basis/checksums/crc16/crc16.factor b/basis/checksums/crc16/crc16.factor
new file mode 100644 (file)
index 0000000..d70f498
--- /dev/null
@@ -0,0 +1,40 @@
+! Copyright (C) 2016 Alexander Ilin.
+! See http://factorcode.org/license.txt for BSD license.
+USING: checksums io.binary kernel math sequences
+sequences.private ;
+IN: checksums.crc16
+
+CONSTANT: crc16-polynomial 0xa001
+
+CONSTANT: crc16-table V{ }
+
+256 iota [
+    8 [
+        [ 2/ ] [ even? ] bi [ crc16-polynomial bitxor ] unless
+    ] times
+] map 0 crc16-table copy
+
+: (crc16) ( crc ch -- crc )
+    dupd bitxor
+    mask-byte crc16-table nth-unsafe
+    swap -8 shift bitxor ; inline
+
+SINGLETON: crc16
+
+INSTANCE: crc16 checksum
+
+: init-crc16 ( input checksum -- x input )
+    drop [ 0xffff ] dip ; inline
+
+: finish-crc16 ( x -- bytes )
+    2 >le ; inline
+
+M: crc16 checksum-bytes
+    init-crc16
+    [ (crc16) ] each
+    finish-crc16 ; inline
+
+M: crc16 checksum-lines
+    init-crc16
+    [ [ (crc16) ] each CHAR: \n (crc16) ] each
+    finish-crc16 ; inline 
diff --git a/basis/checksums/crc16/summary.txt b/basis/checksums/crc16/summary.txt
new file mode 100644 (file)
index 0000000..8e56424
--- /dev/null
@@ -0,0 +1 @@
+CRC16 checksum algorithm
diff --git a/extra/checksums/crc16/authors.txt b/extra/checksums/crc16/authors.txt
deleted file mode 100644 (file)
index 8e1955f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Alexander Ilin
diff --git a/extra/checksums/crc16/crc16-docs.factor b/extra/checksums/crc16/crc16-docs.factor
deleted file mode 100644 (file)
index 81dcd24..0000000
+++ /dev/null
@@ -1,11 +0,0 @@
-USING: help.markup help.syntax math ;
-IN: checksums.crc16
-
-HELP: crc16
-{ $class-description "The crc16 checksum algorithm." } ;
-
-ARTICLE: "checksums.crc16" "crc16 checksum"
-"The crc16 checksum algorithm provides a quick but unreliable way to detect changes in data. Also known as CRC-16 and CRC-16-ANSI. Used in Bisync, Modbus, USB, ANSI X3.28 and many other protocols."
-{ $subsections crc16 } ;
-
-ABOUT: "checksums.crc16"
diff --git a/extra/checksums/crc16/crc16-tests.factor b/extra/checksums/crc16/crc16-tests.factor
deleted file mode 100644 (file)
index 6ee242e..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-! Copyright (C) 2016 Alexander Ilin.
-! See http://factorcode.org/license.txt for BSD license.
-USING: tools.test checksums checksums.crc16 ;
-IN: checksums.crc16.tests
-
-{ B{ 0xb8 0x80 } } [
-    B{ 0x01 0x04 0x02 0xFF 0xFF } crc16 checksum-bytes
-] unit-test
-
-{ B{ 0x21 0xc1 } } [
-    B{ 0x68 0x11 0x08 0x18 0x00 0x00 0x01 0x43 0x04 0x6e 0xda }
-    crc16 checksum-bytes
-] unit-test
diff --git a/extra/checksums/crc16/crc16.factor b/extra/checksums/crc16/crc16.factor
deleted file mode 100644 (file)
index d70f498..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-! Copyright (C) 2016 Alexander Ilin.
-! See http://factorcode.org/license.txt for BSD license.
-USING: checksums io.binary kernel math sequences
-sequences.private ;
-IN: checksums.crc16
-
-CONSTANT: crc16-polynomial 0xa001
-
-CONSTANT: crc16-table V{ }
-
-256 iota [
-    8 [
-        [ 2/ ] [ even? ] bi [ crc16-polynomial bitxor ] unless
-    ] times
-] map 0 crc16-table copy
-
-: (crc16) ( crc ch -- crc )
-    dupd bitxor
-    mask-byte crc16-table nth-unsafe
-    swap -8 shift bitxor ; inline
-
-SINGLETON: crc16
-
-INSTANCE: crc16 checksum
-
-: init-crc16 ( input checksum -- x input )
-    drop [ 0xffff ] dip ; inline
-
-: finish-crc16 ( x -- bytes )
-    2 >le ; inline
-
-M: crc16 checksum-bytes
-    init-crc16
-    [ (crc16) ] each
-    finish-crc16 ; inline
-
-M: crc16 checksum-lines
-    init-crc16
-    [ [ (crc16) ] each CHAR: \n (crc16) ] each
-    finish-crc16 ; inline 
diff --git a/extra/checksums/crc16/summary.txt b/extra/checksums/crc16/summary.txt
deleted file mode 100644 (file)
index 8e56424..0000000
+++ /dev/null
@@ -1 +0,0 @@
-CRC16 checksum algorithm