From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id GD03NxSaEV8BKAAA0tVLHw (envelope-from ) for ; Fri, 17 Jul 2020 12:31:16 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id aBHlMhSaEV8INgAAbx9fmQ (envelope-from ) for ; Fri, 17 Jul 2020 12:31:16 +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 6EB08940667 for ; Fri, 17 Jul 2020 12:31:15 +0000 (UTC) Received: from localhost ([::1]:52198 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jwPWC-0003aq-OC for larch@yhetil.org; Fri, 17 Jul 2020 08:31:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42460) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jwPVg-0003ZF-Cx for emacs-orgmode@gnu.org; Fri, 17 Jul 2020 08:30:40 -0400 Received: from mail-ej1-f45.google.com ([209.85.218.45]:37082) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jwPVd-0002xK-TD for emacs-orgmode@gnu.org; Fri, 17 Jul 2020 08:30:40 -0400 Received: by mail-ej1-f45.google.com with SMTP id lx13so10565227ejb.4 for ; Fri, 17 Jul 2020 05:30:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TynvHgd3Ux7C6cFbyJ+3Q+ZOhrNgTJgzTYi14+PgoG4=; b=RuDEITE5fMuFJqjV6zQhZTVEplJGzb+NOGBAW7mgEIDL8V1ERKIZPafApwHn84qxJ1 zvvqLeXt37bo81ayIy9haoXHapgCJFIFohxW1rGLGHQWxZgvJxUgXJrbAwXXtDF3P4Kg tfTp52OPdxc64DvWfRpo/75Rh4UQw/u6sfq098URBfFtkhPdV0JUfB7i+IcAbiZ4Fi/t WxZPMD61gQcB36qQypWmeIBJGCQdspoD0/51rWJ9+pqWXsBxv3tMKJzcVjiDiDcIqtjw gVASL3R7R58B1EAF5FmVeUQDwmh/9N5x9gl1o7xA8pR+8NjI2Wo/oIJL1qwYlEf9ELEk Cjfg== X-Gm-Message-State: AOAM531f9Bo5S7l7cmXe/lUjNRnV7HGfoI1HkIUiIcdXgnkFC0mmCinh ZirtkZpddEmkAu/qwQ2IQ4GTkfWDYuS+KPH3qkQ= X-Google-Smtp-Source: ABdhPJyh/lebTKH//4hDHmK5mV5ZxwYiuwcKesrRGAkDsjLUuoF4UrbiW/2VGevCS3JNiez44KIXZpRa/2kB95n58ME= X-Received: by 2002:a17:906:ca43:: with SMTP id jx3mr8132821ejb.208.1594989035601; Fri, 17 Jul 2020 05:30:35 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: ian martins Date: Fri, 17 Jul 2020 08:30:24 -0400 Message-ID: Subject: Re: Why is Babel-C trimming its output? To: =?UTF-8?Q?Micha=C3=ABl_Cadilhac?= Content-Type: multipart/alternative; boundary="000000000000e342ab05aaa2528c" Received-SPF: pass client-ip=209.85.218.45; envelope-from=ianxm1@gmail.com; helo=mail-ej1-f45.google.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/07/17 08:30:36 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: 3 X-Spam_score: 0.3 X-Spam_bar: / X-Spam_report: (0.3 / 5.0 requ) BAYES_00=-1.9, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FORGED_FROMDOMAIN=1, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no 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: Org-Mode mailing list Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Scanner: scn0 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=jhu.edu (policy=none); 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: 0.09 X-TUID: KX9wCMP3sEMs --000000000000e342ab05aaa2528c Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Fortunately the author wrote tests, so we can tie the behavior of the code to use cases. Unfortunately all the tests pass with the call to org-trim removed. Also the call is there from the first commit of the file in git, so there's no commit message to explain. My guess is that it was added to clean up cases that resulted in extra trailing whitespace, but I dunno. On Wed, Jul 15, 2020 at 7:12 PM Micha=C3=ABl Cadilhac wrote: > Hello, > > Quick question here: in ob-C.el, before returning the output of a C > file, there's this line: > > (setq results (org-trim (org-remove-indentation results))) > > That seems quite arbitrary; is it on purpose? I have a C file that > outputs some sort of list of formatted numbers, e.g.: > > 0 -17.8 > 40 4.4 > 80 26.7 > 120 48.9 > > and only the first line gets trimmed, leading to a faulty output. > > This does not seem to be a universal thing in Babel; for instance: > > #+begin_src emacs-lisp :exports both :results value raw > " 0\n 1\n2\n" > #+end_src > > =E2=80=A6results in: > > #+RESULTS: > 0 > 1 > 2 > > But the same thing in C: > > #+begin_src C :exports both :results output raw > printf (" 0\n 1\n2\n"); > #+end_src > > =E2=80=A6results in: > #+RESULTS: > 0 > 1 > 2 > > Cheers, > M. > > --000000000000e342ab05aaa2528c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Fortunately the author wrote tests, so we can tie the= behavior of the code to use cases. Unfortunately all the tests pass with t= he call to org-trim removed. Also the call is there from the first commit o= f the file in git, so there's no commit message to explain.

My guess is that it was added to clean up cases that resu= lted in extra trailing whitespace, but I dunno.


On = Wed, Jul 15, 2020 at 7:12 PM Micha=C3=ABl Cadilhac <michael@cadilhac.name> wrote:=
Hello,

Quick question here: in ob-C.el, before returning the output of a C
file, there's this line:

(setq results (org-trim (org-remove-indentation results)))

That seems quite arbitrary; is it on purpose?=C2=A0 I have a C file that outputs some sort of list of formatted numbers, e.g.:

=C2=A0 0=C2=A0 -17.8
=C2=A040=C2=A0 =C2=A0 4.4
=C2=A080=C2=A0 =C2=A026.7
120=C2=A0 =C2=A048.9

and only the first line gets trimmed, leading to a faulty output.

This does not seem to be a universal thing in Babel; for instance:

#+begin_src emacs-lisp :exports both :results value raw
=C2=A0 " 0\n 1\n2\n"
#+end_src

=E2=80=A6results in:

#+RESULTS:
=C2=A00
=C2=A01
2

But the same thing in C:

#+begin_src C :exports both :results output raw
=C2=A0 printf (" 0\n 1\n2\n");
#+end_src

=E2=80=A6results in:
#+RESULTS:
0
=C2=A01
2

Cheers,
M.

--000000000000e342ab05aaa2528c--