The R Project SVN R

Rev

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

Rev 75529 Rev 75532
Line 1980... Line 1980...
1980
void attribute_hidden
1980
void attribute_hidden
1981
R_BadValueInRCode(SEXP value, SEXP call, SEXP rho, const char *rawmsg,
1981
R_BadValueInRCode(SEXP value, SEXP call, SEXP rho, const char *rawmsg,
1982
                  const char *errmsg, const char *warnmsg,
1982
                  const char *errmsg, const char *warnmsg,
1983
                  const char *varname, Rboolean warnByDefault)
1983
                  const char *varname, Rboolean warnByDefault)
1984
{
1984
{
-
 
1985
    int nprotect = 0;
1985
    char *check = getenv(varname);
1986
    char *check = getenv(varname);
1986
    const void *vmax = vmaxget();
1987
    const void *vmax = vmaxget();
1987
    Rboolean err = check && StringTrue(check);
1988
    Rboolean err = check && StringTrue(check);
1988
    if (!err && check && StringFalse(check))
1989
    if (!err && check && StringFalse(check))
1989
	check = NULL; /* disabled */
1990
	check = NULL; /* disabled */
Line 2003... Line 2004...
2003
	size_t lwprefix = strlen(wprefix);
2004
	size_t lwprefix = strlen(wprefix);
2004
	size_t lcpname = strlen(cpname);
2005
	size_t lcpname = strlen(cpname);
2005
	Rboolean ignore = FALSE;
2006
	Rboolean ignore = FALSE;
2006
 
2007
 
2007
	SEXP spkg = R_NilValue;
2008
	SEXP spkg = R_NilValue;
2008
	for(; spkg == R_NilValue && rho != R_EmptyEnv; rho = ENCLOS(rho))
2009
	for(; rho != R_EmptyEnv; rho = ENCLOS(rho))
2009
	    if (R_IsPackageEnv(rho))
2010
	    if (R_IsPackageEnv(rho)) {
2010
		spkg = R_PackageEnvName(rho);
2011
		PROTECT(spkg = R_PackageEnvName(rho));
-
 
2012
		nprotect++;
-
 
2013
		break;
2011
	    else if (R_IsNamespaceEnv(rho))
2014
	    } else if (R_IsNamespaceEnv(rho)) {
2012
		spkg = R_NamespaceEnvSpec(rho);
2015
		PROTECT(spkg = R_NamespaceEnvSpec(rho));
-
 
2016
		nprotect++;
-
 
2017
		break;
-
 
2018
	    }
2013
	if (spkg != R_NilValue)
2019
	if (spkg != R_NilValue)
2014
	    pkgname = translateChar(STRING_ELT(spkg, 0));
2020
	    pkgname = translateChar(STRING_ELT(spkg, 0));
2015
 
2021
 
2016
	while (check[0] != '\0') {
2022
	while (check[0] != '\0') {
2017
	    if (!strncmp(pprefix, check, lpprefix)) {
2023
	    if (!strncmp(pprefix, check, lpprefix)) {
Line 2099... Line 2105...
2099
    else if (err)
2105
    else if (err)
2100
	errorcall(call, errmsg);
2106
	errorcall(call, errmsg);
2101
    else if (warn || warnByDefault)
2107
    else if (warn || warnByDefault)
2102
	warningcall(call, warnmsg);
2108
	warningcall(call, warnmsg);
2103
    vmaxset(vmax);
2109
    vmaxset(vmax);
-
 
2110
    UNPROTECT(nprotect);
2104
}
2111
}
2105
 
2112
 
2106
 
2113
 
2107
/* These functions are to be used in error messages, and available for others to use in the API
2114
/* These functions are to be used in error messages, and available for others to use in the API
2108
   GetCurrentSrcref returns the first non-NULL srcref after skipping skip of them.  If it
2115
   GetCurrentSrcref returns the first non-NULL srcref after skipping skip of them.  If it