Skip to content

Commit

Permalink
Merge pull request #47 from Zulu-Inuoe/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Zulu-Inuoe authored May 7, 2023
2 parents 535a598 + 6f5db45 commit d6428d6
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 21 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v1.1.1

Changes relative to [v1.1.0](#v110)

* **Major fix** - Fix printing floating point without fractional or exponent parts. https://github.com/Zulu-Inuoe/jzon/issues/45

## v1.1.0

Changes relative to [v1.0.0](#v100)
Expand Down
2 changes: 1 addition & 1 deletion src/com.inuoe.jzon.asd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(defsystem #:com.inuoe.jzon
:version "1.1.0"
:version "1.1.1"
:description "A correct and safe(er) JSON RFC 8259 parser with sane defaults."
:author "Wilfredo Velázquez-Rodríguez <zulu.inuoe@gmail.com>"
:license "MIT"
Expand Down
40 changes: 20 additions & 20 deletions src/schubfach.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -211,30 +211,30 @@
(setf (char buf (+ pos 1)) (code-char (ldb (byte 7 8) d)))
(+ pos 2))))

(defun %write-positive-int-digits (q0 pos buf ds)
(declare (type (unsigned-byte 31) q0)
(type (integer 0 23) pos)
(defun %write-positive-int-digits (q p buf ds)
(declare (type (unsigned-byte 31) q)
(type (integer 0 23) p)
(type (or (simple-base-string 15)
(simple-base-string 24)) buf)
(type (simple-array (unsigned-byte 16) (100)) ds))
(cond
((< q0 100)
(cond
((< q0 10)
(setf (char buf pos) (code-char (+ q0 (char-code #\0)))))
(t
(let ((d (aref ds q0)))
(setf (char buf (- pos 1)) (code-char (ldb (byte 7 0) d)))
(setf (char buf (- pos 0)) (code-char (ldb (byte 7 8) d))))))
(values))
(t
(let* ((q1 (%int32 (%>>64 (* q0 1374389535) 37)))
(let ((q0 q)
(pos p))
(loop
(setf pos (- pos 2))
(when (< q0 100)
(return))

(let* ((q1 (%int32 (%>>64 (%int64 (* q0 1374389535)) 37)))
(d (aref ds (- q0 (* q1 100)))))

(setf (char buf (- pos 1)) (code-char (ldb (byte 7 0) d)))
(setf (char buf (- pos 0)) (code-char (ldb (byte 7 8) d)))

(%write-positive-int-digits q1 (- pos 2) buf ds)))))
(setf (char buf (+ pos 0)) (code-char (ldb (byte 7 0) d)))
(setf (char buf (+ pos 1)) (code-char (ldb (byte 7 8) d)))
(setf q0 q1)))
(if (< q0 10)
(setf (char buf (+ pos 1)) (code-char (+ q0 (char-code #\0))))
(let ((d (aref ds q0)))
(setf (char buf (+ pos 0)) (code-char (ldb (byte 7 0) d)))
(setf (char buf (+ pos 1)) (code-char (ldb (byte 7 8) d))))))
(values))

(defmacro %single-float-bits (x)
#-ecl
Expand Down
12 changes: 12 additions & 0 deletions test/jzon-tests.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -1177,6 +1177,18 @@
(is (string= "5" (jzon:stringify 5)))
(is (string= "0" (jzon:stringify 0))))

(test stringify-1.0s0
(is (string= "1.0" (jzon:stringify 1.0s0))))

(test stringify-1.0d0
(is (string= "1.0" (jzon:stringify 1.0d0))))

(test strigify-12.0d0
(is (string= "12.0" (jzon:stringify 12.0d0))))

(test stringify-123456.0s0
(is (string= "123456.0" (jzon:stringify 123456.0s0))))

(test stringify-1.2d0
(is (string= "1.2" (jzon:stringify 1.2d0))))

Expand Down

0 comments on commit d6428d6

Please sign in to comment.