|
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.58 2004/10/0717:29:12 momjian Exp $ |
| 42 | + * $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.59 2004/10/0718:57:26 tgl Exp $ |
43 | 43 | *
|
44 | 44 | *-------------------------------------------------------------------------
|
45 | 45 | */
|
@@ -181,7 +181,7 @@ static void vacuum_db(void);
|
181 | 181 | staticvoidmake_template0(void);
|
182 | 182 | staticvoidtrapsig(intsignum);
|
183 | 183 | staticvoidcheck_ok(void);
|
184 |
| -staticvoidescape_locale(char**locale); |
| 184 | +staticchar*escape_quotes(constchar*src); |
185 | 185 | staticboolchklocale(constchar*locale);
|
186 | 186 | staticvoidsetlocales(void);
|
187 | 187 | staticvoidusage(constchar*progname);
|
@@ -1100,20 +1100,19 @@ setup_config(void)
|
1100 | 1100 | snprintf(repltok,sizeof(repltok),"shared_buffers = %d",n_buffers);
|
1101 | 1101 | conflines=replace_token(conflines,"#shared_buffers = 1000",repltok);
|
1102 | 1102 |
|
1103 |
| - |
1104 |
| -escape_locale(&lc_messages); |
| 1103 | +lc_messages=escape_quotes(lc_messages); |
1105 | 1104 | snprintf(repltok,sizeof(repltok),"lc_messages = '%s'",lc_messages);
|
1106 | 1105 | conflines=replace_token(conflines,"#lc_messages = 'C'",repltok);
|
1107 | 1106 |
|
1108 |
| -escape_locale(&lc_monetary); |
| 1107 | +lc_monetary=escape_quotes(lc_monetary); |
1109 | 1108 | snprintf(repltok,sizeof(repltok),"lc_monetary = '%s'",lc_monetary);
|
1110 | 1109 | conflines=replace_token(conflines,"#lc_monetary = 'C'",repltok);
|
1111 | 1110 |
|
1112 |
| -escape_locale(&lc_numeric); |
| 1111 | +lc_numeric=escape_quotes(lc_numeric); |
1113 | 1112 | snprintf(repltok,sizeof(repltok),"lc_numeric = '%s'",lc_numeric);
|
1114 | 1113 | conflines=replace_token(conflines,"#lc_numeric = 'C'",repltok);
|
1115 | 1114 |
|
1116 |
| -escape_locale(&lc_time); |
| 1115 | +lc_time=escape_quotes(lc_time); |
1117 | 1116 | snprintf(repltok,sizeof(repltok),"lc_time = '%s'",lc_time);
|
1118 | 1117 | conflines=replace_token(conflines,"#lc_time = 'C'",repltok);
|
1119 | 1118 |
|
@@ -1902,22 +1901,23 @@ check_ok()
|
1902 | 1901 | }
|
1903 | 1902 |
|
1904 | 1903 | /*
|
1905 |
| - * Escape any single quotes or backslashes inlocale |
| 1904 | + * Escape any single quotes or backslashes ingiven string |
1906 | 1905 | */
|
1907 |
| -staticvoid |
1908 |
| -escape_locale(char**locale) |
| 1906 | +staticchar* |
| 1907 | +escape_quotes(constchar*src) |
1909 | 1908 | {
|
1910 |
| -intlen=strlen(*locale), |
| 1909 | +intlen=strlen(src), |
1911 | 1910 | i,j;
|
1912 |
| -char*loc_temp=xmalloc(len*2+1); |
| 1911 | +char*result=xmalloc(len*2+1); |
1913 | 1912 |
|
1914 | 1913 | for (i=0,j=0;i<len;i++)
|
1915 | 1914 | {
|
1916 |
| -if ((*locale)[i]=='\''||(*locale)[i]=='\\') |
1917 |
| -loc_temp[j++]='\\'; |
1918 |
| -loc_temp[j++]=(*locale)[i]; |
| 1915 | +if (src[i]=='\''||src[i]=='\\') |
| 1916 | +result[j++]='\\'; |
| 1917 | +result[j++]=src[i]; |
1919 | 1918 | }
|
1920 |
| -*locale=loc_temp; |
| 1919 | +result[j]='\0'; |
| 1920 | +returnresult; |
1921 | 1921 | }
|
1922 | 1922 |
|
1923 | 1923 | /*
|
|