aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHugo Hörnquist <hugo@lysator.liu.se>2020-08-23 16:31:55 +0200
committerHugo Hörnquist <hugo@lysator.liu.se>2020-08-23 16:31:55 +0200
commitb866096e7a84f59b33b90fc2e7875e2969b05df2 (patch)
tree225b88955d1314a8100dad8602d13c7933cca0f6
parentRemove custom if + *unspecified*. (diff)
downloadcalp-b866096e7a84f59b33b90fc2e7875e2969b05df2.tar.gz
calp-b866096e7a84f59b33b90fc2e7875e2969b05df2.tar.xz
Base64 now free floating top level.
-rw-r--r--module/base64.scm (renamed from module/util/base64.scm)41
-rw-r--r--module/html/util.scm3
-rw-r--r--module/vcomponent/ical/types.scm2
-rw-r--r--module/vcomponent/parse/types.scm2
-rw-r--r--module/vcomponent/xcal/parse.scm2
-rw-r--r--tests/base64.scm2
6 files changed, 26 insertions, 26 deletions
diff --git a/module/util/base64.scm b/module/base64.scm
index 148055c9..594edf1f 100644
--- a/module/util/base64.scm
+++ b/module/base64.scm
@@ -1,5 +1,7 @@
-(define-module (util base64)
- :use-module (util)
+(define-module (base64)
+ :use-module ((ice-9 optargs) :select (define*-public))
+ :use-module ((srfi srfi-71) :select (let*))
+ :use-module (srfi srfi-88) ; suffix keywords
:use-module ((rnrs bytevectors)
:select (bytevector-u8-ref
bytevector-u8-set!
@@ -66,10 +68,9 @@
(let ((aa (logior (ash a 2) (ash b -4)))
(ab (logior (ash (logand b #xF) 4) (ash c -2)))
(ac (logior (ash (logand c 3) 6) d)))
-
- (set! (ref ret (+ (* i 3) 0)) aa
- (ref ret (+ (* i 3) 1)) ab
- (ref ret (+ (* i 3) 2)) ac))))
+ (set! (ref ret (+ (* i 3) 0)) aa)
+ (set! (ref ret (+ (* i 3) 1)) ab)
+ (set! (ref ret (+ (* i 3) 2)) ac))))
(case rest
@@ -84,8 +85,8 @@
(c (encoded->real (ref bv (+ (* (floor x) 4) 2)))))
(let ((aa (logior (ash a 2) (ash b -4)))
(ab (logior (ash (logand b #xF) 4) (ash c -2))))
- (set! (ref ret (- ret-len 2)) aa
- (ref ret (- ret-len 1)) ab)))])
+ (set! (ref ret (- ret-len 2)) aa)
+ (set! (ref ret (- ret-len 1)) ab)))])
ret))))
@@ -105,30 +106,30 @@
(ab (logior (ash (logand #b11 a) 4) (ash b -4)))
(ac (logior (ash (logand b #b1111) 2) (ash c -6)))
(ad (logand c #x3F)))
- (set! (ref ret (+ (* i 4) 0)) (real->encoded aa)
- (ref ret (+ (* i 4) 1)) (real->encoded ab)
- (ref ret (+ (* i 4) 2)) (real->encoded ac)
- (ref ret (+ (* i 4) 3)) (real->encoded ad)))))
+ (set! (ref ret (+ (* i 4) 0)) (real->encoded aa))
+ (set! (ref ret (+ (* i 4) 1)) (real->encoded ab))
+ (set! (ref ret (+ (* i 4) 2)) (real->encoded ac))
+ (set! (ref ret (+ (* i 4) 3)) (real->encoded ad)))))
(case rest
[(1)
(let ((byte (ref bv (- len 1))))
(let ((a (ash byte -2))
(b (ash (logand byte 3) 4)))
- (set! (ref ret (+ 0 (* 4 iterations))) (real->encoded a)
- (ref ret (+ 1 (* 4 iterations))) (real->encoded b)
- (ref ret (+ 2 (* 4 iterations))) (char->integer #\=)
- (ref ret (+ 3 (* 4 iterations))) (char->integer #\=))))]
+ (set! (ref ret (+ 0 (* 4 iterations))) (real->encoded a))
+ (set! (ref ret (+ 1 (* 4 iterations))) (real->encoded b))
+ (set! (ref ret (+ 2 (* 4 iterations))) (char->integer #\=))
+ (set! (ref ret (+ 3 (* 4 iterations))) (char->integer #\=))))]
[(2)
(let ((byte1 (ref bv (- len 2)))
(byte2 (ref bv (- len 1))))
(let ((a (ash byte1 -2))
(b (logior (ash (logand byte1 3) 4) (ash byte2 -4 )))
(c (ash (logand byte2 #xF) 2)))
- (set! (ref ret (+ 0 (* 4 iterations))) (real->encoded a)
- (ref ret (+ 1 (* 4 iterations))) (real->encoded b)
- (ref ret (+ 2 (* 4 iterations))) (real->encoded c)
- (ref ret (+ 3 (* 4 iterations))) (char->integer #\=))))])
+ (set! (ref ret (+ 0 (* 4 iterations))) (real->encoded a))
+ (set! (ref ret (+ 1 (* 4 iterations))) (real->encoded b))
+ (set! (ref ret (+ 2 (* 4 iterations))) (real->encoded c))
+ (set! (ref ret (+ 3 (* 4 iterations))) (char->integer #\=))))])
ret))
diff --git a/module/html/util.scm b/module/html/util.scm
index c9252122..4e15356a 100644
--- a/module/html/util.scm
+++ b/module/html/util.scm
@@ -1,6 +1,5 @@
(define-module (html util)
- :use-module ((util base64)
- :select (base64encode base64decode))
+ :use-module ((base64) :select (base64encode base64decode))
:use-module (util))
;;; @var{html-attr} & @var{html-unattr} used to just strip any
diff --git a/module/vcomponent/ical/types.scm b/module/vcomponent/ical/types.scm
index f2787693..b46bb236 100644
--- a/module/vcomponent/ical/types.scm
+++ b/module/vcomponent/ical/types.scm
@@ -2,7 +2,7 @@
(define-module (vcomponent ical types)
:use-module (util)
:use-module (util exceptions)
- :use-module (util base64)
+ :use-module (base64)
:use-module (datetime))
diff --git a/module/vcomponent/parse/types.scm b/module/vcomponent/parse/types.scm
index 3ae3a74a..c12da750 100644
--- a/module/vcomponent/parse/types.scm
+++ b/module/vcomponent/parse/types.scm
@@ -1,7 +1,7 @@
(define-module (vcomponent parse types)
:use-module (util)
:use-module (util exceptions)
- :use-module (util base64)
+ :use-module (base64)
:use-module (datetime)
:use-module (srfi srfi-9 gnu)
)
diff --git a/module/vcomponent/xcal/parse.scm b/module/vcomponent/xcal/parse.scm
index 16e47e6f..a4b51b5b 100644
--- a/module/vcomponent/xcal/parse.scm
+++ b/module/vcomponent/xcal/parse.scm
@@ -1,7 +1,7 @@
(define-module (vcomponent xcal parse)
:use-module (util)
:use-module (util exceptions)
- :use-module (util base64)
+ :use-module (base64)
:use-module (ice-9 match)
:use-module (sxml match)
:use-module (vcomponent)
diff --git a/tests/base64.scm b/tests/base64.scm
index 6b862a38..b0bb992a 100644
--- a/tests/base64.scm
+++ b/tests/base64.scm
@@ -1,4 +1,4 @@
-(((util base64) base64encode base64decode))
+(((base64) base64encode base64decode))
;; Examples from RFC4648