39
39
* Portions Copyright (c) 1994, Regents of the University of California
40
40
* Portions taken from FreeBSD.
41
41
*
42
- * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.70 2004/11/29 03:05:03 tgl Exp $
42
+ * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.71 2004/12/27 20:39:21 tgl Exp $
43
43
*
44
44
*-------------------------------------------------------------------------
45
45
*/
@@ -147,9 +147,10 @@ char backend_exec[MAXPGPATH];
147
147
148
148
static void * xmalloc (size_t size );
149
149
static char * xstrdup (const char * s );
150
- static char * * replace_token (char * * lines , char * token , char * replacement );
150
+ static char * * replace_token (char * * lines ,
151
+ const char * token , const char * replacement );
151
152
#ifndef HAVE_UNIX_SOCKETS
152
- static char * * filter_lines_with_token (char * * lines , char * token );
153
+ static char * * filter_lines_with_token (char * * lines , const char * token );
153
154
#endif
154
155
static char * * readfile (char * path );
155
156
static void writefile (char * path , char * * lines );
@@ -275,7 +276,7 @@ xstrdup(const char *s)
275
276
* doesn't need any regexp stuff.
276
277
*/
277
278
static char * *
278
- replace_token (char * * lines , char * token , char * replacement )
279
+ replace_token (char * * lines , const char * token , const char * replacement )
279
280
{
280
281
int numlines = 1 ;
281
282
int i ;
@@ -300,7 +301,6 @@ replace_token(char **lines, char *token, char *replacement)
300
301
int pre ;
301
302
302
303
/* just copy pointer if NULL or no change needed */
303
-
304
304
if (lines [i ] == NULL || (where = strstr (lines [i ], token )) == NULL )
305
305
{
306
306
result [i ] = lines [i ];
@@ -320,21 +320,19 @@ replace_token(char **lines, char *token, char *replacement)
320
320
strcpy (newline + pre + replen , lines [i ] + pre + toklen );
321
321
322
322
result [i ] = newline ;
323
-
324
323
}
325
324
326
325
return result ;
327
-
328
326
}
329
327
330
328
/*
331
329
* make a copy of lines without any that contain the token
332
- * a sort of poor man's grep -v
333
330
*
331
+ * a sort of poor man's grep -v
334
332
*/
335
333
#ifndef HAVE_UNIX_SOCKETS
336
334
static char * *
337
- filter_lines_with_token (char * * lines , char * token )
335
+ filter_lines_with_token (char * * lines , const char * token )
338
336
{
339
337
int numlines = 1 ;
340
338
int i , src , dst ;
@@ -1165,6 +1163,11 @@ setup_config(void)
1165
1163
snprintf (repltok , sizeof (repltok ), "shared_buffers = %d" , n_buffers );
1166
1164
conflines = replace_token (conflines , "#shared_buffers = 1000" , repltok );
1167
1165
1166
+ #if DEF_PGPORT != 5432
1167
+ snprintf (repltok , sizeof (repltok ), "#port = %d" , DEF_PGPORT );
1168
+ conflines = replace_token (conflines , "#port = 5432" , repltok );
1169
+ #endif
1170
+
1168
1171
lc_messages = escape_quotes (lc_messages );
1169
1172
snprintf (repltok , sizeof (repltok ), "lc_messages = '%s'" , lc_messages );
1170
1173
conflines = replace_token (conflines , "#lc_messages = 'C'" , repltok );
0 commit comments