Hi,

attached patches marks several char* variables as const where they are
initialized with constant strings.

Regards,
Stefan

Index: src/backend/regex/regc_locale.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/regex/regc_locale.c,v
retrieving revision 1.8
diff -u -u -r1.8 regc_locale.c
--- src/backend/regex/regc_locale.c	22 Nov 2005 18:17:19 -0000	1.8
+++ src/backend/regex/regc_locale.c	14 Mar 2007 16:17:12 -0000
@@ -54,7 +54,7 @@
 
 static struct cname
 {
-	char	   *name;
+	const char	*name;
 	char		code;
 }	cnames[] =
 
@@ -604,7 +604,7 @@
 {
 	size_t		len;
 	struct cvec *cv = NULL;
-	char	  **namePtr;
+	const char **namePtr;
 	int			i,
 				index;
 
@@ -612,7 +612,7 @@
 	 * The following arrays define the valid character class names.
 	 */
 
-	static char *classNames[] = {
+	static const char *classNames[] = {
 		"alnum", "alpha", "ascii", "blank", "cntrl", "digit", "graph",
 		"lower", "print", "punct", "space", "upper", "xdigit", NULL
 	};
Index: src/backend/regex/regerror.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/regex/regerror.c,v
retrieving revision 1.27
diff -u -u -r1.27 regerror.c
--- src/backend/regex/regerror.c	29 Nov 2003 19:51:55 -0000	1.27
+++ src/backend/regex/regerror.c	14 Mar 2007 16:17:12 -0000
@@ -40,8 +40,8 @@
 static struct rerr
 {
 	int			code;
-	char	   *name;
-	char	   *explain;
+	const char	   *name;
+	const char	   *explain;
 }	rerrs[] =
 
 {
@@ -63,7 +63,7 @@
 			size_t errbuf_size) /* available space in errbuf, can be 0 */
 {
 	struct rerr *r;
-	char	   *msg;
+	const char   *msg;
 	char		convbuf[sizeof(unk) + 50];		/* 50 = plenty for int */
 	size_t		len;
 	int			icode;
Index: src/backend/utils/adt/ruleutils.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v
retrieving revision 1.252
diff -u -u -r1.252 ruleutils.c
--- src/backend/utils/adt/ruleutils.c	27 Feb 2007 23:48:08 -0000	1.252
+++ src/backend/utils/adt/ruleutils.c	14 Mar 2007 16:17:14 -0000
@@ -106,9 +106,9 @@
  * ----------
  */
 static void *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 void *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";
 
 
 /* ----------
Index: src/bin/initdb/initdb.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/initdb/initdb.c,v
retrieving revision 1.134
diff -u -u -r1.134 initdb.c
--- src/bin/initdb/initdb.c	20 Feb 2007 23:49:38 -0000	1.134
+++ src/bin/initdb/initdb.c	14 Mar 2007 16:17:14 -0000
@@ -727,7 +727,7 @@
 struct encoding_match
 {
 	enum pg_enc pg_enc_code;
-	char	   *system_enc_name;
+	const char *system_enc_name;
 };
 
 struct encoding_match encoding_match_list[] = {
@@ -1481,8 +1481,8 @@
 setup_auth(void)
 {
 	PG_CMD_DECL;
-	char	  **line;
-	static char *pg_authid_setup[] = {
+	const char **line;
+	static const char *pg_authid_setup[] = {
 		/*
 		 * Create triggers to ensure manual updates to shared catalogs will be
 		 * reflected into their "flat file" copies.
@@ -1623,8 +1623,8 @@
 setup_depend(void)
 {
 	PG_CMD_DECL;
-	char	  **line;
-	static char *pg_depend_setup[] = {
+	const char	  **line;
+	static const char *pg_depend_setup[] = {
 		/*
 		 * Make PIN entries in pg_depend for all objects made so far in the
 		 * tables that the dependency code handles.  This is overkill (the
@@ -1990,8 +1990,8 @@
 make_template0(void)
 {
 	PG_CMD_DECL;
-	char	  **line;
-	static char *template0_setup[] = {
+	const char **line;
+	static const char *template0_setup[] = {
 		"CREATE DATABASE template0;\n",
 		"UPDATE pg_database SET "
 		"	datistemplate = 't', "
@@ -2045,8 +2045,8 @@
 make_postgres(void)
 {
 	PG_CMD_DECL;
-	char	  **line;
-	static char *postgres_setup[] = {
+	const char **line;
+	static const char *postgres_setup[] = {
 		"CREATE DATABASE postgres;\n",
 		NULL
 	};
Index: src/bin/pg_controldata/pg_controldata.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_controldata/pg_controldata.c,v
retrieving revision 1.33
diff -u -u -r1.33 pg_controldata.c
--- src/bin/pg_controldata/pg_controldata.c	3 Mar 2007 20:02:27 -0000	1.33
+++ src/bin/pg_controldata/pg_controldata.c	14 Mar 2007 16:17:14 -0000
@@ -72,7 +72,7 @@
 	char		pgctime_str[128];
 	char		ckpttime_str[128];
 	char		sysident_str[32];
-	char	   *strftime_fmt = "%c";
+	const char *strftime_fmt = "%c";
 	const char *progname;
 
 	set_pglocale_pgservice(argv[0], "pg_controldata");
Index: src/bin/pg_ctl/pg_ctl.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_ctl/pg_ctl.c,v
retrieving revision 1.78
diff -u -u -r1.78 pg_ctl.c
--- src/bin/pg_ctl/pg_ctl.c	10 Feb 2007 14:58:55 -0000	1.78
+++ src/bin/pg_ctl/pg_ctl.c	14 Mar 2007 16:17:14 -0000
@@ -91,7 +91,7 @@
 static const char *progname;
 static char *log_file = 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_password = NULL;
 static char *argv0 = NULL;
Index: src/bin/pg_dump/pg_backup_archiver.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_backup_archiver.c,v
retrieving revision 1.142
diff -u -u -r1.142 pg_backup_archiver.c
--- src/bin/pg_dump/pg_backup_archiver.c	19 Feb 2007 15:05:06 -0000	1.142
+++ src/bin/pg_dump/pg_backup_archiver.c	14 Mar 2007 16:17:15 -0000
@@ -37,7 +37,7 @@
 
 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,
Index: src/bin/pg_dump/pg_backup_custom.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_backup_custom.c,v
retrieving revision 1.37
diff -u -u -r1.37 pg_backup_custom.c
--- src/bin/pg_dump/pg_backup_custom.c	19 Feb 2007 15:05:06 -0000	1.37
+++ src/bin/pg_dump/pg_backup_custom.c	14 Mar 2007 16:17:15 -0000
@@ -91,7 +91,7 @@
 static pgoff_t _getFilePos(ArchiveHandle *AH, lclContext *ctx);
 static int	_DoDeflate(ArchiveHandle *AH, lclContext *ctx, int flush);
 
-static char *modulename = gettext_noop("custom archiver");
+static const char *modulename = gettext_noop("custom archiver");
 
 
 
Index: src/bin/pg_dump/pg_backup_files.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_backup_files.c,v
retrieving revision 1.31
diff -u -u -r1.31 pg_backup_files.c
--- src/bin/pg_dump/pg_backup_files.c	19 Feb 2007 15:05:06 -0000	1.31
+++ src/bin/pg_dump/pg_backup_files.c	14 Mar 2007 16:17:15 -0000
@@ -65,7 +65,7 @@
 	char	   *filename;
 } 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 _getBlobTocEntry(ArchiveHandle *AH, Oid *oid, char *fname);
 
Index: src/bin/pg_dump/pg_backup_tar.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_backup_tar.c,v
retrieving revision 1.57
diff -u -u -r1.57 pg_backup_tar.c
--- src/bin/pg_dump/pg_backup_tar.c	19 Feb 2007 15:05:06 -0000	1.57
+++ src/bin/pg_dump/pg_backup_tar.c	14 Mar 2007 16:17:20 -0000
@@ -102,7 +102,7 @@
 	char	   *filename;
 } lclTocEntry;
 
-static char *modulename = gettext_noop("tar archiver");
+static const char *modulename = gettext_noop("tar archiver");
 
 static void _LoadBlobs(ArchiveHandle *AH, RestoreOptions *ropt);
 
Index: src/bin/pg_dump/pg_dump_sort.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/pg_dump/pg_dump_sort.c,v
retrieving revision 1.17
diff -u -u -r1.17 pg_dump_sort.c
--- src/bin/pg_dump/pg_dump_sort.c	23 Jan 2007 17:54:50 -0000	1.17
+++ src/bin/pg_dump/pg_dump_sort.c	14 Mar 2007 16:17:20 -0000
@@ -16,7 +16,7 @@
 #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.
Index: src/bin/psql/describe.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/psql/describe.c,v
retrieving revision 1.152
diff -u -u -r1.152 describe.c
--- src/bin/psql/describe.c	20 Feb 2007 10:23:38 -0000	1.152
+++ src/bin/psql/describe.c	14 Mar 2007 16:17:21 -0000
@@ -1359,7 +1359,7 @@
 		/* print inherits */
 		for (i = 0; i < inherits_count; i++)
 		{
-			char	   *s = _("Inherits");
+			const char   *s = _("Inherits");
 
 			if (i == 0)
 				printfPQExpBuffer(&buf, "%s: %s", s, PQgetvalue(result6, i, 0));
@@ -1373,7 +1373,7 @@
 
 		if (verbose)
 		{
-			char	   *s = _("Has OIDs");
+			const char   *s = _("Has OIDs");
 
 			printfPQExpBuffer(&buf, "%s: %s", s,
 							  (tableinfo.hasoids ? _("yes") : _("no")));
Index: src/interfaces/ecpg/ecpglib/connect.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/interfaces/ecpg/ecpglib/connect.c,v
retrieving revision 1.39
diff -u -u -r1.39 connect.c
--- src/interfaces/ecpg/ecpglib/connect.c	12 Jan 2007 10:00:12 -0000	1.39
+++ src/interfaces/ecpg/ecpglib/connect.c	14 Mar 2007 16:17:21 -0000
@@ -473,7 +473,7 @@
 	if (PQstatus(this->connection) == CONNECTION_BAD)
 	{
 		const char *errmsg = PQerrorMessage(this->connection);
-		char	   *db = realname ? realname : "<DEFAULT>";
+		const char *db = realname ? realname : "<DEFAULT>";
 
 		ECPGlog("connect: could not open database %s on %s port %s %s%s%s%s in line %d\n\t%s\n",
 				db,
Index: src/interfaces/ecpg/pgtypeslib/timestamp.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/interfaces/ecpg/pgtypeslib/timestamp.c,v
retrieving revision 1.37
diff -u -u -r1.37 timestamp.c
--- src/interfaces/ecpg/pgtypeslib/timestamp.c	4 Oct 2006 00:30:12 -0000	1.37
+++ src/interfaces/ecpg/pgtypeslib/timestamp.c	14 Mar 2007 16:17:21 -0000
@@ -542,7 +542,7 @@
 					 */
 				case 'g':
 					{
-						char	   *fmt = "%g"; /* Keep compiler quiet about
+						const char *fmt = "%g"; /* Keep compiler quiet about
 												 * 2-digit year */
 
 						tm->tm_mon -= 1;
@@ -744,7 +744,7 @@
 					 */
 				case 'x':
 					{
-						char	   *fmt = "%x"; /* Keep compiler quiet about
+						const char *fmt = "%x"; /* Keep compiler quiet about
 												 * 2-digit year */
 
 						tm->tm_mon -= 1;
---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

               http://www.postgresql.org/docs/faq

Reply via email to