~ubuntu-branches/ubuntu/oneiric/postgresql-9.1/oneiric-security

« back to all changes in this revision

Viewing changes to doc/src/sgml/html/source-format.html

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2011-05-11 10:41:53 UTC
  • Revision ID: james.westby@ubuntu.com-20110511104153-psbh2o58553fv1m0
Tags: upstream-9.1~beta1
ImportĀ upstreamĀ versionĀ 9.1~beta1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 
2
<HTML
 
3
><HEAD
 
4
><TITLE
 
5
>Formatting</TITLE
 
6
><META
 
7
NAME="GENERATOR"
 
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
 
9
REV="MADE"
 
10
HREF="mailto:pgsql-docs@postgresql.org"><LINK
 
11
REL="HOME"
 
12
TITLE="PostgreSQL 9.1beta1 Documentation"
 
13
HREF="index.html"><LINK
 
14
REL="UP"
 
15
TITLE="PostgreSQL Coding Conventions"
 
16
HREF="source.html"><LINK
 
17
REL="PREVIOUS"
 
18
TITLE="PostgreSQL Coding Conventions"
 
19
HREF="source.html"><LINK
 
20
REL="NEXT"
 
21
TITLE="Reporting Errors Within the Server"
 
22
HREF="error-message-reporting.html"><LINK
 
23
REL="STYLESHEET"
 
24
TYPE="text/css"
 
25
HREF="stylesheet.css"><META
 
26
HTTP-EQUIV="Content-Type"
 
27
CONTENT="text/html; charset=ISO-8859-1"><META
 
28
NAME="creation"
 
29
CONTENT="2011-04-27T21:20:33"></HEAD
 
30
><BODY
 
31
CLASS="SECT1"
 
32
><DIV
 
33
CLASS="NAVHEADER"
 
34
><TABLE
 
35
SUMMARY="Header navigation table"
 
36
WIDTH="100%"
 
37
BORDER="0"
 
38
CELLPADDING="0"
 
39
CELLSPACING="0"
 
40
><TR
 
41
><TH
 
42
COLSPAN="5"
 
43
ALIGN="center"
 
44
VALIGN="bottom"
 
45
><A
 
46
HREF="index.html"
 
47
>PostgreSQL 9.1beta1 Documentation</A
 
48
></TH
 
49
></TR
 
50
><TR
 
51
><TD
 
52
WIDTH="10%"
 
53
ALIGN="left"
 
54
VALIGN="top"
 
55
><A
 
56
TITLE="PostgreSQL Coding Conventions"
 
57
HREF="source.html"
 
58
ACCESSKEY="P"
 
59
>Prev</A
 
60
></TD
 
61
><TD
 
62
WIDTH="10%"
 
63
ALIGN="left"
 
64
VALIGN="top"
 
65
><A
 
66
TITLE="PostgreSQL Coding Conventions"
 
67
HREF="source.html"
 
68
>Fast Backward</A
 
69
></TD
 
70
><TD
 
71
WIDTH="60%"
 
72
ALIGN="center"
 
73
VALIGN="bottom"
 
74
>Chapter 47. PostgreSQL Coding Conventions</TD
 
75
><TD
 
76
WIDTH="10%"
 
77
ALIGN="right"
 
78
VALIGN="top"
 
79
><A
 
80
TITLE="PostgreSQL Coding Conventions"
 
81
HREF="source.html"
 
82
>Fast Forward</A
 
83
></TD
 
84
><TD
 
85
WIDTH="10%"
 
86
ALIGN="right"
 
87
VALIGN="top"
 
88
><A
 
89
TITLE="Reporting Errors Within the Server"
 
90
HREF="error-message-reporting.html"
 
91
ACCESSKEY="N"
 
92
>Next</A
 
93
></TD
 
94
></TR
 
95
></TABLE
 
96
><HR
 
97
ALIGN="LEFT"
 
98
WIDTH="100%"></DIV
 
99
><DIV
 
100
CLASS="SECT1"
 
101
><H1
 
102
CLASS="SECT1"
 
103
><A
 
104
NAME="SOURCE-FORMAT"
 
105
>47.1. Formatting</A
 
106
></H1
 
107
><P
 
108
>    Source code formatting uses 4 column tab spacing, with
 
109
    tabs preserved (i.e., tabs are not expanded to spaces).
 
110
    Each logical indentation level is one additional tab stop.
 
111
   </P
 
112
><P
 
113
>    Layout rules (brace positioning, etc) follow BSD conventions.  In
 
114
    particular, curly braces for the controlled blocks of <TT
 
115
CLASS="LITERAL"
 
116
>if</TT
 
117
>,
 
118
    <TT
 
119
CLASS="LITERAL"
 
120
>while</TT
 
121
>, <TT
 
122
CLASS="LITERAL"
 
123
>switch</TT
 
124
>, etc go on their own lines.
 
125
   </P
 
126
><P
 
127
>    Limit line lengths so that the code is readable in an 80-column window.
 
128
    (This doesn't mean that you must never go past 80 columns.  For instance,
 
129
    breaking a long error message string in arbitrary places just to keep the
 
130
    code within 80 columns is probably not a net gain in readability.)
 
