The R Project SVN R

Rev

Rev 27383 | Rev 28766 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 27383 Rev 28762
Line 249... Line 249...
249
 
249
 
250
static SEXP negativeSubscript(SEXP s, int ns, int nx)
250
static SEXP negativeSubscript(SEXP s, int ns, int nx)
251
{
251
{
252
    SEXP indx;
252
    SEXP indx;
253
    int stretch = 0;
253
    int stretch = 0;
254
    int i;
254
    int i, ix;
255
    PROTECT(indx = allocVector(INTSXP, nx));
255
    PROTECT(indx = allocVector(INTSXP, nx));
256
    for (i = 0; i < nx; i++)
256
    for (i = 0; i < nx; i++)
257
	INTEGER(indx)[i] = 1;
257
	INTEGER(indx)[i] = 1;
258
    for (i = 0; i < ns; i++)
258
    for (i = 0; i < ns; i++) {
259
	if (INTEGER(s)[i] != 0)
259
	ix = INTEGER(s)[i]; 
-
 
260
	if (ix != 0 && ix != NA_INTEGER && -ix <= nx)
260
	    INTEGER(indx)[-INTEGER(s)[i] - 1] = 0;
261
	    INTEGER(indx)[-ix - 1] = 0;
-
 
262
    }
261
    s = logicalSubscript(indx, nx, nx, &stretch);
263
    s = logicalSubscript(indx, nx, nx, &stretch);
262
    UNPROTECT(1);
264
    UNPROTECT(1);
263
    return s;
265
    return s;
264
}
266
}
265
 
267