Skip to content

Commit c70627c

Browse files
author
ripley
committed
correct some comments
git-svn-id: https://svn.r-project.org/R/trunk@87389 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent c6b0952 commit c70627c

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/main/bind.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1360,13 +1360,16 @@ static SEXP cbind(SEXP call, SEXP args, SEXPTYPE mode, SEXP rho,
13601360
}
13611361
}
13621362
}
1363-
else { /* everything else, currently REALSXP, INTSXP, LGLSXP */
1363+
else { /* everything else, currently NILSXP, REALSXP, INTSXP, LGLSXP */
13641364
for (t = args; t != R_NilValue; t = CDR(t)) {
13651365
u = PRVALUE(CAR(t)); /* type of u can be any of: RAW, LGL, INT, REAL, or NULL */
13661366
if (isMatrix(u) || length(u) >= lenmin) {
13671367
R_xlen_t k = xlength(u); /* use xlength since u can be NULL */
13681368
R_xlen_t idx = (!isMatrix(u)) ? rows : k;
1369-
if (TYPEOF(u) <= INTSXP) { /* INT or LGL */
1369+
if (TYPEOF(u) <= INTSXP) { /* NILSXP or INT or LGL */
1370+
/* taking INTERER(NILSXP) should segfault, and
1371+
* sometimes does. But if cbinding a NULL, there
1372+
* are zero rows so nothing to do. */
13701373
if (mode <= INTSXP) {
13711374
xcopyIntegerWithRecycle(INTEGER(result), INTEGER(u),
13721375
n, idx, k);
@@ -1384,11 +1387,13 @@ static SEXP cbind(SEXP call, SEXP args, SEXPTYPE mode, SEXP rho,
13841387
xcopyRealWithRecycle(REAL(result), REAL(u), n, idx, k);
13851388
n += idx;
13861389
}
1387-
else { /* RAWSXP */
1390+
else { /* u is a RAWSXP */
13881391
/* FIXME: I'm not sure what the author intended when the sequence was
13891392
defined as raw < logical -- it is possible to represent logical as
13901393
raw losslessly but not vice versa. So due to the way this was
1391-
defined the raw -> logical conversion is bound to be lossy .. */
1394+
defined the raw -> logical conversion is bound to be lossy ..
1395+
But it is not: logicals include NAs, raws do not.
1396+
*/
13921397
if (mode == LGLSXP) {
13931398
R_xlen_t i, i1;
13941399
MOD_ITERATE1(idx, k, i, i1, {
@@ -1613,13 +1618,16 @@ static SEXP rbind(SEXP call, SEXP args, SEXPTYPE mode, SEXP rho,
16131618
}
16141619
}
16151620
}
1616-
else { /* everything else, currently REALSXP, INTSXP, LGLSXP */
1621+
else { /* everything else, currently NILSXP, REALSXP, INTSXP, LGLSXP */
16171622
for (t = args; t != R_NilValue; t = CDR(t)) {
16181623
u = PRVALUE(CAR(t)); /* type of u can be any of: RAW, LGL, INT, REAL */
16191624
if (isMatrix(u) || length(u) >= lenmin) {
16201625
R_xlen_t k = XLENGTH(u);
16211626
R_xlen_t idx = (isMatrix(u)) ? nrows(u) : (k > 0);
16221627
if (TYPEOF(u) <= INTSXP) {
1628+
/* taking INTERER(NILSXP) should segfault, and
1629+
* sometimes does. But if rbinding a NULL, there
1630+
* are zero cols so nothing to do. */
16231631
if (mode <= INTSXP) {
16241632
xfillIntegerMatrixWithRecycle(INTEGER(result),
16251633
INTEGER(u), n, rows,
@@ -1643,7 +1651,7 @@ static SEXP rbind(SEXP call, SEXP args, SEXPTYPE mode, SEXP rho,
16431651
FILL_MATRIX_ITERATE(n, rows, idx, cols, k)
16441652
LOGICAL(result)[didx] = RAW(u)[sidx] ? TRUE : FALSE;
16451653
}
1646-
else
1654+
else // cbind covers INTSXP and RAWSXP, so this is incomplete
16471655
FILL_MATRIX_ITERATE(n, rows, idx, cols, k)
16481656
INTEGER(result)[didx] = (unsigned char) RAW(u)[sidx];
16491657
}

0 commit comments

Comments
 (0)