35 #define WHITESPACE " \t\n\r"
43 tzEntry **base,
int *arraysize,
int n);
61 GUC_check_errmsg(
"time zone abbreviation \"%s\" is too long (maximum %d characters) in time zone file \"%s\", line %d",
73 GUC_check_errmsg(
"time zone offset %d is out of range in time zone file \"%s\", line %d",
82 for (p = (
unsigned char *) tzentry->
abbrev; *p; p++)
113 GUC_check_errmsg(
"missing time zone abbreviation in time zone file \"%s\", line %d",
122 GUC_check_errmsg(
"missing time zone offset in time zone file \"%s\", line %d",
128 if (isdigit((
unsigned char) *offset) || *offset ==
'+' || *offset ==
'-')
130 tzentry->
zone = NULL;
131 tzentry->
offset = strtol(offset, &offset_endptr, 10);
132 if (offset_endptr == offset || *offset_endptr !=
'\0')
134 GUC_check_errmsg(
"invalid number for time zone offset in time zone file \"%s\", line %d",
168 if (remain[0] !=
'#')
206 int mid = (low + high) >> 1;
207 tzEntry *midptr = arrayptr + mid;
220 if ((midptr->
zone == NULL && entry->
zone == NULL &&
223 (midptr->
zone != NULL && entry->
zone != NULL &&
224 strcmp(midptr->
zone, entry->
zone) == 0))
240 GUC_check_errdetail(
"Entry in time zone file \"%s\", line %d, conflicts with entry in file \"%s\", line %d.",
256 arrayptr = *base + low;
258 memmove(arrayptr + 1, arrayptr, (n - low) *
sizeof(
tzEntry));
260 memcpy(arrayptr, entry,
sizeof(
tzEntry));
278 tzEntry **base,
int *arraysize,
int n)
287 bool override =
false;
298 if (!isalpha((
unsigned char) *p))
321 snprintf(file_path,
sizeof(file_path),
"%s/timezonesets/%s",
332 int save_errno = errno;
335 snprintf(file_path,
sizeof(file_path),
"%s/timezonesets",
342 GUC_check_errhint(
"This may indicate an incomplete PostgreSQL installation, or that the file \"%s\" has been moved away from its proper location.",
353 if (errno != ENOENT || depth > 0)
360 while (!feof(tzFile))
363 if (fgets(tzbuf,
sizeof(tzbuf), tzFile) == NULL)
375 if (strlen(tzbuf) ==
sizeof(tzbuf) - 1)
386 while (*line && isspace((
unsigned char) *line))
397 char *includeFile =
pstrdup(line + strlen(
"@INCLUDE"));
401 if (!includeFile || !*includeFile)
403 GUC_check_errmsg(
"@INCLUDE without file name in time zone file \"%s\", line %d",
431 n =
addToArray(base, arraysize, n, &tzentry,
override);
TimeZoneAbbrevTable * ConvertTimeZoneAbbrevs(struct tzEntry *abbrevs, int n)
FILE * AllocateFile(const char *name, const char *mode)
DIR * AllocateDir(const char *dirname)
char my_exec_path[MAXPGPATH]
#define GUC_check_errdetail
#define GUC_check_errhint
char * pstrdup(const char *in)
MemoryContext CurrentMemoryContext
void * repalloc(void *pointer, Size size)
void MemoryContextDelete(MemoryContext context)
#define AllocSetContextCreate
#define ALLOCSET_SMALL_SIZES
void get_share_path(const char *my_exec_path, char *ret_path)
int pg_strcasecmp(const char *s1, const char *s2)
unsigned char pg_tolower(unsigned char ch)
int pg_strncasecmp(const char *s1, const char *s2, size_t n)
MemoryContextSwitchTo(old_ctx)
static int cmp(const chr *x, const chr *y, size_t len)
static bool validateTzEntry(tzEntry *tzentry)
static bool splitTzLine(const char *filename, int lineno, char *line, tzEntry *tzentry)
TimeZoneAbbrevTable * load_tzoffsets(const char *filename)
static int addToArray(tzEntry **base, int *arraysize, int n, tzEntry *entry, bool override)
static int ParseTzFile(const char *filename, int depth, tzEntry **base, int *arraysize, int n)