Skip site navigation (1) Skip section navigation (2)

Coding standards

From: Bryce Nesbitt <bryce2(at)obviously(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Coding standards
Date: 2008-04-18 06:44:46
Message-ID: 4808435E.2020200@obviously.com (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Alvaro Herrera wrote:
> People [are] complaining here that we don't teach people here anyway, so
> hopefully my comments were still useful :-)
>   
Yes they are useful.  As a new patcher, where should I look for coding 
standards?  How about a little FAQ at the
top of the CVS source tree?

Though, darn it, I sure like //

And my vi is set to:
  set sw=4
  set ts=4
  set expandtab
Because my corporate projects require spaces not tabs.

> Some random comments:
>
> * Don't use C++ style comments (//).  Some compilers don't like these.
>
> * Beware of brace position: we use braces on their own, indented at the
>   start of a new line, so
>
> ! 	while(--count) {
> !         lines++;                
> ! 		lines->ptr   = NULL;
> ! 		lines->width = 0;
> !         }
>
> becomes
>
>
> ! 	while(--count)
> !       {
> !         lines++;                
> ! 		lines->ptr   = NULL;
> ! 		lines->width = 0;
> !         }
>
> (with correct indentation anyway)
>
>
> * Always use tabs, not spaces, to indent.  Tabs are 4 spaces wide.
>
> * Don't use double stars in comments.
>
> * "} else" is forbidden too.  Use two separate lines.


In response to

Responses

pgsql-hackers by date

Next:From: Heikki LinnakangasDate: 2008-04-18 06:52:54
Subject: Re: DROP DATABASE vs patch to not remove files right away
Previous:From: Bryce NesbittDate: 2008-04-18 06:36:14
Subject: Re: Proposed patch - psql wraps at window width

pgsql-patches by date

Next:From: Bryce NesbittDate: 2008-04-18 07:07:29
Subject: Re: Proposed patch - psql wraps at window width
Previous:From: Bryce NesbittDate: 2008-04-18 06:36:14
Subject: Re: Proposed patch - psql wraps at window width

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group