Commits

Anonymous committed 93504fa

Fix fixnum encoding bug when write-4 encounters a negative number

  • Participants
  • Parent commits 40eb43f

Comments (0)

Files changed (1)

File src/scheme-bert.ss

            (put-u8 outpr (bsr short 8))
            (put-u8 outpr (band short #xff)))
          
-         (define (write-4 outpr long)
-           (put-u8 outpr (bsr long 24))
-           (put-u8 outpr (band #xff (bsr long 16)))
-           (put-u8 outpr (band #xff (bsr long 8)))
-           (put-u8 outpr (band long #xff)))
+         (define (write-4 outpr long)         
+           (let ((b (make-bytevector 4)))
+             (bytevector-s32-set! b 0 long (endianness big))
+             (put-bytevector outpr b)))         
          
          (define (write-binary outpr data)
            (write-1 outpr BIN)