1- // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2- // jedit: :folding=explicit:
1+
32//
43// Date.cpp: Rcpp R/C++ interface class library -- Date type
54//
6- // Copyright (C) 2010 - 2016 Dirk Eddelbuettel and Romain Francois
5+ // Copyright (C) 2010 - 2019 Dirk Eddelbuettel and Romain Francois
76//
87// The mktime00() as well as the gmtime_() replacement function are
98// Copyright (C) 2000 - 2010 The R Development Core Team.
@@ -85,11 +84,11 @@ namespace Rcpp {
8584 year0 = year_base + tm.tm_year ;
8685 /* safety check for unbounded loops */
8786 if (year0 > 3000 ) {
88- excess = (int )(year0/2000 ) - 1 ;
87+ excess = (int )(year0/2000 ) - 1 ; // #nocov start
8988 year0 -= excess * 2000 ;
9089 } else if (year0 < 0 ) {
9190 excess = -1 - (int )(-year0/2000 );
92- year0 -= excess * 2000 ;
91+ year0 -= excess * 2000 ; // #nocov end
9392 }
9493
9594 for (i = 0 ; i < tm.tm_mon ; i++) day += days_in_month[i];
@@ -461,12 +460,12 @@ struct tzhead {
461460 ** or if j < INT_MIN - i; given i < 0, INT_MIN - i cannot overflow.
462461 */
463462 if ((i >= 0 ) ? (j > INT_MAX - i) : (j < INT_MIN - i))
464- return TRUE ;
463+ return TRUE ; // #nocov
465464 *ip += j;
466465 return FALSE ;
467466 }
468467
469- static int increment_overflow_time (time_t *tp, int_fast32_t j) {
468+ static int increment_overflow_time (time_t *tp, int_fast32_t j) { // #nocov start
470469 /*
471470 ** This is like
472471 ** 'if (! (time_t_min <= *tp + j && *tp + j <= time_t_max)) ...',
@@ -477,10 +476,10 @@ struct tzhead {
477476 : *tp <= time_t_max - j))
478477 return TRUE ;
479478 *tp += j;
480- return FALSE ;
479+ return FALSE ;
481480 }
482481
483- static int_fast32_t detzcode (const char *const codep) { // #nocov start
482+ static int_fast32_t detzcode (const char *const codep) {
484483 int_fast32_t result = (codep[0 ] & 0x80 ) ? -1 : 0 ;
485484 for (int i = 0 ; i < 4 ; ++i)
486485 result = (result << 8 ) | (codep[i] & 0xff );
@@ -1241,7 +1240,7 @@ struct tzhead {
12411240 hit = 0 ;
12421241 i = sp->leapcnt ;
12431242 while (--i >= 0 ) {
1244- lp = &sp->lsis [i];
1243+ lp = &sp->lsis [i]; // #nocov start
12451244 if (*timep >= lp->ls_trans ) {
12461245 if (*timep == lp->ls_trans ) {
12471246 hit = ((i == 0 && lp->ls_corr > 0 ) ||
@@ -1257,7 +1256,7 @@ struct tzhead {
12571256 }
12581257 }
12591258 corr = lp->ls_corr ;
1260- break ;
1259+ break ; // #nocov end
12611260 }
12621261 }
12631262 y = EPOCH_YEAR;
@@ -1272,7 +1271,7 @@ struct tzhead {
12721271 tdelta = tdays / DAYSPERLYEAR;
12731272 if (! ((! TYPE_SIGNED (time_t ) || INT_MIN <= tdelta)
12741273 && tdelta <= INT_MAX))
1275- return NULL ;
1274+ return NULL ; // #nocov
12761275 idelta = (int )tdelta;
12771276 if (idelta == 0 )
12781277 idelta = (tdays < 0 ) ? -1 : 1 ;
@@ -1297,7 +1296,7 @@ struct tzhead {
12971296 */
12981297 idays = (int )tdays;
12991298 rem += offset - corr;
1300- while (rem < 0 ) {
1299+ while (rem < 0 ) { // #nocov start
13011300 rem += SECSPERDAY;
13021301 --idays;
13031302 }
@@ -1313,14 +1312,14 @@ struct tzhead {
13131312 while (idays >= year_lengths[isleap (y)]) {
13141313 idays -= year_lengths[isleap (y)];
13151314 if (increment_overflow (&y, 1 ))
1316- return NULL ;
1315+ return NULL ; // #nocov end
13171316 }
13181317 // Previously we returned 'year + base', so keep behaviour
13191318 // It seems like R now returns just 'year - 1900' (as libc does)
13201319 // But better for continuity to do as before
13211320 tmp->tm_year = y + TM_YEAR_BASE;
13221321 if (increment_overflow (&tmp->tm_year , -TM_YEAR_BASE))
1323- return NULL ;
1322+ return NULL ; // #nocov
13241323 tmp->tm_yday = idays;
13251324 /*
13261325 ** The "extra" mods below avoid overflow problems.
@@ -1333,7 +1332,7 @@ struct tzhead {
13331332 idays;
13341333 tmp->tm_wday %= DAYSPERWEEK;
13351334 if (tmp->tm_wday < 0 )
1336- tmp->tm_wday += DAYSPERWEEK;
1335+ tmp->tm_wday += DAYSPERWEEK; // #nocov
13371336 tmp->tm_hour = (int ) (rem / SECSPERHOUR);
13381337 rem %= SECSPERHOUR;
13391338 tmp->tm_min = (int ) (rem / SECSPERMIN);
0 commit comments