The R Project SVN R

Rev

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

Rev 28762 Rev 28766
Line 285... Line 285...
285
}
285
}
286
 
286
 
287
static SEXP integerSubscript(SEXP s, int ns, int nx, int *stretch)
287
static SEXP integerSubscript(SEXP s, int ns, int nx, int *stretch)
288
{
288
{
289
    int i, ii, min, max, canstretch;
289
    int i, ii, min, max, canstretch;
-
 
290
    Rboolean isna = FALSE;
290
    canstretch = *stretch;
291
    canstretch = *stretch;
291
    *stretch = 0;
292
    *stretch = 0;
292
    min = 0;
293
    min = 0;
293
    max = 0;
294
    max = 0;
294
    for (i = 0; i < ns; i++) {
295
    for (i = 0; i < ns; i++) {
Line 296... Line 297...
296
	if (ii != NA_INTEGER) {
297
	if (ii != NA_INTEGER) {
297
	    if (ii < min)
298
	    if (ii < min)
298
		min = ii;
299
		min = ii;
299
	    if (ii > max)
300
	    if (ii > max)
300
		max = ii;
301
		max = ii;
301
	}
302
	} else isna = TRUE;
302
    }
303
    }
303
    if (min < -nx)
304
    if (min < -nx)
304
	error("subscript out of bounds");
305
	error("subscript out of bounds");
305
    if (max > nx) {
306
    if (max > nx) {
306
	if(canstretch) *stretch = max;
307
	if(canstretch) *stretch = max;
307
	else error("subscript out of bounds");
308
	else error("subscript out of bounds");
308
    }
309
    }
309
    if (min < 0) {
310
    if (min < 0) {
310
	if (max == 0) return negativeSubscript(s, ns, nx);
311
	if (max == 0 && !isna) return negativeSubscript(s, ns, nx);
311
	else error("only 0's may mix with negative subscripts");
312
	else error("only 0's may mix with negative subscripts");
312
    }
313
    }
313
    else return positiveSubscript(s, ns, nx);
314
    else return positiveSubscript(s, ns, nx);
314
    return R_NilValue;
315
    return R_NilValue;
315
}
316
}