131
   </P
 
132
><P
 
133
>    Do not use C++ style comments (<TT
 
134
CLASS="LITERAL"
 
135
>//</TT
 
136
> comments).  Strict ANSI C
 
137
    compilers do not accept them.  For the same reason, do not use C++
 
138
    extensions such as declaring new variables mid-block.
 
139
   </P
 
140
><P
 
141
>    The preferred style for multi-line comment blocks is
 
142
</P><PRE
 
143
CLASS="PROGRAMLISTING"
 
144
>/*
 
145
 * comment text begins here
 
146
 * and continues here
 
147
 */</PRE
 
148
><P>
 
149
    Note that comment blocks that begin in column 1 will be preserved as-is
 
150
    by <SPAN
 
151
CLASS="APPLICATION"
 
152
>pgindent</SPAN
 
153
>, but it will re-flow indented comment blocks
 
154
    as though they were plain text.  If you want to preserve the line breaks
 
155
    in an indented block, add dashes like this:
 
156
</P><PRE
 
157
CLASS="PROGRAMLISTING"
 
158
>    /*----------
 
159
     * comment text begins here
 
160
     * and continues here
 
161
     *----------
 
162
     */</PRE
 
163
><P>
 
164
   </P
 
165
><P
 
166
>    While submitted patches do not absolutely have to follow these formatting
 
167
    rules, it's a good idea to do so.  Your code will get run through
 
168
    <SPAN
 
169
CLASS="APPLICATION"
 
170
>pgindent</SPAN
 
171
> before the next release, so there's no point in
 
172
    making it look nice under some other set of formatting conventions.
 
173
    A good rule of thumb for patches is <SPAN
 
174
CLASS="QUOTE"
 
175
>"make the new code look like
 
176
    the existing code around it"</SPAN
 
177
>.
 
178
   </P
 
179
><P
 
180
>    The <TT
 
181
CLASS="FILENAME"
 
182
>src/tools</TT
 
183
> directory contains sample settings
 
184
    files that can be used with the <SPAN
 
185
CLASS="PRODUCTNAME"
 
186
>emacs</SPAN
 
187
>,
 
188
    <SPAN
 
189
CLASS="PRODUCTNAME"
 
190
>xemacs</SPAN
 
191
> or <SPAN
 
192
CLASS="PRODUCTNAME"
 
193
>vim</SPAN
 
194
>
 
195
    editors to help ensure that they format code according to these
 
196
    conventions.
 
197
   </P
 
198
><P
 
199
>    The text browsing tools <SPAN
 
200
CLASS="APPLICATION"
 
201
>more</SPAN
 
202
> and
 
203
    <SPAN
 
204
CLASS="APPLICATION"
 
205
>less</SPAN
 
206
> can be invoked as:
 
207
</P><PRE
 
208
CLASS="PROGRAMLISTING"
 
209
>more -x4
 
210
less -x4</PRE
 
211
><P>
 
212
    to make them show tabs appropriately.
 
213
   </P
 
214
></DIV
 
215
><DIV
 
216
CLASS="NAVFOOTER"
 
217
><HR
 
218
ALIGN="LEFT"
 
219
WIDTH="100%"><TABLE
 
220
SUMMARY="Footer navigation table"
 
221
WIDTH="100%"
 
222
BORDER="0"
 
223
CELLPADDING="0"
 
224
CELLSPACING="0"
 
225
><TR
 
226
><TD
 
227
WIDTH="33%"
 
228
ALIGN="left"
 
229
VALIGN="top"
 
230
><A
 
231
HREF="source.html"
 
232
ACCESSKEY="P"
 
233
>Prev</A
 
234
></TD
 
235
><TD
 
236
WIDTH="34%"
 
237
ALIGN="center"
 
238
VALIGN="top"
 
239
><A
 
240
HREF="index.html"
 
241
ACCESSKEY="H"
 
242
>Home</A
 
243
></TD
 
244
><TD
 
245
WIDTH="33%"
 
246
ALIGN="right"
 
247
VALIGN="top"
 
248
><A
 
249
HREF="error-message-reporting.html"
 
250
ACCESSKEY="N"
 
251
>Next</A
 
252
></TD
 
253
></TR
 
254
><TR
 
255
><TD
 
256
WIDTH="33%"
 
257
ALIGN="left"
 
258
VALIGN="top"
 
259
>PostgreSQL Coding Conventions</TD
 
260
><TD
 
261
WIDTH="34%"
 
262
ALIGN="center"
 
263
VALIGN="top"
 
264
><A
 
265
HREF="source.html"
 
266
ACCESSKEY="U"
 
267
>Up</A
 
268
></TD
 
269
><TD
 
270
WIDTH="33%"
 
271
ALIGN="right"
 
272
VALIGN="top"
 
273
>Reporting Errors Within the Server</TD
 
274
></TR
 
275
></TABLE
 
276
></DIV
 
277
></BODY
 
278
></HTML
 
279
>
 
 
b'\\ No newline at end of file'