Skip to content

Commit 0bb64f9

Browse files
author
ripley
committed
more Rboolean tweaks
git-svn-id: https://svn.r-project.org/R/trunk@87815 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 126423e commit 0bb64f9

File tree

11 files changed

+46
-44
lines changed

11 files changed

+46
-44
lines changed

src/main/envir.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1677,7 +1677,7 @@ void defineVar(SEXP symbol, SEXP value, SEXP rho)
16771677
}
16781678
hashcode = HASHVALUE(c) % HASHSIZE(HASHTAB(rho));
16791679
R_HashSet(hashcode, symbol, HASHTAB(rho), value,
1680-
FRAME_IS_LOCKED(rho));
1680+
(Rboolean) FRAME_IS_LOCKED(rho));
16811681
if (R_HashSizeCheck(HASHTAB(rho)))
16821682
SET_HASHTAB(rho, R_HashResize(HASHTAB(rho)));
16831683
}
@@ -2136,7 +2136,8 @@ attribute_hidden SEXP do_get(SEXP call, SEXP op, SEXP args, SEXP rho)
21362136
error(_("invalid '%s' argument"), "inherits");
21372137

21382138
/* Search for the object */
2139-
rval = findVar1mode(t1, genv, gmode, wants_S4, ginherits, PRIMVAL(op));
2139+
rval = findVar1mode(t1, genv, gmode, wants_S4, ginherits,
2140+
(Rboolean) PRIMVAL(op));
21402141
if (rval == R_MissingArg) { // signal a *classed* error:
21412142
R_MissingArgError(t1, call, "getMissingError");
21422143
}
@@ -2391,7 +2392,7 @@ Rboolean R_isMissing(SEXP symbol, SEXP rho)
23912392
int oldseen = PRSEEN(CAR(vl));
23922393
SET_PRSEEN(CAR(vl), 1);
23932394
PROTECT(vl);
2394-
int val = R_isMissing(PREXPR(CAR(vl)), PRENV(CAR(vl)));
2395+
Rboolean val = R_isMissing(PREXPR(CAR(vl)), PRENV(CAR(vl)));
23952396
UNPROTECT(1); /* vl */
23962397
/* The oldseen value will usually be 0, but might be 2
23972398
from an interrupted evaluation. LT */
@@ -2934,7 +2935,7 @@ attribute_hidden SEXP do_ls(SEXP call, SEXP op, SEXP args, SEXP rho)
29342935
int sort_nms = asLogical(CADDR(args)); /* sorted = TRUE/FALSE */
29352936
if (sort_nms == NA_LOGICAL) sort_nms = 0;
29362937

2937-
return R_lsInternal3(env, all, sort_nms);
2938+
return R_lsInternal3(env, (Rboolean) all, (Rboolean) sort_nms);
29382939
}
29392940

