* Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD.
*
- * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.61 2004/10/12 21:54:42 petere Exp $
+ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.68 2004/11/27 18:51:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
#include "mb/pg_wchar.h"
#include "getopt_long.h"
-#ifndef HAVE_OPTRESET
+#ifndef HAVE_INT_OPTRESET
int optreset;
#endif
/*
* write an array of lines to a file
+ *
+ * This is only used to write text files. Use fopen "w" not PG_BINARY_W
+ * so that the resulting configuration files are nicely editable on Windows.
*/
static void
writefile(char *path, char **lines)
FILE *out_file;
char **line;
- if ((out_file = fopen(path, PG_BINARY_W)) == NULL)
+ if ((out_file = fopen(path, "w")) == NULL)
{
fprintf(stderr, _("%s: could not open file \"%s\" for writing: %s\n"),
progname, path, strerror(errno));
if (strlen(lc_monetary) == 0 || !chklocale(lc_monetary))
lc_monetary = xstrdup(setlocale(LC_MONETARY, NULL));
if (strlen(lc_messages) == 0 || !chklocale(lc_messages))
-#ifdef LC_MESSAGES
+#if defined(LC_MESSAGES) && !defined(WIN32)
{
/* when available get the current locale setting */
lc_messages = xstrdup(setlocale(LC_MESSAGES, NULL));
if (authmethod == NULL || !strlen(authmethod))
{
authwarning = _("\nWARNING: enabling \"trust\" authentication for local connections\n"
- "You can change this by editing pg_hba.conf or using the -A flag the\n"
+ "You can change this by editing pg_hba.conf or using the -A option the\n"
"next time you run initdb.\n");
authmethod = "trust";
}
if ((ret = find_other_exec(argv[0], "postgres", PG_VERSIONSTR,
backend_exec)) < 0)
{
+ char full_path[MAXPGPATH];
+
+ if (find_my_exec(argv[0], full_path) < 0)
+ StrNCpy(full_path, progname, MAXPGPATH);
+
if (ret == -1)
fprintf(stderr,
_("The program \"postgres\" is needed by %s "
- "but was not found in the same directory as \"%s\".\n"
+ "but was not found in the\n"
+ "same directory as \"%s\".\n"
"Check your installation.\n"),
- progname, progname);
+ progname, full_path);
else
fprintf(stderr,
- _("The program \"postgres\" was found by %s "
- "but was not the same version as \"%s\".\n"
+ _("The program \"postgres\" was found by \"%s\"\n"
+ "but was not the same version as %s.\n"
"Check your installation.\n"),
- progname, progname);
+ full_path, progname);
exit(1);
}
if (chmod(pg_data, 0700) != 0)
{
- perror(pg_data);
+ fprintf(stderr, _("%s: could not change permissions of directory \"%s\": %s\n"),
+ progname, pg_data, strerror(errno));
exit_nicely();
}
else
default:
/* Trouble accessing directory */
- perror(pg_data);
+ fprintf(stderr, _("%s: could not access directory \"%s\": %s\n"),
+ progname, pg_data, strerror(errno));
exit_nicely();
}