|
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.54 2004/09/02 17:58:41 tgl Exp $ |
| 42 | + * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.55 2004/10/06 09:01:18 momjian Exp $ |
43 | 43 | *
|
44 | 44 | *-------------------------------------------------------------------------
|
45 | 45 | */
|
@@ -147,6 +147,9 @@ char backend_exec[MAXPGPATH];
|
147 | 147 | static void *xmalloc(size_t size);
|
148 | 148 | static char *xstrdup(const char *s);
|
149 | 149 | static char **replace_token(char **lines, char *token, char *replacement);
|
| 150 | +#ifdef WIN32 |
| 151 | +static char **filter_lines_with_token(char **lines, char *token); |
| 152 | +#endif |
150 | 153 | static char **readfile(char *path);
|
151 | 154 | static void writefile(char *path, char **lines);
|
152 | 155 | static int mkdir_p(char *path, mode_t omode);
|
@@ -310,6 +313,34 @@ replace_token(char **lines, char *token, char *replacement)
|
310 | 313 |
|
311 | 314 | }
|
312 | 315 |
|
| 316 | +/* |
| 317 | + * make a copy of lines without any that contain the token |
| 318 | + * a sort of poor man's grep -v |
| 319 | + * |
| 320 | + */ |
| 321 | +#ifdef WIN32 |
| 322 | +static char ** |
| 323 | +filter_lines_with_token(char **lines, char *token) |
| 324 | +{ |
| 325 | + int numlines = 1; |
| 326 | + int i, src, dst; |
| 327 | + char **result; |
| 328 | + |
| 329 | + for (i = 0; lines[i]; i++) |
| 330 | + numlines++; |
| 331 | + |
| 332 | + result = (char **) xmalloc(numlines * sizeof(char *)); |
| 333 | + |
| 334 | + for (src = 0, dst = 0; src < numlines; src++) |
| 335 | + { |
| 336 | + if (lines[src] == NULL || strstr(lines[src], token) == NULL) |
| 337 | + result[dst++] = lines[src]; |
| 338 | + } |
| 339 | + |
| 340 | + return result; |
| 341 | +} |
| 342 | +#endif |
| 343 | + |
313 | 344 | /*
|
314 | 345 | * get the lines from a text file
|
315 | 346 | */
|
@@ -1093,6 +1124,12 @@ setup_config(void)
|
1093 | 1124 |
|
1094 | 1125 | conflines = readfile(hba_file);
|
1095 | 1126 |
|
| 1127 | +#ifdef WIN32 |
| 1128 | + conflines = filter_lines_with_token(conflines,"@remove-line-for-win32@"); |
| 1129 | +#else |
| 1130 | + conflines = replace_token(conflines,"@remove-line-for-win32@",""); |
| 1131 | +#endif |
| 1132 | + |
1096 | 1133 | #ifndef HAVE_IPV6
|
1097 | 1134 | conflines = replace_token(conflines,
|
1098 | 1135 | "host all all ::1",
|
|
0 commit comments