1
-
2
- //
3
1
// Date.cpp: Rcpp R/C++ interface class library -- Date type
4
2
//
5
- // Copyright (C) 2010 - 2019 Dirk Eddelbuettel and Romain Francois
3
+ // Copyright (C) 2010 - 2023 Dirk Eddelbuettel and Romain Francois
6
4
//
7
5
// The mktime00() as well as the gmtime_() replacement function are
8
6
// Copyright (C) 2000 - 2010 The R Development Core Team.
@@ -85,10 +83,10 @@ namespace Rcpp {
85
83
/* safety check for unbounded loops */
86
84
if (year0 > 3000 ) {
87
85
excess = (int )(year0/2000 ) - 1 ; // #nocov start
88
- year0 -= excess * 2000 ;
86
+ year0 -= ( int )( excess * 2000 ) ;
89
87
} else if (year0 < 0 ) {
90
88
excess = -1 - (int )(-year0/2000 );
91
- year0 -= excess * 2000 ; // #nocov end
89
+ year0 -= ( int )( excess * 2000 ) ; // #nocov end
92
90
}
93
91
94
92
for (i = 0 ; i < tm .tm_mon ; i++) day += days_in_month[i];
@@ -450,7 +448,7 @@ struct tzhead {
450
448
** Normalize logic courtesy Paul Eggert.
451
449
*/
452
450
453
- static int increment_overflow (int *const ip, int j) {
451
+ static int increment_overflow (int *const ip, int j) {
454
452
int const i = *ip;
455
453
456
454
/*
@@ -460,7 +458,7 @@ struct tzhead {
460
458
** or if j < INT_MIN - i; given i < 0, INT_MIN - i cannot overflow.
461
459
*/
462
460
if ((i >= 0 ) ? (j > INT_MAX - i) : (j < INT_MIN - i))
463
- return TRUE ; // #nocov
461
+ return TRUE ; // #nocov
464
462
*ip += j;
465
463
return FALSE ;
466
464
}
@@ -476,10 +474,10 @@ struct tzhead {
476
474
: *tp <= time_t_max - j))
477
475
return TRUE ;
478
476
*tp += j;
479
- return FALSE ;
477
+ return FALSE ;
480
478
}
481
479
482
- static int_fast32_t detzcode (const char *const codep) {
480
+ static int_fast32_t detzcode (const char *const codep) {
483
481
int_fast32_t result = (codep[0 ] & 0x80 ) ? -1 : 0 ;
484
482
for (int i = 0 ; i < 4 ; ++i)
485
483
result = (result << 8 ) | (codep[i] & 0xff );
@@ -628,7 +626,7 @@ struct tzhead {
628
626
return strp;
629
627
}
630
628
631
- // this routine modified / simplified / reduced in 2010
629
+ // this routine modified / simplified / reduced in 2010
632
630
static int tzload (const char * name, struct state * const sp, const int doextend) {
633
631
const char * p;
634
632
int i;
@@ -701,7 +699,7 @@ struct tzhead {
701
699
}
702
700
703
701
}
704
- nread = read (fid, u.buf , sizeof u.buf );
702
+ nread = ( int ) read (fid, u.buf , sizeof u.buf );
705
703
if (close (fid) < 0 || nread <= 0 )
706
704
return -1 ;
707
705
for (stored = 4 ; stored <= 8 ; stored *= 2 ) {
@@ -851,7 +849,7 @@ struct tzhead {
851
849
while (i < ts.timecnt &&
852
850
sp->timecnt < TZ_MAX_TIMES) {
853
851
sp->ats [sp->timecnt ] = ts.ats [i];
854
- sp->types [sp->timecnt ] = sp->typecnt + ts.types [i];
852
+ sp->types [sp->timecnt ] = ( unsigned char ) sp->typecnt + ts.types [i];
855
853
++sp->timecnt ;
856
854
++i;
857
855
}
@@ -1217,7 +1215,7 @@ struct tzhead {
1217
1215
&sp->chars [bp->tt_abbrind ]) == 0 ;
1218
1216
}
1219
1217
return result;
1220
- } // #nocov end
1218
+ } // #nocov end
1221
1219
1222
1220
static int leaps_thru_end_of (const int y) {
1223
1221
return (y >= 0 ) ? (y / 4 - y / 100 + y / 400 ) :
@@ -1316,7 +1314,7 @@ struct tzhead {
1316
1314
}
1317
1315
// Previously we returned 'year + base', so keep behaviour
1318
1316
// It seems like R now returns just 'year - 1900' (as libc does)
1319
- // But better for continuity to do as before
1317
+ // But better for continuity to do as before
1320
1318
tmp->tm_year = y + TM_YEAR_BASE;
1321
1319
if (increment_overflow (&tmp->tm_year , -TM_YEAR_BASE))
1322
1320
return NULL ; // #nocov
0 commit comments