提交 7221b4fa 编写于 作者: N Neil Conway

Code cleanup: mark some variables with the "const" modifier, when they

are initialized with a string literal. Patch from Stefan Huehner.
上级 b9954fbb
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.255 2007/03/17 01:15:55 tgl Exp $ * $PostgreSQL: pgsql/src/backend/utils/adt/ruleutils.c,v 1.256 2007/03/18 16:50:42 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -106,9 +106,9 @@ typedef struct ...@@ -106,9 +106,9 @@ typedef struct
* ---------- * ----------
*/ */
static SPIPlanPtr plan_getrulebyoid = NULL; static SPIPlanPtr plan_getrulebyoid = NULL;
static char *query_getrulebyoid = "SELECT * FROM pg_catalog.pg_rewrite WHERE oid = $1"; static const char *query_getrulebyoid = "SELECT * FROM pg_catalog.pg_rewrite WHERE oid = $1";
static SPIPlanPtr plan_getviewrule = NULL; static SPIPlanPtr plan_getviewrule = NULL;
static char *query_getviewrule = "SELECT * FROM pg_catalog.pg_rewrite WHERE ev_class = $1 AND rulename = $2"; static const char *query_getviewrule = "SELECT * FROM pg_catalog.pg_rewrite WHERE ev_class = $1 AND rulename = $2";
/* ---------- /* ----------
......
...@@ -42,7 +42,7 @@ ...@@ -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.134 2007/02/20 23:49:38 momjian Exp $ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.135 2007/03/18 16:50:43 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -727,7 +727,7 @@ get_encoding_id(char *encoding_name) ...@@ -727,7 +727,7 @@ get_encoding_id(char *encoding_name)
struct encoding_match struct encoding_match
{ {
enum pg_enc pg_enc_code; enum pg_enc pg_enc_code;
char *system_enc_name; const char *system_enc_name;
}; };
struct encoding_match encoding_match_list[] = { struct encoding_match encoding_match_list[] = {
...@@ -1481,8 +1481,8 @@ static void ...@@ -1481,8 +1481,8 @@ static void
setup_auth(void) setup_auth(void)
{ {
PG_CMD_DECL; PG_CMD_DECL;
char **line; const char **line;
static char *pg_authid_setup[] = { static const char *pg_authid_setup[] = {
/* /*
* Create triggers to ensure manual updates to shared catalogs will be * Create triggers to ensure manual updates to shared catalogs will be
* reflected into their "flat file" copies. * reflected into their "flat file" copies.
...@@ -1623,8 +1623,8 @@ static void ...@@ -1623,8 +1623,8 @@ static void
setup_depend(void) setup_depend(void)
{ {
PG_CMD_DECL; PG_CMD_DECL;
char **line; const char **line;
static char *pg_depend_setup[] = { static const char *pg_depend_setup[] = {
/* /*
* Make PIN entries in pg_depend for all objects made so far in the * Make PIN entries in pg_depend for all objects made so far in the
* tables that the dependency code handles. This is overkill (the * tables that the dependency code handles. This is overkill (the
...@@ -1990,8 +1990,8 @@ static void ...@@ -1990,8 +1990,8 @@ static void
make_template0(void) make_template0(void)
{ {
PG_CMD_DECL; PG_CMD_DECL;
char **line; const char **line;
static char *template0_setup[] = { static const char *template0_setup[] = {
"CREATE DATABASE template0;\n", "CREATE DATABASE template0;\n",
"UPDATE pg_database SET " "UPDATE pg_database SET "
" datistemplate = 't', " " datistemplate = 't', "
...@@ -2045,8 +2045,8 @@ static void ...@@ -2045,8 +2045,8 @@ static void
make_postgres(void) make_postgres(void)
{ {
PG_CMD_DECL; PG_CMD_DECL;
char **line; const char **line;
static char *postgres_setup[] = { static const char *postgres_setup[] = {
"CREATE DATABASE postgres;\n", "CREATE DATABASE postgres;\n",
NULL NULL
}; };
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001; * copyright (c) Oliver Elphick <olly@lfix.co.uk>, 2001;
* licence: BSD * licence: BSD
* *
* $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.33 2007/03/03 20:02:27 momjian Exp $ * $PostgreSQL: pgsql/src/bin/pg_controldata/pg_controldata.c,v 1.34 2007/03/18 16:50:43 neilc Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -72,7 +72,7 @@ main(int argc, char *argv[]) ...@@ -72,7 +72,7 @@ main(int argc, char *argv[])
char pgctime_str[128]; char pgctime_str[128];
char ckpttime_str[128]; char ckpttime_str[128];
char sysident_str[32]; char sysident_str[32];
char *strftime_fmt = "%c"; const char *strftime_fmt = "%c";
const char *progname; const char *progname;
set_pglocale_pgservice(argv[0], "pg_controldata"); set_pglocale_pgservice(argv[0], "pg_controldata");
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
* *
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.78 2007/02/10 14:58:55 petere Exp $ * $PostgreSQL: pgsql/src/bin/pg_ctl/pg_ctl.c,v 1.79 2007/03/18 16:50:44 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -91,7 +91,7 @@ static char *post_opts = NULL; ...@@ -91,7 +91,7 @@ static char *post_opts = NULL;
static const char *progname; static const char *progname;
static char *log_file = NULL; static char *log_file = NULL;
static char *postgres_path = NULL; static char *postgres_path = NULL;
static char *register_servicename = "PostgreSQL"; /* FIXME: + version ID? */ static const char *register_servicename = "PostgreSQL"; /* FIXME: + version ID? */
static char *register_username = NULL; static char *register_username = NULL;
static char *register_password = NULL; static char *register_password = NULL;
static char *argv0 = NULL; static char *argv0 = NULL;
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.142 2007/02/19 15:05:06 mha Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_archiver.c,v 1.143 2007/03/18 16:50:44 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
const char *progname; const char *progname;
static char *modulename = gettext_noop("archiver"); static const char *modulename = gettext_noop("archiver");
static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt, static ArchiveHandle *_allocAH(const char *FileSpec, const ArchiveFormat fmt,
......
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.37 2007/02/19 15:05:06 mha Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_custom.c,v 1.38 2007/03/18 16:50:44 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -91,7 +91,7 @@ static void _EndDataCompressor(ArchiveHandle *AH, TocEntry *te); ...@@ -91,7 +91,7 @@ static void _EndDataCompressor(ArchiveHandle *AH, TocEntry *te);
static pgoff_t _getFilePos(ArchiveHandle *AH, lclContext *ctx); static pgoff_t _getFilePos(ArchiveHandle *AH, lclContext *ctx);
static int _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush); static int _DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush);
static char *modulename = gettext_noop("custom archiver"); static const char *modulename = gettext_noop("custom archiver");
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.31 2007/02/19 15:05:06 mha Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_files.c,v 1.32 2007/03/18 16:50:44 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -65,7 +65,7 @@ typedef struct ...@@ -65,7 +65,7 @@ typedef struct
char *filename; char *filename;
} lclTocEntry; } lclTocEntry;
static char *modulename = gettext_noop("file archiver"); static const char *modulename = gettext_noop("file archiver");
static void _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt); static void _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt);
static void _getBlobTocEntry(ArchiveHandle *AH, Oid *oid, char *fname); static void _getBlobTocEntry(ArchiveHandle *AH, Oid *oid, char *fname);
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.57 2007/02/19 15:05:06 mha Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_backup_tar.c,v 1.58 2007/03/18 16:50:44 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -102,7 +102,7 @@ typedef struct ...@@ -102,7 +102,7 @@ typedef struct
char *filename; char *filename;
} lclTocEntry; } lclTocEntry;
static char *modulename = gettext_noop("tar archiver"); static const char *modulename = gettext_noop("tar archiver");
static void _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt); static void _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt);
......
...@@ -9,14 +9,14 @@ ...@@ -9,14 +9,14 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump_sort.c,v 1.17 2007/01/23 17:54:50 tgl Exp $ * $PostgreSQL: pgsql/src/bin/pg_dump/pg_dump_sort.c,v 1.18 2007/03/18 16:50:44 neilc Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
#include "pg_backup_archiver.h" #include "pg_backup_archiver.h"
static char *modulename = gettext_noop("sorter"); static const char *modulename = gettext_noop("sorter");
/* /*
* Sort priority for object types when dumping a pre-7.3 database. * Sort priority for object types when dumping a pre-7.3 database.
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* Copyright (c) 2000-2007, PostgreSQL Global Development Group * Copyright (c) 2000-2007, PostgreSQL Global Development Group
* *
* $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.153 2007/03/16 08:28:01 mha Exp $ * $PostgreSQL: pgsql/src/bin/psql/describe.c,v 1.154 2007/03/18 16:50:44 neilc Exp $
*/ */
#include "postgres_fe.h" #include "postgres_fe.h"
#include "describe.h" #include "describe.h"
...@@ -1360,7 +1360,7 @@ describeOneTableDetails(const char *schemaname, ...@@ -1360,7 +1360,7 @@ describeOneTableDetails(const char *schemaname,
/* print inherits */ /* print inherits */
for (i = 0; i < inherits_count; i++) for (i = 0; i < inherits_count; i++)
{ {
char *s = _("Inherits"); const char *s = _("Inherits");
if (i == 0) if (i == 0)
printfPQExpBuffer(&buf, "%s: %s", s, PQgetvalue(result6, i, 0)); printfPQExpBuffer(&buf, "%s: %s", s, PQgetvalue(result6, i, 0));
...@@ -1374,7 +1374,7 @@ describeOneTableDetails(const char *schemaname, ...@@ -1374,7 +1374,7 @@ describeOneTableDetails(const char *schemaname,
if (verbose) if (verbose)
{ {
char *s = _("Has OIDs"); const char *s = _("Has OIDs");
printfPQExpBuffer(&buf, "%s: %s", s, printfPQExpBuffer(&buf, "%s: %s", s,
(tableinfo.hasoids ? _("yes") : _("no"))); (tableinfo.hasoids ? _("yes") : _("no")));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册