localtime.c (17706) | localtime.c (18834) |
---|---|
1/* 2** This file is in the public domain, so clarified as of 3** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov). 4*/ 5 6#ifndef lint 7#ifndef NOID 8static char elsieid[] = "@(#)localtime.c 7.57"; 9#endif /* !defined NOID */ 10#endif /* !defined lint */ 11 12/* 13** Leap second handling from Bradley White (bww@k.gp.cs.cmu.edu). 14** POSIX-style TZ environment variable handling from Guy Harris 15** (guy@auspex.com). 16*/ 17 18/*LINTLIBRARY*/ 19 | 1/* 2** This file is in the public domain, so clarified as of 3** June 5, 1996 by Arthur David Olson (arthur_david_olson@nih.gov). 4*/ 5 6#ifndef lint 7#ifndef NOID 8static char elsieid[] = "@(#)localtime.c 7.57"; 9#endif /* !defined NOID */ 10#endif /* !defined lint */ 11 12/* 13** Leap second handling from Bradley White (bww@k.gp.cs.cmu.edu). 14** POSIX-style TZ environment variable handling from Guy Harris 15** (guy@auspex.com). 16*/ 17 18/*LINTLIBRARY*/ 19 |
20#include <sys/types.h> 21#include <sys/stat.h> 22 |
|
20#include "private.h" 21#include "tzfile.h" 22#include "fcntl.h" 23#ifdef _THREAD_SAFE 24#include <pthread.h> 25#include "pthread_private.h" 26#endif 27 --- 241 unchanged lines hidden (view full) --- 269 register const char * p; 270 register int i; 271 register int fid; 272 273 if (name == NULL && (name = TZDEFAULT) == NULL) 274 return -1; 275 { 276 register int doaccess; | 23#include "private.h" 24#include "tzfile.h" 25#include "fcntl.h" 26#ifdef _THREAD_SAFE 27#include <pthread.h> 28#include "pthread_private.h" 29#endif 30 --- 241 unchanged lines hidden (view full) --- 272 register const char * p; 273 register int i; 274 register int fid; 275 276 if (name == NULL && (name = TZDEFAULT) == NULL) 277 return -1; 278 { 279 register int doaccess; |
280 struct stat stab; |
|
277 /* 278 ** Section 4.9.1 of the C standard says that 279 ** "FILENAME_MAX expands to an integral constant expression | 281 /* 282 ** Section 4.9.1 of the C standard says that 283 ** "FILENAME_MAX expands to an integral constant expression |
280 ** that is the sie needed for an array of char large enough | 284 ** that is the size needed for an array of char large enough |
281 ** to hold the longest file name string that the implementation 282 ** guarantees can be opened." 283 */ 284 char fullname[FILENAME_MAX + 1]; 285 286 if (name[0] == ':') 287 ++name; 288 doaccess = name[0] == '/'; --- 11 unchanged lines hidden (view full) --- 300 if (strchr(name, '.') != NULL) 301 doaccess = TRUE; 302 name = fullname; 303 } 304 if (doaccess && access(name, R_OK) != 0) 305 return -1; 306 if ((fid = open(name, OPEN_MODE)) == -1) 307 return -1; | 285 ** to hold the longest file name string that the implementation 286 ** guarantees can be opened." 287 */ 288 char fullname[FILENAME_MAX + 1]; 289 290 if (name[0] == ':') 291 ++name; 292 doaccess = name[0] == '/'; --- 11 unchanged lines hidden (view full) --- 304 if (strchr(name, '.') != NULL) 305 doaccess = TRUE; 306 name = fullname; 307 } 308 if (doaccess && access(name, R_OK) != 0) 309 return -1; 310 if ((fid = open(name, OPEN_MODE)) == -1) 311 return -1; |
312 if ((fstat(fid, &stab) < 0) || !S_ISREG(stab.st_mode)) 313 return -1; |
|
308 } 309 { 310 struct tzhead * tzhp; 311 char buf[sizeof *sp + sizeof *tzhp]; 312 int ttisstdcnt; 313 int ttisgmtcnt; 314 315 i = read(fid, buf, sizeof buf); --- 1434 unchanged lines hidden --- | 314 } 315 { 316 struct tzhead * tzhp; 317 char buf[sizeof *sp + sizeof *tzhp]; 318 int ttisstdcnt; 319 int ttisgmtcnt; 320 321 i = read(fid, buf, sizeof buf); --- 1434 unchanged lines hidden --- |