Minor style cleanup in tab-complete.c

Started by Thomas Munroover 8 years ago3 messages
#1Thomas Munro
thomas.munro@enterprisedb.com
1 attachment(s)

Hi,

From the triviality department: I noticed some branches in
tab-complete.c's gargantuan if statement, mostly brand new, that break
from the established brace style. Should we fix that like this?

--
Thomas Munro
http://www.enterprisedb.com

Attachments:

remove-extraneous-braces-from-tab-complete.patchapplication/octet-stream; name=remove-extraneous-braces-from-tab-complete.patchDownload
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 17344d9d17..e9fdc908c7 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -1533,47 +1533,31 @@ psql_completion(const char *text, int start, int end)
 	}
 	/* ALTER PUBLICATION <name> */
 	else if (Matches3("ALTER", "PUBLICATION", MatchAny))
-	{
 		COMPLETE_WITH_LIST5("ADD TABLE", "DROP TABLE", "OWNER TO", "RENAME TO", "SET");
-	}
 	/* ALTER PUBLICATION <name> SET */
 	else if (Matches4("ALTER", "PUBLICATION", MatchAny, "SET"))
-	{
 		COMPLETE_WITH_LIST2("(", "TABLE");
-	}
 	/* ALTER PUBLICATION <name> SET ( */
 	else if (HeadMatches3("ALTER", "PUBLICATION", MatchAny) && TailMatches2("SET", "("))
-	{
 		COMPLETE_WITH_CONST("publish");
-	}
 	/* ALTER SUBSCRIPTION <name> */
 	else if (Matches3("ALTER", "SUBSCRIPTION", MatchAny))
-	{
 		COMPLETE_WITH_LIST7("CONNECTION", "ENABLE", "DISABLE", "OWNER TO",
 							"RENAME TO", "REFRESH PUBLICATION", "SET");
-	}
 	/* ALTER SUBSCRIPTION <name> REFRESH PUBLICATION */
 	else if (HeadMatches3("ALTER", "SUBSCRIPTION", MatchAny) &&
 			 TailMatches2("REFRESH", "PUBLICATION"))
-	{
 		COMPLETE_WITH_CONST("WITH (");
-	}
 	/* ALTER SUBSCRIPTION <name> REFRESH PUBLICATION WITH ( */
 	else if (HeadMatches3("ALTER", "SUBSCRIPTION", MatchAny) &&
 			 TailMatches4("REFRESH", "PUBLICATION", "WITH", "("))
-	{
 		COMPLETE_WITH_CONST("copy_data");
-	}
 	/* ALTER SUBSCRIPTION <name> SET */
 	else if (Matches4("ALTER", "SUBSCRIPTION", MatchAny, "SET"))
-	{
 		COMPLETE_WITH_LIST2("(", "PUBLICATION");
-	}
 	/* ALTER SUBSCRIPTION <name> SET ( */
 	else if (HeadMatches3("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches2("SET", "("))
-	{
 		COMPLETE_WITH_LIST2("slot_name", "synchronous_commit");
-	}
 	/* ALTER SUBSCRIPTION <name> SET PUBLICATION */
 	else if (HeadMatches3("ALTER", "SUBSCRIPTION", MatchAny) && TailMatches2("SET", "PUBLICATION"))
 	{
@@ -1582,15 +1566,11 @@ psql_completion(const char *text, int start, int end)
 	/* ALTER SUBSCRIPTION <name> SET PUBLICATION <name> */
 	else if (HeadMatches3("ALTER", "SUBSCRIPTION", MatchAny) &&
 			 TailMatches3("SET", "PUBLICATION", MatchAny))
-	{
 		COMPLETE_WITH_CONST("WITH (");
-	}
 	/* ALTER SUBSCRIPTION <name> SET PUBLICATION <name> WITH ( */
 	else if (HeadMatches3("ALTER", "SUBSCRIPTION", MatchAny) &&
 			 TailMatches5("SET", "PUBLICATION", MatchAny, "WITH", "("))
-	{
 		COMPLETE_WITH_LIST2("copy_data", "refresh");
-	}
 	/* ALTER SCHEMA <name> */
 	else if (Matches3("ALTER", "SCHEMA", MatchAny))
 		COMPLETE_WITH_LIST2("OWNER TO", "RENAME TO");
@@ -3558,13 +3538,9 @@ psql_completion(const char *text, int start, int end)
 			COMPLETE_WITH_LIST_CS2("single", "double");
 	}
 	else if (TailMatchesCS1("\\unset"))
-	{
 		matches = complete_from_variables(text, "", "", true);
-	}
 	else if (TailMatchesCS1("\\set"))
-	{
 		matches = complete_from_variables(text, "", "", false);
-	}
 	else if (TailMatchesCS2("\\set", MatchAny))
 	{
 		if (TailMatchesCS1("AUTOCOMMIT|ON_ERROR_STOP|QUIET|"
#2Michael Paquier
michael.paquier@gmail.com
In reply to: Thomas Munro (#1)
Re: Minor style cleanup in tab-complete.c

On Wed, Jul 12, 2017 at 11:19 AM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:

From the triviality department: I noticed some branches in
tab-complete.c's gargantuan if statement, mostly brand new, that break
from the established brace style. Should we fix that like this?

For consistency I think it does.
--
Michael

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#3Heikki Linnakangas
hlinnaka@iki.fi
In reply to: Michael Paquier (#2)
Re: Minor style cleanup in tab-complete.c

On 07/12/2017 07:39 AM, Michael Paquier wrote:

On Wed, Jul 12, 2017 at 11:19 AM, Thomas Munro
<thomas.munro@enterprisedb.com> wrote:

From the triviality department: I noticed some branches in
tab-complete.c's gargantuan if statement, mostly brand new, that break
from the established brace style. Should we fix that like this?

For consistency I think it does.

Agreed. Committed, thanks.

- Heikki

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers