MCPcopy Create free account
hub / github.com/RcppCore/Rcpp / tzload

Function tzload

src/date.cpp:631–872  ·  view source on GitHub ↗

this routine modified / simplified / reduced in 2010

Source from the content-addressed store, hash-verified

629
630 // this routine modified / simplified / reduced in 2010
631 static int tzload(const char * name, struct state * const sp, const int doextend) {
632 const char * p;
633 int i;
634 int fid;
635 int stored;
636 int nread;
637 union {
638 struct tzhead tzhead;
639 char buf[2 * sizeof(struct tzhead) +
640 2 * sizeof *sp + 4 * TZ_MAX_TIMES];
641 } u;
642
643 sp->goback = sp->goahead = FALSE;
644 /* if (name == NULL && (name = TZDEFAULT) == NULL) return -1; */
645 if (name == NULL) {
646 // edd 06 Jul 2010 let's do without getTZinfo()
647 //name = getTZinfo();
648 //if( strcmp(name, "unknown") == 0 ) name = TZDEFAULT;
649 name = TZDEFAULT;
650 }
651
652 {
653 int doaccess;
654 /*
655 ** Section 4.9.1 of the C standard says that
656 ** "FILENAME_MAX expands to an integral constant expression
657 ** that is the size needed for an array of char large enough
658 ** to hold the longest file name string that the implementation
659 ** guarantees can be opened."
660 */
661 char fullname[FILENAME_MAX + 1];
662 // edd 08 Jul 2010 not currently needed const char *sname = name;
663
664 if (name[0] == ':')
665 ++name;
666 doaccess = name[0] == '/';
667 if (!doaccess) {
668 char buf[1000];
669 p = getenv("TZDIR");
670 if (p == NULL) {
671 snprintf(buf, 1000, "%s/share/zoneinfo",
672 getenv("R_HOME"));
673 buf[999] = '\0';
674 p = buf;
675 }
676 /* if ((p = TZDIR) == NULL) return -1; */
677 if ((strlen(p) + strlen(name) + 1) >= sizeof fullname)
678 return -1;
679 (void) strcpy(fullname, p);
680 (void) strcat(fullname, "/");
681 (void) strcat(fullname, name);
682 /*
683 ** Set doaccess if '.' (as in "../") shows up in name.
684 */
685 if (strchr(name, '.') != NULL) doaccess = TRUE;
686 name = fullname;
687 }
688 // edd 16 Jul 2010 comment out whole block

Callers 2

tzparseFunction · 0.85
gmtloadFunction · 0.85

Calls 5

detzcodeFunction · 0.85
detzcode64Function · 0.85
tzparseFunction · 0.85
typesequivFunction · 0.85
differ_by_repeatFunction · 0.85

Tested by

no test coverage detected