标题: 开发规范参考
无双
荣誉斑竹
Rank: 14Rank: 14Rank: 14Rank: 14
天才猪



UID 4
精华 84
积分 5863
帖子 11390
活跃指数 0
LU金币 4248 个
LU金条 0 个
阅读权限 200
注册 2003-9-16
来自 杭州
 
发表于 2004-2-11 16:52  资料  个人空间  主页 短消息  加为好友 
http://worldhello.net/doc/program_rules/format.html


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>格式规范</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"/><LINK
REV="MADE"
HREF="mailto:johnson.AT.worldhello.net"/><LINK
REL="HOME"
TITLE="开发规范参考"
HREF="index.html"/><LINK
REL="PREVIOUS"
TITLE="命名规范"
HREF="naming.html"/><LINK
REL="NEXT"
TITLE="Makefile"
HREF="makefile.html"/><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="../images/docbook.css"/><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=gb2312"/></HEAD
><BODY
CLASS="SECT1"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>开发规范参考</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="naming.html"
ACCESSKEY="P"
>后退</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
><A
HREF="makefile.html"
ACCESSKEY="N"
>前进</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"/></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="FORMAT"
>3. 格式规范</A
></H1
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="GENERAL"
>3.1. 一般格式原则</A
></H2
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN192"
>3.1.1. 规则</A
></H3
><P
></P
><OL
TYPE="1"
><LI
><P
>缩进用tab,不用空格;</P
></LI
><LI
><P
>一个tab定义为四个空格,原因见后面表格;</P
></LI
><LI
><P
>标点符号的右边留一个空格(左括号除外);</P
></LI
><LI
><P
>赋值、判断、运算符号两边都要加一个空格;</P
></LI
><LI
><P
>空行也是注释,适当的空行使逻辑更清楚,函数内部不应该有连续空行,函数之间至少有两个连续空行;</P
></LI
></OL
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN205"
>3.1.2. 实例</A
></H3
><P
>略...</P
></DIV
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN208"
>3.2. 变量</A
></H2
><P
></P
><OL
TYPE="1"
><LI
><P
>当出现变量和常量比较和判断时,常量放在左边,以防止"= ="错误输入为"=",时可以由编译器检验;(强制)</P
></LI
><LI
><P
>变量定义块分两部分,外部定义在前,且加上extern关键字;</P
></LI
><LI
><P
>程序的include 块也分两部分;一部分为包含标准头文件,后一部分为本工程内部定义的头文件;</P
></LI
></OL
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="AEN217"
>3.3. 函数</A
></H2
><P
></P
><OL
TYPE="1"
><LI
><P
>所有调用函数在".h"头文件中声名,对于只是在本模块中调用的函数,用static关键字限制;</P
></LI
><LI
><P
>main函数,一定有返回值,且为int类型;</P
></LI
><LI
><P
>函数之间空两行,以示区分;</P
></LI
><LI
><P
>函数的类型和函数名分开两行写,即函数类型和函数名都从1列开始;</P
><P
>方便使用命令 <B
CLASS="COMMAND"
>grep "^函数名" 文件名</B
> 快速查找函数定义,而不会定位到函数调用的代码;</P
></LI
><LI
><P
>函数的参数一个一行(推荐);</P
></LI
><LI
><P
>一个函数不长于100行左右,即不超过两屏,如果超过,说明应该考虑进一步模块化;</P
></LI
></OL
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="COMMENT"
>3.4. 注释</A
></H2
><P
>应把注释看做和代码一样重要,也要统计到代码量中去。注释除了能够使得代码更易读、清晰外,还能用来生成文档。参见:<A
HREF="http://www.doxygen.org/"
TARGET="_top"
>Doxygen 计划</A
>。</P
><P
></P
><UL
><LI
><P
>分类</P
><P
></P
><OL
TYPE="1"
><LI
><P
>按位置分:</P
><P
>1. 位于语句后;2. 变量声明后;3. 予处理后;4. 或单独开始的注释(又有是否从第一行开始的区别)。</P
></LI
><LI
><P
>按照形式分:</P
><P
>块注释;单行注释(又有是否独立一行或者在代码后面的区别)。</P
><P
>块注释(boxed comments):Boxed comments are defined as those in which the initial `/*' is followed immediately by the character `*', `=', `_', or `-', or those in which the beginning comment delimiter (`/*') is on a line by itself, and the following line begins with a `*' in the same column as the star of the opening delimiter.</P
></LI
><LI
><P
>以上各个类型的注释可以被indent工具区分和格式化;indent忽略块注释,对齐单行注释等等;</P
></LI
></OL
><DIV
CLASS="TIP"
><P
></P
><TABLE
CLASS="TIP"
WIDTH="90%"
BORDER="0"
><TR
><TD
WIDTH="25"
ALIGN="CENTER"
VALIGN="TOP"
><IMG
SRC="../images/tip.gif"
HSPACE="5"
ALT="提示"/></TD
><TD
ALIGN="LEFT"
VALIGN="TOP"
><P
>For larger blocks of code that I want to comment and un-comment regularly (eg, debug code),
I like to use comments in this style:</P
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="90%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
>/* debug code ------------- //
echo "This is debug code";
...
// ---------------------- */</PRE
></FONT
></TD
></TR
></TABLE
><P
>You can easily uncoment the whole block by changing the /* to //, and vice versa.</P
></TD
></TR
></TABLE
></DIV
></LI
><LI
><P
>书写规范</P
><P
></P
><OL
TYPE="1"
><LI
><P
>可以用c++风格注释"//",或者用c风格"/* */";</P
></LI
><LI
><P
>注释最好用英文,英文困难找翻译;</P
></LI
><LI
><P
>文件头注释结构:为块注释。参见:<A
HREF="http://www.doxygen.org/"
TARGET="_top"
>Doxygen 的风格</A
>。</P
></LI
><LI
><P
>函数前注释结构:为块注释。注名功能。如果参数名不能表达意义,还要说明参数意义。</P
></LI
><LI
><P
>块注释写法:</P
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="90%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
> /*
* a space before *
*/</PRE
></FONT
></TD
></TR
></TABLE
><P
>或者</P
><TABLE
BORDER="1"
BGCOLOR="#E0E0E0"
WIDTH="90%"
><TR
><TD
><FONT
COLOR="#000000"
><PRE
CLASS="SCREEN"
> /* have a space after
three spaces before */</PRE
></FONT
></TD
></TR
></TABLE
></LI
></OL
></LI
></UL
></DIV
><DIV
CLASS="SECT2"
><H2
CLASS="SECT2"
><A
NAME="INDENT"
>3.5. 用 indent 进行代码格式化</A
></H2
><P
>一个范例,胜过前言万语。用 indent 格式化代码,再从格式化前后的格式变化,
来学习格式化规范。</P
><P
>可以用不同的参数调用 indent,</P
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="AEN276"
>3.5.1. introduce indent</A
></H3
><P
></P
><OL
TYPE="1"
><LI
><P
>What is Indent</P
><P
>The `indent' program can be used to make code easier to read. It can also convert from one style of writing C to another.</P
></LI
><LI
><P
>Download</P
><P
>Current Version: GNU indent 2.2.7。
Download : <A
HREF="ftp://ftp.gnu.org/gnu/indent/indent-2.2.7.tar.gz"
TARGET="_top"
>ftp.gnu.org/gnu/indent/indent-2.2.7.tar.gz</A
></P
></LI
></OL
></DIV
><DIV
CLASS="SECT3"
><H3
CLASS="SECT3"
><A
NAME="INDENT-OPT"
>3.5.2. Indent参数规范</A
></H3
><P
>我们参照GNU,Kernighan &amp; Ritchie,Berkeley风格,制定了自己风格:</P
><P
></P
><OL
TYPE="1"
><LI
><P
>indent命令参数:</P
><P
>-bad -bap -bbb -bbo -nbc -bl -bli0 -bls -c33 -cd33 -ncdb -ncdw -nce
-cli0 -cp33 -cs -d0 -nbfda -di2 -nfc1 -nfca -hnl -ip5 -l75 -lp -pcs -nprs
-psl -saf -sai -saw -nsc -nsob -nss -i4 -ts4 -ut</P
></LI
><LI
><P
>indent配置文件</P
><P
>如上参数可写入用户目录下的文件:".indent.pro",作为运行indent的确省参数。</P
></LI
><LI
><P
>indent配置说明</P
><DIV
CLASS="TABLE"
><A
NAME="AEN298"
></A
><P
><B
>表格 1. Indent代码格式化说明</B
></P
><TABLE
BORDER="1"
FRAME="border"
RULES="all"
CLASS="CALSTABLE"
><COL/><COL/><COL/><THEAD
><TR
><TH
ALIGN="CENTER"
>使用的indent参数</TH
><TH
ALIGN="CENTER"
>值</TH
><TH
ALIGN="CENTER"
>含义</TH
></TR
></THEAD
><TBODY
><TR
><TD
>--blank-lines-after-declarations</TD
><TD
>bad</TD
><TD
>变量声明后加空行</TD
></TR
><TR
><TD
>--blank-lines-after-procedures</TD
><TD
>bap</TD
><TD
>函数结束后加空行</TD
></TR
><TR
><TD
>--blank-lines-before-block-comments</TD
><TD
>bbb</TD
><TD
>块注释前加空行</TD
></TR
><TR
><TD
>--break-before-boolean-operator</TD
><TD
>bbo</TD
><TD
>较长的行,在逻辑运算符前分行</TD
></TR
><TR
><TD
>--blank-lines-after-commas</TD
><TD
>nbc</TD
><TD
>变量声明中,逗号分隔的变量不分行</TD
></TR
><TR
><TD
>--braces-after-if-line</TD
><TD
>bl</TD
><TD
>"if"和"{"分做两行</TD
></TR
><TR
><TD
>--brace-indent 0</TD
><TD
>bli0</TD
><TD
>"{"不继续缩进</TD
></TR
><TR
><TD
>--braces-after-struct-decl-line</TD
><TD
>bls</TD
><TD
>定义结构,"struct"和"{"分行</TD
></TR
><TR
><TD
>--comment-indentationn</TD
><TD
>c33</TD
><TD
>语句后注释开始于行33</TD
></TR
><TR
><TD
>--declaration-comment-columnn</TD
><TD
>cd33</TD
><TD
>变量声明后注释开始于行33</TD
></TR
><TR
><TD
>--comment-delimiters-on-blank-lines</TD
><TD
>ncdb</TD
><TD
>不将单行注释变为块注释</TD
></TR
><TR
><TD
>--cuddle-do-while</TD
><TD
>ncdw</TD
><TD
>"do --- while"的"while"和其前面的"}"另起一行</TD
></TR
><TR
><TD
>--cuddle-else</TD
><TD
>nce</TD
><TD
>"else"和其前面的"}"另起一行</TD
></TR
><TR
><TD
>--case-indentation 0</TD
><TD
>cli0</TD
><TD
>switch中的case语句所进0个空格</TD
></TR
><TR
><TD
>--else-endif-columnn</TD
><TD
>cp33</TD
><TD
>#else, #endif后面的注释开始于行33</TD
></TR
><TR
><TD
>--space-after-cast</TD
><TD
>cs</TD
><TD
>在类型转换后面加空格</TD
></TR
><TR
><TD
>--line-comments-indentation n</TD
><TD
>d0</TD
><TD
>单行注释(不从1列开始的),不向左缩进</TD
></TR
><TR
><TD
>--break-function-decl-args</TD
><TD
>nbfda</TD
><TD
>关闭:函数的参数一个一行</TD
></TR
><TR
><TD
>--declaration-indentationn</TD
><TD
>di2</TD
><TD
>变量声明,变量开始于2行,即不必对齐</TD
></TR
><TR
><TD
>--format-first-column-comments</TD
><TD
>nfc1</TD
><TD
>不格式化起于第一行的注释</TD
></TR
><TR
><TD
>--format-all-comments</TD
><TD
>nfca</TD
><TD
>不开启全部格式化注释的开关</TD
></TR
><TR
><TD
>--honour-newlines</TD
><TD
>hnl</TD
><TD
>Prefer to break long lines at the position of newlines in the input.</TD
></TR
><TR
><TD
>--indent-leveln</TD
><TD
>i4</TD
><TD
>设置缩进多少字符,如果为tab的整数倍,用tab来缩进,否则用空格填充。</TD
></TR
><TR
><TD
>--parameter-indentationn</TD
><TD
>ip5</TD
><TD
>旧风格的函数定义中参数说明缩进5个空格</TD
></TR
><TR
><TD
>--line-length 75</TD
><TD
>l75</TD
><TD
>非注释行最长75</TD
></TR
><TR
><TD
>--continue-at-parentheses</TD
><TD
>lp</TD
><TD
>续行从上一行出现的括号开始</TD
></TR
><TR
><TD
>--space-after-procedure-calls</TD
><TD
>pcs</TD
><TD
>函数和"("之间插入一个空格</TD
></TR
><TR
><TD
>--space-after-parentheses</TD
><TD
>nprs</TD
><TD
>在"("后")"前不插入空格</TD
></TR
><TR
><TD
>--procnames-start-lines</TD
><TD
>psl</TD
><TD
>将函数名和返回类型放在两行定义</TD
></TR
><TR
><TD
>--space-after-for</TD
><TD
>saf</TD
><TD
>for后面有空格</TD
></TR
><TR
><TD
>--space-after-if</TD
><TD
>sai</TD
><TD
>if后面有空格</TD
></TR
><TR
><TD
>--space-after-while</TD
><TD
>saw</TD
><TD
>while后面有空格</TD
></TR
><TR
><TD
>--start-left-side-of-comments</TD
><TD
>nsc</TD
><TD
>不在生成的块注释中加*</TD
></TR
><TR
><TD
>--swallow-optional-blank-lines</TD
><TD
>nsob</TD
><TD
>不去掉可添加的空行</TD
></TR
><TR
><TD
>--space-special-semicolon</TD
><TD
>nss</TD
><TD
>一行的for或while语句,在";"前不加空。</TD
></TR
><TR
><TD
>--tab-size</TD
><TD
>ts4</TD
><TD
>一个tab为4个空格(要能整除"-in")</TD
></TR
><TR
><TD
>--use-tabs</TD
><TD
>ut</TD
><TD
>使用tab来缩进</TD
></TR
></TBODY
></TABLE
></DIV
></LI
></OL
><P
>indent详细参数以及各种编程排版风格见: <A
HREF="appendix-indent.html"
>附录</A
>。</P
></DIV
></DIV
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"/><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="naming.html"
ACCESSKEY="P"
>后退</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起点</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="makefile.html"
ACCESSKEY="N"
>前进</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>命名规范</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>Makefile</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>




