aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Oteiza2017-02-15 20:43:55 -0500
committerMark Oteiza2017-02-15 20:43:55 -0500
commit236648fe2623a10c8ca02637b79cd0ceffd0b6b9 (patch)
tree41b00884fce1f47829202c2d59514b8e0fbf8011
parent1b4442bee921d6698fc8ecac1c95c39f7ca2efe4 (diff)
downloademacs-236648fe2623a10c8ca02637b79cd0ceffd0b6b9.tar.gz
emacs-236648fe2623a10c8ca02637b79cd0ceffd0b6b9.zip
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.
-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."
188;; Reader utilities 188;; Reader utilities
189 189
190(defsubst json-advance (&optional n) 190(defsubst json-advance (&optional n)
191 "Skip past the following N characters." 191 "Advance N characters forward."
192 (forward-char n)) 192 (forward-char n))
193 193
194(defsubst json-peek () 194(defsubst json-peek ()
@@ -381,13 +381,13 @@ representation will be parsed correctly."
381 ;; this clause overlaps with the next one and therefore has to 381 ;; this clause overlaps with the next one and therefore has to
382 ;; come first. 382 ;; come first.
383 ((looking-at 383 ((looking-at
384 (rx (group (any "Dd") (any "89ABab") (= 2 (any "0-9A-Fa-f"))) 384 (rx (group (any "Dd") (any "89ABab") (= 2 (any xdigit)))
385 "\\u" (group (any "Dd") (any "C-Fc-f") (= 2 (any "0-9A-Fa-f"))))) 385 "\\u" (group (any "Dd") (any "C-Fc-f") (= 2 (any xdigit)))))
386 (json-advance 10) 386 (json-advance 10)
387 (json--decode-utf-16-surrogates 387 (json--decode-utf-16-surrogates
388 (string-to-number (match-string 1) 16) 388 (string-to-number (match-string 1) 16)
389 (string-to-number (match-string 2) 16))) 389 (string-to-number (match-string 2) 16)))
390 ((looking-at "[0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f][0-9A-Fa-f]") 390 ((looking-at (rx (= 4 xdigit)))
391 (let ((hex (match-string 0))) 391 (let ((hex (match-string 0)))
392 (json-advance 4) 392 (json-advance 4)
393 (string-to-number hex 16))) 393 (string-to-number hex 16)))
@@ -396,14 +396,14 @@ representation will be parsed correctly."
396 396
397(defun json-read-string () 397(defun json-read-string ()
398 "Read the JSON string at point." 398 "Read the JSON string at point."
399 (unless (char-equal (json-peek) ?\") 399 (unless (= (json-peek) ?\")
400 (signal 'json-string-format (list "doesn't start with `\"'!"))) 400 (signal 'json-string-format (list "doesn't start with `\"'!")))
401 ;; Skip over the '"' 401 ;; Skip over the '"'
402 (json-advance) 402 (json-advance)
403 (let ((characters '()) 403 (let ((characters '())
404 (char (json-peek))) 404 (char (json-peek)))
405 (while (not (char-equal char ?\")) 405 (while (not (= char ?\"))
406 (push (if (char-equal char ?\\) 406 (push (if (= char ?\\)
407 (json-read-escaped-char) 407 (json-read-escaped-char)
408 (json-pop)) 408 (json-pop))
409 characters) 409 characters)