From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id KM5hNAeOz14wPQAA0tVLHw (envelope-from ) for ; Thu, 28 May 2020 10:10:15 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id MNtGMAeOz165UQAAB5/wlQ (envelope-from ) for ; Thu, 28 May 2020 10:10:15 +0000 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 30149940A38 for ; Thu, 28 May 2020 10:10:15 +0000 (UTC) Received: from localhost ([::1]:46214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jeFUK-0006UX-Q9 for larch@yhetil.org; Thu, 28 May 2020 06:10:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42382) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jeFTr-0006UQ-S0 for emacs-orgmode@gnu.org; Thu, 28 May 2020 06:09:43 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]:40611) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jeFTq-0002l3-MA; Thu, 28 May 2020 06:09:43 -0400 Received: by mail-wm1-x336.google.com with SMTP id r15so2509314wmh.5; Thu, 28 May 2020 03:09:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=1G/0L6kfRn1RY62iCBv7dMOpjbyPE6TarGJgcBBxQiw=; b=S+lwVOx++VMI3lKM1/tthXhMmnIVKu0zQ0GSXQWpwrikyCpb/9bUtLjn0pIekGYjSU JGABuTvqu6tEU+FKJUaPKUwlwXfUqHn7fT2bArUBq2fHEVJtpvj6tEaU1EcF5Y/0GSut jq+SkFQGhudamo0Mzc6sc5opiN5NUxIz/o18hJT61MiA1t1iOMNOuEWMx8nd7Y+ytKT5 IFfnimucZLdjfrHpX7CovC7ihi6T+puYCobN4qnbhoZlg747aqgu84V0KVJcGOH4af+M q+Huit+KpN54cLfjOcOMu0IotBh633pU2PcWSMJHzd6oGAPkRSuhfz02u8kfeKusc+W2 /X1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=1G/0L6kfRn1RY62iCBv7dMOpjbyPE6TarGJgcBBxQiw=; b=gwekSYJN8dAphNIXrPxe8NUkG3ycgeRuagVeDxhav3m0qC4DvZfCIHa/oFwheUlm84 lKYlsT4WHgEmQghSdS5FFpycZ4czCub7Vf2KE6zmPqcuOT1D8SYELe210//a8+mX95VU Skfkzfy473vmGr/8ToAm+3vWas4NPhZ5nSSHYxKxbBj7269tuYK57Diom/GFXF52NEK8 rDNTV41NJxugaZ8upGOEGirKBPKH+DNETerzztotawyITRvxI3Qbc1HluajCcmT5eLvN +/9l5zhxHnKpRe4xQpf3d1Fwy414Tk0gD4AWa+n5Z57A/KrAQQMjkuNra3Py0TBYodPL 2f2w== X-Gm-Message-State: AOAM533pXaRr9vQHU0BvkJO3mOIRAYIMv6BSp6bYPBiaxwbgdNBDPE1w 1uKApddsORbxNPQ6kzDC6RnrIX6k X-Google-Smtp-Source: ABdhPJwUWu5dPBYzuHUMOn7ymqaoht60JjDfSGj1w0ijsjFKvSeR2X1HGFZZFkblMltxXNsyOvgRsA== X-Received: by 2002:a1c:e903:: with SMTP id q3mr2567133wmc.76.1590660580460; Thu, 28 May 2020 03:09:40 -0700 (PDT) Received: from klegouguec-HP-ProBook-450-G1 (200.143.13.109.rev.sfr.net. [109.13.143.200]) by smtp.gmail.com with ESMTPSA id 10sm6001528wmw.26.2020.05.28.03.09.35 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 28 May 2020 03:09:36 -0700 (PDT) From: =?utf-8?Q?K=C3=A9vin_Le_Gouguec?= To: Kyle Meyer Subject: Re: Possible fix for :includes header argument in org-babel C source blocks References: <21b0cd85-d678-2fe6-3c22-e41abc6cf242@guttersohn.org> <87wo51jo5w.fsf@gnu.org> <875zchyq7y.fsf@gmail.com> <87imggx045.fsf@kyleam.com> <875zcgwjo7.fsf@gmail.com> Date: Thu, 28 May 2020 12:09:35 +0200 In-Reply-To: <875zcgwjo7.fsf@gmail.com> (=?utf-8?Q?=22K=C3=A9vin?= Le Gouguec"'s message of "Thu, 28 May 2020 10:25:12 +0200") Message-ID: <87blm8v09s.fsf@gmail.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=kevin.legouguec@gmail.com; helo=mail-wm1-x336.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Bastien , Brandon Guttersohn , emacs-orgmode@gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=S+lwVOx+; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Spam-Score: -1.71 X-TUID: kx0jaF2Ruxwe --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable K=C3=A9vin Le Gouguec writes: > That leads me to believe that the coercion was an unintended side-effect > of (format =E2=80=A6). Never mind, the ORG-NEWS entry for 9.1 shows an example of unquoted header, so I guess it is intentional. Here is a patch to fix the regression: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Coerce-symbols-found-in-includes-header-arguments-to.patch >From b68122821a26578470506938c3a358f52f5d7a46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= Date: Thu, 28 May 2020 11:09:18 +0200 Subject: [PATCH 1/2] Coerce symbols found in :includes header arguments to strings Fix regression from 2020-05-24T16:23:26Z!brandon@guttersohn.org (commit 44cb98fdb), which broke test ob-C/string-var. * lisp/ob-C.el (org-babel-C-expand-C): Make sure items in :includes arguments are strings before performing string operations on them. --- lisp/ob-C.el | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lisp/ob-C.el b/lisp/ob-C.el index c3e72c680..42c60c296 100644 --- a/lisp/ob-C.el +++ b/lisp/ob-C.el @@ -233,6 +233,9 @@ its header arguments." ;; includes (mapconcat (lambda (inc) + ;; :includes '( ) gives us a list of + ;; symbols; convert those to strings. + (when (symbolp inc) (setq inc (symbol-name inc))) (if (string-prefix-p "<" inc) (format "#include %s" inc) (format "#include \"%s\"" inc))) -- 2.17.1 --=-=-= Content-Type: text/plain And here is a patch to add a test for the unquoted-single-header case, since otherwise it's hard to tell whether this behaviour is intentional: --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Add-test-case-for-symbol-coercion-in-C-Babel-blocks.patch >From cf1bb27215a46a521bb2f50d16b7dbc7441d81ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Le=20Gouguec?= Date: Thu, 28 May 2020 11:47:25 +0200 Subject: [PATCH 2/2] Add test case for symbol coercion in C Babel blocks The ORG-NEWS entry for version 9.1 suggests that this coercion was always intended, though AFAICT there was no test case for it. * testing/lisp/test-ob-C.el (ob-C/symbol-include): Check explicitly that :includes (with no double-quotes around ) will be parsed correctly. (ob-D/simple-program, ob-C/integer-var, ob-D/integer-var, ob-C/two-integer-var, ob-D/two-integer-var, ob-C/string-var, ob-D/string-var, ob-C/preprocessor): Adjust block indices. * testing/examples/ob-C-test.org (Simple tests): Add input for the new test. --- testing/examples/ob-C-test.org | 6 ++++++ testing/lisp/test-ob-C.el | 23 +++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/testing/examples/ob-C-test.org b/testing/examples/ob-C-test.org index 0faf630b9..347607cae 100644 --- a/testing/examples/ob-C-test.org +++ b/testing/examples/ob-C-test.org @@ -10,6 +10,12 @@ return 0; #+end_src +#+source: simple +#+begin_src cpp :includes :results silent + std::cout << 42; + return 0; +#+end_src + #+source: simple #+begin_src D :results silent writefln ("%s", 42); diff --git a/testing/lisp/test-ob-C.el b/testing/lisp/test-ob-C.el index 3e4a63f88..6b6b728a2 100644 --- a/testing/lisp/test-ob-C.el +++ b/testing/lisp/test-ob-C.el @@ -32,60 +32,67 @@ (org-babel-next-src-block 1) (should (= 42 (org-babel-execute-src-block)))))) +(ert-deftest ob-C/symbol-include () + "Hello world program with unquoted :includes." + (if (executable-find org-babel-C++-compiler) + (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577" + (org-babel-next-src-block 2) + (should (= 42 (org-babel-execute-src-block)))))) + (ert-deftest ob-D/simple-program () "Hello world program." (if (executable-find org-babel-D-compiler) (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577" - (org-babel-next-src-block 2) + (org-babel-next-src-block 3) (should (= 42 (org-babel-execute-src-block)))))) (ert-deftest ob-C/integer-var () "Test of an integer variable." (if (executable-find org-babel-C++-compiler) (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577" - (org-babel-next-src-block 3) + (org-babel-next-src-block 4) (should (= 12 (org-babel-execute-src-block)))))) (ert-deftest ob-D/integer-var () "Test of an integer variable." (if (executable-find org-babel-D-compiler) (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577" - (org-babel-next-src-block 4) + (org-babel-next-src-block 5) (should (= 12 (org-babel-execute-src-block)))))) (ert-deftest ob-C/two-integer-var () "Test of two input variables" (if (executable-find org-babel-C++-compiler) (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577" - (org-babel-next-src-block 5) + (org-babel-next-src-block 6) (should (= 22 (org-babel-execute-src-block)))))) (ert-deftest ob-D/two-integer-var () "Test of two input variables" (if (executable-find org-babel-D-compiler) (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577" - (org-babel-next-src-block 6) + (org-babel-next-src-block 7) (should (= 22 (org-babel-execute-src-block)))))) (ert-deftest ob-C/string-var () "Test of a string input variable" (if (executable-find org-babel-C++-compiler) (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577" - (org-babel-next-src-block 7) + (org-babel-next-src-block 8) (should (equal "word 4" (org-babel-execute-src-block)))))) (ert-deftest ob-D/string-var () "Test of a string input variable" (if (executable-find org-babel-D-compiler) (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577" - (org-babel-next-src-block 8) + (org-babel-next-src-block 9) (should (equal "word 4" (org-babel-execute-src-block)))))) (ert-deftest ob-C/preprocessor () "Test of a string variable" (if (executable-find org-babel-C++-compiler) (org-test-at-id "fa6db330-e960-4ea2-ac67-94bb845b8577" - (org-babel-next-src-block 9) + (org-babel-next-src-block 10) (should (= 42 (org-babel-execute-src-block)))))) (ert-deftest ob-C/table () -- 2.17.1 --=-=-= Content-Type: text/plain (Is the Org source for the C/C++/D Babel syntax[1] committed somewhere, BTW? I could not find it in the Org repo.) I'd like to say that all tests pass now, but I'm getting failures on master (even without my changes) for two other tests: > FAILED ob-tangle/jump-to-org > FAILED test-org-attach/dir [1] https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-C.html --=-=-=--