Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2cf3f66

Browse files
committed
Add a few more details in the source-code-formatting documentation.
This isn't exhaustive but it covers some of the more common layoutmistakes I've seen in submitted patches.
1 parent1cfd878 commit2cf3f66

File tree

1 file changed

+42
-10
lines changed

1 file changed

+42
-10
lines changed

‎doc/src/sgml/sources.sgml

Lines changed: 42 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/sources.sgml,v 2.30 2008/03/24 18:08:47 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/sources.sgml,v 2.31 2008/09/07 02:01:04 tgl Exp $ -->
22

33
<chapter id="source">
44
<title>PostgreSQL Coding Conventions</title>
@@ -7,24 +7,56 @@
77
<title>Formatting</title>
88

99
<para>
10-
Source code formatting uses 4 column tab spacing, with
11-
tabs preserved (i.e. tabs are not expanded to spaces).
10+
Source code formatting uses 4 column tab spacing, with
11+
tabs preserved (i.e., tabs are not expanded to spaces).
1212
Each logical indentation level is one additional tab stop.
13-
Layout rules (brace positioning, etc) follow BSD conventions.
13+
</para>
14+
15+
<para>
16+
Layout rules (brace positioning, etc) follow BSD conventions. In
17+
particular, curly braces for the controlled blocks of <literal>if</>,
18+
<literal>while</>, <literal>switch</>, etc go on their own lines.
19+
</para>
20+
21+
<para>
22+
Do not use C++ style comments (<literal>//</> comments). Strict ANSI C
23+
compilers do not accept them. For the same reason, do not use C++
24+
extensions such as declaring new variables mid-block.
25+
</para>
26+
27+
<para>
28+
The preferred style for multi-line comment blocks is
29+
<programlisting>
30+
/*
31+
* comment text begins here
32+
* and continues here
33+
*/
34+
</programlisting>
35+
Note that comment blocks that begin in column 1 will be preserved as-is
36+
by <application>pgindent</>, but it will re-flow indented comment blocks
37+
as though they were plain text. If you want to preserve the line breaks
38+
in an indented block, add dashes like this:
39+
<programlisting>
40+
/*----------
41+
* comment text begins here
42+
* and continues here
43+
*----------
44+
*/
45+
</programlisting>
1446
</para>
1547

1648
<para>
1749
While submitted patches do not absolutely have to follow these formatting
1850
rules, it's a good idea to do so. Your code will get run through
19-
<application>pgindent</>, so there's no point in making it look nice
20-
under some other set of formatting conventions.
51+
<application>pgindent</> before the next release, so there's no point in
52+
making it look niceunder some other set of formatting conventions.
2153
</para>
2254

2355
<para>
24-
The <filename>src/tools</filename> directory contains sample settings
25-
files that can be used with the <productname>emacs</productname>,
26-
<productname>xemacs</productname> or <productname>vim</productname>
27-
editors to help ensure that they format code according to these
56+
The <filename>src/tools</filename> directory contains sample settings
57+
files that can be used with the <productname>emacs</productname>,
58+
<productname>xemacs</productname> or <productname>vim</productname>
59+
editors to help ensure that they format code according to these
2860
conventions.
2961
</para>
3062

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp