From Prof Brian Ripley <ripley@stats.ox.ac.uk>  Mon May 22 15:48:52 2000
From: Prof Brian Ripley <ripley@stats.ox.ac.uk> (Prof Brian Ripley)
Date: Mon, 22 May 2000 15:48:52 +0100 (BST)
Subject: [Rd] character arguments with call_R (PR#552)
Message-ID: <200005221448.PAA14128@toucan.stats.ox.ac.uk>


> From: jlindsey@alpha.luc.ac.be
> Date: Mon, 22 May 2000 16:13:34 +0200 (MET DST)
> To: r-devel@stat.math.ethz.ch
> Subject: [Rd] character arguments with call_R (PR#552)
> CC: R-bugs@biostat.ku.dk
> X-Loop: R-bugs@biostat.ku.dk
> 
> character arguments with call_R do not work except in the first
> position. (In other positions, they just yield a single blank
> character.)
>  The error is at line 1858 of dotcode.c which should be changed from
> STRING(CAR(pcall))[i]=s;
> to
> STRING(CAR(pcall))[0]=s;
>   Jim

It's much worse than that, as this happens n times inside a loop.
It looks to me as if the code has fairly thoroughly confused character
strings and character vectors.  I suspect it should be more like

	    for (j = 0 ; j < n ; j++) {
		s = allocSExp(CHARSXP);
		CHAR(s) = ((char**)(arguments[i]))[j];
		LENGTH(s) = strlen(CHAR(s));
		STRING(CAR(pcall))[j] = s;
	    }

or, more consisely

	    for (j = 0 ; j < n ; j++) {
		cptr = (char**)arguments[i]
		STRING(CAR(pcall))[j] = mkChar(cptr[j])
	    }

Do you have a succinct example on which we could test out solutions?

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] character arguments with call_R (PR#552)
Prof Brian Ripley