More json.el changes

* lisp/json.el (json-read-keyword, json-read-number, json-read-object):
(json-read-array): Just use = for char comparison.
This commit is contained in:
Mark Oteiza 2017-02-18 20:25:50 -05:00
parent 861ff2ba2c
commit 7f89c208bf

View file

@ -293,7 +293,7 @@ KEYWORD is the keyword expected."
(unless (member keyword json-keywords)
(signal 'json-unknown-keyword (list keyword)))
(mapc (lambda (char)
(unless (char-equal char (json-peek))
(when (/= char (json-peek))
(signal 'json-unknown-keyword
(list (save-excursion
(backward-word-strictly 1)
@ -330,10 +330,10 @@ representation will be parsed correctly."
;; If SIGN is non-nil, the number is explicitly signed.
(let ((number-regexp
"\\([0-9]+\\)?\\(\\.[0-9]+\\)?\\([Ee][+-]?[0-9]+\\)?"))
(cond ((and (null sign) (char-equal (json-peek) ?-))
(cond ((and (null sign) (= (json-peek) ?-))
(json-advance)
(- (json-read-number t)))
((and (null sign) (char-equal (json-peek) ?+))
((and (null sign) (= (json-peek) ?+))
(json-advance)
(json-read-number t))
((and (looking-at number-regexp)
@ -495,11 +495,11 @@ Please see the documentation of `json-object-type' and `json-key-type'."
;; read key/value pairs until "}"
(let ((elements (json-new-object))
key value)
(while (not (char-equal (json-peek) ?}))
(while (not (= (json-peek) ?}))
(json-skip-whitespace)
(setq key (json-read-string))
(json-skip-whitespace)
(if (char-equal (json-peek) ?:)
(if (= (json-peek) ?:)
(json-advance)
(signal 'json-object-format (list ":" (json-peek))))
(json-skip-whitespace)
@ -510,8 +510,8 @@ Please see the documentation of `json-object-type' and `json-key-type'."
(funcall json-post-element-read-function))
(setq elements (json-add-to-object elements key value))
(json-skip-whitespace)
(unless (char-equal (json-peek) ?})
(if (char-equal (json-peek) ?,)
(when (/= (json-peek) ?})
(if (= (json-peek) ?,)
(json-advance)
(signal 'json-object-format (list "," (json-peek))))))
;; Skip over the "}"
@ -621,7 +621,7 @@ become JSON objects."
(json-skip-whitespace)
;; read values until "]"
(let (elements)
(while (not (char-equal (json-peek) ?\]))
(while (not (= (json-peek) ?\]))
(json-skip-whitespace)
(when json-pre-element-read-function
(funcall json-pre-element-read-function (length elements)))
@ -629,8 +629,8 @@ become JSON objects."
(when json-post-element-read-function
(funcall json-post-element-read-function))
(json-skip-whitespace)
(unless (char-equal (json-peek) ?\])
(if (char-equal (json-peek) ?,)
(when (/= (json-peek) ?\])
(if (= (json-peek) ?,)
(json-advance)
(signal 'json-error (list 'bleah)))))
;; Skip over the "]"