From ripley at stats.ox.ac.uk  Sat Dec 27 06:59:24 2008
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Sat, 27 Dec 2008 05:59:24 +0000 (GMT)
Subject: [Rd] Patch to fix small bug in do_External and do_dotcall
In-Reply-To: <1230337825-sup-1196@bloxx.plex>
References: <1230337825-sup-1196@bloxx.plex>
Message-ID: <alpine.LFD.2.00.0812270557360.20482@gannet.stats.ox.ac.uk>

Thank you, but can we see the patch please (no attachement arrived)?

On Sat, 27 Dec 2008, Olaf Mersmann wrote:

> I've stumbled upon a small bug/inconsitency in do_External and do_dotcall:
>
> Here's an example:
>
>  % LC_ALL=C R  --vanilla < symname-bug.R
>
>  R version 2.8.0 (2008-10-20)
>  *snip*
>  > options(error=expression(0))
>  > ## Call 'R_GD_nullDevice' with incorrect parameter count:
>  > .Call("R_GD_nullDevice", 1)
>  Error in .Call("R_GD_nullDevice", 1) :
>    Incorrect number of arguments (1), expecting 0 for R_GD_nullDevice
>  >
>  > ## Same call made via a NativeSymbolInfo object:
>  > sym <- getDLLRegisteredRoutines("grDevices")$.Call[["R_GD_nullDevice"]]
>  > .Call(sym$address, 1)
>  Error: 'getEncChar' must be called on a CHARSXP
>
> The error stems from the fact, that both do_External and do_dotcall
> expect CAR(args) to be a string, while it might be a NativeSymbolInfo
> object. checkValidSymbolId() already handles this, so the fix is to
> use the symbol name returned from resolveNativeRoutine().
>
> After applying the attached patch (against R-trunk revision 47348) the
> output looks like this:
>
>  % LC_ALL=C bin/R  --vanilla < symname-bug.R
>
>  R version 2.9.0 Under development (unstable) (2008-12-26 r47348)
>  *snip*
>  > options(error=expression(0))
>  > ## Call 'R_GD_nullDevice' with incorrect parameter count:
>  > .Call("R_GD_nullDevice", 1)
>  Error in .Call("R_GD_nullDevice", 1) :
>    Incorrect number of arguments (1), expecting 0 for R_GD_nullDevice
>  >
>  > ## Same call made via a NativeSymbolInfo object:
>  > sym <- getDLLRegisteredRoutines("grDevices")$.Call[["R_GD_nullDevice"]]
>  > .Call(sym$address, 1)
>  Error in .Call(sym$address, 1) :
>    Incorrect number of arguments (1), expecting 0 for R_GD_nullDevice
>
> Greetings from Dortmund
> Olaf
>

-- 
Brian D. Ripley,                  ripley at 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 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] Patch to fix small bug in do_External and do_dotcall
Prof Brian Ripley