Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
d1cee549
Commit
d1cee549
authored
Oct 07, 2004
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Escape single quotes and backslashes used in locales placed in
postgresql.conf. Zhong Xubin
parent
2b8fab84
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
4 deletions
+25
-4
src/bin/initdb/initdb.c
src/bin/initdb/initdb.c
+25
-4
No files found.
src/bin/initdb/initdb.c
View file @
d1cee549
...
...
@@ -39,7 +39,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
* Portions taken from FreeBSD.
*
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.5
6 2004/10/06 09:13:10
momjian Exp $
* $PostgreSQL: pgsql/src/bin/initdb/initdb.c,v 1.5
7 2004/10/07 16:53:25
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -181,6 +181,7 @@ static void vacuum_db(void);
static
void
make_template0
(
void
);
static
void
trapsig
(
int
signum
);
static
void
check_ok
(
void
);
static
void
escape_locale
(
char
**
locale
);
static
bool
chklocale
(
const
char
*
locale
);
static
void
setlocales
(
void
);
static
void
usage
(
const
char
*
progname
);
...
...
@@ -1099,16 +1100,20 @@ setup_config(void)
snprintf
(
repltok
,
sizeof
(
repltok
),
"shared_buffers = %d"
,
n_buffers
);
conflines
=
replace_token
(
conflines
,
"#shared_buffers = 1000"
,
repltok
);
escape_locale
(
&
lc_messages
);
snprintf
(
repltok
,
sizeof
(
repltok
),
"lc_messages = '%s'"
,
lc_messages
);
conflines
=
replace_token
(
conflines
,
"#lc_messages = 'C'"
,
repltok
);
escape_locale
(
&
lc_monetary
);
snprintf
(
repltok
,
sizeof
(
repltok
),
"lc_monetary = '%s'"
,
lc_monetary
);
conflines
=
replace_token
(
conflines
,
"#lc_monetary = 'C'"
,
repltok
);
escape_locale
(
&
lc_numeric
);
snprintf
(
repltok
,
sizeof
(
repltok
),
"lc_numeric = '%s'"
,
lc_numeric
);
conflines
=
replace_token
(
conflines
,
"#lc_numeric = 'C'"
,
repltok
);
escape_locale
(
&
lc_time
);
snprintf
(
repltok
,
sizeof
(
repltok
),
"lc_time = '%s'"
,
lc_time
);
conflines
=
replace_token
(
conflines
,
"#lc_time = 'C'"
,
repltok
);
...
...
@@ -1896,11 +1901,27 @@ check_ok()
}
}
/*
* Escape any single quotes or backslashes in locale
*/
static
void
escape_locale
(
char
**
locale
)
{
int
len
=
strlen
(
*
locale
),
i
,
j
;
char
*
loc_temp
=
xmalloc
(
len
*
2
);
for
(
i
=
0
,
j
=
0
;
i
<
len
;
i
++
)
{
if
((
*
locale
)[
i
]
==
'\''
||
(
*
locale
)[
i
]
==
'\\'
)
loc_temp
[
j
++
]
=
'\\'
;
loc_temp
[
j
++
]
=
(
*
locale
)[
i
];
}
*
locale
=
loc_temp
;
}
/*
* check if given string is a valid locale specifier
* based on some code given to me by Peter Eisentraut
* (but I take responsibility for it :-)
*/
static
bool
chklocale
(
const
char
*
locale
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment