The R Project SVN R

Rev

Rev 28254 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 28254 Rev 28362
Line 211... Line 211...
211
	}
211
	}
212
    }
212
    }
213
    return NA_STRING;
213
    return NA_STRING;
214
}
214
}
215
 
215
 
-
 
216
R_len_t asVecSize(SEXP x)
-
 
217
{
-
 
218
    int warn = 0, res;
-
 
219
    double d;
-
 
220
 
-
 
221
    if (isVectorAtomic(x) && LENGTH(x) >= 1) {
-
 
222
	switch (TYPEOF(x)) {
-
 
223
	case LGLSXP:
-
 
224
	    res = IntegerFromLogical(LOGICAL(x)[0], &warn);
-
 
225
	    if(res == NA_INTEGER) error("vector size cannot be NA");
-
 
226
	    return res;
-
 
227
	case INTSXP:
-
 
228
	    res = INTEGER(x)[0];
-
 
229
	    if(res == NA_INTEGER) error("vector size cannot be NA");
-
 
230
	    return res;
-
 
231
	case REALSXP:
-
 
232
	    d = REAL(x)[0];
-
 
233
	    if(d < 0) error("vector size cannot be negative");
-
 
234
	    if(d > R_LEN_T_MAX) error("vector size specified is too large");
-
 
235
	    return (R_size_t) d;
-
 
236
	}
-
 
237
    }
-
 
238
    return -1;
-
 
239
}
-
 
240
 
216
 
241
 
217
const static char type_msg[] = "invalid type passed to internal function\n";
242
const static char type_msg[] = "invalid type passed to internal function\n";
218
 
243
 
219
 
244
 
220
void internalTypeCheck(SEXP call, SEXP s, SEXPTYPE type)
245
void internalTypeCheck(SEXP call, SEXP s, SEXPTYPE type)