[Rd] Patch to fix small bug in do_External and do_dotcall
Olaf Mersmann
olafm at kimberly.tako.de
Sat Dec 27 01:38:44 CET 2008
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
More information about the R-devel
mailing list