Bug 16544 - system(..., intern=TRUE) truncates lines at 8095 chars
Summary: system(..., intern=TRUE) truncates lines at 8095 chars
Status: CLOSED FIXED
Alias: None
Product: R
Classification: Unclassified
Component: Low-level (show other bugs)
Version: R-devel (trunk)
Hardware: Other Linux
: P5 normal
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2015-09-23 17:09 UTC by Karl Millar
Modified: 2015-12-14 13:48 UTC (History)
1 user (show)

See Also:


Attachments
Patch against current r-devel (1.69 KB, text/plain)
2015-09-23 17:09 UTC, Karl Millar
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Karl Millar 2015-09-23 17:09:56 UTC
Created attachment 1915 [details]
Patch against current r-devel

Currently, for long lines output from system(), the line is split at 8095 characters, the continuation becomes the next line and a warning is issued.

This patch fixes that.
Comment 1 Martin Maechler 2015-10-09 10:42:31 UTC
This sounds useful ...  I'm hoping there's not much old code relying on the old behavior as a feature.

(Note that the patch file does not apply cleanly for me, for some reason; but it's been easy to apply the two failing chunks manually)
Comment 2 Martin Maechler 2015-10-09 13:14:04 UTC
(In reply to Karl Millar from comment #0)
> Created attachment 1915 [details]
> Patch against current r-devel
> 
> Currently, for long lines output from system(), the line is split at 8095
> characters, the continuation becomes the next line and a warning is issued.
> 
> This patch fixes that.

Indeed, it does.. and I've also added a small regression check in my local version of R.

One remaining problem:

The patch uses  getline()  from <stdio.h>  which is fine, but "somewhat" newish.
Adding a check to  configure.ac  looks like only one simple line,
but my remaining question is if we must workaround a missing  getline() via #ifdef ..  and alternative code  {from where could I get that?}
or if it is fine to signal a configuration error (how exactly?) when getline() is not found on the build platform.
Comment 3 Martin Maechler 2015-10-14 10:41:46 UTC
(In reply to Martin Maechler from comment #2)
> (In reply to Karl Millar from comment #0)
> > Created attachment 1915 [details]
> > Patch against current r-devel
> > 
> > Currently, for long lines output from system(), the line is split at 8095
> > characters, the continuation becomes the next line and a warning is issued.
> > 
> > This patch fixes that.
> 
> Indeed, it does.. and I've also added a small regression check in my local
> version of R.
> 
> One remaining problem:
> 
> The patch uses  getline()  from <stdio.h>  which is fine, but "somewhat"
> newish.
> Adding a check to  configure.ac  looks like only one simple line,
> but my remaining question is if we must workaround a missing  getline() via
> #ifdef ..  and alternative code  {from where could I get that?}
> or if it is fine to signal a configuration error (how exactly?) when
> getline() is not found on the build platform.

I have now committed an extended version of your patch....
only "#ifdef HAVE_getline" ... so this will be save
(and revert to the old behavior on build platforms that lack a 'getline()').

Only for R-devel, because of the configure-implications.

------------------------------------------------------------------------
r69512 | maechler | 2015-10-14 12:38:27 +0200 (Wed, 14 Oct 2015) | 1 line
Changed paths:
   M configure
   M configure.ac
   M doc/NEWS.Rd
   M src/include/config.h.in
   M src/unix/sys-unix.c
   M tests/reg-tests-1c.R

on unix-alikes with working C getline(), our system() no longer splits and truncates lines longer than 8192
------------------------------------------------------------------------