1-
2- //
31// Date.cpp: Rcpp R/C++ interface class library -- Date type
42//
5- // Copyright (C) 2010 - 2019 Dirk Eddelbuettel and Romain Francois
3+ // Copyright (C) 2010 - 2023 Dirk Eddelbuettel and Romain Francois
64//
75// The mktime00() as well as the gmtime_() replacement function are
86// Copyright (C) 2000 - 2010 The R Development Core Team.
@@ -85,10 +83,10 @@ namespace Rcpp {
8583 /* safety check for unbounded loops */
8684 if (year0 > 3000 ) {
8785 excess = (int )(year0/2000 ) - 1 ; // #nocov start
88- year0 -= excess * 2000 ;
86+ year0 -= ( int )( excess * 2000 ) ;
8987 } else if (year0 < 0 ) {
9088 excess = -1 - (int )(-year0/2000 );
91- year0 -= excess * 2000 ; // #nocov end
89+ year0 -= ( int )( excess * 2000 ) ; // #nocov end
9290 }
9391
9492 for (i = 0 ; i < tm.tm_mon ; i++) day += days_in_month[i];
@@ -450,7 +448,7 @@ struct tzhead {
450448 ** Normalize logic courtesy Paul Eggert.
451449 */
452450
453- static int increment_overflow (int *const ip, int j) {
451+ static int increment_overflow (int *const ip, int j) {
454452 int const i = *ip;
455453
456454 /*
@@ -460,7 +458,7 @@ struct tzhead {
460458 ** or if j < INT_MIN - i; given i < 0, INT_MIN - i cannot overflow.
461459 */
462460 if ((i >= 0 ) ? (j > INT_MAX - i) : (j < INT_MIN - i))
463- return TRUE ; // #nocov
461+ return TRUE ; // #nocov
464462 *ip += j;
465463 return FALSE ;
466464 }
@@ -476,10 +474,10 @@ struct tzhead {
476474 : *tp <= time_t_max - j))
477475 return TRUE ;
478476 *tp += j;
479- return FALSE ;
477+ return FALSE ;
480478 }
481479
482- static int_fast32_t detzcode (const char *const codep) {
480+ static int_fast32_t detzcode (const char *const codep) {
483481 int_fast32_t result = (codep[0 ] & 0x80 ) ? -1 : 0 ;
484482 for (int i = 0 ; i < 4 ; ++i)
485483 result = (result << 8 ) | (codep[i] & 0xff );
@@ -628,7 +626,7 @@ struct tzhead {
628626 return strp;
629627 }
630628
631- // this routine modified / simplified / reduced in 2010
629+ // this routine modified / simplified / reduced in 2010
632630 static int tzload (const char * name, struct state * const sp, const int doextend) {
633631 const char * p;
634632 int i;
@@ -701,7 +699,7 @@ struct tzhead {
701699 }
702700
703701 }
704- nread = read (fid, u.buf , sizeof u.buf );
702+ nread = ( int ) read (fid, u.buf , sizeof u.buf );
705703 if (close (fid) < 0 || nread <= 0 )
706704 return -1 ;
707705 for (stored = 4 ; stored <= 8 ; stored *= 2 ) {
@@ -851,7 +849,7 @@ struct tzhead {
851849 while (i < ts.timecnt &&
852850 sp->timecnt < TZ_MAX_TIMES) {
853851 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];
855853 ++sp->timecnt ;
856854 ++i;
857855 }
@@ -1217,7 +1215,7 @@ struct tzhead {
12171215 &sp->chars [bp->tt_abbrind ]) == 0 ;
12181216 }
12191217 return result;
1220- } // #nocov end
1218+ } // #nocov end
12211219
12221220 static int leaps_thru_end_of (const int y) {
12231221 return (y >= 0 ) ? (y / 4 - y / 100 + y / 400 ) :
@@ -1316,7 +1314,7 @@ struct tzhead {
13161314 }
13171315 // Previously we returned 'year + base', so keep behaviour
13181316 // 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
13201318 tmp->tm_year = y + TM_YEAR_BASE;
13211319 if (increment_overflow (&tmp->tm_year , -TM_YEAR_BASE))
13221320 return NULL ; // #nocov
0 commit comments