]> granicus.if.org Git - postgresql/commitdiff
Use SYSTEMQUOTE as concatentation to strings, rather than %s printf
authorBruce Momjian <bruce@momjian.us>
Thu, 26 Jun 2008 01:35:45 +0000 (01:35 +0000)
committerBruce Momjian <bruce@momjian.us>
Thu, 26 Jun 2008 01:35:45 +0000 (01:35 +0000)
patterns, for clarity.

src/backend/postmaster/postmaster.c
src/bin/initdb/initdb.c
src/bin/pg_ctl/pg_ctl.c
src/bin/pg_dump/pg_dumpall.c
src/bin/psql/command.c

index 73d6dae56d8f7ea9674bc8235c01132e1aee05c3..8d94408a48b1503a33a8799f026f1c61454d3898 100644 (file)
@@ -37,7 +37,7 @@
  *
  *
  * 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
  *
@@ -4184,7 +4184,7 @@ CreateOptsFile(int argc, char *argv[], char *fullprogname)
 
        fprintf(fp, "%s", fullprogname);
        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);
 
        if (fclose(fp))
index 7e29f9ddd5d5d7fb4a9a021f17bc08c2f7ef3c11..cc2ea273ea559a100331ae4bb0c844cce08b2431 100644 (file)
@@ -42,7 +42,7 @@
  * Portions Copyright (c) 1994, Regents of the University of California
  * 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);
 
                snprintf(cmd, sizeof(cmd),
-                                "%s\"%s\" --boot -x0 %s "
+                                SYSTEMQUOTE "\"%s\" --boot -x0 %s "
                                 "-c max_connections=%d "
                                 "-c shared_buffers=%d "
                                 "-c max_fsm_pages=%d "
-                                "< \"%s\" > \"%s\" 2>&1%s",
-                                SYSTEMQUOTE, backend_exec, boot_options,
+                                "< \"%s\" > \"%s\" 2>&1" SYSTEMQUOTE,
+                                backend_exec, boot_options,
                                 test_conns, test_buffs, test_max_fsm,
-                                DEVNULL, DEVNULL, SYSTEMQUOTE);
+                                DEVNULL, DEVNULL);
                status = system(cmd);
                if (status == 0)
                {
@@ -1114,14 +1114,14 @@ test_config_settings(void)
                test_max_fsm = FSM_FOR_BUFS(test_buffs);
 
                snprintf(cmd, sizeof(cmd),
-                                "%s\"%s\" --boot -x0 %s "
+                                SYSTEMQUOTE "\"%s\" --boot -x0 %s "
                                 "-c max_connections=%d "
                                 "-c shared_buffers=%d "
                                 "-c max_fsm_pages=%d "
-                                "< \"%s\" > \"%s\" 2>&1%s",
-                                SYSTEMQUOTE, backend_exec, boot_options,
+                                "< \"%s\" > \"%s\" 2>&1" SYSTEMQUOTE,
+                                backend_exec, boot_options,
                                 n_connections, test_buffs, test_max_fsm,
-                                DEVNULL, DEVNULL, SYSTEMQUOTE);
+                                DEVNULL, DEVNULL);
                status = system(cmd);
                if (status == 0)
                        break;
index a4684cf74f04c15149c2e5083c07520be9facd79..84cb35125d5f84ddc71521ae1fd9d03de2ae0734 100644 (file)
@@ -4,7 +4,7 @@
  *
  * 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.
         */
        if (log_file != NULL)
-               snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1 &%s",
-                                SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
-                                DEVNULL, log_file, SYSTEMQUOTE);
+               snprintf(cmd, MAXPGPATH, SYSTEMQUOTE "\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1 &" SYSTEMQUOTE,
+                                postgres_path, pgdata_opt, post_opts,
+                                DEVNULL, log_file);
        else
-               snprintf(cmd, MAXPGPATH, "%s\"%s\" %s%s < \"%s\" 2>&1 &%s",
-                                SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
-                                DEVNULL, SYSTEMQUOTE);
+               snprintf(cmd, MAXPGPATH, SYSTEMQUOTE "\"%s\" %s%s < \"%s\" 2>&1 &" SYSTEMQUOTE,
+                                postgres_path, pgdata_opt, post_opts, DEVNULL);
 
        return system(cmd);
 #else                                                  /* WIN32 */