29402941
/* takes an environment, a boolean indicating whether to get all
@@ -3398,7 +3399,7 @@ attribute_hidden SEXP do_lockEnv(SEXP call, SEXP op, SEXP args, SEXP rho)
33983399
Rboolean bindings;
33993400
checkArity(op, args);
34003401
frame = CAR(args);
3401-
bindings = asLogical(CADR(args));
3402+
bindings = asRbool(CADR(args), call);
34023403
R_LockEnvironment(frame, bindings);
34033404
return R_NilValue;
34043405
}

src/main/errors.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
in more places. LT */
4040
static SEXP evalKeepVis(SEXP e, SEXP rho)
4141
{
42-
int oldvis = R_Visible;
42+
Rboolean oldvis = R_Visible;
4343
SEXP val = eval(e, rho);
4444
R_Visible = oldvis;
4545
return val;
@@ -1209,7 +1209,7 @@ attribute_hidden SEXP do_gettext(SEXP call, SEXP op, SEXP args, SEXP rho)
12091209
trim = TRUE;
12101210
else
12111211
#endif
1212-
trim = asLogical(CADDR(args));
1212+
trim = asRbool(CADDR(args), call);
12131213
for(int i = 0; i < n; i++) {
12141214
int ihead = 0, itail = 0;
12151215
const char * This = translateChar(STRING_ELT(string, i));
@@ -2159,9 +2159,9 @@ do_printDeferredWarnings(SEXP call, SEXP op, SEXP args, SEXP env)
21592159
attribute_hidden SEXP
21602160
do_interruptsSuspended(SEXP call, SEXP op, SEXP args, SEXP env)
21612161
{
2162-
int orig_value = R_interrupts_suspended;
2162+
Rboolean orig_value = R_interrupts_suspended;
21632163
if (args != R_NilValue)
2164-
R_interrupts_suspended = asLogical(CAR(args));
2164+
R_interrupts_suspended = asRbool(CAR(args), call);
21652165
return ScalarLogical(orig_value);
21662166
}
21672167

@@ -2441,7 +2441,7 @@ typedef struct {
24412441
void *hdata;
24422442
void (*finally)(void *);
24432443
void *fdata;
2444-
int suspended;
2444+
Rboolean suspended;
24452445
} tryCatchData_t;
24462446

24472447
static SEXP default_tryCatch_handler(SEXP cond, void *data)

src/main/gram.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4125,11 +4125,11 @@ SEXP R_Parse1Buffer(IoBuffer *buffer, int gencode, ParseStatus *status)
41254125

41264126
R_InitSrcRefState(&cntxt);
41274127
if (gencode) {
4128-
keepSource = asLogical(GetOption1(install("keep.source")));
4128+
keepSource = asRbool(GetOption1(install("keep.source")), R_NilValue);
41294129
if (keepSource) {
41304130
ParseState.keepSrcRefs = TRUE;
41314131
ParseState.keepParseData =
4132-
asLogical(GetOption1(install("keep.parse.data")));
4132+
asRbool(GetOption1(install("keep.parse.data")), R_NilValue);
41334133
PS_SET_SRCFILE(NewEnvironment(R_NilValue, R_NilValue, R_EmptyEnv));
41344134
PS_SET_ORIGINAL(PS_SRCFILE);
41354135
PS_SET_SRCREFS(R_NilValue);
@@ -4191,7 +4191,7 @@ static SEXP R_Parse(int n, ParseStatus *status, SEXP srcfile)
41914191
if (isEnvironment(srcfile)) {
41924192
ParseState.keepSrcRefs = TRUE;
41934193
ParseState.keepParseData =
4194-
asLogical(GetOption1(install("keep.parse.data")));
4194+
asRbool(GetOption1(install("keep.parse.data")), R_NilValue);
41954195
PS_SET_SRCREFS(R_NilValue);
41964196
}
41974197

@@ -4332,7 +4332,7 @@ SEXP R_ParseBuffer(IoBuffer *buffer, int n, ParseStatus *status, SEXP prompt,
43324332
if (isEnvironment(srcfile)) {
43334333
ParseState.keepSrcRefs = TRUE;
43344334
ParseState.keepParseData =
4335-
asLogical(GetOption1(install("keep.parse.data")));
4335+
asRbool(GetOption1(install("keep.parse.data")), R_NilValue);
43364336
PS_SET_SRCREFS(R_NilValue);
43374337
}
43384338

src/main/gram.y

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
%{
33
/*
44
* R : A Computer Language for Statistical Data Analysis
5-
* Copyright (C) 1997--2024 The R Core Team
5+
* Copyright (C) 1997--2025 The R Core Team
66
* Copyright (C) 2009--2011 Romain Francois
77
* Copyright (C) 1995--1997 Robert Gentleman and Ross Ihaka
88
*
@@ -1816,11 +1816,11 @@ SEXP R_Parse1Buffer(IoBuffer *buffer, int gencode, ParseStatus *status)
18161816

18171817
R_InitSrcRefState(&cntxt);
18181818
if (gencode) {
1819-
keepSource = asLogical(GetOption1(install("keep.source")));
1819+
keepSource = asRbool(GetOption1(install("keep.source")), R_NilValue);
18201820
if (keepSource) {
18211821
ParseState.keepSrcRefs = TRUE;
18221822
ParseState.keepParseData =
1823-
asLogical(GetOption1(install("keep.parse.data")));
1823+
asRbool(GetOption1(install("keep.parse.data")), R_NilValue);
18241824
PS_SET_SRCFILE(NewEnvironment(R_NilValue, R_NilValue, R_EmptyEnv));
18251825
PS_SET_ORIGINAL(PS_SRCFILE);
18261826
PS_SET_SRCREFS(R_NilValue);
@@ -1882,7 +1882,7 @@ static SEXP R_Parse(int n, ParseStatus *status, SEXP srcfile)
18821882
if (isEnvironment(srcfile)) {
18831883
ParseState.keepSrcRefs = TRUE;
18841884
ParseState.keepParseData =
1885-
asLogical(GetOption1(install("keep.parse.data")));
1885+
asRbool(GetOption1(install("keep.parse.data")), R_NilValue);
18861886
PS_SET_SRCREFS(R_NilValue);
18871887
}
18881888

@@ -2023,7 +2023,7 @@ SEXP R_ParseBuffer(IoBuffer *buffer, int n, ParseStatus *status, SEXP prompt,
20232023
if (isEnvironment(srcfile)) {
20242024
ParseState.keepSrcRefs = TRUE;
20252025
ParseState.keepParseData =
2026-
asLogical(GetOption1(install("keep.parse.data")));
2026+
asRbool(GetOption1(install("keep.parse.data")), R_NilValue);
20272027
PS_SET_SRCREFS(R_NilValue);
20282028
}
20292029

src/main/identical.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* R : A Computer Language for Statistical Data Analysis
3-
* Copyright (C) 2001-2023 The R Core Team
3+
* Copyright (C) 2001-2025 The R Core Team
44
*
55
* This program is free software; you can redistribute it and/or modify
66
* it under the terms of the GNU General Public License as published by
@@ -118,7 +118,7 @@ R_compute_identical(SEXP x, SEXP y, int flags)
118118
-- such attributes are used for the cache. */
119119
if(TYPEOF(x) == CHARSXP) {
120120
/* This matches NAs */
121-
return Seql(x, y);
121+
return Seql(x, y) == 1;
122122
}
123123
SEXP ax, ay;
124124
if (IGNORE_SRCREF && TYPEOF(x) == CLOSXP) {
@@ -280,7 +280,7 @@ R_compute_identical(SEXP x, SEXP y, int flags)
280280
case CHARSXP: /* Probably unreachable, but better safe than sorry... */
281281
{
282282
/* This matches NAs */
283-
return Seql(x, y);
283+
return Seql(x, y) == 1;
284284
}
285285
case VECSXP:
286286
case EXPRSXP:

src/main/logic.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ attribute_hidden SEXP do_logic3(SEXP call, SEXP op, SEXP args, SEXP env)
448448
all(logical(0)) -> TRUE
449449
any(logical(0)) -> FALSE
450450
*/
451-
Rboolean val = PRIMVAL(op) == _OP_ALL ? TRUE : FALSE;
451+
int val = PRIMVAL(op) == _OP_ALL ? TRUE : FALSE;
452452

453453
PROTECT(args = fixup_NaRm(args));
454454
PROTECT(call2 = shallow_duplicate(call));

src/main/match.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* R : A Computer Language for Statistical Data Analysis
33
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
4-
* Copyright (C) 1998-2024 The R Core Team.
4+
* Copyright (C) 1998-2025 The R Core Team.
55
*
66
* This program is free software; you can redistribute it and/or modify
77
* it under the terms of the GNU General Public License as published by
@@ -439,7 +439,7 @@ void patchArgument(SEXP suppliedSlot, SEXP name, fstype_t *farg, SEXP cloenv) {
439439
attribute_hidden SEXP
440440
patchArgsByActuals(SEXP formals, SEXP supplied, SEXP cloenv)
441441
{
442-
int i, seendots, farg_i;
442+
int i, farg_i;
443443
SEXP f, a, b, prsupplied;
444444

445445
int nfarg = length(formals);
@@ -479,13 +479,13 @@ patchArgsByActuals(SEXP formals, SEXP supplied, SEXP cloenv)
479479
/* An exact match is required after first ... */
480480
/* The location of the first ... is saved in "dots" */
481481

482-
seendots = 0;
482+
Rboolean seendots = FALSE;
483483
f = formals;
484484
farg_i = 0;
485485
while (f != R_NilValue) {
486486
if (farg[farg_i] == FS_UNMATCHED) {
487487
if (TAG(f) == R_DotsSymbol && !seendots) {
488-
seendots = 1;
488+
seendots = TRUE;
489489
} else {
490490
for (b = prsupplied; b != R_NilValue; b = CDR(b)) {
491491
if (!ARGUSED(b) && TAG(b) != R_NilValue &&

src/main/objects.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1810,7 +1810,8 @@ attribute_hidden SEXP do_setS4Object(SEXP call, SEXP op, SEXP args, SEXP env)
18101810
{
18111811
checkArity(op, args);
18121812
SEXP object = CAR(args);
1813-
int flag = asLogical(CADR(args)), complete = asInteger(CADDR(args));
1813+
Rboolean flag = asRbool(CADR(args), call);
1814+
int complete = asInteger(CADDR(args));
18141815
if(length(CADR(args)) != 1 || flag == NA_INTEGER)
18151816
error("invalid '%s' argument", "flag");
18161817
if(complete == NA_INTEGER)

src/main/options.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* R : A Computer Language for Statistical Data Analysis
3-
* Copyright (C) 1998-2024 The R Core Team.
3+
* Copyright (C) 1998-2025 The R Core Team.
44
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
55
*
66
* This program is free software; you can redistribute it and/or modify
@@ -635,7 +635,7 @@ attribute_hidden SEXP do_options(SEXP call, SEXP op, SEXP args, SEXP rho)
635635
else if (streql(CHAR(namei), "keep.source")) {
636636
if (TYPEOF(argi) != LGLSXP || LENGTH(argi) != 1)
637637
error(_("invalid value for '%s'"), CHAR(namei));
638-
int k = asLogical(argi);
638+
Rboolean k = asRbool(argi, call);
639639
R_KeepSource = k;
640640
SET_VECTOR_ELT(value, i, SetOption(tag, ScalarLogical(k)));
641641
}
@@ -782,27 +782,27 @@ attribute_hidden SEXP do_options(SEXP call, SEXP op, SEXP args, SEXP rho)
782782
}
783783
else if (streql(CHAR(namei), "warnPartialMatchDollar")) {
784784
check_TRUE_FALSE(argi, CHAR(namei));
785-
R_warn_partial_match_dollar = LOGICAL(argi)[0];
785+
R_warn_partial_match_dollar = asRbool(argi, call);
786786
SET_VECTOR_ELT(value, i, SetOption(tag, argi));
787787
}
788788
else if (streql(CHAR(namei), "warnPartialMatchArgs")) {
789789
check_TRUE_FALSE(argi, CHAR(namei));
790-
R_warn_partial_match_args = LOGICAL(argi)[0];
790+
R_warn_partial_match_args = asRbool(argi, call);
791791
SET_VECTOR_ELT(value, i, SetOption(tag, argi));
792792
}
793793
else if (streql(CHAR(namei), "warnPartialMatchAttr")) {
794794
check_TRUE_FALSE(argi, CHAR(namei));
795-
R_warn_partial_match_attr = LOGICAL(argi)[0];
795+
R_warn_partial_match_attr = asRbool(argi, call);
796796
SET_VECTOR_ELT(value, i, SetOption(tag, argi));
797797
}
798798
else if (streql(CHAR(namei), "showWarnCalls")) {
799799
check_TRUE_FALSE(argi, CHAR(namei));
800-
R_ShowWarnCalls = LOGICAL(argi)[0];
800+
R_ShowWarnCalls = asRbool(argi, call);
801801
SET_VECTOR_ELT(value, i, SetOption(tag, argi));
802802
}
803803
else if (streql(CHAR(namei), "showErrorCalls")) {
804804
check_TRUE_FALSE(argi, CHAR(namei));
805-
R_ShowErrorCalls = LOGICAL(argi)[0];
805+
R_ShowErrorCalls = asRbool(argi, call);
806806
SET_VECTOR_ELT(value, i, SetOption(tag, argi));
807807
}
808808
else if (streql(CHAR(namei), "showNCalls")) {
@@ -817,12 +817,12 @@ attribute_hidden SEXP do_options(SEXP call, SEXP op, SEXP args, SEXP rho)
817817
}
818818
else if (streql(CHAR(namei), "browserNLdisabled")) {
819819
check_TRUE_FALSE(argi, CHAR(namei));
820-
R_DisableNLinBrowser = LOGICAL(argi)[0];
820+
R_DisableNLinBrowser = asRbool(argi, call);
821821
SET_VECTOR_ELT(value, i, SetOption(tag, argi));
822822
}
823823
else if (streql(CHAR(namei), "CBoundsCheck")) {
824824
check_TRUE_FALSE(argi, CHAR(namei));
825-
R_CBoundsCheck = LOGICAL(argi)[0];
825+
R_CBoundsCheck = asRbool(argi, call);
826826
SET_VECTOR_ELT(value, i, SetOption(tag, argi));
827827
}
828828
else if (streql(CHAR(namei), "matprod")) {
@@ -894,7 +894,7 @@ attribute_hidden SEXP do_options(SEXP call, SEXP op, SEXP args, SEXP rho)
894894
else if (streql(CHAR(namei), "verbose")) {
895895
if (TYPEOF(argi) != LGLSXP || LENGTH(argi) != 1)
896896
error(_("invalid value for '%s'"), CHAR(namei));
897-
int k = asLogical(argi);
897+
Rboolean k = asRbool(argi, call);
898898
R_Verbose = k;
899899
SET_VECTOR_ELT(value, i, SetOption(tag, ScalarLogical(k)));
900900
}

src/main/paste.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
* R : A Computer Language for Statistical Data Analysis
3-
* Copyright (C) 1997--2024 The R Core Team
3+
* Copyright (C) 1997--2025 The R Core Team
44
* Copyright (C) 1995, 1996 Robert Gentleman and Ross Ihaka
55
*
66
* This program is free software; you can redistribute it and/or modify
@@ -120,12 +120,12 @@ attribute_hidden SEXP do_paste(SEXP call, SEXP op, SEXP args, SEXP env)
120120
sepBytes = IS_BYTES(sep);
121121
collapse = CADDR(args);
122122
if(correct_nargs)
123-
recycle_0 = asLogical(CADDDR(args));
123+
recycle_0 = asRbool(CADDDR(args), call);
124124
} else { /* paste0(..., .) */
125125
u_sepw = sepw = 0; sep = R_NilValue;/* -Wall */
126126
collapse = CADR(args);
127127
if(correct_nargs)
128-
recycle_0 = asLogical(CADDR(args));
128+
recycle_0 = asRbool(CADDR(args), call);
129129
}
130130
Rboolean do_collapse = (collapse != R_NilValue); // == !isNull(collapse)
131131
if (do_collapse)

0 commit comments

Comments
 (0)