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++)
112 GUC_check_errmsg(
"missing time zone abbreviation in time zone file \"%s\", line %d",
121 GUC_check_errmsg(
"missing time zone offset in time zone file \"%s\", line %d",
127 if (isdigit((
unsigned char) *offset) || *offset ==
'+' || *offset ==
'-')
129 tzentry->
zone = NULL;
130 tzentry->
offset = strtol(offset, &offset_endptr, 10);
131 if (offset_endptr == offset || *offset_endptr !=
'\0')
133 GUC_check_errmsg(
"invalid number for time zone offset in time zone file \"%s\", line %d",
167 if (remain[0] !=
'#')
205 int mid = (low + high) >> 1;
206 tzEntry *midptr = arrayptr + mid;
219 if ((midptr->
zone == NULL && entry->
zone == NULL &&
222 (midptr->
zone != NULL && entry->
zone != NULL &&
223 strcmp(midptr->
zone, entry->
zone) == 0))
239 GUC_check_errdetail(
"Entry in time zone file \"%s\", line %d, conflicts with entry in file \"%s\", line %d.",
255 arrayptr = *base + low;
257 memmove(arrayptr + 1, arrayptr, (n - low) *
sizeof(
tzEntry));
259 memcpy(arrayptr, entry,
sizeof(
tzEntry));
277 tzEntry **base,
int *arraysize,
int n)
286 bool override =
false;
297 if (!isalpha((
unsigned char) *p))
320 snprintf(file_path,
sizeof(file_path),
"%s/timezonesets/%s",
331 int save_errno = errno;
334 snprintf(file_path,
sizeof(file_path),
"%s/timezonesets",
341 GUC_check_errhint(
"This may indicate an incomplete PostgreSQL installation, or that the file \"%s\" has been moved away from its proper location.",
352 if (errno != ENOENT || depth > 0)
359 while (!feof(tzFile))
362 if (fgets(tzbuf,
sizeof(tzbuf), tzFile) == NULL)
374 if (strlen(tzbuf) ==
sizeof(tzbuf) - 1)
385 while (*line && isspace((
unsigned char) *line))
396 char *includeFile =
pstrdup(line + strlen(
"@INCLUDE"));
398 includeFile = strtok(includeFile,
WHITESPACE);
399 if (!includeFile || !*includeFile)
401 GUC_check_errmsg(
"@INCLUDE without file name in time zone file \"%s\", line %d",
429 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)