summaryrefslogtreecommitdiff
path: root/lisp/json.el
diff options
context:
space:
mode:
authorMark Oteiza <mvoteiza@udel.edu>2017-02-15 20:43:55 -0500
committerMark Oteiza <mvoteiza@udel.edu>2017-02-15 20:43:55 -0500
commit236648fe2623a10c8ca02637b79cd0ceffd0b6b9 (patch)
tree41b00884fce1f47829202c2d59514b8e0fbf8011 /lisp/json.el
parent1b4442bee921d6698fc8ecac1c95c39f7ca2efe4 (diff)
downloademacs-236648fe2623a10c8ca02637b79cd0ceffd0b6b9.tar.gz
Minor changes in json.el
* lisp/json.el (json-advance): Simpler docstring. (json-read-escaped-char): Use xdigit subform in rx expression. (json-read-string): Just use = for char comparison.
Diffstat (limited to 'lisp/json.el')
-rw-r--r--lisp/json.el14
1 files changed, 7 insertions, 7 deletions
diff --git a/lisp/json.el b/lisp/json.el
index b2ac356641b..59942dbed8f 100644
--- a/lisp/json.el
+++ b/lisp/json.el
@@ -188,7 +188,7 @@ Unlike `reverse', this keeps the property-value pairs intact."
;; Reader utilities
(defsubst json-advance (&optional n)
- "Skip past the following N characters."
+ "Advance N characters forward."
(forward-char n))
(defsubst json-peek ()
@@ -381,13 +381,13 @@ representation will be parsed correctly."
;; this clause overlaps with the next one and therefore has to
;; come first.
((looking-at
- (rx (group (any "Dd") (any "89ABab") (= 2 (any "0-9A-Fa-f")))
- "\\u" (group (any "Dd") (any "C-Fc-f") (= 2 (any "0-9A-Fa-f")))))
+ (rx (group (any "Dd") (any "89ABab") (= 2 (any xdigit)))
+ "\\u" (group (any "Dd") (any "C-Fc-f") (= 2 (any xdigit)))))
(json-advance 10)
(json--decode-utf-16-surrogates
(string-to-number (match-string 1) 16)
(string-to-number (match-string 2) 16)))
- ((looking-at "[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]")
+ ((looking-at (rx (= 4 xdigit)))
(let ((hex (match-string 0)))
(json-advance 4)
(string-to-number hex 16)))
@@ -396,14 +396,14 @@ representation will be parsed correctly."
(defun json-read-string ()
"Read the JSON string at point."
- (unless (char-equal (json-peek) ?\")
+ (unless (= (json-peek) ?\")
(signal 'json-string-format (list "doesn't start with `\"'!")))
;; Skip over the '"'
(json-advance)
(let ((characters '())
(char (json-peek)))
- (while (not (char-equal char ?\"))
- (push (if (char-equal char ?\\)
+ (while (not (= char ?\"))
+ (push (if (= char ?\\)
(json-read-escaped-char)
(json-pop))
characters)