Re: [PATCHES] Coding standards
Alvaro Herrera wrote: > The developer's FAQ is supposed to contain this kind of thing, but I > think it's rather thin on actual details. (Some time ago it was > proposed to create a "style guide", but people here thought it was a > waste of time and "it will not cover what's really important", so we're > stuck with repeating the advice over and over.) Excellent wiki material ... -- Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-patches
Re: [PATCHES] Coding standards
[EMAIL PROTECTED] (Bryce Nesbitt) writes: > 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. Note that you can find config for vim and emacs to get them to support the coding standards in: /opt/src/pgsql-HEAD/src/tools/editors/emacs.samples /opt/src/pgsql-HEAD/src/tools/editors/vim.samples For vim, the essentials are thus: :if match(getcwd(), "/pgsql") >=0 || match(getcwd(), "/postgresql") >= 0 : set cinoptions=(0 : set tabstop=4 : set shiftwidth=4 :endif The hooks are slightly different (though not by spectacularly much, somewhat surprisingly) for Emacs... -- let name="cbbrowne" and tld="cbbrowne.com" in name ^ "@" ^ tld;; http://cbbrowne.com/info/advocacy.html "A language that doesn't affect the way you think about programming, is not worth knowing." -- Alan J. Perlis -- Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-patches
Re: [PATCHES] Coding standards
Bryce Nesbitt wrote: > 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? The developer's FAQ is supposed to contain this kind of thing, but I think it's rather thin on actual details. (Some time ago it was proposed to create a "style guide", but people here thought it was a waste of time and "it will not cover what's really important", so we're stuck with repeating the advice over and over.) > 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. I use this: :if match(getcwd(), "/home/alvherre/Code/CVS/pgsql") == 0 : set cinoptions=(0 : set tabstop=4 : set shiftwidth=4 : let $CSCOPE_DB=substitute(getcwd(), "^\\(.*/pgsql/source/[^/]*\\)/.*", "\\1", "") : let &tags=substitute(getcwd(), "^\\(.*/pgsql/source/[^/]*\\)/.*", "\\1", "") . "/tags" : let &path=substitute(getcwd(), "^\\(.*/pgsql/source/[^/]*\\)/.*", "\\1", "") . "/src/include" :endif Of course, you need to adjust the paths. The cscope, tags and path things let me quickly navigate through the files, but they don't affect the editor behavior. I never set expandtab so it's not a problem for me, but I guess you can do ":set noexpandtab" in that block to reset it for Postgres use. -- Alvaro Herrerahttp://www.CommandPrompt.com/ PostgreSQL Replication, Consulting, Custom Development, 24x7 support -- Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-patches
Re: [PATCHES] Coding standards
Bryce Nesbitt wrote: > 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. See the developer FAQ on the website. IIRC, it even contains what you should put in your vi config file to make it do the right thing... //Magnus -- Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-patches
[PATCHES] Coding standards
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. -- Sent via pgsql-patches mailing list (pgsql-patches@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-patches