Skip to content

Commit 5d92c1b

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

File tree

3 files changed

+106
-106
lines changed

3 files changed

+106
-106
lines changed

src/include/Parse.h

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) 1998-2018 R Core Team
3+
* Copyright (C) 1998-2025 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
@@ -37,9 +37,9 @@ typedef struct SrcRefState SrcRefState;
3737

3838
struct SrcRefState {
3939

40-
Rboolean keepSrcRefs; /* Whether to attach srcrefs to objects as they are parsed */
41-
Rboolean keepParseData; /* Whether to attach also parse data to srcrefs */
42-
Rboolean didAttach; /* Record of whether a srcref was attached */
40+
bool keepSrcRefs; /* Whether to attach srcrefs to objects as they are parsed */
41+
bool keepParseData; /* Whether to attach also parse data to srcrefs */
42+
bool didAttach; /* Record of whether a srcref was attached */
4343
SEXP data; /* Parse data as in sexps, also here for performance */
4444
SEXP sexps;
4545
/* SrcRefs */

src/main/gram.c

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
#define PARSE_ERROR_SIZE 256 /* Parse error messages saved here */
112112
#define PARSE_CONTEXT_SIZE 256 /* Recent parse context kept in a circular buffer */
113113

114-
static Rboolean busy = FALSE;
114+
static bool busy = false;
115115
static SEXP R_NullSymbol = NULL;
116116

117117
static int identifier ;
@@ -254,12 +254,12 @@ static SEXP NewList(void);
254254
static void NextArg(SEXP, SEXP, SEXP); /* add named element to list end */
255255
static SEXP TagArg(SEXP, SEXP, YYLTYPE *);
256256
static int processLineDirective(int *);
257-
static int checkForPlaceholder(SEXP placeholder, SEXP arg);
257+
static bool checkForPlaceholder(SEXP placeholder, SEXP arg);
258258

259-
static int HavePlaceholder = FALSE;
259+
static int HavePlaceholder = FALSE; // could be bool
260260
attribute_hidden SEXP R_PlaceholderToken = NULL;
261261

262-
static int HavePipeBind = FALSE;
262+
static int HavePipeBind = FALSE; // could be bool
263263
static SEXP R_PipeBindSymbol = NULL;
264264

265265
/* These routines allocate constants */
@@ -2989,7 +2989,7 @@ static int add_mbcs_byte_to_parse_context(void)
29892989
static void finish_mbcs_in_parse_context(void)
29902990
{
29912991
int i, c, nbytes = 0, first;
2992-
Rboolean mbcs = FALSE;
2992+
bool mbcs = false;
29932993

29942994
/* find the first byte of the context */
29952995
for(i = R_ParseContextLast;
@@ -3027,7 +3027,7 @@ static void finish_mbcs_in_parse_context(void)
30273027
return;
30283028
}
30293029
} else
3030-
mbcs = TRUE;
3030+
mbcs = true;
30313031
}
30323032
if (!mbcs)
30333033
return;
@@ -3109,7 +3109,7 @@ static void attachSrcrefs(SEXP val)
31093109
setAttrib(val, R_WholeSrcrefSymbol, makeSrcref(&wholeFile, PS_SRCFILE));
31103110
}
31113111
PS_SET_SRCREFS(R_NilValue);
3112-
ParseState.didAttach = TRUE;
3112+
ParseState.didAttach = true;
31133113
UNPROTECT(1); /* srval */
31143114
}
31153115

@@ -3459,7 +3459,7 @@ static SEXP mkChar2(const char *name)
34593459
return mkCharLenCE(name, (int) strlen(name), enc);
34603460
}
34613461

3462-
static SEXP mkString2(const char *s, size_t len, Rboolean escaped)
3462+
static SEXP mkString2(const char *s, size_t len, bool escaped)
34633463
{
34643464
SEXP t;
34653465
cetype_t enc = CE_NATIVE;
@@ -3480,7 +3480,7 @@ static SEXP xxdefun(SEXP fname, SEXP formals, SEXP body, YYLTYPE *lloc)
34803480
if (GenerateCode) {
34813481
if (ParseState.keepSrcRefs) {
34823482
srcref = makeSrcref(lloc, PS_SRCFILE);
3483-
ParseState.didAttach = TRUE;
3483+
ParseState.didAttach = true;
34843484
} else
34853485
srcref = R_NilValue;
34863486
PRESERVE_SV(ans = lang4(fname, CDR(formals), body, srcref));
@@ -3533,12 +3533,12 @@ static void checkTooManyPlaceholders(SEXP rhs, SEXP args, YYLTYPE *lloc)
35333533
_("pipe placeholder may only appear once (%s:%d:%d)"));
35343534
}
35353535

