View | Details | Raw Unified | Return to bug 16932 | Differences between
and this patch

Collapse All | Expand All

(-)seq.c (-16 / +24 lines)
Lines 334-340 Link Here
334
	      type2char(TYPEOF(s)));
334
	      type2char(TYPEOF(s)));
335
335
336
    nc = xlength(ncopy); // might be 0
336
    nc = xlength(ncopy); // might be 0
337
    if (nc != 1 && nc == xlength(s))
337
    if (nc == xlength(s)
338
#ifdef LONG_VECTOR_SUPPORT
339
    && !(nc == 1 && TYPEOF(ncopy) == REALSXP && REAL(ncopy)[0] > INT_MAX)
340
#endif
341
    )
338
	PROTECT(a = rep2(s, ncopy));
342
	PROTECT(a = rep2(s, ncopy));
339
    else {
343
    else {
340
	if (nc != 1) error(_("invalid '%s' value"), "times");
344
	if (nc != 1) error(_("invalid '%s' value"), "times");
Lines 652-684 Link Here
652
	nt = 1;
656
	nt = 1;
653
    } else {
657
    } else {
654
	R_xlen_t sum = 0;
658
	R_xlen_t sum = 0;
655
	nt = CADR(args) == R_MissingArg ? 1 : XLENGTH(CADR(args));
659
	times = CADR(args);
660
#ifdef LONG_VECTOR_SUPPORT
661
	if (!(TYPEOF(times) == REALSXP &&
662
	    XLENGTH(times) == 1 && REAL(times)[0] > INT_MAX))
663
#endif
664
	{
665
	    if(times == R_MissingArg) PROTECT(times = ScalarInteger(1));
666
	    else PROTECT(times = coerceVector(times, INTSXP));
667
	    nprotect++;
668
	}
669
	nt = XLENGTH(times);
656
	if(nt == 1) {
670
	if(nt == 1) {
657
	    R_xlen_t it;
671
	    R_xlen_t it;
658
	    if(CADR(args) == R_MissingArg) it = 1; else {
659
		if(!isVectorAtomic(CADR(args))) {
660
		    warningcall(call, _("'%s' is not an atomic vector.  This is deprecated."),
661
				"times");
662
		    PROTECT(times = coerceVector(CADR(args), REALSXP)); nprotect++;
663
		} else times = CADR(args);
664
#ifdef LONG_VECTOR_SUPPORT
672
#ifdef LONG_VECTOR_SUPPORT
665
		double rt = asReal(times); // asReal(CADR(args));
673
	    if (TYPEOF(times) == REALSXP) {
674
		double rt = REAL(times)[0];
666
		if (!R_FINITE(rt) || rt < 0)
675
		if (!R_FINITE(rt) || rt < 0)
667
		    errorcall(call, _("invalid '%s' argument"), "times");
676
		    errorcall(call, _("invalid '%s' argument"), "times");
668
		it = (R_xlen_t) rt;
677
		it = (R_xlen_t) rt;
669
#else
678
	    } else
670
		it = asInteger(times); // asInteger(CADR(args));
679
#endif
680
	    {
681
		it = INTEGER(times)[0];
671
		if (it == NA_INTEGER || it < 0)
682
		if (it == NA_INTEGER || it < 0)
672
		    errorcall(call, _("invalid '%s' argument"), "times");
683
		    errorcall(call, _("invalid '%s' argument"), "times");
673
#endif
674
	    }
684
	    }
675
	    len = lx * it * each;
685
	    len = lx * it * each;
676
	} else { // nt != 1 -- only for this case 'times' is accessed, here and in rep4()
686
	} else { // nt != 1
677
	    if(nt != lx * each)
687
	    if(nt != lx * each)
678
		errorcall(call, _("invalid '%s' argument"), "times");
688
		errorcall(call, _("invalid '%s' argument"), "times");
679
	    // FIXME: 1. allow large int., i.e. REALSXP; would need even more changes in rep4()
689
	    // FIXME: allow large int., i.e. REALSXP; would need even more changes in rep4()
680
	    //        2. this does still work with  list(1,2) [which should be deprecated]
681
	    PROTECT(times = coerceVector(CADR(args), INTSXP)); nprotect++;
682
	    for(i = 0; i < nt; i++) {
690
	    for(i = 0; i < nt; i++) {
683
		int it = INTEGER(times)[i];
691
		int it = INTEGER(times)[i];
684
		if (it == NA_INTEGER || it < 0)
692
		if (it == NA_INTEGER || it < 0)

Return to bug 16932