Question

Using babel with org-mode, I'm trying the get the output of the following C code:

#+begin_src C :includes <stdio.h> :results output verbatim :exports both
puts("[1] 2 3 3");
#+end_src

Unfortunately, hitting C-cC-c on this block produces only:

#+RESULTS:
: [1]

It seems that despite my use of :results verbatim, is output is interpreted somehow and everything after [1] is ignored. I would like to know how to configure org-babel so that the above results contains the full output, i.e., I expect:

#+RESULTS:
: [1] 2 3 3

Note that if I the output does not start with [.*], it is displayed as I expect:

#+begin_src C :includes <stdio.h> :results outputs verbatim :exports both
puts("foo");
puts("[1] 2 3 3");
#+end_src
#+RESULTS:
: foo
: [1] 2 3 3

I'm using Org-mode version 8.2 (8.2-6-gd745cd-elpa).

Was it helpful?

Solution

Had to add one letter in the source to get this to work:

#+begin_src C :results output
puts("[1] 2 3 3");
#+end_src

#+RESULTS:
: [1] 2 3 3

Here's the patch:

Modified   lisp/ob-C.el
diff --git a/lisp/ob-C.el b/lisp/ob-C.el
index e9eec93..c35b3d0 100644
--- a/lisp/ob-C.el
+++ b/lisp/ob-C.el
@@ -106,7 +106,7 @@ or `org-babel-execute:C++'."
     ((lambda (results)
        (org-babel-reassemble-table
    (org-babel-result-cond (cdr (assoc :result-params params))
-     (org-babel-read results)
+     (org-babel-read results t)
      (let ((tmp-file (org-babel-temp-file "c-")))
        (with-temp-file tmp-file (insert results))
        (org-babel-import-elisp-from-file tmp-file)))

I've sent a patch to the mailing list as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top