The R Project SVN R

Rev

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

Rev 62372 Rev 62580
Line 1... Line 1...
1
/*
1
/*
2
 *  R : A Computer Language for Statistical Data Analysis
2
 *  R : A Computer Language for Statistical Data Analysis
3
 *  Copyright (C) 1995--2012  The R Core Team.
3
 *  Copyright (C) 1995--2013  The R Core Team.
4
 *
4
 *
5
 *  This program is free software; you can redistribute it and/or modify
5
 *  This program is free software; you can redistribute it and/or modify
6
 *  it under the terms of the GNU General Public License as published by
6
 *  it under the terms of the GNU General Public License as published by
7
 *  the Free Software Foundation; either version 2 of the License, or
7
 *  the Free Software Foundation; either version 2 of the License, or
8
 *  (at your option) any later version.
8
 *  (at your option) any later version.
Line 645... Line 645...
645
	len = strlen(head) + strlen(mid) + strlen(tail);
645
	len = strlen(head) + strlen(mid) + strlen(tail);
646
	
646
	
647
	Rvsnprintf(tmp, min(BUFSIZE, R_WarnLength) - strlen(head), format, ap);
647
	Rvsnprintf(tmp, min(BUFSIZE, R_WarnLength) - strlen(head), format, ap);
648
	dcall = CHAR(STRING_ELT(deparse1s(call), 0));
648
	dcall = CHAR(STRING_ELT(deparse1s(call), 0));
649
	if (len + strlen(dcall) + strlen(tmp) < BUFSIZE) {
649
	if (len + strlen(dcall) + strlen(tmp) < BUFSIZE) {
650
	    sprintf(errbuf, "%s%s%s", head, dcall, mid);
650
	    snprintf(errbuf, BUFSIZE,  "%s%s%s", head, dcall, mid);
651
	    if (mbcslocale) {
651
	    if (mbcslocale) {
652
		int msgline1;
652
		int msgline1;
653
		char *p = strchr(tmp, '\n');
653
		char *p = strchr(tmp, '\n');
654
		if (p) {
654
		if (p) {
655
		    *p = '\0';
655
		    *p = '\0';
Line 665... Line 665...
665
		if (14 + strlen(dcall) + msgline1 > LONGWARN)
665
		if (14 + strlen(dcall) + msgline1 > LONGWARN)
666
		    strcat(errbuf, tail);
666
		    strcat(errbuf, tail);
667
	    }
667
	    }
668
	    strcat(errbuf, tmp);
668
	    strcat(errbuf, tmp);
669
	} else {
669
	} else {
670
	    sprintf(errbuf, _("Error: "));
670
	    snprintf(errbuf, BUFSIZE, _("Error: "));
671
	    strcat(errbuf, tmp);
671
	    strcat(errbuf, tmp); // FIXME
672
	}
672
	}
673
	UNPROTECT(protected);
673
	UNPROTECT(protected);
674
    }
674
    }
675
    else {
675
    else {
676
	sprintf(errbuf, _("Error: "));
676
	snprintf(errbuf, BUFSIZE, _("Error: "));
677
	p = errbuf + strlen(errbuf);
677
	p = errbuf + strlen(errbuf);
678
	Rvsnprintf(p, min(BUFSIZE, R_WarnLength) - strlen(errbuf), format, ap);
678
	Rvsnprintf(p, min(BUFSIZE, R_WarnLength) - strlen(errbuf), format, ap);
679
    }
679
    }
680
 
680
 
681
    p = errbuf + strlen(errbuf) - 1;
681
    p = errbuf + strlen(errbuf) - 1;
Line 954... Line 954...
954
		break;
954
		break;
955
	    }
955
	    }
956
	    rho = CDR(rho);
956
	    rho = CDR(rho);
957
	}
957
	}
958
	if(strlen(domain)) {
958
	if(strlen(domain)) {
959
	    R_CheckStack2(strlen(domain)+3);
959
	    size_t len = strlen(domain)+3;
-
 
960
	    R_CheckStack2(len);
960
	    buf = (char *) alloca(strlen(domain)+3);
961
	    buf = (char *) alloca(len);
961
	    sprintf(buf, "R-%s", domain);
962
	    snprintf(buf, len, "R-%s", domain);
962
	    domain = buf;
963
	    domain = buf;
963
	}
964
	}
964
    } else if(isString(CAR(args)))
965
    } else if(isString(CAR(args)))
965
	domain = translateChar(STRING_ELT(CAR(args),0));
966
	domain = translateChar(STRING_ELT(CAR(args),0));
966
    else if(isLogical(CAR(args)) && LENGTH(CAR(args)) == 1 && LOGICAL(CAR(args))[0] == NA_LOGICAL) ;
967
    else if(isLogical(CAR(args)) && LENGTH(CAR(args)) == 1 && LOGICAL(CAR(args))[0] == NA_LOGICAL) ;
Line 1056... Line 1057...
1056
		break;
1057
		break;
1057
	    }
1058
	    }
1058
	    rho = CDR(rho);
1059
	    rho = CDR(rho);
1059
	}
1060
	}
1060
	if(strlen(domain)) {
1061
	if(strlen(domain)) {
1061
	    R_CheckStack2(strlen(domain)+3);
1062
	    size_t len = strlen(domain)+3;
-
 
1063
	    R_CheckStack2(len);
1062
	    buf = (char *) alloca(strlen(domain)+3);
1064
	    buf = (char *) alloca(len);
1063
	    sprintf(buf, "R-%s", domain);
1065
	    snprintf(buf, len, "R-%s", domain);
1064
	    domain = buf;
1066
	    domain = buf;
1065
	}
1067
	}
1066
    } else if(isString(sdom))
1068
    } else if(isString(sdom))
1067
	domain = CHAR(STRING_ELT(sdom,0));
1069
	domain = CHAR(STRING_ELT(sdom,0));
1068
    else if(isLogical(sdom) && LENGTH(sdom) == 1 && LOGICAL(sdom)[0] == NA_LOGICAL) ;
1070
    else if(isLogical(sdom) && LENGTH(sdom) == 1 && LOGICAL(sdom)[0] == NA_LOGICAL) ;