Browse Source

ob-C: do not swallow double quotes on raw output

* lisp/ob-C.el (org-babel-C-execute): Remove the erroneous
  call to `org-babel-read' when output is raw.
* testing/examples/ob-C-test.org (Output),
  testing/lisp/test-ob-C.el (ob-C/ouput-doublequotes):
  Add a test with double quotes output.

https://list.orgmode.org/orgmode/bc004962-679e-498f-b245-ae253aae6271@www.fastmail.com/
Thierry Banel 1 year ago
parent
commit
aa3eac143d
3 changed files with 22 additions and 1 deletions
  1. 1 1
      lisp/ob-C.el
  2. 12 0
      testing/examples/ob-C-test.org
  3. 9 0
      testing/lisp/test-ob-C.el

+ 1 - 1
lisp/ob-C.el

@@ -185,7 +185,7 @@ or `org-babel-execute:C++' or `org-babel-execute:D'."
 	(setq results (org-remove-indentation results))
 	(org-babel-reassemble-table
 	 (org-babel-result-cond (cdr (assq :result-params params))
-	   (org-babel-read results t)
+	   results
 	   (let ((tmp-file (org-babel-temp-file "c-")))
 	     (with-temp-file tmp-file (insert results))
 	     (org-babel-import-elisp-from-file tmp-file)))

+ 12 - 0
testing/examples/ob-C-test.org

@@ -162,3 +162,15 @@ void main()
   writefln ("Friday %s", tinomogen_h(4,"day"));
 }
 #+end_src
+
+* Output
+:PROPERTIES:
+:ID:       9386490b-4063-4400-842c-4a634edbedf5
+:END:
+
+#+source: double_quotes
+#+begin_src cpp :includes <iostream> :results output verbatim raw
+std::cout << "\"line 1\"\n";
+std::cout << "\"line 2\"\n";
+std::cout << "\"line 3\"\n";
+#+end_src

+ 9 - 0
testing/lisp/test-ob-C.el

@@ -183,5 +183,14 @@
 				 ("Friday" "friday"))
 			       (org-babel-execute-src-block))))))
 
+(ert-deftest ob-C/ouput-doublequotes ()
+  "Double quotes not swallowed in raw output"
+  (if (executable-find org-babel-C++-compiler)
+      (org-test-at-id "9386490b-4063-4400-842c-4a634edbedf5"
+                      (org-babel-next-src-block 1)
+                      (should (equal
+                               "\"line 1\"\n\"line 2\"\n\"line 3\"\n"
+                               (org-babel-execute-src-block))))))
+
 (provide 'test-ob-C)
 ;;; test-ob-C.el ends here