/*-------------------------------------------------------------------------
 *
 * pgtz.c
 *	  Timezone Library Integration Functions
 *
 * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
 *	  $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.6 2004/05/01 22:07:03 momjian Exp $
 *
 *-------------------------------------------------------------------------
 */

#include "pgtz.h"
#include "tzfile.h"


static char tzdir[MAXPGPATH];
static int	done_tzdir = 0;
char *
pg_TZDIR(void)
{
	char	   *p;

	if (done_tzdir)
		return tzdir;

#ifndef WIN32
	StrNCpy(tzdir, PGDATADIR, MAXPGPATH);
#else
	if (GetModuleFileName(NULL, tzdir, MAXPGPATH) == 0)
		return NULL;
#endif

	canonicalize_path(tzdir);
#ifdef WIN32
	/* trim off binary name, then go up a directory */
	if ((p = last_path_separator(tzdir)) == NULL)
		return NULL;
	else
		*p = '\0';
	strcat(tzdir, "/../share/timezone");
#endif
	strcat(tzdir, "/timezone");


	done_tzdir = 1;
	return tzdir;
}

/*-------------------------------------------------------------------------
 *
 * pgtz.c
 *	  Timezone Library Integration Functions
 *
 * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
 *
 * IDENTIFICATION
 *	  $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.5 2004/05/01 01:38:53 momjian Exp $
 *
 *-------------------------------------------------------------------------
 */

#include "pgtz.h"
#include "tzfile.h"


static char tzdir[MAXPGPATH];
static int	done_tzdir = 0;
char *
pg_TZDIR(void)
{
	char	   *p;

	if (done_tzdir)
		return tzdir;

#ifndef WIN32
	StrNCpy(tzdir, PGDATADIR, MAXPGPATH);
#else
	if (GetModuleFileName(NULL, tzdir, MAXPGPATH) == 0)
		return NULL;
#endif

	canonicalize_path(tzdir);
#if 0
	if ((p = last_path_separator(tzdir)) == NULL)
		return NULL;
	else
		*p = '\0';
#endif

	strcat(tzdir, "/timezone");

	done_tzdir = 1;
	return tzdir;
}

--- 
+++ 
@@ -6,7 +6,7 @@
  * Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.5 2004/05/01 01:38:53 momjian Exp $
+ *	  $PostgreSQL: pgsql/src/timezone/pgtz.c,v 1.6 2004/05/01 22:07:03 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -33,14 +33,16 @@
 #endif
 
 	canonicalize_path(tzdir);
-#if 0
+#ifdef WIN32
+	/* trim off binary name, then go up a directory */
 	if ((p = last_path_separator(tzdir)) == NULL)
 		return NULL;
 	else
 		*p = '\0';
+	strcat(tzdir, "/../share/timezone");
 #endif
+	strcat(tzdir, "/timezone");
 
-	strcat(tzdir, "/timezone");
 
 	done_tzdir = 1;
 	return tzdir;
Fix timezone data path for Unix and win32.
