Index: src/bin/pg_ctl/pg_ctl.c =================================================================== RCS file: /cvsroot/pgsql/src/bin/pg_ctl/pg_ctl.c,v retrieving revision 1.44 diff -c -c -r1.44 pg_ctl.c *** src/bin/pg_ctl/pg_ctl.c 27 Oct 2004 19:44:14 -0000 1.44 --- src/bin/pg_ctl/pg_ctl.c 4 Nov 2004 22:18:05 -0000 *************** *** 335,341 **** * http://dev.remotenetworktechnology.com/cmd/cmdfaq.htm */ if (log_file != NULL) ! #if !defined(WIN32) /* Cygwin doesn't have START */ snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1 &%s", #else snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s%s < \"%s\" >> \"%s\" 2>&1%s", --- 335,341 ---- * http://dev.remotenetworktechnology.com/cmd/cmdfaq.htm */ if (log_file != NULL) ! #ifndef WIN32 /* Cygwin doesn't have START */ snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1 &%s", #else snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s%s < \"%s\" >> \"%s\" 2>&1%s", *************** *** 343,349 **** SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts, DEVNULL, log_file, SYSTEMQUOTE); else ! #if !defined(WIN32) /* Cygwin doesn't have START */ snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" 2>&1 &%s", #else snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s%s < \"%s\" 2>&1%s", --- 343,349 ---- SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts, DEVNULL, log_file, SYSTEMQUOTE); else ! #ifndef WIN32 /* Cygwin doesn't have START */ snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" 2>&1 &%s", #else snprintf(cmd, MAXPGPATH, "%sSTART /B \"\" \"%s\" %s%s < \"%s\" 2>&1%s", Index: src/bin/psql/command.c =================================================================== RCS file: /cvsroot/pgsql/src/bin/psql/command.c,v retrieving revision 1.129 diff -c -c -r1.129 command.c *** src/bin/psql/command.c 16 Oct 2004 03:10:16 -0000 1.129 --- src/bin/psql/command.c 4 Nov 2004 22:18:08 -0000 *************** *** 23,28 **** --- 23,32 ---- #include #include #include + #ifndef WIN32_CLIENT_ONLY + #include /* for umask() */ + #include /* for stat() */ + #endif #endif #include "libpq-fe.h" *************** *** 1097,1103 **** #ifndef WIN32 "exec " #endif ! "%s '%s'", editorName, fname); result = system(sys); if (result == -1) psql_error("could not start editor \"%s\"\n", editorName); --- 1101,1107 ---- #ifndef WIN32 "exec " #endif ! "%s\"%s\" \"%s\"%s", SYSTEMQUOTE, editorName, fname, SYSTEMQUOTE); result = system(sys); if (result == -1) psql_error("could not start editor \"%s\"\n", editorName); *************** *** 1119,1125 **** bool error = false; int fd; ! #ifndef WIN32 struct stat before, after; #endif --- 1123,1129 ---- bool error = false; int fd; ! #ifndef WIN32_CLIENT_ONLY struct stat before, after; #endif *************** *** 1130,1142 **** { /* make a temp file to edit */ #ifndef WIN32 ! const char *tmpdirenv = getenv("TMPDIR"); ! snprintf(fnametmp, sizeof(fnametmp), "%s/psql.edit.%d.%d", ! tmpdirenv ? tmpdirenv : "/tmp", geteuid(), (int)getpid()); #else ! GetTempFileName(".", "psql", 0, fnametmp); #endif fname = (const char *) fnametmp; fd = open(fname, O_WRONLY | O_CREAT | O_EXCL, 0600); --- 1134,1168 ---- { /* make a temp file to edit */ #ifndef WIN32 ! const char *tmpdir = getenv("TMPDIR"); ! ! if (!tmpdir) ! tmpdir = "/tmp"; ! #else ! char tmpdir[MAXPGPATH]; ! int ret; ! ret = GetTempPath(MAXPGPATH, tmpdir); ! if (ret == 0 || ret > MAXPGPATH) ! { ! psql_error("Can not locate temporary directory: %s", ! !ret ? strerror(errno) : ""); ! return false; ! } ! /* ! * No canonicalize_path() here. ! * EDIT.EXE run from CMD.EXE prepends the current directory to the ! * supplied path unless we use only backslashes, so we do that. ! */ ! #endif ! snprintf(fnametmp, sizeof(fnametmp), "%s%spsql.edit.%d", tmpdir, ! #ifndef WIN32 ! "/", #else ! "", /* trailing separator already present */ #endif + (int)getpid()); + fname = (const char *) fnametmp; fd = open(fname, O_WRONLY | O_CREAT | O_EXCL, 0600); *************** *** 1174,1180 **** } } ! #ifndef WIN32 if (!error && stat(fname, &before) != 0) { psql_error("%s: %s\n", fname, strerror(errno)); --- 1200,1206 ---- } } ! #ifndef WIN32_CLIENT_ONLY if (!error && stat(fname, &before) != 0) { psql_error("%s: %s\n", fname, strerror(errno)); *************** *** 1186,1192 **** if (!error) error = !editFile(fname); ! #ifndef WIN32 if (!error && stat(fname, &after) != 0) { psql_error("%s: %s\n", fname, strerror(errno)); --- 1212,1218 ---- if (!error) error = !editFile(fname); ! #ifndef WIN32_CLIENT_ONLY if (!error && stat(fname, &after) != 0) { psql_error("%s: %s\n", fname, strerror(errno)); *************** *** 1509,1517 **** if (!command) { char *sys; ! const char *shellName; ! shellName = getenv("SHELL"); if (shellName == NULL) shellName = DEFAULT_SHELL; --- 1535,1547 ---- if (!command) { char *sys; ! const char *shellName = NULL; ! #ifdef WIN32 ! shellName = getenv("COMSPEC"); ! #endif ! if (shellName == NULL) ! shellName = getenv("SHELL"); if (shellName == NULL) shellName = DEFAULT_SHELL; *************** *** 1520,1526 **** #ifndef WIN32 "exec " #endif ! "%s", shellName); result = system(sys); free(sys); } --- 1550,1556 ---- #ifndef WIN32 "exec " #endif ! "%s\"%s\"%s", SYSTEMQUOTE, shellName, SYSTEMQUOTE); result = system(sys); free(sys); }