<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML
><HEAD
><TITLE
>不同编程风格参考</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.7"/><LINK
REV="MADE"
HREF="mailto:johnson.AT.worldhello.net"/><LINK
REL="HOME"
TITLE="开发规范参考"
HREF="index.html"/><LINK
REL="PREVIOUS"
TITLE="用DocBook来写文档"
HREF="docbook.html"/><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="../images/docbook.css"/><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=gb2312"/></HEAD
><BODY
CLASS="APPENDIX"
BGCOLOR="#FFFFFF"
TEXT="#000000"
LINK="#0000FF"
VLINK="#840084"
ALINK="#0000FF"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="3"
ALIGN="center"
>开发规范参考</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="bottom"
><A
HREF="docbook.html"
ACCESSKEY="P"
>后退</A
></TD
><TD
WIDTH="80%"
ALIGN="center"
VALIGN="bottom"
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="bottom"
>&nbsp;</TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"/></DIV
><DIV
CLASS="APPENDIX"
><H1
CLASS="APPENDIX"
><A
NAME="APPENDIX-INDENT"
>A. 不同编程风格参考</A
></H1
><P
>通过indent参数分析,比较自定义风格和GNU,KR,BSD编程风格。</P
><DIV
CLASS="TABLE"
><A
NAME="AEN478"
></A
><P
><B
>表格 A-1. 自定义风格和GNU,KR,BSD风格比较</B
></P
><TABLE
BORDER="1"
FRAME="border"
RULES="all"
CLASS="CALSTABLE"
><COL/><COL/><COL/><COL/><COL/><COL/><THEAD
><TR
><TH
ALIGN="CENTER"
>参数</TH
><TH
ALIGN="CENTER"
>含义</TH
><TH
ALIGN="CENTER"
>我们的风格</TH
><TH
ALIGN="CENTER"
>GNU风格</TH
><TH
ALIGN="CENTER"
>KR风格</TH
><TH
ALIGN="CENTER"
>BSD风格</TH
></TR
></THEAD
><TBODY
><TR
><TD
>-bad</TD
><TD
>--blank-lines-after-declarations</TD
><TD
>y</TD
><TD
>n</TD
><TD
>n</TD
><TD
>n</TD
></TR
><TR
><TD
>-bap</TD
><TD
>--blank-lines-after-procedures</TD
><TD
>y</TD
><TD
>y</TD
><TD
>y</TD
><TD
>n</TD
></TR
><TR
><TD
>-bbb</TD
><TD
>--blank-lines-before-block-comments</TD
><TD
>y</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-bbo</TD
><TD
>--break-before-boolean-operator</TD
><TD
>y</TD
><TD
>y</TD
><TD
>y</TD
><TD
>y</TD
></TR
><TR
><TD
>-bc</TD
><TD
>--blank-lines-after-commas</TD
><TD
>n</TD
><TD
>n</TD
><TD
>n</TD
><TD
>y</TD
></TR
><TR
><TD
>-bl</TD
><TD
>--braces-after-if-line</TD
><TD
>y</TD
><TD
>y</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-blin</TD
><TD
>--brace-indent n</TD
><TD
>0</TD
><TD
>2</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-bls</TD
><TD
>--braces-after-struct-decl-line</TD
><TD
>y</TD
><TD
>y</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-br</TD
><TD
>--braces-on-if-line</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>y</TD
><TD
>y</TD
></TR
><TR
><TD
>-brs</TD
><TD
>--braces-on-struct-decl-line</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>y</TD
><TD
>y</TD
></TR
><TR
><TD
>-bs</TD
><TD
>--blank-before-sizeof</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-cn</TD
><TD
>--comment-indentationn</TD
><TD
>33</TD
><TD
>&nbsp;</TD
><TD
>33</TD
><TD
>33</TD
></TR
><TR
><TD
>-cbin</TD
><TD
>--case-brace-indentationn</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-cdn</TD
><TD
>--declaration-comment-columnn</TD
><TD
>33</TD
><TD
>&nbsp;</TD
><TD
>33</TD
><TD
>33</TD
></TR
><TR
><TD
>-cdb</TD
><TD
>--comment-delimiters-on-blank-lines</TD
><TD
>n</TD
><TD
>n</TD
><TD
>n</TD
><TD
>y</TD
></TR
><TR
><TD
>-cdw</TD
><TD
>--cuddle-do-while</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-ce</TD
><TD
>--cuddle-else</TD
><TD
>n</TD
><TD
>n</TD
><TD
>n</TD
><TD
>y</TD
></TR
><TR
><TD
>-cin</TD
><TD
>--continuation-indentationn</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>4</TD
><TD
>4</TD
></TR
><TR
><TD
>-clin</TD
><TD
>--case-indentationn</TD
><TD
>0</TD
><TD
>&nbsp;</TD
><TD
>0</TD
><TD
>0</TD
></TR
><TR
><TD
>-cpn</TD
><TD
>--else-endif-columnn</TD
><TD
>33</TD
><TD
>1</TD
><TD
>33</TD
><TD
>33</TD
></TR
><TR
><TD
>-cs</TD
><TD
>--space-after-cast</TD
><TD
>y</TD
><TD
>y</TD
><TD
>y</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-dn</TD
><TD
>--line-comments-indentationn</TD
><TD
>0</TD
><TD
>&nbsp;</TD
><TD
>0</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-ndj</TD
><TD
>indents declarations the same as code </TD
><TD
>&nbsp;</TD
><TD
>y</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-bfda</TD
><TD
>--break-function-decl-args</TD
><TD
>n</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-din</TD
><TD
>--declaration-indentationn</TD
><TD
>2</TD
><TD
>2</TD
><TD
>1</TD
><TD
>16</TD
></TR
><TR
><TD
>-fc1</TD
><TD
>--format-first-column-comments</TD
><TD
>n</TD
><TD
>n</TD
><TD
>n</TD
><TD
>y</TD
></TR
><TR
><TD
>-fca</TD
><TD
>--format-all-comments</TD
><TD
>n</TD
><TD
>n</TD
><TD
>n</TD
><TD
>y</TD
></TR
><TR
><TD
>-gnu</TD
><TD
>--gnu-style</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-hnl</TD
><TD
>--honour-newlines</TD
><TD
>y</TD
><TD
>y</TD
><TD
>y</TD
><TD
>y</TD
></TR
><TR
><TD
>-in</TD
><TD
>--indent-leveln</TD
><TD
>4</TD
><TD
>2</TD
><TD
>4</TD
><TD
>4</TD
></TR
><TR
><TD
>-ipn</TD
><TD
>--parameter-indentationn</TD
><TD
>5</TD
><TD
>5</TD
><TD
>0</TD
><TD
>4</TD
></TR
><TR
><TD
>-kr</TD
><TD
>--k-and-r-style</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-ln</TD
><TD
>--line-lengthn</TD
><TD
>75</TD
><TD
>&nbsp;</TD
><TD
>75</TD
><TD
>75</TD
></TR
><TR
><TD
>-cs</TD
><TD
>--space-after-cast</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-dn</TD
><TD
>--line-comments-indentationn</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-bfda</TD
><TD
>--break-function-decl-args</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-din</TD
><TD
>--declaration-indentationn</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-fc1</TD
><TD
>--format-first-column-comments</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-fca</TD
><TD
>--format-all-comments</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-gnu</TD
><TD
>--gnu-style</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-hnl</TD
><TD
>--honour-newlines</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-in</TD
><TD
>--indent-leveln</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-ipn</TD
><TD
>--parameter-indentationn</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-kr</TD
><TD
>--k-and-r-style</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-ln</TD
><TD
>--line-lengthn</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-lcn</TD
><TD
>--comment-line-lengthn</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-lp</TD
><TD
>--continue-at-parentheses</TD
><TD
>y</TD
><TD
>&nbsp;</TD
><TD
>y</TD
><TD
>y</TD
></TR
><TR
><TD
>-lps</TD
><TD
>--leave-preprocessor-space</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-orig</TD
><TD
>--original</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-npro</TD
><TD
>--ignore-profile</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-pcs</TD
><TD
>--space-after-procedure-calls</TD
><TD
>y</TD
><TD
>y</TD
><TD
>n</TD
><TD
>n</TD
></TR
><TR
><TD
>-pin</TD
><TD
>--paren-indentationn</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-pmt</TD
><TD
>--preserve-mtime</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-prs</TD
><TD
>--space-after-parentheses</TD
><TD
>n</TD
><TD
>n</TD
><TD
>n</TD
><TD
>n</TD
></TR
><TR
><TD
>-psl</TD
><TD
>--procnames-start-lines</TD
><TD
>y</TD
><TD
>y</TD
><TD
>n</TD
><TD
>y</TD
></TR
><TR
><TD
>-saf</TD
><TD
>--space-after-for</TD
><TD
>y</TD
><TD
>y</TD
><TD
>y</TD
><TD
>y</TD
></TR
><TR
><TD
>-sai</TD
><TD
>--space-after-if</TD
><TD
>y</TD
><TD
>y</TD
><TD
>y</TD
><TD
>y</TD
></TR
><TR
><TD
>-saw</TD
><TD
>--space-after-while</TD
><TD
>y</TD
><TD
>y</TD
><TD
>y</TD
><TD
>y</TD
></TR
><TR
><TD
>-sbin</TD
><TD
>--struct-brace-indentationn</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-sc</TD
><TD
>--start-left-side-of-comments</TD
><TD
>n</TD
><TD
>n</TD
><TD
>n</TD
><TD
>y</TD
></TR
><TR
><TD
>-sob</TD
><TD
>--swallow-optional-blank-lines</TD
><TD
>n</TD
><TD
>n</TD
><TD
>n</TD
><TD
>n</TD
></TR
><TR
><TD
>-ss</TD
><TD
>--space-special-semicolon</TD
><TD
>n</TD
><TD
>&nbsp;</TD
><TD
>n</TD
><TD
>n</TD
></TR
><TR
><TD
>-st</TD
><TD
>--standard-output</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-T typenames</TD
><TD
>Tell indent the name of typenames.</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-tsn</TD
><TD
>--tab-sizen</TD
><TD
>4</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>8</TD
></TR
><TR
><TD
>-ut</TD
><TD
>--use-tabs</TD
><TD
>y</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-v</TD
><TD
>--verbose</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
><TR
><TD
>-version</TD
><TD
>Output the version number of indent.</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
><TD
>&nbsp;</TD
></TR
></TBODY
></TABLE
></DIV
><P
>$Date: 2003/07/16 06:11:53 $</P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"/><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="docbook.html"
ACCESSKEY="P"
>后退</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>起点</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>&nbsp;</TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>用DocBook来写文档</TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
>&nbsp;</TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
>&nbsp;</TD
></TR
></TABLE
></DIV
></BODY
></HTML>





不要问我结果 我只研究过程与思路
无双客栈
顶部
Bell
LU天使
Rank: 4
三军总司令



UID 1782
精华 9
积分 699
帖子 1361
活跃指数 0
LU金币 2006 个
LU金条 0 个
阅读权限 50
注册 2003-11-6
来自 MIT
 
发表于 2004-2-11 17:01  资料  个人空间  主页 短消息  加为好友 
QUOTE(无双 @ 2004-02-11 09:52:43)
缩进用tab,不用空格;
一个tab定义为四个空格,原因见后面表格;
标点符号的右边留一个空格(左括号除外);
赋值、判断、运算符号两边都要加一个空格;
空行也是注释,适当的空行使逻辑更清楚,函数内部不应该有连续空行,函数之间至少有两个连续空行;

哎,这就是我的毛病啊。 awkard.gif





Ensemble à tout jamais!
user posted imageuser posted image
顶部
 



当前时区 GMT+8, 现在时间是 2008-10-7 22:35
乐悠LoveUnix论坛-京ICP备05005823号

Thanks to Discuz!  © 2001-2007    Power by LoveUnix.net
Processed in 0.051324 second(s), 6 queries , Gzip enabled

清除 Cookies - 联系我们 - 乐悠LoveUnix - Archiver