From b37199fdc4277cb4ff15d34bf482490343d4fb39 Mon Sep 17 00:00:00 2001 From: Louis Brauer Date: Thu, 5 Oct 2023 01:29:49 +0200 Subject: [PATCH 01/11] Add LispWorks 8 for structure serialization --- src/jzon.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jzon.lisp b/src/jzon.lisp index 298e5ce..986d7df 100644 --- a/src/jzon.lisp +++ b/src/jzon.lisp @@ -1156,7 +1156,7 @@ Example return value: ") (:method (element) nil) - #+(or ccl clisp sbcl) + #+(or ccl clisp sbcl lispworks8) (:method ((element structure-object)) (%coerced-fields-slots element)) (:method ((element standard-object)) From d7d517e703e581bc8e8e11748b504561d4550ea7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilfredo=20Vel=C3=A1zquez-Rodr=C3=ADguez?= Date: Fri, 6 Oct 2023 07:07:44 -0400 Subject: [PATCH 02/11] Changelog bump --- CHANGELOG.md | 2 ++ src/com.inuoe.jzon.asd | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a6e4e5..54dc63a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ Changes relative to [v1.1.2](#v112) +* LispWorks 8 Structure Serialization + ## v1.1.2 Changes relative to [v1.1.1](#v111) diff --git a/src/com.inuoe.jzon.asd b/src/com.inuoe.jzon.asd index 34b8312..a2ea1ce 100644 --- a/src/com.inuoe.jzon.asd +++ b/src/com.inuoe.jzon.asd @@ -1,5 +1,5 @@ (defsystem #:com.inuoe.jzon - :version "1.1.2" + :version "1.1.3" :description "A correct and safe(er) JSON RFC 8259 parser with sane defaults." :author "Wilfredo Velázquez-Rodríguez " :license "MIT" From 938fc430fcc134fb73df14e36e74dca91647b945 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilfredo=20Vel=C3=A1zquez-Rodr=C3=ADguez?= Date: Thu, 19 Oct 2023 10:43:15 -0400 Subject: [PATCH 03/11] Fix error when reading/writing pathnames on LispWorks Fixes https://github.com/Zulu-Inuoe/jzon/issues/56 --- CHANGELOG.md | 1 + src/jzon.lisp | 7 ++++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54dc63a..88be561 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ Changes relative to [v1.1.2](#v112) * LispWorks 8 Structure Serialization +* Fix error when reading/writing from/to pathnames on LispWorks (https://github.com/Zulu-Inuoe/jzon/issues/56) ## v1.1.2 diff --git a/src/jzon.lisp b/src/jzon.lisp index 986d7df..5d91ff2 100644 --- a/src/jzon.lisp +++ b/src/jzon.lisp @@ -700,7 +700,7 @@ see `close-parser'" (multiple-value-bind (input close-action) (typecase in (pathname - (let ((f (open in :direction :input :external-format :utf-8))) + (let ((f (open in :direction :input :external-format :utf-8 :element-type 'character))) (values f (lambda () (close f))))) (t (values in (lambda ())))) (let ((parser (make-instance 'parser)) @@ -1125,7 +1125,7 @@ see `close-parser'" (typecase in (pathname - (with-open-file (in in :direction :input :external-format :utf-8) + (with-open-file (in in :direction :input :external-format :utf-8 :element-type 'character) (parse in :max-depth max-depth :allow-comments allow-comments :allow-trailing-comma allow-trailing-comma :allow-multiple-content allow-multiple-content :max-string-length max-string-length :key-fn key-fn))) (t (multiple-value-bind (%step %read-string %pos) (%make-fns in max-string-length) @@ -1305,7 +1305,8 @@ Example return value: (let ((stream (open stream :direction :output :if-does-not-exist :create :if-exists :supersede - :external-format :utf-8))) + :external-format :utf-8 + :element-type 'character))) (values stream (lambda () (close stream))))) ((streamp stream) (unless (output-stream-p stream) From 4606ba366c1fe72c03ae5b3e6762fadc9ac147a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilfredo=20Vel=C3=A1zquez-Rodr=C3=ADguez?= Date: Sat, 21 Oct 2023 15:17:11 -0400 Subject: [PATCH 04/11] Export `jzon:parser` --- CHANGELOG.md | 1 + src/jzon.lisp | 1 + 2 files changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88be561..2c1bff7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Changes relative to [v1.1.2](#v112) * LispWorks 8 Structure Serialization * Fix error when reading/writing from/to pathnames on LispWorks (https://github.com/Zulu-Inuoe/jzon/issues/56) +* Export `jzon:parser` ## v1.1.2 diff --git a/src/jzon.lisp b/src/jzon.lisp index 5d91ff2..8d11ea9 100644 --- a/src/jzon.lisp +++ b/src/jzon.lisp @@ -5,6 +5,7 @@ #:parse ;;;; Streaming reader + #:parser #:make-parser #:parse-next #:parse-next-element From 67065cb4ebf0f649980ab0e643e81a2cdd824dbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilfredo=20Vel=C3=A1zquez-Rodr=C3=ADguez?= Date: Tue, 14 Nov 2023 13:26:53 -0500 Subject: [PATCH 05/11] Avoid pulling `car` twice --- src/jzon.lisp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/jzon.lisp b/src/jzon.lisp index 8d11ea9..2d929e4 100644 --- a/src/jzon.lisp +++ b/src/jzon.lisp @@ -969,9 +969,9 @@ see `close-parser'" (return value) (let ((container (car stack))) (if (listp container) - (progn (push value (the list (car stack))) + (progn (setf (car stack) (cons value (the list container))) (incf (the (integer 0) (car len)))) - (setf (gethash (pop key) (the hash-table (car stack))) value)))))) + (setf (gethash (pop key) (the hash-table container)) value)))))) (inc-depth () `(progn (when (= depth %max-depth) @@ -1033,9 +1033,9 @@ see `close-parser'" (setf top value)) (let ((container (car stack))) (if (listp container) - (progn (push value (the list (car stack))) + (progn (setf (car stack) (cons value (the list container))) (incf (the (integer 0) (car len)))) - (setf (gethash (pop key) (the hash-table (car stack))) value)))))) + (setf (gethash (pop key) (the hash-table container)) value)))))) (inc-depth () `(progn (when (= depth %max-depth) From a9fb389a57f7a105867ff1dba3810aa6e00251bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilfredo=20Vel=C3=A1zquez-Rodr=C3=ADguez?= Date: Tue, 14 Nov 2023 22:02:26 -0500 Subject: [PATCH 06/11] Unused var --- src/jzon.lisp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/jzon.lisp b/src/jzon.lisp index 2d929e4..edd43f6 100644 --- a/src/jzon.lisp +++ b/src/jzon.lisp @@ -401,7 +401,6 @@ see `json-atom'" (declare (type (integer 1) n)) (loop :with line :of-type (integer 1) := 1 :with col :of-type (integer 1) := 1 - :with cr := nil :for p :from 0 :below (1- n) :for c := (%step step) :do (case c From 5e8f69cef0dac1f886584fb4ee0f9764b3d98c1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilfredo=20Vel=C3=A1zquez-Rodr=C3=ADguez?= Date: Tue, 14 Nov 2023 23:07:09 -0500 Subject: [PATCH 07/11] indent --- src/jzon.lisp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/jzon.lisp b/src/jzon.lisp index edd43f6..5a175b7 100644 --- a/src/jzon.lisp +++ b/src/jzon.lisp @@ -250,16 +250,16 @@ see `json-atom'" (macrolet ((%read-code-point () `(logior (ash (or (digit-char-p (or (%step step) (%raise 'json-eof-error pos "Unexpected end of input reading unicode escape code in string")) 16) (%raise 'json-parse-error pos "Non-digit in unicode escape code in string")) - 12) - (ash (or (digit-char-p (or (%step step) (%raise 'json-eof-error pos "Unexpected end of input reading unicode escape code in string")) 16) + 12) + (ash (or (digit-char-p (or (%step step) (%raise 'json-eof-error pos "Unexpected end of input reading unicode escape code in string")) 16) (%raise 'json-parse-error pos "Non-digit in unicode escape code in string")) - 8) - (ash (or (digit-char-p (or (%step step) (%raise 'json-eof-error pos "Unexpected end of input reading unicode escape code in string")) 16) + 8) + (ash (or (digit-char-p (or (%step step) (%raise 'json-eof-error pos "Unexpected end of input reading unicode escape code in string")) 16) (%raise 'json-parse-error pos "Non-digit in unicode escape code in string")) - 4) - (ash (or (digit-char-p (or (%step step) (%raise 'json-eof-error pos "Unexpected end of input reading unicode escape code in string")) 16) - (%raise 'json-parse-error pos "Non-digit in unicode escape code in string")) - 0)))) + 4) + (ash (or (digit-char-p (or (%step step) (%raise 'json-eof-error pos "Unexpected end of input reading unicode escape code in string")) 16) + (%raise 'json-parse-error pos "Non-digit in unicode escape code in string")) + 0)))) (let ((code-point (%read-code-point))) (code-char (if (<= #xD800 code-point #xDBFF) From 1f7799dc9dd938a0a9cb8f41b83098e704b21d93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilfredo=20Vel=C3=A1zquez-Rodr=C3=ADguez?= Date: Tue, 21 Nov 2023 20:09:36 -0500 Subject: [PATCH 08/11] Fix unit tests under LispWorks We want single-float, but s0 indicates short-float Fixes https://github.com/Zulu-Inuoe/jzon/issues/57 --- CHANGELOG.md | 1 + test/jzon-tests.lisp | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c1bff7..1d99cd0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ Changes relative to [v1.1.2](#v112) * LispWorks 8 Structure Serialization * Fix error when reading/writing from/to pathnames on LispWorks (https://github.com/Zulu-Inuoe/jzon/issues/56) * Export `jzon:parser` +* Fix unit tests on LispWorks (https://github.com/Zulu-Inuoe/jzon/issues/57) ## v1.1.2 diff --git a/test/jzon-tests.lisp b/test/jzon-tests.lisp index 8d19235..3e4c1d2 100644 --- a/test/jzon-tests.lisp +++ b/test/jzon-tests.lisp @@ -1177,8 +1177,8 @@ (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.0f0 + (is (string= "1.0" (jzon:stringify 1.0f0)))) (test stringify-1.0d0 (is (string= "1.0" (jzon:stringify 1.0d0)))) @@ -1186,14 +1186,14 @@ (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-123456.0f0 + (is (string= "123456.0" (jzon:stringify 123456.0f0)))) (test stringify-1.2d0 (is (string= "1.2" (jzon:stringify 1.2d0)))) -(test stringify-1.2s0 - (is (string= "1.2" (jzon:stringify 1.2s0)))) +(test stringify-1.2f0 + (is (string= "1.2" (jzon:stringify 1.2f0)))) (test stringify-strings (is (string= "\"hello, world!\"" (jzon:stringify "hello, world!"))) @@ -1255,17 +1255,17 @@ (let ((*print-base* 2)) (is (string= "{\"10\":10}" (jzon:stringify (ph 10 10))))))) -(test stringify-coerce-key-writes-single-floats-without-s0 +(test stringify-coerce-key-writes-single-floats-without-f0 (with-standard-io-syntax - (is (string= "{\"1.5\":1.5}" (jzon:stringify (ph 1.5s0 1.5s0)))) + (is (string= "{\"1.5\":1.5}" (jzon:stringify (ph 1.5f0 1.5f0)))) (let ((*read-default-float-format* 'double-float)) - (is (string= "{\"1.5\":1.5}" (jzon:stringify (ph 1.5s0 1.5s0))))))) + (is (string= "{\"1.5\":1.5}" (jzon:stringify (ph 1.5f0 1.5f0))))))) (test stringify-coerce-key-writes-double-floats-without-d0 (with-standard-io-syntax (is (string= "{\"1.5\":1.5}" (jzon:stringify (ph 1.5d0 1.5d0)))) (let ((*read-default-float-format* 'double-float)) - (is (string= "{\"1.5\":1.5}" (jzon:stringify (ph 1.5s0 1.5s0))))))) + (is (string= "{\"1.5\":1.5}" (jzon:stringify (ph 1.5f0 1.5f0))))))) (test stringify-coerce-key-writes-rationals-like-floats (with-standard-io-syntax From 67c0411916222f5efbadcb47b7e9bc0a12297780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilfredo=20Vel=C3=A1zquez-Rodr=C3=ADguez?= Date: Wed, 20 Dec 2023 20:44:25 -0500 Subject: [PATCH 09/11] Remove several risky dynamic-extent decls On SBCL 2.3.10, lists allocated on the stack can blow the stack for deep structures --- CHANGELOG.md | 1 + src/jzon.lisp | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d99cd0..4db7f66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ Changes relative to [v1.1.2](#v112) * Fix error when reading/writing from/to pathnames on LispWorks (https://github.com/Zulu-Inuoe/jzon/issues/56) * Export `jzon:parser` * Fix unit tests on LispWorks (https://github.com/Zulu-Inuoe/jzon/issues/57) +* Fix stack overflow on deeply nested JSON on SBCL 2.3.10+ ## v1.1.2 diff --git a/src/jzon.lisp b/src/jzon.lisp index 5a175b7..66b14c8 100644 --- a/src/jzon.lisp +++ b/src/jzon.lisp @@ -960,7 +960,6 @@ see `close-parser'" (%allow-comments (slot-value parser '%allow-comments)) (%allow-multiple-content (slot-value parser '%allow-multiple-content)) (%parser-state (slot-value parser '%parser-state))) - (declare (dynamic-extent stack key len)) (declare (type list stack key len)) (macrolet ((finish-value (value) `(let ((value ,value)) @@ -1016,7 +1015,6 @@ see `close-parser'" stack key len) - (declare (dynamic-extent %parser-state stack key)) (declare (type (integer 0 #xFFFF) depth)) (declare (type list stack key len)) (macrolet ((finish-value (value &optional check-lc) From c1289314a54cef6c3a06f8f11056581f542d8775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilfredo=20Vel=C3=A1zquez-Rodr=C3=ADguez?= Date: Wed, 20 Dec 2023 20:44:41 -0500 Subject: [PATCH 10/11] Minor indent fix --- src/jzon.lisp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jzon.lisp b/src/jzon.lisp index 66b14c8..927cd13 100644 --- a/src/jzon.lisp +++ b/src/jzon.lisp @@ -330,7 +330,7 @@ see `json-atom'" (let ((exp10 (+ exp10 (* exp-sign exp-val)))) (return (values (or (el:make-double mantissa exp10 (minusp sign)) - (rtd:ratio-to-double (* mantissa (expt 10 exp10) sign))) + (rtd:ratio-to-double (* mantissa (expt 10 exp10) sign))) c))) c)))) (prog ((sign 1) From 0e5b445fced56f549bf4831e2bca9d14afa4d233 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wilfredo=20Vel=C3=A1zquez-Rodr=C3=ADguez?= Date: Wed, 20 Dec 2023 20:48:02 -0500 Subject: [PATCH 11/11] Preparing for a 1.1.3 release --- CHANGELOG.md | 2 +- README.md | 2 +- src/com.inuoe.jzon.asd | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4db7f66..aa1a422 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -## PENDING v1.1.3 +## v1.1.3 Changes relative to [v1.1.2](#v112) diff --git a/README.md b/README.md index 822052e..066db73 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # jzon -A correct and safe(er) JSON [RFC 8259][JSONRFC] parser with sane defaults. +A correct and safe(er) JSON [RFC 8259][JSONRFC] reader/writer with sane defaults. Please see the section [Motivation and Features](#motivation-and-features) for a set of motivations driving jzon and why you should consider it over the other hundred options available for JSON in CL. diff --git a/src/com.inuoe.jzon.asd b/src/com.inuoe.jzon.asd index a2ea1ce..917f7a2 100644 --- a/src/com.inuoe.jzon.asd +++ b/src/com.inuoe.jzon.asd @@ -1,6 +1,6 @@ (defsystem #:com.inuoe.jzon :version "1.1.3" - :description "A correct and safe(er) JSON RFC 8259 parser with sane defaults." + :description "A correct and safe(r) JSON RFC 8259 reader/writer with sane defaults." :author "Wilfredo Velázquez-Rodríguez " :license "MIT" :depends-on (#:closer-mop