base16/32/64/85/91: declare base>ch as fixnum.
parent
c6e14ce3ca
commit
53d404a150
|
@ -1,8 +1,8 @@
|
|||
! Copyright (C) 2008 Doug Coleman, Daniel Ehrenberg.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: arrays assocs byte-arrays combinators fry io io.binary
|
||||
io.encodings.binary io.streams.byte-array kernel literals math
|
||||
namespaces sbufs sequences ;
|
||||
io.encodings.binary io.streams.byte-array kernel kernel.private
|
||||
literals math namespaces sbufs sequences ;
|
||||
IN: base64
|
||||
|
||||
ERROR: malformed-base64 ;
|
||||
|
@ -26,7 +26,7 @@ CONSTANT: alphabet $[
|
|||
|
||||
: base64>ch ( ch -- ch )
|
||||
$[ alphabet alphabet-inverse 0 CHAR: = pick set-nth ] nth
|
||||
[ malformed-base64 ] unless* ; inline
|
||||
[ malformed-base64 ] unless* { fixnum } declare ; inline
|
||||
|
||||
: (write-lines) ( column byte-array -- column' )
|
||||
output-stream get dup '[
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
! Copyright (C) 2019 John Benediktsson.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: base64.private byte-arrays combinators io
|
||||
io.encodings.binary io.streams.byte-array kernel literals locals
|
||||
math namespaces sequences ;
|
||||
io.encodings.binary io.streams.byte-array kernel kernel.private
|
||||
literals locals math namespaces sequences ;
|
||||
IN: base16
|
||||
|
||||
ERROR: malformed-base16 ;
|
||||
|
@ -20,7 +20,7 @@ CONSTANT: alphabet $[ "0123456789ABCDEF" >byte-array ]
|
|||
|
||||
: base16>ch ( ch -- ch )
|
||||
$[ alphabet alphabet-inverse ] nth
|
||||
[ malformed-base16 ] unless* ; inline
|
||||
[ malformed-base16 ] unless* { fixnum } declare ; inline
|
||||
|
||||
:: (encode-base16) ( stream -- )
|
||||
stream stream-read1 [
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
! Copyright (C) 2019 John Benediktsson
|
||||
! See http://factorcode.org/license.txt for BSD license
|
||||
USING: base64.private byte-arrays combinators fry io io.binary
|
||||
io.encodings.binary io.streams.byte-array kernel literals math
|
||||
namespaces sequences ;
|
||||
io.encodings.binary io.streams.byte-array kernel kernel.private
|
||||
literals math namespaces sequences ;
|
||||
IN: base32
|
||||
|
||||
ERROR: malformed-base32 ;
|
||||
|
@ -22,7 +22,7 @@ CONSTANT: alphabet $[ "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" >byte-array ]
|
|||
|
||||
: base32>ch ( ch -- ch )
|
||||
$[ alphabet alphabet-inverse 0 CHAR: = pick set-nth ] nth
|
||||
[ malformed-base32 ] unless* ; inline
|
||||
[ malformed-base32 ] unless* { fixnum } declare ; inline
|
||||
|
||||
: encode5 ( seq -- byte-array )
|
||||
be> { -35 -30 -25 -20 -15 -10 -5 0 } '[
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
! Copyright (C) 2013 John Benediktsson.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: base64.private byte-arrays combinators io io.binary
|
||||
io.encodings.binary io.streams.byte-array kernel literals math
|
||||
namespaces sequences ;
|
||||
io.encodings.binary io.streams.byte-array kernel kernel.private
|
||||
literals math namespaces sequences ;
|
||||
IN: base85
|
||||
|
||||
ERROR: malformed-base85 ;
|
||||
|
@ -21,7 +21,7 @@ CONSTANT: alphabet $[
|
|||
|
||||
: base85>ch ( ch -- ch )
|
||||
$[ alphabet alphabet-inverse ] nth
|
||||
[ malformed-base85 ] unless* ; inline
|
||||
[ malformed-base85 ] unless* { fixnum } declare ; inline
|
||||
|
||||
: encode4 ( seq -- seq' )
|
||||
be> 5 [ 85 /mod ch>base85 ] B{ } replicate-as reverse! nip ; inline
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
! Copyright (C) 2019 John Benediktsson.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
USING: base64.private byte-arrays kernel literals locals math
|
||||
sequences ;
|
||||
USING: base64.private byte-arrays kernel kernel.private
|
||||
literals locals math sequences ;
|
||||
IN: base91
|
||||
|
||||
ERROR: malformed-base91 ;
|
||||
|
@ -20,7 +20,7 @@ CONSTANT: alphabet $[
|
|||
|
||||
: base91>ch ( ch -- ch )
|
||||
$[ alphabet alphabet-inverse ] nth
|
||||
[ malformed-base91 ] unless* ; inline
|
||||
[ malformed-base91 ] unless* { fixnum } declare ; inline
|
||||
|
||||
PRIVATE>
|
||||
|
||||
|
|
Loading…
Reference in New Issue