|
43 | 43 | * Portions Copyright (c) 1994, Regents of the University of California |
44 | 44 | * Portions taken from FreeBSD. |
45 | 45 | * |
46 | | - * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.23 2004/03/09 04:49:02 momjian Exp $ |
| 46 | + * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.24 2004/05/05 16:09:31 tgl Exp $ |
47 | 47 | * |
48 | 48 | *------------------------------------------------------------------------- |
49 | 49 | */ |
@@ -263,6 +263,24 @@ xstrdup(const char *s) |
263 | 263 | returnresult; |
264 | 264 | } |
265 | 265 |
|
| 266 | +/* |
| 267 | + * unsetenv() doesn't exist everywhere, so emulate it with this ugly |
| 268 | + * but well-tested technique (borrowed from backend's variable.c). |
| 269 | + */ |
| 270 | +staticvoid |
| 271 | +pg_unsetenv(constchar*varname) |
| 272 | +{ |
| 273 | +char*envstr=xmalloc(strlen(varname)+2); |
| 274 | + |
| 275 | +/* First, override any existing setting by forcibly defining the var */ |
| 276 | +sprintf(envstr,"%s=",varname); |
| 277 | +putenv(envstr); |
| 278 | + |
| 279 | +/* Now we can clobber the variable definition this way: */ |
| 280 | +strcpy(envstr,"="); |
| 281 | +putenv(envstr); |
| 282 | +} |
| 283 | + |
266 | 284 | /* |
267 | 285 | * delete a directory tree recursively |
268 | 286 | * assumes path points to a valid directory |
@@ -1242,7 +1260,10 @@ bootstrap_template1(char *short_version) |
1242 | 1260 | snprintf(cmd,sizeof(cmd),"LC_CTYPE=%s",lc_ctype); |
1243 | 1261 | putenv(xstrdup(cmd)); |
1244 | 1262 |
|
1245 | | -putenv("LC_ALL"); |
| 1263 | +pg_unsetenv("LC_ALL"); |
| 1264 | + |
| 1265 | +/* Also ensure backend isn't confused by this environment var: */ |
| 1266 | +pg_unsetenv("PGCLIENTENCODING"); |
1246 | 1267 |
|
1247 | 1268 | snprintf(cmd,sizeof(cmd), |
1248 | 1269 | "\"%s/postgres\" -boot -x1 %s %s template1", |
|