Use SYSTEMQUOTE as concatentation to strings, rather than %s printf

patterns, for clarity.
This commit is contained in:
Bruce Momjian 2008-06-26 01:35:45 +00:00
parent 124c22d5fd
commit a1183238be
5 changed files with 29 additions and 34 deletions

View File

@ -37,7 +37,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.559 2008/06/19 21:32:56 tgl Exp $ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.560 2008/06/26 01:35:45 momjian Exp $
* *
* NOTES * NOTES
* *
@ -4184,7 +4184,7 @@ CreateOptsFile(int argc, char *argv[], char *fullprogname)
fprintf(fp, "%s", fullprogname); fprintf(fp, "%s", fullprogname);
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
fprintf(fp, " %s%s%s", SYSTEMQUOTE, argv[i], SYSTEMQUOTE); fprintf(fp, " " SYSTEMQUOTE "%s" SYSTEMQUOTE, argv[i]);
fputs("\n", fp); fputs("\n", fp);
if (fclose(fp)) if (fclose(fp))

View File

@ -42,7 +42,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD. * Portions taken from FreeBSD.
* *
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.156 2008/06/02 03:48:00 tgl Exp $ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.157 2008/06/26 01:35:45 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1078,14 +1078,14 @@ test_config_settings(void)
test_max_fsm = FSM_FOR_BUFS(test_buffs); test_max_fsm = FSM_FOR_BUFS(test_buffs);
snprintf(cmd, sizeof(cmd), snprintf(cmd, sizeof(cmd),
"%s\"%s\" --boot -x0 %s " SYSTEMQUOTE "\"%s\" --boot -x0 %s "
"-c max_connections=%d " "-c max_connections=%d "
"-c shared_buffers=%d " "-c shared_buffers=%d "
"-c max_fsm_pages=%d " "-c max_fsm_pages=%d "
"< \"%s\" > \"%s\" 2>&1%s", "< \"%s\" > \"%s\" 2>&1" SYSTEMQUOTE,
SYSTEMQUOTE, backend_exec, boot_options, backend_exec, boot_options,
test_conns, test_buffs, test_max_fsm, test_conns, test_buffs, test_max_fsm,
DEVNULL, DEVNULL, SYSTEMQUOTE); DEVNULL, DEVNULL);
status = system(cmd); status = system(cmd);
if (status == 0) if (status == 0)
{ {
@ -1114,14 +1114,14 @@ test_config_settings(void)
test_max_fsm = FSM_FOR_BUFS(test_buffs); test_max_fsm = FSM_FOR_BUFS(test_buffs);
snprintf(cmd, sizeof(cmd), snprintf(cmd, sizeof(cmd),
"%s\"%s\" --boot -x0 %s " SYSTEMQUOTE "\"%s\" --boot -x0 %s "
"-c max_connections=%d " "-c max_connections=%d "
"-c shared_buffers=%d " "-c shared_buffers=%d "
"-c max_fsm_pages=%d " "-c max_fsm_pages=%d "
"< \"%s\" > \"%s\" 2>&1%s", "< \"%s\" > \"%s\" 2>&1" SYSTEMQUOTE,
SYSTEMQUOTE, backend_exec, boot_options, backend_exec, boot_options,
n_connections, test_buffs, test_max_fsm, n_connections, test_buffs, test_max_fsm,
DEVNULL, DEVNULL, SYSTEMQUOTE); DEVNULL, DEVNULL);
status = system(cmd); status = system(cmd);
if (status == 0) if (status == 0)
break; break;

View File

@ -4,7 +4,7 @@
* *
* Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.99 2008/06/26 01:12:20 momjian Exp $ * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.100 2008/06/26 01:35:45 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -361,13 +361,12 @@ start_postmaster(void)
* everything to a shell to process them. * everything to a shell to process them.
*/ */
if (log_file != NULL) if (log_file != NULL)
snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1 &%s", snprintf(cmd, MAXPGPATH, SYSTEMQUOTE "\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1 &" SYSTEMQUOTE,
SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts, postgres_path, pgdata_opt, post_opts,
DEVNULL, log_file, SYSTEMQUOTE); DEVNULL, log_file);
else else
snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" 2>&1 &%s", snprintf(cmd, MAXPGPATH, SYSTEMQUOTE "\"%s\" %s%s < \"%s\" 2>&1 &" SYSTEMQUOTE,
SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts, postgres_path, pgdata_opt, post_opts, DEVNULL);
DEVNULL, SYSTEMQUOTE);
return system(cmd); return system(cmd);
#else /* WIN32 */ #else /* WIN32 */
@ -380,13 +379,11 @@ start_postmaster(void)
PROCESS_INFORMATION pi; PROCESS_INFORMATION pi;
if (log_file != NULL) if (log_file != NULL)
snprintf(cmd, MAXPGPATH, "CMD /C %s\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1%s", snprintf(cmd, MAXPGPATH, "CMD /C " SYSTEMQUOTE "\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1" SYSTEMQUOTE,
SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts, postgres_path, pgdata_opt, post_opts, DEVNULL, log_file);
DEVNULL, log_file, SYSTEMQUOTE);
else else
snprintf(cmd, MAXPGPATH, "CMD /C %s\"%s\" %s%s < \"%s\" 2>&1%s", snprintf(cmd, MAXPGPATH, "CMD /C " SYSTEMQUOTE "\"%s\" %s%s < \"%s\" 2>&1" SYSTEMQUOTE,
SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts, postgres_path, pgdata_opt, post_opts, DEVNULL);
DEVNULL, SYSTEMQUOTE);
if (!CreateRestrictedProcess(cmd, &pi)) if (!CreateRestrictedProcess(cmd, &pi))
return GetLastError(); return GetLastError();