3536-
static int checkForPlaceholderList(SEXP placeholder, SEXP list)
3536+
static bool checkForPlaceholderList(SEXP placeholder, SEXP list)
35373537
{
35383538
for (; list != R_NilValue; list = CDR(list))
35393539
if (checkForPlaceholder(placeholder, CAR(list)))
3540-
return TRUE;
3541-
return FALSE;
3540+
return true;
3541+
return false;
35423542
}
35433543

35443544
static SEXP findExtractorChainPHCell(SEXP placeholder, SEXP rhs, SEXP expr,
@@ -3913,17 +3913,17 @@ void R_InitSrcRefState(RCNTXT* cptr)
39133913
R_NilValue, R_NilValue);
39143914
cptr->cend = &FinalizeSrcRefStateOnError;
39153915
cptr->cenddata = NULL;
3916-
ParseState.keepSrcRefs = FALSE;
3917-
ParseState.keepParseData = TRUE;
3918-
ParseState.didAttach = FALSE;
3916+
ParseState.keepSrcRefs = false;
3917+
ParseState.keepParseData = true;
3918+
ParseState.didAttach = false;
39193919
PS_SET_SRCFILE(R_NilValue);
39203920
PS_SET_ORIGINAL(R_NilValue);
39213921
ParseState.data_count = 0;
39223922
ParseState.xxlineno = 1;
39233923
ParseState.xxcolno = 0;
39243924
ParseState.xxbyteno = 0;
39253925
ParseState.xxparseno = 1;
3926-
busy = TRUE;
3926+
busy = true;
39273927
}
39283928

39293929
attribute_hidden
@@ -3963,7 +3963,7 @@ void R_FinalizeSrcRefState(void)
39633963
UseSrcRefState(prev);
39643964
free(prev);
39653965
} else
3966-
busy = FALSE;
3966+
busy = false;
39673967
}
39683968

39693969
static void UseSrcRefState(SrcRefState *state)
@@ -3978,7 +3978,7 @@ static void UseSrcRefState(SrcRefState *state)
39783978
ParseState.xxbyteno = state->xxbyteno;
39793979
ParseState.xxparseno = state->xxparseno;
39803980
ParseState.prevState = state->prevState;
3981-
busy = TRUE;
3981+
busy = true;
39823982
}
39833983

39843984
static void PutSrcRefState(SrcRefState *state)
@@ -4024,17 +4024,17 @@ static void ParseContextInit(void)
40244024
initData();
40254025
}
40264026

4027-
static int checkForPipeBind(SEXP arg)
4027+
static bool checkForPipeBind(SEXP arg)
40284028
{
40294029
if (! HavePipeBind)
4030-
return FALSE;
4030+
return false;
40314031
else if (arg == R_PipeBindSymbol)
4032-
return TRUE;
4032+
return true;
40334033
else if (TYPEOF(arg) == LANGSXP)
40344034
for (SEXP cur = arg; cur != R_NilValue; cur = CDR(cur))
40354035
if (checkForPipeBind(CAR(cur)))
4036-
return TRUE;
4037-
return FALSE;
4036+
return true;
4037+
return false;
40384038
}
40394039

