]> gitweb.factorcode.org Git - factor.git/commitdiff
byte-arrays.hex: removing HEX{ ab cd ef } in favor of B{ 0xab 0xcd 0xef }.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 9 Nov 2016 05:10:58 +0000 (21:10 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 9 Nov 2016 05:10:58 +0000 (21:10 -0800)
basis/byte-arrays/hex/authors.txt [deleted file]
basis/byte-arrays/hex/hex-docs.factor [deleted file]
basis/byte-arrays/hex/hex-tests.factor [deleted file]
basis/byte-arrays/hex/hex.factor [deleted file]
extra/crypto/aes/aes-tests.factor
extra/io/encodings/detect/detect-tests.factor
extra/io/encodings/detect/detect.factor
extra/midi/midi-tests.factor
misc/fuel/strange-syntax.factor

diff --git a/basis/byte-arrays/hex/authors.txt b/basis/byte-arrays/hex/authors.txt
deleted file mode 100644 (file)
index 8f20b8c..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-Maxim Savchenko
-Slava Pestov
diff --git a/basis/byte-arrays/hex/hex-docs.factor b/basis/byte-arrays/hex/hex-docs.factor
deleted file mode 100644 (file)
index c2cac8d..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-! Copyright (C) 2009 Maxim Savchenko, Slava Pestov.
-! See http://factorcode.org/license.txt for BSD license.
-IN: byte-arrays.hex
-USING: byte-arrays help.markup help.syntax ;
-
-HELP: HEX{
-{ $syntax "HEX{ 0123 45 67 89abcdef }" }
-{ $description "Constructs a " { $link byte-array } " from data specified in hexadecimal format. Whitespace between the curly braces is ignored. There must be an even number of hex digits or an error is thrown." } ;
diff --git a/basis/byte-arrays/hex/hex-tests.factor b/basis/byte-arrays/hex/hex-tests.factor
deleted file mode 100644 (file)
index ad78111..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-! Copyright (C) 2011 Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: byte-arrays.hex eval tools.test ;
-
-{ B{ 16 0 8 0 } } [ HEX{ 10 00 08 00 } ] unit-test
-{ B{ 255 255 15 255 255 255 } } [ HEX{ ffff 0fff ffff } ] unit-test
-
-[ "HEX{ ffff fff ffff }" parse-string ] must-fail
-[ "HEX{ 10 00 08 0 }" parse-string ] must-fail
-[ "HEX{ 1 00 00 80 }" parse-string ] must-fail
diff --git a/basis/byte-arrays/hex/hex.factor b/basis/byte-arrays/hex/hex.factor
deleted file mode 100644 (file)
index 41444b5..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-! Copyright (C) 2009,2011 Maxim Savchenko, Slava Pestov, Doug Coleman.
-! See http://factorcode.org/license.txt for BSD license.
-USING: ascii grouping kernel math.parser sequences
-strings.parser lexer math ;
-IN: byte-arrays.hex
-
-ERROR: odd-length-hex-string string ;
-
-SYNTAX: HEX{
-    "}" parse-tokens concat
-    [ blank? ] reject
-    dup length even? [ odd-length-hex-string ] unless
-    2 <groups> [ hex> ] B{ } map-as
-    suffix! ;
index 43ef7bc72ffd49ac35ca4365b952ba3f52a1e070..a2c4068cd60d4e3dbf00599e930f7be1b278ccf2 100644 (file)
@@ -1,12 +1,12 @@
 ! Copyright (C) 2008 Doug Coleman.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors byte-arrays.hex crypto.aes crypto.aes.private
-crypto.aes.utils grouping kernel sequences tools.test ;
+USING: accessors crypto.aes crypto.aes.private crypto.aes.utils
+grouping kernel sequences tools.test ;
 IN: crypto.aes.tests
 
 ! fips-197 test vectors
-CONSTANT: plaintext HEX{ 32 43 f6 a8 88 5a 30 8d 31 31 98 a2 e0 37 07 34 }
-CONSTANT: key HEX{ 2b 7e 15 16 28 ae d2 a6 ab f7 15 88 09 cf 4f 3c }
+CONSTANT: plaintext B{ 0x32 0x43 0xf6 0xa8 0x88 0x5a 0x30 0x8d 0x31 0x31 0x98 0xa2 0xe0 0x37 0x07 0x34 }
+CONSTANT: key B{ 0x2b 0x7e 0x15 0x16 0x28 0xae 0xd2 0xa6 0xab 0xf7 0x15 0x88 0x09 0xcf 0x4f 0x3c }
 
 { {
         0x00 0x01 0x02 0x04 0x08 0x10
@@ -170,7 +170,7 @@ V{ 729683222 682545830 2885096840 164581180 2700803607 2287217841
    2893506291 435870753 684796225 1465647214 3491035560 3387827593
    3779005640 3059944614 }
 } [
-  HEX{ 2b 7e 15 16 28 ae d2 a6 ab f7 15 88 09 cf 4f 3c } ! AES-128 key expansion test vector from FIPS-197 (appendix)
+  B{ 0x2b 0x7e 0x15 0x16 0x28 0xae 0xd2 0xa6 0xab 0xf7 0x15 0x88 0x09 0xcf 0x4f 0x3c } ! AES-128 key expansion test vector from FIPS-197 (appendix)
         10 (expand-enc-key)
     ] unit-test
 
index 1069af2420b01fea4c7ffc5f1508b52917eef733..112abe56122e4a37fb69ec8fc60ac422b14b7bd2 100644 (file)
@@ -1,16 +1,16 @@
 ! (c)2010 Joe Groff bsd license
-USING: byte-arrays byte-arrays.hex io.encodings.8-bit.koi8-r
+USING: byte-arrays io.encodings.8-bit.koi8-r
 io.encodings.8-bit.latin1 io.encodings.binary
 io.encodings.detect io.encodings.utf16 io.encodings.utf32
 io.encodings.utf8 namespaces tools.test ;
 IN: io.encodings.detect.tests
 
 ! UTF encodings with BOMs
-{ utf16be } [ HEX{ FEFF 0031 0032 0033 } detect-byte-array ] unit-test
-{ utf16le } [ HEX{ FFFE 3100 3200 3300 } detect-byte-array ] unit-test
-{ utf32be } [ HEX{ 0000FEFF 00000031 00000032 00000033 } detect-byte-array ] unit-test
-{ utf32le } [ HEX{ FFFE0000 31000000 32000000 33000000 } detect-byte-array ] unit-test
-{ utf8 } [ HEX{ EF BB BF 31 32 33 } detect-byte-array ] unit-test
+{ utf16be } [ B{ 0xFE 0xFF 0x00 0x31 0x00 0x32 0x00 0x33 } detect-byte-array ] unit-test
+{ utf16le } [ B{ 0xFF 0xFE 0x31 0x00 0x32 0x00 0x33 0x00 } detect-byte-array ] unit-test
+{ utf32be } [ B{ 0x00 0x00 0xFE 0xFF 0x00 0x00 0x00 0x31 0x00 0x00 0x00 0x32 0x00 0x00 0x00 0x33 } detect-byte-array ] unit-test
+{ utf32le } [ B{ 0xFF 0xFE 0x00 0x00 0x31 0x00 0x00 0x00 0x32 0x00 0x00 0x00 0x33 0x00 0x00 0x00 } detect-byte-array ] unit-test
+{ utf8 } [ B{ 0xEF 0xBB 0xBF 0x31 0x32 0x33 } detect-byte-array ] unit-test
 
 ! XML prolog
 { utf8 }
@@ -30,15 +30,15 @@ unit-test
 unit-test
 
 ! Default to utf8 if decoding succeeds and there are no nulls
-{ utf8 } [ HEX{ } detect-byte-array ] unit-test
-{ utf8 } [ HEX{ 31 32 33 } detect-byte-array ] unit-test
-{ utf8 } [ HEX{ 31 32 C2 A0 33 } detect-byte-array ] unit-test
-{ latin1 } [ HEX{ 31 32 A0 33 } detect-byte-array ] unit-test
+{ utf8 } [ B{ } detect-byte-array ] unit-test
+{ utf8 } [ B{ 0x31 0x32 0x33 } detect-byte-array ] unit-test
+{ utf8 } [ B{ 0x31 0x32 0xC2 0xA0 0x33 } detect-byte-array ] unit-test
+{ latin1 } [ B{ 0x31 0x32 0xA0 0x33 } detect-byte-array ] unit-test
 { koi8-r } [
     koi8-r default-8bit-encoding [
-        HEX{ 31 32 A0 33 } detect-byte-array
+        B{ 0x31 0x32 0xA0 0x33 } detect-byte-array
     ] with-variable
 ] unit-test
 
-{ binary } [ HEX{ 31 32 33 C2 A0 00 } detect-byte-array ] unit-test
-{ binary } [ HEX{ 31 32 33 C2 A0 00 30 } detect-byte-array ] unit-test
+{ binary } [ B{ 0x31 0x32 0x33 0xC2 0xA0 0x00 } detect-byte-array ] unit-test
+{ binary } [ B{ 0x31 0x32 0x33 0xC2 0xA0 0x00 0x30 } detect-byte-array ] unit-test
index dbf0c8d0d9d9d9e8aac43d58f9ef37badc1bf3e0..ab6158b6395147e8799be1dc73bc27481846bd01 100644 (file)
@@ -1,10 +1,10 @@
 ! (c)2010 Joe Groff bsd license
-USING: accessors byte-arrays byte-arrays.hex combinators
-continuations fry io io.encodings io.encodings.8-bit.latin1
-io.encodings.ascii io.encodings.binary io.encodings.iana
-io.encodings.string io.encodings.utf16 io.encodings.utf32
-io.encodings.utf8 io.files io.streams.string kernel literals
-math namespaces sequences strings ;
+USING: accessors byte-arrays combinators continuations fry io
+io.encodings io.encodings.8-bit.latin1 io.encodings.ascii
+io.encodings.binary io.encodings.iana io.encodings.string
+io.encodings.utf16 io.encodings.utf32 io.encodings.utf8
+io.files io.streams.string kernel literals math namespaces
+sequences strings ;
 IN: io.encodings.detect
 
 SYMBOL: default-8bit-encoding
@@ -31,11 +31,11 @@ PRIVATE>
 
 : detect-byte-array ( bytes -- encoding )
     {
-        { [ dup HEX{ 0000FEFF } head? ] [ drop utf32be ] }
-        { [ dup HEX{ FFFE0000 } head? ] [ drop utf32le ] }
-        { [ dup HEX{ FEFF } head? ] [ drop utf16be ] }
-        { [ dup HEX{ FFFE } head? ] [ drop utf16le ] }
-        { [ dup HEX{ EF BB BF } head? ] [ drop utf8 ] }
+        { [ dup B{ 0x00 0x00 0xFE 0xFF } head? ] [ drop utf32be ] }
+        { [ dup B{ 0xFF 0xFE 0x00 0x00 } head? ] [ drop utf32le ] }
+        { [ dup B{ 0xFE 0xFF } head? ] [ drop utf16be ] }
+        { [ dup B{ 0xFF 0xFE } head? ] [ drop utf16le ] }
+        { [ dup B{ 0xEF 0xBB 0xBF } head? ] [ drop utf8 ] }
         { [ dup $[ "<?xml" >byte-array ] head? ] [ detect-xml-prolog ] }
         { [ 0 over member? ] [ drop binary ] }
         { [ dup empty? ] [ drop utf8 ] }
index f019ee1e6e9ae937dd50472d58f3126cc3254f49..3e19cf0da4fa890db783a745ea9153cb87a8a853 100644 (file)
@@ -1,4 +1,4 @@
-USING: byte-arrays.hex io.encodings.binary io.streams.byte-array midi
+USING: io.encodings.binary io.streams.byte-array midi
 midi.private sequences tools.test ;
 IN: midi.tests
 
@@ -20,35 +20,35 @@ IN: midi.tests
     }
 } [
     {
-        HEX{ 00 }
-        HEX{ 40 }
-        HEX{ 7f }
-        HEX{ 81 00 }
-        HEX{ C0 00 }
-        HEX{ ff 7f }
-        HEX{ 81 80 00 }
-        HEX{ C0 80 00 }
-        HEX{ ff ff 7f }
-        HEX{ 81 80 80 00 }
-        HEX{ C0 80 80 00 }
-        HEX{ ff ff ff 7f }
+        B{ 0x00 }
+        B{ 0x40 }
+        B{ 0x7f }
+        B{ 0x81 0x00 }
+        B{ 0xC0 0x00 }
+        B{ 0xff 0x7f }
+        B{ 0x81 0x80 0x00 }
+        B{ 0xC0 0x80 0x00 }
+        B{ 0xff 0xff 0x7f }
+        B{ 0x81 0x80 0x80 0x00 }
+        B{ 0xC0 0x80 0x80 0x00 }
+        B{ 0xff 0xff 0xff 0x7f }
     } [ binary [ read-number ] with-byte-reader ] map
 ] unit-test
 
 {
     {
-        HEX{ 00 }
-        HEX{ 40 }
-        HEX{ 7f }
-        HEX{ 81 00 }
-        HEX{ C0 00 }
-        HEX{ ff 7f }
-        HEX{ 81 80 00 }
-        HEX{ C0 80 00 }
-        HEX{ ff ff 7f }
-        HEX{ 81 80 80 00 }
-        HEX{ C0 80 80 00 }
-        HEX{ ff ff ff 7f }
+        B{ 0x00 }
+        B{ 0x40 }
+        B{ 0x7f }
+        B{ 0x81 0x00 }
+        B{ 0xC0 0x00 }
+        B{ 0xff 0x7f }
+        B{ 0x81 0x80 0x00 }
+        B{ 0xC0 0x80 0x00 }
+        B{ 0xff 0xff 0x7f }
+        B{ 0x81 0x80 0x80 0x00 }
+        B{ 0xC0 0x80 0x80 0x00 }
+        B{ 0xff 0xff 0xff 0x7f }
     }
 } [
     {
@@ -232,29 +232,29 @@ IN: midi.tests
         }
     }
 } [
-    HEX{
-        4D 54 68 64
-            00 00 00 06
-            000
-            001
-            060
+    B{
+        0x4D 0x54 0x68 0x64
+            0x00 0x00 0x00 0x06
+            0x00 0x00
+            0x00 0x01
+            0x00 0x60
 
-        4D 54 72 6B
-            00 00 00 3B
-            00 FF 58 04 04 02 18 08
-            00 FF 51 03 07 A1 20
-            00 C0 05
-            00 C1 2E
-            00 C2 46
-            00 92 30 60
-            00 3C 60
-            60 91 43 40
-            60 90 4C 20
-            81 40 82 30 40
-            00 3C 40
-            00 81 43 40
-            00 80 4C 40
-            00 FF 2F 00
+        0x4D 0x54 0x72 0x6B
+            0x00 0x00 0x00 0x3B
+            0x00 0xFF 0x58 0x04 0x04 0x02 0x18 0x08
+            0x00 0xFF 0x51 0x03 0x07 0xA1 0x20
+            0x00 0xC0 0x05
+            0x00 0xC1 0x2E
+            0x00 0xC2 0x46
+            0x00 0x92 0x30 0x60
+            0x00 0x3C 0x60
+            0x60 0x91 0x43 0x40
+            0x60 0x90 0x4C 0x20
+            0x81 0x40 0x82 0x30 0x40
+            0x00 0x3C 0x40
+            0x00 0x81 0x43 0x40
+            0x00 0x80 0x4C 0x40
+            0x00 0xFF 0x2F 0x00
     } >midi
 ] unit-test
 
@@ -456,40 +456,40 @@ IN: midi.tests
         }
     }
 } [
-    HEX{
-        4D 54 68 64
-            00 00 00 06
-            001
-            004
-            060
+    B{
+        0x4D 0x54 0x68 0x64
+            0x00 0x00 0x00 0x06
+            0x00 0x01
+            0x00 0x04
+            0x00 0x60
 
-        4D 54 72 6B
-            00 00 00 14
-            00 FF 58 04 04 02 18 08
-            00 FF 51 03 07 A1 20
-            83 00 FF 2F 00
+        0x4D 0x54 0x72 0x6B
+            0x00 0x00 0x00 0x14
+            0x00 0xFF 0x58 0x04 0x04 0x02 0x18 0x08
+            0x00 0xFF 0x51 0x03 0x07 0xA1 0x20
+            0x83 0x00 0xFF 0x2F 0x00
 
-        4D 54 72 6B
-            00 00 00 10
-            00 C0 05
-            81 40 90 4C 20
-            81 40 4C 00
-            00 FF 2F 00
+        0x4D 0x54 0x72 0x6B
+            0x00 0x00 0x00 0x10
+            0x00 0xC0 0x05
+            0x81 0x40 0x90 0x4C 0x20
+            0x81 0x40 0x4C 0x00
+            0x00 0xFF 0x2F 0x00
 
-        4D 54 72 6B
-            00 00 00 0F
-            00 C1 2E
-            60 91 43 40
-            82 20 43 00
-            00 FF 2F 00
+        0x4D 0x54 0x72 0x6B
+            0x00 0x00 0x00 0x0F
+            0x00 0xC1 0x2E
+            0x60 0x91 0x43 0x40
+            0x82 0x20 0x43 0x00
+            0x00 0xFF 0x2F 0x00
 
-        4D 54 72 6B
-            00 00 00 15
-            00 C2 46
-            00 92 30 60
-            00 3C 60
-            83 00 30 00
-            00 3C 00
-            00 FF 2F 00
+        0x4D 0x54 0x72 0x6B
+            0x00 0x00 0x00 0x15
+            0x00 0xC2 0x46
+            0x00 0x92 0x30 0x60
+            0x00 0x3C 0x60
+            0x83 0x00 0x30 0x00
+            0x00 0x3C 0x00
+            0x00 0xFF 0x2F 0x00
     } >midi
 ] unit-test
index da763dc0d2152bd843c91b8189a20b48a8d44782..cdd440026b17e168a516d079c7f3f69c7ac1eda9 100644 (file)
@@ -1,4 +1,4 @@
-USING: accessors alien.c-types alien.syntax byte-arrays.hex
+USING: accessors alien.c-types alien.syntax
 classes.struct colors.constants colors.hex kernel literals logging
 math ;
 IN: strange
@@ -84,9 +84,6 @@ HS{ 9 8 3 } drop
 
 flags{ 10 20 } drop
 
-! TODO: Highlight contents too.
-HEX{ ab cd ef } drop
-
 ! ! Alien functions
 STRUCT: timeval
     { sec long }