Skip to content

Commit

Permalink
correct to isValidString()
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@8017 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
maechler committed Feb 7, 2000
1 parent a7c80da commit 6cc1167
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/main/devices.c
Expand Up @@ -230,7 +230,7 @@ SEXP do_X11(SEXP call, SEXP op, SEXP args, SEXP env)
if (gamma < 0 || gamma > 100)
errorcall(call, "invalid gamma value");

if (!isString(CAR(args)) || length(CAR(args)) < 1)
if (!isValidString(CAR(args)))
error("invalid colortype passed to X11 driver");
cname = CHAR(STRING(CAR(args))[0]);
if (strcmp(cname, "mono") == 0)
Expand All @@ -251,7 +251,7 @@ SEXP do_X11(SEXP call, SEXP op, SEXP args, SEXP env)
maxcubesize = asInteger(CAR(args));
if (maxcubesize < 1 || maxcubesize > 256)
maxcubesize = 256;

/* Allocate and initialize the device driver data */
if (!(dd = (DevDesc*)malloc(sizeof(DevDesc))))
return 0;
Expand Down
25 changes: 12 additions & 13 deletions src/main/envir.c
Expand Up @@ -899,11 +899,9 @@ static SEXP mfindVarInFrame(SEXP rho, SEXP symbol)

/*----------------------------------------------------------------------
do_assign
*/
do_assign : .Internal(assign(x, value, envir, inherits))
*/
SEXP do_assign(SEXP call, SEXP op, SEXP args, SEXP rho)
{
SEXP name, val, aenv;
Expand All @@ -912,18 +910,18 @@ SEXP do_assign(SEXP call, SEXP op, SEXP args, SEXP rho)
name = findVar(CAR(args), rho);
PROTECT(args = evalList(args, rho));
if (!isString(CAR(args)) || length(CAR(args)) == 0)
error("assign: invalid first argument");
error("invalid first argument");
else
name = install(CHAR(STRING(CAR(args))[0]));
PROTECT(val = CADR(args));
R_Visible = 0;
aenv = CAR(CDDR(args));
if (TYPEOF(aenv) != ENVSXP && aenv != R_NilValue)
error("invalid envir argument");
errorcall(call, "invalid `envir' argument");
if (isLogical(CAR(nthcdr(args, 3))))
ginherits = LOGICAL(CAR(nthcdr(args, 3)))[0];
else
error("get: invalid inherits argument");
errorcall(call, "invalid `inherits' argument");
if (ginherits)
setVar(name, val, aenv);
else
Expand Down Expand Up @@ -968,28 +966,30 @@ static int RemoveVariable(SEXP name, int hashcode, SEXP env)

SEXP do_remove(SEXP call, SEXP op, SEXP args, SEXP rho)
{
/* .Internal(remove(list, envir, inherits)) */

SEXP name, envarg, tsym, tenv;
int ginherits = 0;
int done, i, hashcode;
checkArity(op, args);

name = CAR(args);
if (!isString(name))
error("invalid first argument to remove.");
errorcall(call, "invalid first argument to remove.");
args = CDR(args);

envarg = CAR(args);
if (envarg != R_NilValue) {
if (TYPEOF(envarg) != ENVSXP)
error("invalid envir argument");
errorcall(call, "invalid `envir' argument");
}
else envarg = R_GlobalContext->sysparent;
args = CDR(args);

if (isLogical(CAR(args)))
ginherits = asLogical(CAR(args));
else
error("get: invalid inherits argument");
errorcall(call, "invalid `inherits' argument");

for (i = 0; i < LENGTH(name); i++) {
done = 0;
Expand Down Expand Up @@ -1048,8 +1048,7 @@ SEXP do_get(SEXP call, SEXP op, SEXP args, SEXP rho)
/* The first arg is the object name */
/* It must be present and a string */

if (!isString(CAR(args)) || length(CAR(args)) < 1
|| strlen(CHAR(STRING(CAR(args))[0])) == 0) {
if (!isValidStringF(CAR(args))) {
errorcall(call, "invalid first argument");
t1 = R_NilValue;
}
Expand Down Expand Up @@ -1239,7 +1238,7 @@ SEXP do_attach(SEXP call, SEXP op, SEXP args, SEXP env)
error("attach: pos must be an integer");

name = CADDR(args);
if (!isString(name) || length(name) != 1)
if (!isValidStringF(name))
error("attach: invalid object name");

for (x = CAR(args); x != R_NilValue; x = CDR(x))
Expand Down

0 comments on commit 6cc1167

Please sign in to comment.