@@ -380,13 +379,11 @@ start_postmaster(void)
        PROCESS_INFORMATION pi;
 
        if (log_file != NULL)
-               snprintf(cmd, MAXPGPATH, "CMD /C %s\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1%s",
-                                SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
-                                DEVNULL, log_file, SYSTEMQUOTE);
+               snprintf(cmd, MAXPGPATH, "CMD /C " SYSTEMQUOTE "\"%s\" %s%s < \"%s\" >> \"%s\" 2>&1" SYSTEMQUOTE,
+                                postgres_path, pgdata_opt, post_opts, DEVNULL, log_file);
        else
-               snprintf(cmd, MAXPGPATH, "CMD /C %s\"%s\" %s%s < \"%s\" 2>&1%s",
-                                SYSTEMQUOTE, postgres_path, pgdata_opt, post_opts,
-                                DEVNULL, SYSTEMQUOTE);
+               snprintf(cmd, MAXPGPATH, "CMD /C " SYSTEMQUOTE "\"%s\" %s%s < \"%s\" 2>&1" SYSTEMQUOTE,
+                                postgres_path, pgdata_opt, post_opts, DEVNULL);
 
        if (!CreateRestrictedProcess(cmd, &pi))
                return GetLastError();
index 7d3affbc8ff94a3a2c4edca3d544d420c2fb19dc..2e0a83fcccfa05ef4143b7d0e39d67245d750d1a 100644 (file)
@@ -6,7 +6,7 @@
  * 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)
        {
 #ifndef WIN32
-               appendPQExpBuffer(cmd, "%s\"%s\" %s -Fa '", SYSTEMQUOTE, pg_dump_bin,
+               appendPQExpBuffer(cmd, SYSTEMQUOTE"\"%s\" %s -Fa '", pg_dump_bin,
 #else
-               appendPQExpBuffer(cmd, "%s\"%s\" %s -Fa \"", SYSTEMQUOTE, pg_dump_bin,
+               appendPQExpBuffer(cmd, SYSTEMQUOTE"\"%s\" %s -Fa \"", pg_dump_bin,
 #endif
                                                  pgdumpopts->data);
        }
        else
        {
 #ifndef WIN32
-               appendPQExpBuffer(cmd, "%s\"%s\" %s -Fp '", SYSTEMQUOTE, pg_dump_bin,
+               appendPQExpBuffer(cmd, SYSTEMQUOTE "\"%s\" %s -Fp '", pg_dump_bin,
 #else
-               appendPQExpBuffer(cmd, "%s\"%s\" %s -Fp \"", SYSTEMQUOTE, pg_dump_bin,
+               appendPQExpBuffer(cmd, SYSTEMQUOTE "\"%s\" %s -Fp \"", pg_dump_bin,
 #endif
                                                  pgdumpopts->data);
        }
index 1a1241bd5c7b9e81f89f5f4f447880d0c0837365..e6167d7ee00ef35456d4dfdc020b25e74570975a 100644 (file)
@@ -3,7 +3,7 @@
  *
  * 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 "command.h"
@@ -1288,8 +1288,7 @@ editFile(const char *fname)
 #ifndef WIN32
        sprintf(sys, "exec %s '%s'", editorName, fname);
 #else
-       sprintf(sys, "%s\"%s\" \"%s\"%s",
-                       SYSTEMQUOTE, editorName, fname, SYSTEMQUOTE);
+       sprintf(sys, SYSTEMQUOTE "\"%s\" \"%s\"" SYSTEMQUOTE, editorName, fname);
 #endif
        result = system(sys);
        if (result == -1)
@@ -1790,9 +1789,8 @@ do_shell(const char *command)
                /* See EDITOR handling comment for an explaination */
                                "exec %s", shellName);
 #else
-               sprintf(sys,
                /* See EDITOR handling comment for an explaination */
-                               "%s\"%s\"%s", SYSTEMQUOTE, shellName, SYSTEMQUOTE);
+               sprintf(sys, SYSTEMQUOTE "\"%s\"" SYSTEMQUOTE, shellName);
 #endif
                result = system(sys);
                free(sys);