summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicolas Goaziou <mail@nicolasgoaziou.fr>2017-05-08 11:25:17 +0200
committerNicolas Goaziou <mail@nicolasgoaziou.fr>2017-05-08 11:25:17 +0200
commitf1da21f7d911e412cc6846acd66dd3d2056553d5 (patch)
tree7285e55362c8e3dae74e886fda3a2532732cff89
parenta4f29410e98d185f0c5bfe3b887b654ac5d388c2 (diff)
downloadorg-mode-f1da21f7d911e412cc6846acd66dd3d2056553d5.tar.gz
ob-core: Fix regression
* lisp/ob-core.el (org-babel-balanced-split): Fix regression introduced in 500abcd7fbe24abc887300faec2058905a13fa33. * testing/lisp/test-ob.el (test-ob/balanced-split): Add tests. Reported-by: Eric S Fraga <e.fraga@ucl.ac.uk> <http://permalink.gmane.org/gmane.emacs.orgmode/113401>
-rw-r--r--lisp/ob-core.el18
-rw-r--r--testing/lisp/test-ob.el10
2 files changed, 17 insertions, 11 deletions
diff --git a/lisp/ob-core.el b/lisp/ob-core.el
index 8a4c1ba..c630b70 100644
--- a/lisp/ob-core.el
+++ b/lisp/ob-core.el
@@ -1487,19 +1487,17 @@ balanced instances of \"[ \t]:\", set ALTS to ((32 9) . 58)."
(push after partial)
(goto-char (1+ origin)))))
((and (eq ?\" (char-after)) (not (eq ?\\ (char-before))))
- ;; Include everything between non-escaped double quotes.
- (push ?\" partial)
+ ;; Include everything from current double quote to next
+ ;; non-escaped double quote.
(let ((origin (point)))
- (condition-case nil
- ;; Use `read' since it is fast and takes care of
- ;; escaped quotes already.
+ (if (re-search-forward "[^\\]\"" nil t)
(setq partial
- (nconc (cons ?\"
- (nreverse (string-to-list
- (read (current-buffer)))))
+ (nconc (nreverse (string-to-list
+ (buffer-substring origin (point))))
partial))
- ;; No closing double quote found. Backtrack.
- (end-of-file (goto-char (1+ origin))))))
+ ;; No closing double quote. Backtrack.
+ (push ?\" partial)
+ (forward-char))))
(t (push (char-after) partial)
(forward-char))))
;; Add pending parsing and return result.
diff --git a/testing/lisp/test-ob.el b/testing/lisp/test-ob.el
index fe4ecb8..a1bdc54 100644
--- a/testing/lisp/test-ob.el
+++ b/testing/lisp/test-ob.el
@@ -717,7 +717,15 @@ x
;; Handle un-balanced quotes.
(should
(equal '(":foo \"1" "bar 3")
- (org-babel-balanced-split ":foo \"1 :bar 3" '((32 9) . 58)))))
+ (org-babel-balanced-split ":foo \"1 :bar 3" '((32 9) . 58))))
+ ;; Handle empty string.
+ (should
+ (equal '(":foo \"\"")
+ (org-babel-balanced-split ":foo \"\"" '((32 9) . 58))))
+ ;; Handle control characters within double quotes.
+ (should
+ (equal '(":foo \"\\n\"")
+ (org-babel-balanced-split ":foo \"\\n\"" '((32 9) . 58)))))
(ert-deftest test-ob/commented-last-block-line-no-var ()
(org-test-with-temp-text-in-file "