Skip to content

Commit 0b58c37

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

File tree

4 files changed

+32
-29
lines changed

4 files changed

+32
-29
lines changed

src/main/altclasses.c

Lines changed: 11 additions & 11 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) 2016--2024 The R Core Team
3+
* Copyright (C) 2016--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
@@ -1104,9 +1104,9 @@ static SEXP mmap_Unserialize(SEXP class, SEXP state)
11041104
{
11051105
SEXP file = MMAP_STATE_FILE(state);
11061106
int type = MMAP_STATE_TYPE(state);
1107-
Rboolean ptrOK = MMAP_STATE_PTROK(state);
1108-
Rboolean wrtOK = MMAP_STATE_WRTOK(state);
1109-
Rboolean serOK = MMAP_STATE_SEROK(state);
1107+
Rboolean ptrOK = (Rboolean) MMAP_STATE_PTROK(state);
1108+
Rboolean wrtOK = (Rboolean) MMAP_STATE_WRTOK(state);
1109+
Rboolean serOK = (Rboolean) MMAP_STATE_SEROK(state);
11101110

11111111
SEXP val = mmap_file(file, type, ptrOK, wrtOK, serOK, TRUE);
11121112
if (val == NULL) {
@@ -1123,9 +1123,9 @@ static SEXP mmap_Unserialize(SEXP class, SEXP state)
11231123
static Rboolean mmap_Inspect(SEXP x, int pre, int deep, int pvec,
11241124
void (*inspect_subtree)(SEXP, int, int, int))
11251125
{
1126-
Rboolean ptrOK = MMAP_PTROK(x);
1127-
Rboolean wrtOK = MMAP_WRTOK(x);
1128-
Rboolean serOK = MMAP_SEROK(x);
1126+
Rboolean ptrOK = (Rboolean) MMAP_PTROK(x);
1127+
Rboolean wrtOK = (Rboolean) MMAP_WRTOK(x);
1128+
Rboolean serOK = (Rboolean) MMAP_SEROK(x);
11291129
Rprintf(" mmaped %s", R_typeToChar(x));
11301130
Rprintf(" [ptr=%d,wrt=%d,ser=%d]\n", ptrOK, wrtOK, serOK);
11311131
return TRUE;
@@ -1338,8 +1338,8 @@ static SEXP mmap_file(SEXP file, int type, Rboolean ptrOK, Rboolean wrtOK,
13381338

13391339
static Rboolean asLogicalNA(SEXP x, Rboolean dflt)
13401340
{
1341-
Rboolean val = asLogical(x);
1342-
return val == NA_LOGICAL ? dflt : val;
1341+
int val = asLogical(x);
1342+
return val == NA_LOGICAL ? dflt : (Rboolean) val;
13431343
}
13441344

13451345
#ifdef SIMPLEMMAP
@@ -1508,8 +1508,8 @@ static SEXP wrapper_Duplicate(SEXP x, Rboolean deep)
15081508
static Rboolean wrapper_Inspect(SEXP x, int pre, int deep, int pvec,
15091509
void (*inspect_subtree)(SEXP, int, int, int))
15101510
{
1511-
Rboolean srt = WRAPPER_SORTED(x);
1512-
Rboolean no_na = WRAPPER_NO_NA(x);
1511+
Rboolean srt = (Rboolean) WRAPPER_SORTED(x);
1512+
Rboolean no_na = (Rboolean) WRAPPER_NO_NA(x);
15131513
Rprintf(" wrapper [srt=%d,no_na=%d]\n", srt, no_na);
15141514
inspect_subtree(WRAPPER_WRAPPED(x), pre, deep, pvec);
15151515
return TRUE;

src/main/connections.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ static size_t file_write(const void *ptr, size_t size, size_t nitems,
11211121
}
11221122

11231123
static Rconnection newfile(const char *description, int enc, const char *mode,
1124-
int raw)
1124+
Rboolean raw)
11251125
{
11261126
Rconnection new;
11271127
new = (Rconnection) malloc(sizeof(struct Rconn));
@@ -1575,7 +1575,8 @@ attribute_hidden SEXP do_fifo(SEXP call, SEXP op, SEXP args, SEXP env)
15751575
#if (defined(HAVE_MKFIFO) && defined(HAVE_FCNTL_H)) || defined(_WIN32)
15761576
SEXP sfile, sopen, ans, class, enc;
15771577
const char *file, *open;
1578-
int ncon, block;
1578+
int ncon;
1579+
Rboolean block;
15791580
Rconnection con = NULL;
15801581

15811582
checkArity(op, args);
@@ -1589,7 +1590,7 @@ attribute_hidden SEXP do_fifo(SEXP call, SEXP op, SEXP args, SEXP env)
15891590
sopen = CADR(args);
15901591
if(!isString(sopen) || LENGTH(sopen) != 1)
15911592
error(_("invalid '%s' argument"), "open");
1592-
block = asLogical(CADDR(args));
1593+
block = asRbool(CADDR(args), call);
15931594
if(block == NA_LOGICAL)
15941595
error(_("invalid '%s' argument"), "block");
15951596
enc = CADDDR(args);
@@ -3937,7 +3938,8 @@ attribute_hidden SEXP do_sockconn(SEXP call, SEXP op, SEXP args, SEXP env)
39373938
{
39383939
SEXP scmd, sopen, ans, class, enc;
39393940
const char *host, *open;
3940-
int ncon, port, server, blocking, timeout, serverfd, options = 0;
3941+
int ncon, port, server, timeout, serverfd, options = 0;
3942+
Rboolean blocking;
39413943
Rconnection con = NULL;
39423944
Rservsockconn scon = NULL;
39433945

@@ -3964,7 +3966,7 @@ attribute_hidden SEXP do_sockconn(SEXP call, SEXP op, SEXP args, SEXP env)
39643966
serverfd = scon->fd;
39653967
}
39663968
args = CDR(args);
3967-
blocking = asLogical(CAR(args));
3969+
blocking = asRbool(CAR(args), call);
39683970
if(blocking == NA_LOGICAL)
39693971
error(_("invalid '%s' argument"), "blocking");
39703972
args = CDR(args);
@@ -4070,11 +4072,11 @@ attribute_hidden SEXP do_unz(SEXP call, SEXP op, SEXP args, SEXP env)
40704072

40714073
attribute_hidden SEXP do_open(SEXP call, SEXP op, SEXP args, SEXP env)
40724074
{
4073-
int i, block;
4075+
int i;
40744076
Rconnection con=NULL;
40754077
SEXP sopen;
40764078
const char *open;
4077-
Rboolean success;
4079+
Rboolean success, block;
40784080

40794081
checkArity(op, args);
40804082
if(!inherits(CAR(args), "connection"))
@@ -4089,7 +4091,7 @@ attribute_hidden SEXP do_open(SEXP call, SEXP op, SEXP args, SEXP env)
40894091
sopen = CADR(args);
40904092
if(!isString(sopen) || LENGTH(sopen) != 1)
40914093
error(_("invalid '%s' argument"), "open");
4092-
block = asLogical(CADDR(args));
4094+
block = asRbool(CADDR(args), call);
40934095
if(block == NA_LOGICAL)
40944096
error(_("invalid '%s' argument"), "blocking");
40954097
open = CHAR(STRING_ELT(sopen, 0)); /* ASCII */
@@ -5874,11 +5876,12 @@ attribute_hidden SEXP do_url(SEXP call, SEXP op, SEXP args, SEXP env)
58745876
#endif
58755877
char *class2 = "url";
58765878
const char *url, *open;
5877-
int ncon, block, raw = 0, defmeth,
5879+
int ncon, block, defmeth,
58785880
meth = 0, // 0: "internal" | "wininet", 1: "libcurl"
58795881
winmeth = 0; // 0: "internal", 1: "wininet" (Windows only)
58805882
cetype_t ienc = CE_NATIVE;
58815883
Rconnection con = NULL;
5884+
Rboolean raw = FALSE;
58825885

58835886
checkArity(op, args);
58845887
// --------- description
@@ -5966,7 +5969,7 @@ attribute_hidden SEXP do_url(SEXP call, SEXP op, SEXP args, SEXP env)
59665969

59675970
// --------- raw, for file() only
59685971
if(PRIMVAL(op) == 1) {
5969-
raw = asLogical(CAD5R(args));
5972+
raw = asRbool(CAD5R(args), call);
59705973
if(raw == NA_LOGICAL)
59715974
error(_("invalid '%s' argument"), "raw");
59725975
}
@@ -6102,7 +6105,7 @@ attribute_hidden SEXP do_url(SEXP call, SEXP op, SEXP args, SEXP env)
61026105
}
61036106

61046107
Connections[ncon] = con;
6105-
con->blocking = block;
6108+
con->blocking = (Rboolean) block;
61066109
strncpy(con->encname, CHAR(STRING_ELT(enc, 0)), 100); /* ASCII */
61076110
con->encname[100 - 1] = '\0';
61086111

@@ -6421,7 +6424,7 @@ attribute_hidden SEXP do_gzcon(SEXP call, SEXP op, SEXP args, SEXP rho)
64216424
int icon, level, allow;
64226425
Rconnection incon = NULL, new = NULL;
64236426
char *m, *mode = NULL /* -Wall */, description[1000];
6424-
Rboolean text;
6427+
int text;
64256428

64266429
checkArity(op, args);
64276430
if(!inherits(CAR(args), "connection"))
@@ -6469,7 +6472,7 @@ attribute_hidden SEXP do_gzcon(SEXP call, SEXP op, SEXP args, SEXP rho)
64696472
/* for Solaris 12.5 */ new = NULL;
64706473
}
64716474
init_con(new, description, CE_NATIVE, mode);
6472-
new->text = text;
6475+
new->text = (Rboolean) text;
64736476
new->isGzcon = TRUE;
64746477
new->open = &gzcon_open;
64756478
new->close = &gzcon_close;
@@ -6486,7 +6489,7 @@ attribute_hidden SEXP do_gzcon(SEXP call, SEXP op, SEXP args, SEXP rho)
64866489
((Rgzconn)(new->private))->con = incon;
64876490
((Rgzconn)(new->private))->cp = level;
64886491
((Rgzconn)(new->private))->nsaved = -1;
6489-
((Rgzconn)(new->private))->allow = allow;
6492+
((Rgzconn)(new->private))->allow = (Rboolean) allow;
64906493

64916494
/* as there might not be an R-level reference to the wrapped connection */
64926495
R_PreserveObject(incon->ex_ptr);

src/main/context.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ static void R_restore_globals(RCNTXT *cptr)
177177
R_BCFrame = cptr->bcframe;
178178
R_EvalDepth = cptr->evaldepth;
179179
vmaxset(cptr->vmax);
180-
R_interrupts_suspended = cptr->intsusp;
180+
R_interrupts_suspended = (Rboolean) cptr->intsusp;
181181
R_HandlerStack = cptr->handlerstack;
182182
R_RestartStack = cptr->restartstack;
183183
while (R_PendingPromises != cptr->prstack) {
@@ -891,7 +891,7 @@ R_tryEval(SEXP e, SEXP env, int *ErrorOccurred)
891891
SEXP R_tryEvalSilent(SEXP e, SEXP env, int *ErrorOccurred)
892892
{
893893
SEXP val;
894-
Rboolean oldshow = R_ShowErrorMessages;
894+
int oldshow = R_ShowErrorMessages;
895895
R_ShowErrorMessages = FALSE;
896896
val = R_tryEval(e, env, ErrorOccurred);
897897
R_ShowErrorMessages = oldshow;

src/main/main.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1909,7 +1909,7 @@ R_taskCallbackRoutine(SEXP expr, SEXP value, Rboolean succeeded,
19091909
SEXP f = (SEXP) userData;
19101910
SEXP e, val, cur, rho;
19111911
int errorOccurred;
1912-
Rboolean again, useData = LOGICAL(VECTOR_ELT(f, 2))[0];
1912+
Rboolean again, useData = (Rboolean)LOGICAL(VECTOR_ELT(f, 2))[0];
19131913

19141914
/* create an environment with bindings for the function and arguments */
19151915
PROTECT(rho = NewEnvironment(R_NilValue, R_NilValue, R_GlobalEnv));
@@ -1948,7 +1948,7 @@ R_taskCallbackRoutine(SEXP expr, SEXP value, Rboolean succeeded,
19481948
/* It would be nice to identify the function. */
19491949
warning(_("top-level task callback did not return a logical value"));
19501950
}
1951-
again = asLogical(val);
1951+
again = (Rboolean) asLogical(val);
19521952
} else {
19531953
/* warning("error occurred in top-level task callback\n"); */
19541954
again = FALSE;

0 commit comments

Comments
 (0)