mirror of
https://github.com/postgres/postgres.git
synced 2026-10-23 13:29:09 +03:00
initdb: Pad rewritten GUC lines with spaces instead of tabs.
Commitf63ae72bbcconverted postgresql.conf.sample to spaces so that it lines up at any tab width, but replace_guc_value() still pads with tabs when it re-aligns the trailing comment of a rewritten setting. Fix that. Oversight in commitf63ae72bbc. Reviewed-by: Chao Li <li.evan.chao@gmail.com> Discussion: https://postgr.es/m/apRezMywHRuR5h-6%40nathan Backpatch-through: 19
This commit is contained in:
@@ -587,37 +587,16 @@ replace_guc_value(char **lines, const char *guc_name, const char *guc_value,
|
||||
{
|
||||
/*
|
||||
* We try to preserve original indentation, which is tedious.
|
||||
* oldindent and newindent are measured in de-tab-ified columns.
|
||||
*/
|
||||
const char *ptr;
|
||||
int oldindent = 0;
|
||||
int newindent;
|
||||
int oldindent = (int) (where - lines[i]);
|
||||
int newindent = newline->len;
|
||||
|
||||
for (ptr = lines[i]; ptr < where; ptr++)
|
||||
{
|
||||
if (*ptr == '\t')
|
||||
oldindent += 8 - (oldindent % 8);
|
||||
else
|
||||
oldindent++;
|
||||
}
|
||||
/* ignore the possibility of tabs in guc_value */
|
||||
newindent = newline->len;
|
||||
/* append appropriate tabs and spaces, forcing at least one */
|
||||
/* append appropriate spaces, forcing at least one */
|
||||
oldindent = Max(oldindent, newindent + 1);
|
||||
while (newindent < oldindent)
|
||||
{
|
||||
int newindent_if_tab = newindent + 8 - (newindent % 8);
|
||||
|
||||
if (newindent_if_tab <= oldindent)
|
||||
{
|
||||
appendPQExpBufferChar(newline, '\t');
|
||||
newindent = newindent_if_tab;
|
||||
}
|
||||
else
|
||||
{
|
||||
appendPQExpBufferChar(newline, ' ');
|
||||
newindent++;
|
||||
}
|
||||
appendPQExpBufferChar(newline, ' ');
|
||||
newindent++;
|
||||
}
|
||||
/* and finally append the old comment */
|
||||
appendPQExpBufferStr(newline, where);
|
||||
|
||||
Reference in New Issue
Block a user