Skip to content

Commit 8d4c760

Browse files
author
ripley
committed
C standard has attributes before return values
git-svn-id: https://svn.r-project.org/R/trunk@87901 00db46b3-68df-0310-9c12-caf00c1e9a41
1 parent 7f06fa6 commit 8d4c760

21 files changed

+71
-87
lines changed

src/main/altclasses.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2011,7 +2011,7 @@ attribute_hidden SEXP do_wrap_meta(SEXP call, SEXP op, SEXP args, SEXP env)
20112011
return wrap_meta(x, srt, no_na);
20122012
}
20132013

2014-
SEXP /*attribute_hidden*/ R_tryWrap(SEXP x)
2014+
/*attribute_hidden*/ SEXP R_tryWrap(SEXP x)
20152015
{
20162016
return wrap_meta(x, UNKNOWN_SORTEDNESS, FALSE);
20172017
}

src/main/coerce.c

Lines changed: 17 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
} \
7373
} while (0)
7474

75-
void attribute_hidden CoercionWarning(int warn)
75+
attribute_hidden void CoercionWarning(int warn)
7676
{
7777
/* FIXME: Use
7878
=====
@@ -88,29 +88,25 @@ void attribute_hidden CoercionWarning(int warn)
8888
warning(_("out-of-range values treated as 0 in coercion to raw"));
8989
}
9090

91-
int attribute_hidden
92-
LogicalFromInteger(int x, int *warn)
91+
attribute_hidden int LogicalFromInteger(int x, int *warn)
9392
{
9493
return (x == NA_INTEGER) ?
9594
NA_LOGICAL : (x != 0);
9695
}
9796

98-
int attribute_hidden
99-
LogicalFromReal(double x, int *warn)
97+
attribute_hidden int LogicalFromReal(double x, int *warn)
10098
{
10199
return ISNAN(x) ?
102100
NA_LOGICAL : (x != 0);
103101
}
104102

105-
int attribute_hidden
106-
LogicalFromComplex(Rcomplex x, int *warn)
103+
attribute_hidden int LogicalFromComplex(Rcomplex x, int *warn)
107104
{
108105
return (ISNAN(x.r) || ISNAN(x.i)) ?
109106
NA_LOGICAL : (x.r != 0 || x.i != 0);
110107
}
111108

112-
int attribute_hidden
113-
LogicalFromString(SEXP x, int *warn)
109+
attribute_hidden int LogicalFromString(SEXP x, int *warn)
114110
{
115111
if (x != R_NaString) {
116112
if (StringTrue(CHAR(x))) return 1;
@@ -119,15 +115,13 @@ LogicalFromString(SEXP x, int *warn)
119115
return NA_LOGICAL;
120116
}
121117

122-
int attribute_hidden
123-
IntegerFromLogical(int x, int *warn)
118+
attribute_hidden int IntegerFromLogical(int x, int *warn)
124119
{
125120
return (x == NA_LOGICAL) ?
126121
NA_INTEGER : x;
127122
}
128123

129-
int attribute_hidden
130-
IntegerFromReal(double x, int *warn)
124+
attribute_hidden int IntegerFromReal(double x, int *warn)
131125
{
132126
if (ISNAN(x))
133127
return NA_INTEGER;
@@ -138,8 +132,7 @@ IntegerFromReal(double x, int *warn)
138132
return (int) x;
139133
}
140134

141-
int attribute_hidden
142-
IntegerFromComplex(Rcomplex x, int *warn)
135+
attribute_hidden int IntegerFromComplex(Rcomplex x, int *warn)
143136
{
144137
if (ISNAN(x.r) || ISNAN(x.i))
145138
return NA_INTEGER;
@@ -153,8 +146,7 @@ IntegerFromComplex(Rcomplex x, int *warn)
153146
}
154147

155148

156-
int attribute_hidden
157-
IntegerFromString(SEXP x, int *warn)
149+
attribute_hidden int IntegerFromString(SEXP x, int *warn)
158150
{
159151
if (x != R_NaString && !isBlankString(CHAR(x))) { /* ASCII */
160152
char *endp;
@@ -184,21 +176,18 @@ IntegerFromString(SEXP x, int *warn)
184176
return NA_INTEGER;
185177
}
186178