40404040
static SEXP R_Parse1(ParseStatus *status)
@@ -4120,14 +4120,14 @@ static int buffer_getc(void)
41204120
attribute_hidden
41214121
SEXP R_Parse1Buffer(IoBuffer *buffer, int gencode, ParseStatus *status)
41224122
{
4123-
Rboolean keepSource = FALSE;
4123+
bool keepSource = false;
41244124
RCNTXT cntxt;
41254125

41264126
R_InitSrcRefState(&cntxt);
41274127
if (gencode) {
4128-
keepSource = asRbool(GetOption1(install("keep.source")), R_NilValue);
4128+
keepSource = asBool(GetOption1(install("keep.source")));
41294129
if (keepSource) {
4130-
ParseState.keepSrcRefs = TRUE;
4130+
ParseState.keepSrcRefs = true;
41314131
ParseState.keepParseData =
41324132
asRbool(GetOption1(install("keep.parse.data")), R_NilValue);
41334133
PS_SET_SRCFILE(NewEnvironment(R_NilValue, R_NilValue, R_EmptyEnv));
@@ -4189,7 +4189,7 @@ static SEXP R_Parse(int n, ParseStatus *status, SEXP srcfile)
41894189
PS_SET_ORIGINAL(srcfile);
41904190

41914191
if (isEnvironment(srcfile)) {
4192-
ParseState.keepSrcRefs = TRUE;
4192+
ParseState.keepSrcRefs = true;
41934193
ParseState.keepParseData =
41944194
asRbool(GetOption1(install("keep.parse.data")), R_NilValue);
41954195
PS_SET_SRCREFS(R_NilValue);
@@ -4330,7 +4330,7 @@ SEXP R_ParseBuffer(IoBuffer *buffer, int n, ParseStatus *status, SEXP prompt,
43304330
PS_SET_ORIGINAL(srcfile);
43314331

43324332
if (isEnvironment(srcfile)) {
4333-
ParseState.keepSrcRefs = TRUE;
4333+
ParseState.keepSrcRefs = true;
43344334
ParseState.keepParseData =
43354335
asRbool(GetOption1(install("keep.parse.data")), R_NilValue);
43364336
PS_SET_SRCREFS(R_NilValue);
@@ -4834,8 +4834,8 @@ static int SkipComment(void)
48344834
int _first_parsed = ParseState.xxparseno ;
48354835
int type = COMMENT ;
48364836

4837-
Rboolean maybeLine = (ParseState.xxcolno == 1);
4838-
Rboolean doSave;
4837+
bool maybeLine = (ParseState.xxcolno == 1);
4838+
bool doSave;
48394839

48404840
DECLARE_YYTEXT_BUFP(yyp);
48414841

@@ -4845,7 +4845,7 @@ static int SkipComment(void)
48454845
for (i=1; i<5; i++) {
48464846
c = xxgetc();
48474847
if (c != (int)(lineDirective[i])) {
4848-
maybeLine = FALSE;
4848+
maybeLine = false;
48494849
break;
48504850
}
48514851
YYTEXT_PUSH(c, yyp);
@@ -5163,7 +5163,7 @@ static int skipBytesByChar(char *c, int min) {
51635163
memmove(currtext, "... ", 4); \
51645164
memmove(currtext + 4, currtext + skip, 1000 - skip + 1); \
51655165
ct -= skip - 4; \
5166-
currtext_truncated = TRUE; \
5166+
currtext_truncated = true; \
51675167
} \
51685168
*ct++ = ((char) c); \
51695169
} while(0)
@@ -5178,7 +5178,7 @@ static int skipBytesByChar(char *c, int min) {
51785178
} while(0)
51795179

51805180
/* forSymbol is true when parsing backticked symbols */
5181-
static int StringValue(int c, Rboolean forSymbol)
5181+
static int StringValue(int c, bool forSymbol)
51825182
{
51835183
int quote = c;
51845184
char currtext[1010], *ct = currtext;
@@ -5188,7 +5188,7 @@ static int StringValue(int c, Rboolean forSymbol)
51885188
PROTECT_INDEX sti;
51895189
int wcnt = 0;
51905190
ucs_t wcs[10001];
5191-
Rboolean oct_or_hex = FALSE, use_wcs = FALSE, currtext_truncated = FALSE;
5191+
bool oct_or_hex = false, use_wcs = false, currtext_truncated = false;
51925192

51935193
PROTECT_WITH_INDEX(R_NilValue, &sti);
51945194
CTEXT_PUSH(c);
@@ -5231,7 +5231,7 @@ static int StringValue(int c, Rboolean forSymbol)
52315231
raiseLexError("invalidOctal", INT_VALUE, &octal,
52325232
_("\\%o exceeds maximum allowed octal value \\377 (%s:%d:%d)"));
52335233
c = octal;
5234-
oct_or_hex = TRUE;
5234+
oct_or_hex = true;
52355235
}
52365236
else if(c == 'x') {
52375237
int val = 0; int i, ext;
@@ -5259,19 +5259,19 @@ static int StringValue(int c, Rboolean forSymbol)
52595259
raiseLexError("nulNotAllowed", NO_VALUE, NULL,
52605260
_("nul character not allowed (%s:%d:%d)"));
52615261
c = val;
5262-
oct_or_hex = TRUE;
5262+
oct_or_hex = true;
52635263
}
52645264
else if(c == 'u') {
52655265
unsigned int val = 0; int i, ext;
5266-
Rboolean delim = FALSE;
5266+
bool delim = false;
52675267

52685268
if(forSymbol)
52695269
raiseLexError("unicodeInBackticks", NO_VALUE, NULL,
52705270
_("\\uxxxx sequences not supported inside backticks (%s:%d:%d)"));
52715271
c = xxgetc();
52725272
if (c == R_EOF) break;
52735273
if (c == '{') {
5274-
delim = TRUE;
5274+
delim = true;
52755275
CTEXT_PUSH(c);
52765276
} else xxungetc(c);
52775277
for(i = 0; i < 4; i++) {
@@ -5306,19 +5306,19 @@ static int StringValue(int c, Rboolean forSymbol)
53065306
raiseLexError("nulNotAllowed", NO_VALUE, NULL,
53075307
_("nul character not allowed (%s:%d:%d)"));
53085308
WTEXT_PUSH(val); /* this assumes wchar_t is Unicode */
5309-
use_wcs = TRUE;
5309+
use_wcs = true;
53105310
continue;
53115311
}
53125312
else if(c == 'U') {
53135313
unsigned int val = 0; int i, ext;
5314-
Rboolean delim = FALSE;
5314+
bool delim = false;
53155315
if(forSymbol)
53165316
raiseLexError("unicodeInBackticks", NO_VALUE, NULL,
53175317
_("\\Uxxxxxxxx sequences not supported inside backticks (%s:%d:%d)"));
53185318
c = xxgetc();
53195319
if (c == R_EOF) break;
53205320
if (c == '{') {
5321-
delim = TRUE;
5321+
delim = true;
53225322
CTEXT_PUSH(c);
53235323
} else xxungetc(c);
53245324
for(i = 0; i < 8; i++) {
@@ -5368,7 +5368,7 @@ static int StringValue(int c, Rboolean forSymbol)
53685368
}
53695369
#endif
53705370
WTEXT_PUSH(val);
5371-
use_wcs = TRUE;
5371+
use_wcs = true;
53725372
continue;
53735373
}
53745374
else {
@@ -5512,7 +5512,7 @@ static int RawStringValue(int c0, int c)
55125512
PROTECT_INDEX sti;
55135513
int wcnt = 0;
55145514
ucs_t wcs[10001];
5515-
Rboolean oct_or_hex = FALSE, use_wcs = FALSE, currtext_truncated = FALSE;
5515+
bool oct_or_hex = false, use_wcs = false, currtext_truncated = false;
55165516

55175517
CTEXT_PUSH(c0); /* 'r' or 'R' */
55185518
CTEXT_PUSH(c); /* opening quote */
@@ -5746,7 +5746,7 @@ static int Placeholder(int c)
57465746
DECLARE_YYTEXT_BUFP(yyp);
57475747
YYTEXT_PUSH(c, yyp);
57485748
YYTEXT_PUSH('\0', yyp);
5749-
HavePlaceholder = TRUE;
5749+
HavePlaceholder = true;
57505750
PRESERVE_SV(yylval = R_PlaceholderToken);
57515751
return PLACEHOLDER;
57525752
}
@@ -5782,7 +5782,7 @@ static int processLineDirective(int *type)
57825782
linenumber = atoi(yytext);
57835783
c = SkipSpace();
57845784
if (c == '"')
5785-
tok = StringValue(c, FALSE);
5785+
tok = StringValue(c, false);
57865786
else
57875787
xxungetc(c);
57885788
if (tok == STR_CONST)
@@ -5865,7 +5865,7 @@ static int token(void)
58655865
/* literal strings */
58665866

58675867
if (c == '\"' || c == '\'')
5868-
return StringValue(c, FALSE);
5868+
return StringValue(c, false);
58695869

58705870
/* special functions */
58715871

@@ -5875,7 +5875,7 @@ static int token(void)
58755875
/* functions, constants and variables */
58765876

58775877
if (c == '`')
5878-
return StringValue(c, TRUE);
5878+
return StringValue(c, true);
58795879
symbol:
58805880

58815881
if (c == '.') return SymbolValue(c);
@@ -5944,7 +5944,7 @@ static int token(void)
59445944
}
59455945
else if (nextchar('>')) {
59465946
yylval = install_and_save("=>");
5947-
HavePipeBind = TRUE;
5947+
HavePipeBind = true;
59485948
return PIPEBIND;
59495949
}
59505950
yylval = install_and_save("=");
@@ -6713,17 +6713,17 @@ static void growID( int target ){
67136713
PS_SET_IDS(lengthgets2(PS_IDS, new_size));
67146714
}
67156715

6716-
static int checkForPlaceholder(SEXP placeholder, SEXP arg)
6716+
static bool checkForPlaceholder(SEXP placeholder, SEXP arg)
67176717
{
67186718
if (! HavePlaceholder)
6719-
return FALSE;
6719+
return false;
67206720
else if (arg == placeholder)
6721-
return TRUE;
6721+
return true;
67226722
else if (TYPEOF(arg) == LANGSXP)
67236723
for (SEXP cur = arg; cur != R_NilValue; cur = CDR(cur))
67246724
if (checkForPlaceholder(placeholder, CAR(cur)))
6725-
return TRUE;
6726-
return FALSE;
6725+
return true;
6726+
return false;
67276727
}
67286728

67296729
static const char* getFilename(void) {

0 commit comments

Comments
 (0)