diff --git a/websockets.scm b/websockets.scm index c4a761b..a8eed6d 100644 --- a/websockets.scm +++ b/websockets.scm @@ -23,10 +23,17 @@ ;; fragment-optype ) -(import chicken scheme data-structures extras ports posix foreign - srfi-13 srfi-14 srfi-18) -(use srfi-1 srfi-4 spiffy intarweb uri-common base64 simple-sha1 - mailbox comparse) +(cond-expand + (chicken-4 + (import chicken scheme data-structures extras ports posix foreign + srfi-13 srfi-14 srfi-18) + (use srfi-1 srfi-4 spiffy intarweb uri-common base64 simple-sha1 + mailbox comparse)) + (chicken-5 + (import scheme srfi-4 srfi-8 srfi-13 srfi-14 srfi-18 base64 comparse + intarweb mailbox simple-sha1 spiffy (chicken base) (chicken blob) + (chicken bitwise) (chicken condition) (chicken foreign) + (chicken io)))) (define-inline (neq? obj1 obj2) (not (eq? obj1 obj2))) @@ -248,12 +255,12 @@ (bl1 (read-byte inbound-port))) (set! frame-payload-length (+ (arithmetic-shift bl0 8) bl1)))) ((= frame-payload-length 127) - (define (shift i r) - (if (< i 0) - r - (shift (- i 1) (+ (arithmetic-shift (read-byte inbound-port) (* 8 i)) - r)))) - (set! frame-payload-length (shift 7 0)))) + (letrec ((shift (lambda (i r) + (if (< i 0) + r + (shift (- i 1) (+ (arithmetic-shift (read-byte inbound-port) (* 8 i)) + r)))))) + (set! frame-payload-length (shift 7 0))))) (when (or (> frame-payload-length (max-frame-size)) (> (+ frame-payload-length total-size) (max-message-size))) (signal (make-websocket-exception