187-
double attribute_hidden
188-
RealFromLogical(int x, int *warn)
179+
attribute_hidden double RealFromLogical(int x, int *warn)
189180
{
190181
return (x == NA_LOGICAL) ?
191182
NA_REAL : x;
192183
}
193184

194-
double attribute_hidden
195-
RealFromInteger(int x, int *warn)
185+
attribute_hidden double RealFromInteger(int x, int *warn)
196186
{
197187
return (x == NA_INTEGER) ? NA_REAL : x;
198188
}
199189

200-
double attribute_hidden
201-
RealFromComplex(Rcomplex x, int *warn)
190+
attribute_hidden double RealFromComplex(Rcomplex x, int *warn)
202191
{
203192
if (ISNAN(x.r) || ISNAN(x.i))
204193
return NA_REAL;
@@ -207,8 +196,7 @@ RealFromComplex(Rcomplex x, int *warn)
207196
return x.r;
208197
}
209198

210-
double attribute_hidden
211-
RealFromString(SEXP x, int *warn)
199+
attribute_hidden double RealFromString(SEXP x, int *warn)
212200
{
213201
double xdouble;
214202
char *endp;
@@ -226,8 +214,7 @@ RealFromString(SEXP x, int *warn)
226214
_Z_.r = NA_REAL; \
227215
_Z_.i = NA_REAL
228216

229-
Rcomplex attribute_hidden
230-
ComplexFromLogical(int x, int *warn)
217+
attribute_hidden Rcomplex ComplexFromLogical(int x, int *warn)
231218
{
232219
Rcomplex z;
233220
if (x == NA_LOGICAL) {
@@ -245,8 +232,7 @@ ComplexFromLogical(int x, int *warn)
245232
return z;
246233
}
247234

248-
Rcomplex attribute_hidden
249-
ComplexFromInteger(int x, int *warn)
235+
attribute_hidden Rcomplex ComplexFromInteger(int x, int *warn)
250236
{
251237
Rcomplex z;
252238
if (x == NA_INTEGER) {
@@ -264,8 +250,7 @@ ComplexFromInteger(int x, int *warn)
264250
return z;
265251
}
266252

267-
Rcomplex attribute_hidden
268-
ComplexFromReal(double x, int *warn)
253+
attribute_hidden Rcomplex ComplexFromReal(double x, int *warn)
269254
{
270255
Rcomplex z;
271256
#ifdef NA_TO_COMPLEX_NA
@@ -282,8 +267,7 @@ ComplexFromReal(double x, int *warn)
282267
return z;
283268
}
284269

285-
Rcomplex attribute_hidden
286-
ComplexFromString(SEXP x, int *warn)
270+
attribute_hidden Rcomplex ComplexFromString(SEXP x, int *warn)
287271
{
288272
const char *xx = CHAR(x); /* ASCII */
289273
char *endp;

src/main/connections.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
#include <trioremap.h>
125125
#endif
126126

127-
int attribute_hidden R_OutputCon; /* used in printutils.c */
127+
attribute_hidden int R_OutputCon; /* used in printutils.c */
128128

129129
static void con_destroy(int i);
130130

@@ -5691,7 +5691,7 @@ switch_or_tee_stdout(int icon, int closeOnExit, int tee)
56915691
}
56925692

56935693
/* This is only used by cat() */
5694-
Rboolean attribute_hidden switch_stdout(int icon, int closeOnExit)
5694+
attribute_hidden Rboolean switch_stdout(int icon, int closeOnExit)
56955695
{
56965696
return switch_or_tee_stdout(icon, closeOnExit, 0);
56975697
}

src/main/context.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ attribute_hidden SEXP R_sysframe(int n, RCNTXT *cptr)
416416
/* It would be much simpler if sysparent just returned cptr->sysparent */
417417
/* but then we wouldn't be compatible with S. */
418418

419-
int attribute_hidden R_sysparent(int n, RCNTXT *cptr)
419+
attribute_hidden int R_sysparent(int n, RCNTXT *cptr)
420420
{
421421
int j;
422422
SEXP s;
@@ -449,7 +449,7 @@ int attribute_hidden R_sysparent(int n, RCNTXT *cptr)
449449
return n;
450450
}
451451

452-
int attribute_hidden framedepth(RCNTXT *cptr)
452+
attribute_hidden int framedepth(RCNTXT *cptr)
453453
{
454454
int nframe = 0;
455455
while (cptr->nextcontext != NULL) {

src/main/dounzip.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ static int null_fflush(Rconnection con)
503503
return 0;
504504
}
505505

506-
Rconnection attribute_hidden
506+
attribute_hidden Rconnection
507507
R_newunz(const char *description, const char *const mode)
508508
{
509509
Rconnection new;

src/main/duplicate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ static SEXP duplicate1(SEXP, Rboolean deep);
117117
#ifdef R_PROFILING
118118
static unsigned long duplicate_counter = (unsigned long)-1;
119119

120-
unsigned long attribute_hidden
120+
attribute_hidden unsigned long
121121
get_duplicate_counter(void)
122122
{
123123
return duplicate_counter;

src/main/envir.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ attribute_hidden Rboolean R_envHasNoSpecialSymbols (SEXP env)
224224
and hash tables get saved as part of environments so changing it
225225
is a major decision.
226226
*/
227-
int attribute_hidden R_Newhashpjw(const char *s)
227+
attribute_hidden int R_Newhashpjw(const char *s)
228228
{
229229
char *p;
230230
unsigned h = 0, g;

src/main/eval.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7149,7 +7149,7 @@ static SEXP markSpecialArgs(SEXP args)
71497149
return args;
71507150
}
71517151

7152-
Rboolean attribute_hidden R_BCVersionOK(SEXP s)
7152+
attribute_hidden Rboolean R_BCVersionOK(SEXP s)
71537153
{
71547154
if (TYPEOF(s) != BCODESXP)
71557155
return FALSE;
@@ -8972,7 +8972,7 @@ static void const_cleanup(void *data)
89728972

89738973
/* Checks if constants of any registered BCODESXP have been modified.
89748974
Returns TRUE if the constants are ok, otherwise returns false or aborts.*/
8975-
Rboolean attribute_hidden R_checkConstants(Rboolean abortOnError)
8975+
attribute_hidden Rboolean R_checkConstants(Rboolean abortOnError)
89768976
{
89778977
if (R_check_constants <= 0 || R_ConstantsRegistry == NULL)
89788978
return TRUE;

src/main/internet.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ SEXP Rdownload(SEXP args)
8181
}
8282

8383
// As from R 4.2.0 this is only used on Windows
84-
Rconnection attribute_hidden
84+
attribute_hidden Rconnection
8585
R_newurl(const char *description, const char * const mode, SEXP headers, int type)
8686
{
8787
if(!initialized) internet_Init();
@@ -93,7 +93,7 @@ R_newurl(const char *description, const char * const mode, SEXP headers, int typ
9393
}
9494
}
9595

96-
Rconnection attribute_hidden
96+
attribute_hidden Rconnection
9797
R_newsock(const char *host, int port, int server, int serverfd,
9898
const char * const mode, int timeout, int options)
9999
{
@@ -106,7 +106,7 @@ R_newsock(const char *host, int port, int server, int serverfd,
106106
}
107107
}
108108

109-
Rconnection attribute_hidden R_newservsock(int port)
109+
attribute_hidden Rconnection R_newservsock(int port)
110110
{
111111
if(!initialized) internet_Init();
112112
if(initialized > 0)
@@ -285,7 +285,7 @@ attribute_hidden SEXP do_curlDownload(SEXP call, SEXP op, SEXP args, SEXP rho)
285285
}
286286
}
287287

288-
Rconnection attribute_hidden
288+
attribute_hidden Rconnection
289289
R_newCurlUrl(const char *description, const char * const mode, SEXP headers, int type)
290290
{
291291
if(!initialized) internet_Init();

src/main/iosupport.c

Lines changed: 12 additions & 12 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, 1997, Robert Gentleman and Ross Ihaka
4-
* 2007-2020 The R Core Team
4+
* 2007-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
@@ -71,7 +71,7 @@ static int NextReadBufferListItem(IoBuffer *iob)
7171

7272
/* Reset the read/write pointers of an IoBuffer */
7373

74-
int attribute_hidden R_IoBufferWriteReset(IoBuffer *iob)
74+
attribute_hidden int R_IoBufferWriteReset(IoBuffer *iob)
7575
{
7676
if (iob == NULL || iob->start_buf == NULL)
7777
return 0;
@@ -86,7 +86,7 @@ int attribute_hidden R_IoBufferWriteReset(IoBuffer *iob)
8686

8787
/* Reset the read pointer of an IoBuffer */
8888

89-
int attribute_hidden R_IoBufferReadReset(IoBuffer *iob)
89+
attribute_hidden int R_IoBufferReadReset(IoBuffer *iob)
9090
{
9191
if (iob == NULL || iob->start_buf == NULL)
9292
return 0;
@@ -99,7 +99,7 @@ int attribute_hidden R_IoBufferReadReset(IoBuffer *iob)
9999
/* Allocate an initial BufferListItem for IoBuffer */
100100
/* Initialize the counts and pointers. */
101101

102-
int attribute_hidden R_IoBufferInit(IoBuffer *iob)
102+
attribute_hidden int R_IoBufferInit(IoBuffer *iob)
103103
{
104104
if (iob == NULL) return 0;
105105
iob->start_buf = (BufferListItem*)malloc(sizeof(BufferListItem));
@@ -112,7 +112,7 @@ int attribute_hidden R_IoBufferInit(IoBuffer *iob)
112112
/* This resets pointers to NULL, which could be detected */
113113
/* in other calls. */
114114

115-
int attribute_hidden R_IoBufferFree(IoBuffer *iob)
115+
attribute_hidden int R_IoBufferFree(IoBuffer *iob)
116116
{
117117
BufferListItem *thisItem, *nextItem;
118118
if (iob == NULL || iob->start_buf == NULL)
@@ -128,7 +128,7 @@ int attribute_hidden R_IoBufferFree(IoBuffer *iob)
128128

129129
/* Add a character to an IoBuffer */
130130

131-
int attribute_hidden R_IoBufferPutc(int c, IoBuffer *iob)
131+
attribute_hidden int R_IoBufferPutc(int c, IoBuffer *iob)
132132
{
133133
if (iob->write_offset == IOBSIZE)
134134
NextWriteBufferListItem(iob);
@@ -139,7 +139,7 @@ int attribute_hidden R_IoBufferPutc(int c, IoBuffer *iob)
139139

140140
/* Add a (null terminated) string to an IoBuffer */
141141

142-
int attribute_hidden R_IoBufferPuts(char *s, IoBuffer *iob)
142+
attribute_hidden int R_IoBufferPuts(char *s, IoBuffer *iob)
143143
{
144144
char *p;
145145
int n = 0;
@@ -152,7 +152,7 @@ int attribute_hidden R_IoBufferPuts(char *s, IoBuffer *iob)
152152

153153
/* Read a character from an IoBuffer */
154154

155-
int attribute_hidden R_IoBufferGetc(IoBuffer *iob)
155+
attribute_hidden int R_IoBufferGetc(IoBuffer *iob)
156156
{
157157
if (iob->read_buf == iob->write_buf &&
158158
iob->read_offset >= iob->write_offset)
@@ -164,7 +164,7 @@ int attribute_hidden R_IoBufferGetc(IoBuffer *iob)
164164

165165
/* What is our current offset, taking all blocks into account? */
166166

167-
int attribute_hidden R_IoBufferReadOffset(IoBuffer *iob)
167+
attribute_hidden int R_IoBufferReadOffset(IoBuffer *iob)
168168
{
169169
int result = iob->read_offset;
170170
BufferListItem* buf = iob->start_buf;
@@ -196,7 +196,7 @@ static const char *translateCharWithOverride(SEXP x)
196196
return translateChar(x);
197197
}
198198

199-
int attribute_hidden R_TextBufferInit(TextBuffer *txtb, SEXP text)
199+
attribute_hidden int R_TextBufferInit(TextBuffer *txtb, SEXP text)
200200
{
201201
int i, k, l, n;
202202
if (isString(text)) {
@@ -236,15 +236,15 @@ int attribute_hidden R_TextBufferInit(TextBuffer *txtb, SEXP text)
236236

237237
/* Finalization code for text buffers */
238238

239-
int attribute_hidden R_TextBufferFree(TextBuffer *txtb)
239+
attribute_hidden int R_TextBufferFree(TextBuffer *txtb)
240240
{
241241
vmaxset(txtb->vmax);
242242
return 0;/* not used */
243243
}
244244

245245
/* Getc for text buffers */
246246

247-
int attribute_hidden R_TextBufferGetc(TextBuffer *txtb)
247+
attribute_hidden int R_TextBufferGetc(TextBuffer *txtb)
248248
{
249249
if (txtb->buf == NULL)
250250
return EOF;

0 commit comments

Comments
 (0)