Skip to content

Commit 5dc775e

Browse files
author
ripley
committed
Rboolean -> bool
git-svn-id: https://svn.r-project.org/R/trunk@87894 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 36beb1e commit 5dc775e

File tree

14 files changed

+220
-220
lines changed

14 files changed

+220
-220
lines changed

src/library/grDevices/src/colors.c

Lines changed: 6 additions & 6 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-2021 The R Core Team
3+
* Copyright (C) 1997-2025 The R Core Team
44
* Copyright (C) 2003 The R Foundation
55
*
66
* This program is free software; you can redistribute it and/or modify
@@ -137,22 +137,22 @@ static void rgb2hsv(double r, double g, double b,
137137
/* all (r,g,b, h,s,v) values in [0,1] */
138138
{
139139
double min, max, delta;
140-
Rboolean r_max = TRUE, b_max = FALSE;
140+
bool r_max = true, b_max = false;
141141
/* Compute min(r,g,b) and max(r,g,b) and remember where max is: */
142142
min = max = r;
143143
if(min > g) { /* g < r */
144144
if(b < g)
145145
min = b;/* & max = r */
146146
else { /* g <= b, g < r */
147147
min = g;
148-
if(b > r) { max = b; b_max = TRUE; r_max = FALSE; }
148+
if(b > r) { max = b; b_max = true; r_max = false; }
149149
/* else : g <= b <=r */
150150
}
151151
} else { /* r <= g */
152152
if(b > g) {
153-
max = b; b_max = TRUE; r_max = FALSE; /* & min = r */
153+
max = b; b_max = true; r_max = false; /* & min = r */
154154
} else { /* b,r <= g */
155-
max = g; r_max = FALSE; /* & min = r */
155+
max = g; r_max = false; /* & min = r */
156156
if(b < r) min = b; /* else : r <= b <= g */
157157
}
158158
}
@@ -391,7 +391,7 @@ SEXP hcl(SEXP h, SEXP c, SEXP l, SEXP a, SEXP sfixup)
391391
SEXP rgb(SEXP r, SEXP g, SEXP b, SEXP a, SEXP MCV, SEXP nam)
392392
{
393393
R_xlen_t i, l_max, nr, ng, nb, na = 1;
394-
Rboolean max_1 = FALSE;
394+
bool max_1 = false;
395395
double mV = asReal(MCV);
396396

397397
if(!R_FINITE(mV) || mV == 0.)

src/main/RNG.c

Lines changed: 4 additions & 4 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
@@ -341,7 +341,7 @@ static void Randomize(RNGtype kind)
341341
RNG_Init(kind, TimeToSeed());
342342
}
343343

344-
static Rboolean GetRNGkind(SEXP seeds)
344+
static bool GetRNGkind(SEXP seeds)
345345
{
346346
/* Load RNG_kind, N01_kind Sample_kind from .Random.seed if present */
347347
int tmp, *is;
@@ -391,13 +391,13 @@ static Rboolean GetRNGkind(SEXP seeds)
391391
goto invalid;
392392
}
393393
RNG_kind = newRNG; N01_kind = newN01; Sample_kind = newSample;
394-
return FALSE;
394+
return false;
395395
invalid:
396396
RNG_kind = RNG_DEFAULT; N01_kind = N01_DEFAULT; Sample_kind = Sample_DEFAULT;
397397

398398
Randomize(RNG_kind);
399399
PutRNGstate(); // write out to .Random.seed
400-
return TRUE;
400+
return true;
401401
}
402402

403403
static void copy_seeds_in(Int32 *i_seed, SEXP seeds, int len_seed)

src/main/arithmetic.c

Lines changed: 17 additions & 17 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) 2003--2023 The R Foundation
55
* Copyright (C) 1995--1997 Robert Gentleman and Ross Ihaka
66
*
@@ -256,7 +256,7 @@ double R_pow_di(double x, int n)
256256
if (n != 0) {
257257
if (!R_FINITE(x)) return R_POW(x, (double)n);
258258

259-
Rboolean is_neg = (n < 0);
259+
bool is_neg = (n < 0);
260260
if(is_neg) n = -n;
261261
for(;;) {
262262
if(n & 01) xn *= x;
@@ -314,36 +314,36 @@ static SEXP lcall;
314314
#define R_INT_MIN -INT_MAX
315315
// .. relying on fact that NA_INTEGER is outside of these
316316

317-
static R_INLINE int R_integer_plus(int x, int y, Rboolean *pnaflag)
317+
static R_INLINE int R_integer_plus(int x, int y, bool *pnaflag)
318318
{
319319
if (x == NA_INTEGER || y == NA_INTEGER)
320320
return NA_INTEGER;
321321

322322
if (((y > 0) && (x > (R_INT_MAX - y))) ||
323323
((y < 0) && (x < (R_INT_MIN - y)))) {
324324
if (pnaflag != NULL)
325-
*pnaflag = TRUE;
325+
*pnaflag = true;
326326
return NA_INTEGER;
327327
}
328328
return x + y;
329329
}
330330

331-
static R_INLINE int R_integer_minus(int x, int y, Rboolean *pnaflag)
331+
static R_INLINE int R_integer_minus(int x, int y, bool *pnaflag)
332332
{
333333
if (x == NA_INTEGER || y == NA_INTEGER)
334334
return NA_INTEGER;
335335

336336
if (((y < 0) && (x > (R_INT_MAX + y))) ||
337337
((y > 0) && (x < (R_INT_MIN + y)))) {
338338
if (pnaflag != NULL)
339-
*pnaflag = TRUE;
339+
*pnaflag = true;
340340
return NA_INTEGER;
341341
}
342342
return x - y;
343343
}
344344

345345
#define GOODIPROD(x, y, z) ((double) (x) * (double) (y) == (z))
346-
static R_INLINE int R_integer_times(int x, int y, Rboolean *pnaflag)
346+
static R_INLINE int R_integer_times(int x, int y, bool *pnaflag)
347347
{
348348
if (x == NA_INTEGER || y == NA_INTEGER)
349349
return NA_INTEGER;
@@ -353,7 +353,7 @@ static R_INLINE int R_integer_times(int x, int y, Rboolean *pnaflag)
353353
return z;
354354
else {
355355
if (pnaflag != NULL)
356-
*pnaflag = TRUE;
356+
*pnaflag = true;
357357
return NA_INTEGER;
358358
}
359359
}
@@ -446,7 +446,7 @@ attribute_hidden SEXP do_arith(SEXP call, SEXP op, SEXP args, SEXP env)
446446
}
447447
}
448448
else if (IS_SCALAR(arg2, INTSXP)) {
449-
Rboolean naflag = FALSE;
449+
bool naflag = false;
450450
int i2 = SCALAR_IVAL(arg2);
451451
switch (PRIMVAL(op)) {
452452
case PLUSOP:
@@ -520,7 +520,7 @@ attribute_hidden SEXP do_arith(SEXP call, SEXP op, SEXP args, SEXP env)
520520

521521
attribute_hidden SEXP R_binary(SEXP call, SEXP op, SEXP x, SEXP y)
522522
{
523-
Rboolean xattr, yattr, xarray, yarray, xts, yts, xS4, yS4;
523+
bool xattr, yattr, xarray, yarray, xts, yts, xS4, yS4;
524524
PROTECT_INDEX xpi, ypi;
525525
ARITHOP_TYPE oper = (ARITHOP_TYPE) PRIMVAL(op);
526526
int nprotect = 2; /* x and y */
@@ -536,19 +536,19 @@ attribute_hidden SEXP R_binary(SEXP call, SEXP op, SEXP x, SEXP y)
536536
nx = XLENGTH(x),
537537
ny = XLENGTH(y);
538538
if (ATTRIB(x) != R_NilValue) {
539-
xattr = TRUE;
539+
xattr = true;
540540
xarray = isArray(x);
541541
xts = isTs(x);
542542
xS4 = isS4(x);
543543
}
544-
else xattr = xarray = xts = xS4 = FALSE;
544+
else xattr = xarray = xts = xS4 = false;
545545
if (ATTRIB(y) != R_NilValue) {
546-
yattr = TRUE;
546+
yattr = true;
547547
yarray = isArray(y);
548548
yts = isTs(y);
549549
yS4 = isS4(y);
550550
}
551-
else yattr = yarray = yts = yS4 = FALSE;
551+
else yattr = yarray = yts = yS4 = false;
552552

553553
#define R_ARITHMETIC_ARRAY_1_SPECIAL
554554

@@ -698,7 +698,7 @@ attribute_hidden SEXP R_binary(SEXP call, SEXP op, SEXP x, SEXP y)
698698
}
699699

700700
if(xS4 || yS4) { /* Only set the bit: no method defined! */
701-
val = asS4(val, TRUE, TRUE);
701+
val = asS4(val, TRUE, TRUE); // from objects.c
702702
}
703703
UNPROTECT(nprotect);
704704
return val;
@@ -806,7 +806,7 @@ static SEXP integer_binary(ARITHOP_TYPE code, SEXP s1, SEXP s2, SEXP lcall)
806806
R_xlen_t i, i1, i2, n, n1, n2;
807807
int x1, x2;
808808
SEXP ans;
809-
Rboolean naflag = FALSE;
809+
bool naflag = false;
810810

811811
n1 = XLENGTH(s1);
812812
n2 = XLENGTH(s2);
@@ -1652,7 +1652,7 @@ static R_INLINE SEXP match_Math2_dflt_args(SEXP args, SEXP call)
16521652
attribute_hidden SEXP do_Math2(SEXP call, SEXP op, SEXP args, SEXP env)
16531653
{
16541654
SEXP res, call2;
1655-
int is_signif = (PRIMVAL(op) == 10004) ? TRUE : FALSE;
1655+
int is_signif = (PRIMVAL(op) == 10004) ? true : false;
16561656
double dflt_digits = is_signif ? 6.0 : 0.;
16571657

16581658
PROTECT_INDEX api;

src/main/array.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ attribute_hidden SEXP do_matrix(SEXP call, SEXP op, SEXP args, SEXP rho)
107107
byrow0 = asLogical(CAR(args)); args = CDR(args);
108108
if (byrow0 == NA_INTEGER)
109109
error(_("invalid '%s' argument"), "byrow");
110-
Rboolean byrow = (Rboolean) byrow0;
110+
bool byrow = (bool) byrow0;
111111
dimnames = CAR(args);
112112
args = CDR(args);
113113
miss_nr = asLogical(CAR(args)); args = CDR(args);
@@ -396,12 +396,12 @@ attribute_hidden SEXP DropDims(SEXP x)
396396
setAttrib(newdims, R_NamesSymbol, new_nms);
397397
UNPROTECT(1);
398398
}
399-
Rboolean havenames = FALSE;
399+
bool havenames = false;
400400
if (!isNull(dimnames)) {
401401
for (i = 0; i < ndims; i++)
402402
if (dim[i] != 1 &&
403403
VECTOR_ELT(dimnames, i) != R_NilValue)
404-
havenames = TRUE;
404+
havenames = true;
405405
if (havenames) {
406406
PROTECT(newnames = allocVector(VECSXP, n));
407407
PROTECT(newnamesnames = allocVector(STRSXP, n));
@@ -551,7 +551,7 @@ attribute_hidden SEXP do_lengths(SEXP call, SEXP op, SEXP args, SEXP rho)
551551
if (DispatchOrEval(call, op, "lengths", args, rho, &ans, 0, 1))
552552
return(ans);
553553

554-
Rboolean isList = isVectorList(x) || isS4(x);
554+
bool isList = isVectorList(x) || isS4(x);
555555
if(!isList) switch(TYPEOF(x)) {
556556
case NILSXP:
557557
case CHARSXP:
@@ -640,14 +640,14 @@ attribute_hidden SEXP do_rowscols(SEXP call, SEXP op, SEXP args, SEXP rho)
640640
641641
for (R_xlen_t i = 0; i < n; i++)
642642
if (!R_FINITE(x[i])) return TRUE;
643-
return FALSE;
643+
return false;
644644
645645
The present version is imprecise, but faster.
646646
*/
647-
static Rboolean mayHaveNaNOrInf(double *x, R_xlen_t n)
647+
static bool mayHaveNaNOrInf(double *x, R_xlen_t n)
648648
{
649649
if ((n&1) != 0 && !R_FINITE(x[0]))
650-
return TRUE;
650+
return true;
651651
for (R_xlen_t i = n&1; i < n; i += 2)
652652
/* A precise version could use this condition:
653653
*
@@ -661,8 +661,8 @@ static Rboolean mayHaveNaNOrInf(double *x, R_xlen_t n)
661661
* large finite values (e.g. 1e308) may be infinite.
662662
*/
663663
if (!R_FINITE(x[i]+x[i+1]))
664-
return TRUE;
665-
return FALSE;
664+
return true;
665+
return false;
666666
}
667667

668668
/*
@@ -672,7 +672,7 @@ static Rboolean mayHaveNaNOrInf(double *x, R_xlen_t n)
672672
safe here, because the result is only used for an imprecise test for
673673
the presence of NaN and Inf values.
674674
*/
675-
static Rboolean mayHaveNaNOrInf_simd(double *x, R_xlen_t n)
675+
static bool mayHaveNaNOrInf_simd(double *x, R_xlen_t n)
676676
{
677677
double s = 0;
678678
/* SIMD reduction is supported since OpenMP 4.0. The value of _OPENMP is
@@ -687,21 +687,21 @@ static Rboolean mayHaveNaNOrInf_simd(double *x, R_xlen_t n)
687687
return !R_FINITE(s);
688688
}
689689

690-
static Rboolean cmayHaveNaNOrInf(Rcomplex *x, R_xlen_t n)
690+
static bool cmayHaveNaNOrInf(Rcomplex *x, R_xlen_t n)
691691
{
692692
/* With HAVE_FORTRAN_DOUBLE_COMPLEX set, it should be clear that
693693
Rcomplex has no padding, so we could probably use mayHaveNaNOrInf,
694694
but better safe than sorry... */
695695
if ((n&1) != 0 && (!R_FINITE(x[0].r) || !R_FINITE(x[0].i)))
696-
return TRUE;
696+
return true;
697697
for (R_xlen_t i = n&1; i < n; i += 2)
698698
if (!R_FINITE(x[i].r+x[i].i+x[i+1].r+x[i+1].i))
699-
return TRUE;
700-
return FALSE;
699+
return true;
700+
return false;
701701
}
702702

703703
/* experimental version for SIMD hardware (see also mayHaveNaNOrInf_simd) */
704-
static Rboolean cmayHaveNaNOrInf_simd(Rcomplex *x, R_xlen_t n)
704+
static bool cmayHaveNaNOrInf_simd(Rcomplex *x, R_xlen_t n)
705705
{
706706
double s = 0;
707707
/* _OPENMP >= 201307 - see mayHaveNaNOrInf_simd */
@@ -1254,7 +1254,7 @@ static void tccrossprod(Rcomplex *x, int nrx, int ncx,
12541254
attribute_hidden SEXP do_matprod(SEXP call, SEXP op, SEXP args, SEXP rho)
12551255
{
12561256
// .Primitive() ; may have 1 or 2 args, but some methods have more
1257-
Rboolean cross = PRIMVAL(op) != 0;
1257+
bool cross = PRIMVAL(op) != 0;
12581258
int nargs, min_nargs = cross ? 1 : 2;
12591259
if (args == R_NilValue)
12601260
nargs = 0;
@@ -1285,7 +1285,7 @@ attribute_hidden SEXP do_matprod(SEXP call, SEXP op, SEXP args, SEXP rho)
12851285
if (CDDR(args) != R_NilValue)
12861286
warningcall(call, _("more than 2 arguments passed to default method of '%s'"),
12871287
PRIMNAME(op));
1288-
Rboolean sym = isNull(y);
1288+
bool sym = isNull(y);
12891289
if (sym && (PRIMVAL(op) > 0)) y = x;
12901290
if ( !(isNumeric(x) || isComplex(x)) || !(isNumeric(y) || isComplex(y)) )
12911291
errorcall(call, _("requires numeric/complex matrix/vector arguments"));
@@ -1910,7 +1910,7 @@ attribute_hidden SEXP do_colsum(SEXP call, SEXP op, SEXP args, SEXP rho)
19101910
if (p == NA_INTEGER || p < 0)
19111911
error(_("invalid '%s' argument"), "p");
19121912
if (NaRm == NA_LOGICAL) error(_("invalid '%s' argument"), "na.rm");
1913-
Rboolean keepNA = !NaRm;
1913+
bool keepNA = !NaRm;
19141914

19151915
switch (type = TYPEOF(x)) {
19161916
case LGLSXP:
@@ -2158,7 +2158,7 @@ attribute_hidden SEXP do_array(SEXP call, SEXP op, SEXP args, SEXP rho)
21582158
/* Need to guard against possible sharing of values under
21592159
NAMED. This is not needed with reference
21602160
coutning. (PR#15919) */
2161-
Rboolean needsmark = (lendat < nans || MAYBE_REFERENCED(vals));
2161+
bool needsmark = (lendat < nans || MAYBE_REFERENCED(vals));
21622162
for (i = 0; i < nans; i++) {
21632163
SEXP elt = VECTOR_ELT(vals, i % lendat);
21642164
if (needsmark || MAYBE_REFERENCED(elt))
@@ -2366,7 +2366,7 @@ attribute_hidden SEXP do_asplit(SEXP call, SEXP op, SEXP args, SEXP rho)
23662366
SEXP drop = CAR(args);
23672367
SEXP y, e;
23682368
int i, j, k, n1, n2;
2369-
Rboolean havednc, keepdim;
2369+
bool havednc, keepdim;
23702370
n1 = asInteger(d1);
23712371
n2 = asInteger(d2);
23722372
havednc = (!isNull(dnc) && length(dnc) > 0);

0 commit comments

Comments
 (0)