View File

@ -6,7 +6,7 @@
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* *
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.104 2008/04/13 03:49:22 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dumpall.c,v 1.105 2008/06/26 01:35:45 momjian Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -1248,18 +1248,18 @@ runPgDump(const char *dbname)
if (filename) if (filename)
{ {
#ifndef WIN32 #ifndef WIN32
appendPQExpBuffer(cmd, "%s\"%s\" %s -Fa '", SYSTEMQUOTE, pg_dump_bin, appendPQExpBuffer(cmd, SYSTEMQUOTE"\"%s\" %s -Fa '", pg_dump_bin,
#else #else
appendPQExpBuffer(cmd, "%s\"%s\" %s -Fa \"", SYSTEMQUOTE, pg_dump_bin, appendPQExpBuffer(cmd, SYSTEMQUOTE"\"%s\" %s -Fa \"", pg_dump_bin,
#endif #endif
pgdumpopts->data); pgdumpopts->data);
} }
else else
{ {
#ifndef WIN32 #ifndef WIN32
appendPQExpBuffer(cmd, "%s\"%s\" %s -Fp '", SYSTEMQUOTE, pg_dump_bin, appendPQExpBuffer(cmd, SYSTEMQUOTE "\"%s\" %s -Fp '", pg_dump_bin,
#else #else
appendPQExpBuffer(cmd, "%s\"%s\" %s -Fp \"", SYSTEMQUOTE, pg_dump_bin, appendPQExpBuffer(cmd, SYSTEMQUOTE "\"%s\" %s -Fp \"", pg_dump_bin,
#endif #endif
pgdumpopts->data); pgdumpopts->data);
} }

View File

@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2008, PostgreSQL Global Development Group * Copyright (c) 2000-2008, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.190 2008/06/11 10:48:17 heikki Exp $ * $PostgreSQL: pgsql/src/bin/psql/command.c,v 1.191 2008/06/26 01:35:45 momjian Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "command.h" #include "command.h"
@ -1288,8 +1288,7 @@ editFile(const char *fname)
#ifndef WIN32 #ifndef WIN32
sprintf(sys, "exec %s '%s'", editorName, fname); sprintf(sys, "exec %s '%s'", editorName, fname);
#else #else
sprintf(sys, "%s\"%s\" \"%s\"%s", sprintf(sys, SYSTEMQUOTE "\"%s\" \"%s\"" SYSTEMQUOTE, editorName, fname);
SYSTEMQUOTE, editorName, fname, SYSTEMQUOTE);
#endif #endif
result = system(sys); result = system(sys);
if (result == -1) if (result == -1)
@ -1790,9 +1789,8 @@ do_shell(const char *command)
/* See EDITOR handling comment for an explaination */ /* See EDITOR handling comment for an explaination */
"exec %s", shellName); "exec %s", shellName);
#else #else
sprintf(sys,
/* See EDITOR handling comment for an explaination */ /* See EDITOR handling comment for an explaination */
"%s\"%s\"%s", SYSTEMQUOTE, shellName, SYSTEMQUOTE); sprintf(sys, SYSTEMQUOTE "\"%s\"" SYSTEMQUOTE, shellName);
#endif #endif
result = system(sys); result = system(sys);
free(sys); free(sys);