Skip to content
Prev 31106 / 63424 Next

Floating point excepting when cbind()ing a matrix of grobs (orenvironments) with a 0-column matrix

I think the following patch to src/main/bind.c fixes it up.
If the length of an argument to [cr]bind is 0 then it wont't
try to add any data from it to the output any more, just as
is done with the other modes of data.  It was getting the FPE
from i%k when k==0.

Index: src/main/bind.c
===================================================================
--- src/main/bind.c     (revision 47617)
+++ src/main/bind.c     (working copy)
@@ -1218,10 +1218,12 @@
                case LISTSXP:
                    PROTECT(u = coerceVector(u, mode));
                    k = LENGTH(u);
-                   idx = (!isMatrix(u)) ? rows : k;
-                   for (i = 0; i < idx; i++)
-                       SET_VECTOR_ELT(result, n++,
-                                      duplicate(VECTOR_ELT(u, i % k)));
+                   if (k>0) {
+                       idx = (!isMatrix(u)) ? rows : k;
+                       for (i = 0; i < idx; i++)
+                           SET_VECTOR_ELT(result, n++,
+                                          duplicate(VECTOR_ELT(u, i %
k)));
+                   }
                    UNPROTECT(1);
                    break;
                default:

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com