From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id wHcqG4iOD2NocQEAbAwnHQ (envelope-from ) for ; Wed, 31 Aug 2022 18:38:32 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id wHcqG4iOD2NTHAEAauVa8A (envelope-from ) for ; Wed, 31 Aug 2022 18:38:32 +0200 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id F2727B1BC for ; Wed, 31 Aug 2022 18:38:30 +0200 (CEST) Received: from localhost ([::1]:53098 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oTQjW-0001bi-6T for larch@yhetil.org; Wed, 31 Aug 2022 12:38:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oTQgo-0000u1-SC for emacs-orgmode@gnu.org; Wed, 31 Aug 2022 12:35:57 -0400 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]:56089) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oTQgm-0003ln-PE for emacs-orgmode@gnu.org; Wed, 31 Aug 2022 12:35:42 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.west.internal (Postfix) with ESMTP id F0814320016F for ; Wed, 31 Aug 2022 12:35:35 -0400 (EDT) Received: from imap44 ([10.202.2.94]) by compute3.internal (MEProxy); Wed, 31 Aug 2022 12:35:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailservice.ms; h=cc:content-type:date:date:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to; s=fm3; t= 1661963735; x=1662050135; bh=CQ24s3FNiyfsENpCvD2zPGpu2Py38h32EwH jAEWpcTI=; b=liwhHooG7gAeErojhxKVOPkDZJ6ehtuqYqfRYeJPA47SpVk+Fwh L2MqJa2rYHLbhguQWa7NcLhWHrx3eu+R5aBGLB0TW9QSU7vjh9cQxTtIbWgsJ+fj d0u4oXxAHhnB97u+0o13RS/L2DJSwM/FLCN7anPiF7XqOHKDaoqP9DxDauCmZfnc CR7Vjn9IhIzDkC13XtKlECnL/jBhskc0VGXrWyfqd3ESm0t36SgqKK8TLjITdxiX xPu4Fz0RrcT5A7diwEvzybtbVaeHAo+QUDRsUsa63PXnllbti+Pm6hGgHeGXwu5n LYMiQQ03duF7mlx/w1fdaDYVlNp0EP4hmDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:date:feedback-id :feedback-id:from:from:in-reply-to:message-id:mime-version :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1661963735; x= 1662050135; bh=CQ24s3FNiyfsENpCvD2zPGpu2Py38h32EwHjAEWpcTI=; b=I gS0n5yQd5oj4DL5V/jNFs67l0ITcIXcXr2YtqMzbd4qyV+qVYV7DOdP4qQedt8Z4 Ey0Z8taxNiYBv/ZWNR4nD0ZbF+yd+i+nikA3LoJ26Es0SLLo5QRbevQo6up9Xfhn xLKVVRoLNIZxr/olgVGrMP27oLTgym6nEXdgOpb5W450XpRD8tUgO3SlGHCkKjnu FVNTLXTNRwrIZF2ZD6kvyHbiZdO1qSexjomWrnRyGkXjC5l+Vqz95IS+OUzOLoNl 9tmCriGgSwaJbVRLV/SwJXB+mxmZy0CcyM+9vxb6BznH7/YwKCVehdVCVHVzLjhZ IIEgBw3WVy5LHqhFgOBDw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdekiedgjeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpefofgggkfffhffvufgtsehttdertd erredtnecuhfhrohhmpedfofgrrhhtihhnucflvghrrggsvghkfdcuoehomhesmhgrihhl shgvrhhvihgtvgdrmhhsqeenucggtffrrghtthgvrhhnpeelueeutdffjefhtdevvdethf duteegffetheehtdeiheffieeuhfdtvdelvdeltdenucffohhmrghinhepvghlrdhorhhg necuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepohhmse hmrghilhhsvghrvhhitggvrdhmsh X-ME-Proxy: Feedback-ID: i49c94607:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 187B036A0073; Wed, 31 Aug 2022 12:35:34 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.7.0-alpha0-841-g7899e99a45-fm-20220811.002-g7899e99a Mime-Version: 1.0 Message-Id: Date: Wed, 31 Aug 2022 18:35:14 +0200 From: "Martin Jerabek" To: emacs-orgmode@gnu.org Subject: Babel C-mode corrupts double-quoted strings in output Content-Type: text/plain Received-SPF: pass client-ip=64.147.123.25; envelope-from=om@mailservice.ms; helo=wout2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1661963912; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=CQ24s3FNiyfsENpCvD2zPGpu2Py38h32EwHjAEWpcTI=; b=iXKG7i1wdvN6AZs8gpp2+uZHYRG3BlvA6hwv9Ln6bZtqEH8TPQKsPtz7kal42J9XFQy5I4 fS84KxDMfObxay178Stk668ZLgfSpKKJkDf+8hxvePwxYwST2lZNkYfMyNbSosdGbxbYu3 1s+yYIXO+0CKZOLfwxP7OWZb4nBKUo6MGwKA7tRxD/sZKjeMnLwsTNtfhGPv80ncZ6kvyR hJMH6+ON4N4crvGjTSWKwLX1wRd36V74upmlDy2dt/I4g+aAukJQ1GaIsyh7zq50j+NE/S xexHE1p4xrbI1MgPl47PGyvEGjO9bAL8gEvZQhNGsfU+1wHSTVJ+nrAdruNgvg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1661963912; a=rsa-sha256; cv=none; b=qVqxVasz3nZ7Hxb5FbgvvCCu8p3x8EEk5sw1PZ+bcJj/zPngqblJiS62TS0NS7NQhv/Nf6 N/iGeBYQaFTGJXNWCpKawXoROZgl8JjQ7ncbg6WBfFoflPhCK8R0OFgeAh9JRWyVpHnz2V Px2Jnaa7SjnQZwzTT9atcVOzxZrSUyl+Hns/2i0mBocEWfY0Ukfx1PZqPxNQiGdaTonf4m CecspUVFHt/Rj1FnLvSWhbjtuMFs7jqy7e9y9GiQW2+f96JELcx2VfxW1hsQZ4tp9bGi7h 5lMz1ro+KHqFVG2V6ZLR5MGSbge+OmyqoPQjeVSIl1fG6tCNSIcSzvY3cKWHRw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mailservice.ms header.s=fm3 header.b=liwhHooG; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm1 header.b="I gS0n5y"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=mailservice.ms (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: 8.13 X-Spam: Yes Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=mailservice.ms header.s=fm3 header.b=liwhHooG; dkim=fail ("headers rsa verify failed") header.d=messagingengine.com header.s=fm1 header.b="I gS0n5y"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=mailservice.ms (policy=none); spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: F2727B1BC X-Spam-Score: 8.13 X-Migadu-Spam: Yes X-Migadu-Scanner: scn0.migadu.com X-TUID: PEVymwY9WZU5 Hi! I recently started to use Org Babel for C++ programs. One of the programs outputs several lines with double-quoted strings, similar to this: #+NAME: doublequotes_cpp #+begin_src cpp :includes :results output verbatim raw std::cout << "\"line 1\"\n"; std::cout << "\"line 2\"\n"; std::cout << "\"line 3\"\n"; #+end_src #+RESULTS: doublequotes_cpp line 1 As you can see, only the first line is copied to the RESULTS block, and it is stripped of the double quotes. I tracked down the problem to org-babel-read (in ob-core.el). org-babel-C-execute (in ob-C.el) calls this function with the output of the C++ program. The problem is the following line: ((eq (string-to-char cell) ?\") (read cell)) i.e. if the output of the program starts with a double quote, it is passed to read which reads only the first string and also removes the double quotes, resulting in the observed output. The original version of this piece of code was added with the following commit: commit 60a8ba556d682849eafb0f84e689967cd2965549 Author: Eric Schulte Date: Wed Mar 2 07:55:39 2011 -0700 ob: read string variable values wrapped in double quotes, removing the quotes * lisp/ob.el (org-babel-read): Read string variable values wrapped in double quotes, removing the quotes. AFAICT this modification was done in response to the email thread "[Orgmode] org-babel-read should have option NOT to interpret as elisp" started on 2011-02-27, more specifically the email on "Wed, 02 Mar 2011 07:56:45 -0700" from Eric Schulte. This was obviously done for parsing variables in the header line, not for the program output, but the Babel C mode uses org-babel-read also for the output. I assumed that ":results output verbatim raw" would prevent any postprocessing of the output but this is not the case for C mode. I am not sure how to fix this without breaking backward compatibility. I assume it should be fixed directly in org-babel-C-execute, not in a central function like org-babel-read to minimize the impact. Surprisingly (for me) the equivalent shell script works as expected: #+NAME: doublequotes #+begin_src shell :results output verbatim raw echo '"line 1"' echo '"line 2"' echo '"line 3"' #+end_src #+RESULTS: doublequotes "line 1" "line 2" "line 3" because org-babel-execute:shell does not process the output with org-babel-read. I do not know if languages other than the C family (C, C++, D) are affected. At the very least, the documentation of org-babel-read should be expanded to document the fact that if the CELL parameter starts with a double quote, it is processed by the read function. Best regards Martin Jerabek