[Rd] Patch to address (PR#7853) -- tested briefly, seems to work

keithf at amnis.com keithf at amnis.com
Thu May 12 00:01:06 CEST 2005


--- dotcode.c    2004-09-05 02:31:57.000000000 -0700
+++ /usr/local/src/R-2.0.0/src/main/dotcode.c    2005-05-11 
12:24:11.000000000 -0700
@@ -190,6 +190,7 @@
 static void *RObjToCPtr(SEXP s, int naok, int dup, int narg, int Fort, 
const char *name, R_toCConverter **converter,
                           int targetType)
 {
+    unsigned char *rawptr;
     int *iptr;
     float *sptr;
     double *rptr;
@@ -228,6 +229,16 @@
     }
 
     switch(TYPEOF(s)) {
+    case RAWSXP:
+    n = LENGTH(s);
+    rawptr = RAW(s);
+    if (dup) {
+        rawptr = (unsigned char *) R_alloc(n, sizeof(unsigned char));
+        for (i = 0; i < n; i++)
+            rawptr[i] = RAW(s)[i];
+    }
+    return (void *) rawptr;
+    break;
     case LGLSXP:
     case INTSXP:
     n = LENGTH(s);
@@ -329,6 +340,7 @@
 
 static SEXP CPtrToRObj(void *p, SEXP arg, int Fort, 
R_NativePrimitiveArgType type)
 {
+    unsigned char *rawptr;
     int *iptr, n=length(arg);
     float *sptr;
     double *rptr;
@@ -339,6 +351,12 @@
     SEXP s, t;
 
     switch(type) {
+    case RAWSXP:
+    s = allocVector(type, n);
+    rawptr = (unsigned char *)p;
+    for (i = 0; i < n; i++)
+        RAW(s)[i] = rawptr[i];
+    break;
     case LGLSXP:
     case INTSXP:
     s = allocVector(type, n);



More information about the R-devel mailing list