+++ /dev/null
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<!--Converted with LaTeX2HTML 2002-2-1 (1.71)
-original version by: Nikos Drakos, CBLU, University of Leeds
-* revised and updated by: Marcus Hennecke, Ross Moore, Herb Swan
-* with significant contributions from:
- Jens Lippmann, Marek Rouchal, Martin Wilck and others -->
-<HTML>
-<HEAD>
-<TITLE>5 C coding style</TITLE>
-<META NAME="description" CONTENT="5 C coding style">
-<META NAME="keywords" CONTENT="ionnotes">
-<META NAME="resource-type" CONTENT="document">
-<META NAME="distribution" CONTENT="global">
-
-<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
-<META NAME="Generator" CONTENT="LaTeX2HTML v2002-2-1">
-<META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css">
-
-<LINK REL="STYLESHEET" HREF="ionnotes.css">
-
-<LINK REL="next" HREF="node7.html">
-<LINK REL="previous" HREF="node5.html">
-<LINK REL="up" HREF="ionnotes.html">
-<LINK REL="next" HREF="node7.html">
-</HEAD>
-
-<BODY >
-
-<DIV CLASS="navigation"><!--Navigation Panel-->
-<A NAME="tex2html149"
- HREF="node7.html">
-<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A>
-<A NAME="tex2html143"
- HREF="ionnotes.html">
-<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A>
-<A NAME="tex2html137"
- HREF="node5.html">
-<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A>
-<A NAME="tex2html145"
- HREF="node1.html">
-<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>
-<A NAME="tex2html147"
- HREF="node8.html">
-<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A>
-<BR>
-<B> Next:</B> <A NAME="tex2html150"
- HREF="node7.html">A. The GNU General</A>
-<B> Up:</B> <A NAME="tex2html144"
- HREF="ionnotes.html">Ion: Notes for the</A>
-<B> Previous:</B> <A NAME="tex2html138"
- HREF="node5.html">4 Miscellaneous design notes</A>
- <B> <A NAME="tex2html146"
- HREF="node1.html">Contents</A></B>
- <B> <A NAME="tex2html148"
- HREF="node8.html">Index</A></B>
-<BR>
-<BR></DIV>
-<!--End of Navigation Panel-->
-<!--Table of Child-Links-->
-<A NAME="CHILD_LINKS"><STRONG>Subsections</STRONG></A>
-
-<UL CLASS="ChildLinks">
-<LI><A NAME="tex2html151"
- HREF="node6.html#SECTION00061000000000000000"><SPAN CLASS="arabic">5</SPAN>.<SPAN CLASS="arabic">1</SPAN> Whitespace</A>
-<LI><A NAME="tex2html152"
- HREF="node6.html#SECTION00062000000000000000"><SPAN CLASS="arabic">5</SPAN>.<SPAN CLASS="arabic">2</SPAN> Braces</A>
-<LI><A NAME="tex2html153"
- HREF="node6.html#SECTION00063000000000000000"><SPAN CLASS="arabic">5</SPAN>.<SPAN CLASS="arabic">3</SPAN> Names</A>
-<LI><A NAME="tex2html154"
- HREF="node6.html#SECTION00064000000000000000"><SPAN CLASS="arabic">5</SPAN>.<SPAN CLASS="arabic">4</SPAN> Miscellaneous</A>
-</UL>
-<!--End of Table of Child-Links-->
-<HR>
-
-<H1><A NAME="SECTION00060000000000000000">
-<SPAN CLASS="arabic">5</SPAN> C coding style</A>
-</H1>
-
-<P>
-If you want to submit patches to Ion, you <SPAN CLASS="textbf">must</SPAN> follow my coding
-style, even if you think it is the root of all evil. We don't want
-the code to be an incomprehensible mess of styles and I have better
-things to do than fix other people's style to match mine. The style
-should be obvious by studying the source, but here's a list of some
-things to take note of.
-
-<P>
-
-<H2><A NAME="SECTION00061000000000000000">
-<SPAN CLASS="arabic">5</SPAN>.<SPAN CLASS="arabic">1</SPAN> Whitespace</A>
-</H2>
-
-<P>
-
-<UL>
-<LI>Indentations of 4 with spaces.
-
-<P>
-</LI>
-<LI>No extra spaces between operators, delimiters etc. except
-
-<UL>
-<LI>around logical and, or (<TT>&&</TT>, <TT>||</TT>)
-</LI>
-<LI>around the conditional <TT>a ? b : c</TT>
-</LI>
-<LI>after commas and semicolons
-
-</LI>
-</UL>
- In my opinion this helps pointing out arithmetic or other
- expressions within logical expressions or parameter lists.
-
-<P>
-</LI>
-<LI>All kinds of labels are out-tended to the level of the higher
- level block. For example:
-
-<P>
-<PRE>
-void foo()
-{
-again:
- switch(asdf){
- case 1:
- ...
- break;
- default:
- ...
- break;
- }
-}
-</PRE>
-</LI>
-</UL>
-
-<P>
-
-<H2><A NAME="SECTION00062000000000000000">
-<SPAN CLASS="arabic">5</SPAN>.<SPAN CLASS="arabic">2</SPAN> Braces</A>
-</H2>
-
-<P>
-
-<UL>
-<LI>Opening brace is at the end of the line, except in function
- bodies, where it is at the beginning of the line following
- the definition.
-
-<P>
-</LI>
-<LI>Never put the body of a control statement on the same line
- with the statement (e.g. <code>if(foo){ bar() }</code>).
-
-<P>
-For example, the block
-<PRE>
-void foo(int a, int b)
-{
- if(a==b && c+d==e){
- ...
- }
-}
-</PRE>
-
-<P>
-has correct style while the block
-
-<P>
-<PRE>
-void foo(int a,int b) {
- if (a == b && c + d == e) {
- ...
- }
-}
-</PRE>
-
-<P>
-does not.
-
-<P>
-</LI>
-<LI>The <TT>else</TT> keyword follows immediately after the closing brace of
- previous <TT>if</TT>, if any. (This might change so I don't care if you put
- it on the next line.)
-
-<P>
-</LI>
-<LI>I have used the convention that control statement bodies containing
- a single statement do not need braces around the block if, in case of
- the <TT>if</TT> all the blocks in <TT>if ... else if ... else</TT>
- contain just one statement. If you want to, just use braces in every
- case.
-</LI>
-</UL>
-
-<P>
-
-<H2><A NAME="SECTION00063000000000000000">
-<SPAN CLASS="arabic">5</SPAN>.<SPAN CLASS="arabic">3</SPAN> Names</A>
-</H2>
-
-<P>
-
-<UL>
-<LI>Function and variable names only have lower case letters. Type
- names are in mixed case while constants and macros (<TT>#define</TT>s)
- are in upper case letters.
-</LI>
-</UL>
-
-<P>
-
-<H2><A NAME="SECTION00064000000000000000">
-<SPAN CLASS="arabic">5</SPAN>.<SPAN CLASS="arabic">4</SPAN> Miscellaneous</A>
-</H2>
-
-<P>
-
-<UL>
-<LI>In the definition of a pointer variable, the asterisk is attached
- to the variable name: <TT>char *s;</TT>. (One could claim this an
- exception to the second rule.)
-
-<P>
-</LI>
-<LI>You might optionally want to use Jed's foldings to group blocks
- of related code in a file to keep it organized:
-
-<P>
-<PRE>
-/*{{{ Many related functions */
-
-void code()
-{
- ...
-}
-
-...
-
-/*}}}*/
-</PRE>
-</LI>
-</UL>
-
-<P>
-I think that's mostly it. Study the source when in doubt.
-
-<P>
-
-<P>
-
-<DIV CLASS="navigation"><HR>
-<!--Navigation Panel-->
-<A NAME="tex2html149"
- HREF="node7.html">
-<IMG WIDTH="37" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="next" SRC="next.png"></A>
-<A NAME="tex2html143"
- HREF="ionnotes.html">
-<IMG WIDTH="26" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="up" SRC="up.png"></A>
-<A NAME="tex2html137"
- HREF="node5.html">
-<IMG WIDTH="63" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="previous" SRC="prev.png"></A>
-<A NAME="tex2html145"
- HREF="node1.html">
-<IMG WIDTH="65" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="contents" SRC="contents.png"></A>
-<A NAME="tex2html147"
- HREF="node8.html">
-<IMG WIDTH="43" HEIGHT="24" ALIGN="BOTTOM" BORDER="0" ALT="index" SRC="index.png"></A>
-<BR>
-<B> Next:</B> <A NAME="tex2html150"
- HREF="node7.html">A. The GNU General</A>
-<B> Up:</B> <A NAME="tex2html144"
- HREF="ionnotes.html">Ion: Notes for the</A>
-<B> Previous:</B> <A NAME="tex2html138"
- HREF="node5.html">4 Miscellaneous design notes</A>
- <B> <A NAME="tex2html146"
- HREF="node1.html">Contents</A></B>
- <B> <A NAME="tex2html148"
- HREF="node8.html">Index</A></B> </DIV>
-<!--End of Navigation Panel-->
-
-</BODY>
-</HTML>