| 1 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" |
| 2 |
"http://www.w3.org/TR/REC-html40/loose.dtd"> |
| 3 |
|
| 4 |
<HTML> |
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
<HEAD> |
| 31 |
<TITLE>3.3 Coding Style</TITLE> |
| 32 |
<STYLE TYPE="text/css"> <!-- A {text-decoration: none} // --> </STYLE> |
| 33 |
</HEAD> |
| 34 |
<BODY BACKGROUND="binary/background.gif" |
| 35 |
BGCOLOR="#FFFFFF" |
| 36 |
TEXT="#000000" |
| 37 |
VLINK="#660000" |
| 38 |
LINK="#FF0000" |
| 39 |
ALINK="#CC0000"> |
| 40 |
|
| 41 |
<TABLE WIDTH="490"> |
| 42 |
<TR> |
| 43 |
<TD WIDTH="130" VALIGN="top"> |
| 44 |
<IMG SRC="binary/d_clear.gif" ALT="" WIDTH="130" HEIGHT="1"><BR> |
| 45 |
|
| 46 |
<FONT SIZE="2"> |
| 47 |
<BR> |
| 48 |
|
| 49 |
<A HREF="http://www.ross.net/" |
| 50 |
TARGET="rosshome" |
| 51 |
onClick="window.open('','rosshome','location,status,menubar,scrollbars,resizable',false).focus(); return true;" |
| 52 |
> |
| 53 |
<IMG SRC="binary/rossnet_logo.gif" |
| 54 |
WIDTH="64" HEIGHT="32" |
| 55 |
BORDER="0" ALT="RossNet" |
| 56 |
HSPACE="0" VSPACE="1"></A><BR> |
| 57 |
<BR> |
| 58 |
|
| 59 |
<A HREF="../index.shtml" |
| 60 |
TARGET="funnelweb" |
| 61 |
onClick="window.open('','funnelweb','location,status,menubar,scrollbars,resizable',false).focus(); return true;" |
| 62 |
> |
| 63 |
<IMG SRC="binary/linklogo.gif" |
| 64 |
WIDTH="64" HEIGHT="32" |
| 65 |
BORDER="0" ALT="FunnelWeb" |
| 66 |
HSPACE="0" VSPACE="1"></A><BR> |
| 67 |
<BR> |
| 68 |
<TABLE CELLSPACING=0 CELLPADDING=0 BORDER=0><TR><TD BGCOLOR="#000000"> |
| 69 |
<A HREF="../reference/index.html" |
| 70 |
TARGET="funnelwebreference" |
| 71 |
onClick="window.open('','funnelwebreference','location,status,menubar,scrollbars,resizable',false).focus(); return true;" |
| 72 |
><FONT COLOR="#FFFFFF"><B>Reference</B></FONT></A><BR> |
| 73 |
<BR> |
| 74 |
<A HREF="../tutorial/index.html" |
| 75 |
TARGET="funnelwebtutorial" |
| 76 |
onClick="window.open('','funnelwebtutorial','location,status,menubar,scrollbars,resizable',false).focus(); return true;" |
| 77 |
><FONT COLOR="#FFFFFF"><B>Tutorial</B></FONT></A><BR> |
| 78 |
<BR> |
| 79 |
<A HREF="index.html"><FONT COLOR="#FFFFFF"><B>Developer</B></FONT></A><BR> |
| 80 |
<A HREF="compile.html"><FONT COLOR="#FFFFFF">1 Compile</FONT></A><BR> |
| 81 |
<A HREF="design.html"><FONT COLOR="#FFFFFF">2 Design</FONT></A><BR> |
| 82 |
<A HREF="implement.html"><FONT COLOR="#FFFFFF">3 Implement</FONT></A><BR> |
| 83 |
<A HREF="modify.html"><FONT COLOR="#FFFFFF">4 Modify</FONT></A><BR> |
| 84 |
<A HREF="misc.html"><FONT COLOR="#FFFFFF">5 Misc</FONT></A><BR> |
| 85 |
<A HREF="gpl.html"><FONT COLOR="#FFFFFF">6 Licence</FONT></A><BR> |
| 86 |
|
| 87 |
<BR> |
| 88 |
<A HREF="search.html"><FONT COLOR="#FFFFFF"><B>SEARCH</B></FONT></A><BR> |
| 89 |
</FONT> |
| 90 |
</TD></TR></TABLE> |
| 91 |
|
| 92 |
|
| 93 |
</TD> |
| 94 |
<TD WIDTH="360" VALIGN="top"> |
| 95 |
<FONT SIZE="3"> |
| 96 |
|
| 97 |
|
| 98 |
<A HREF="index.html"><IMG SRC="binary/title.gif" |
| 99 |
WIDTH="316" HEIGHT="24" |
| 100 |
BORDER="0" ALT="FunnelWeb Developer Manual" |
| 101 |
HSPACE="0" VSPACE="0"></A> |
| 102 |
<P><FONT SIZE="5">3.3 Coding Style</FONT><BR> |
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
<P>Although FunnelWeb wasn't coded under any formal C |
| 107 |
coding standard, it was coded in accordance with a fairly |
| 108 |
strict personal style of C which developed during the |
| 109 |
development of FunnelWeb. This section aims to describe some |
| 110 |
of the more important elements of the coding style. |
| 111 |
|
| 112 |
<P><B>Portability:</B> This was a major |
| 113 |
goal of the FunnelWeb implementation. Two excellent books |
| 114 |
guided this move to portability. They were |
| 115 |
<STRONG>[Rabinowitz90]</STRONG> (which deals with C code itself) |
| 116 |
and <STRONG>[Horton90]</STRONG> (which deals with the portability |
| 117 |
of various library calls). Other works such as |
| 118 |
<STRONG>[Kernighan88]</STRONG> and <STRONG>[ANSI]</STRONG> were also |
| 119 |
helpful. |
| 120 |
|
| 121 |
<P><B>Identifiers:</B> |
| 122 |
<STRONG>[Rabinowitz90]</STRONG> |
| 123 |
specifies that for wide portability, identifiers of block |
| 124 |
and file scope should be unique to eight characters, and |
| 125 |
identifiers of program scope should be unique to six |
| 126 |
characters. I have gone further in FunnelWeb and actually |
| 127 |
made these restrictions actual limits on identifier length. |
| 128 |
|
| 129 |
<P>Because names must be so short, a system of |
| 130 |
abbreviations was developed to organize the identifiers used |
| 131 |
within FunnelWeb. Each abbreviation consists of a letter |
| 132 |
pair. Here are most of the abbreviations |
| 133 |
used: |
| 134 |
|
| 135 |
<P> |
| 136 |
<PRE> |
| 137 |
bp - Body Part. |
| 138 |
cm - Compare. Used to prefix comparison |
| 139 |
routines that return [-1,0,1]. |
| 140 |
dc - Document component. |
| 141 |
dm - Dump package. |
| 142 |
el - Element. |
| 143 |
eq - Equal. Used to prefix comparison |
| 144 |
routines that return a boolean. |
| 145 |
ex - Expression. |
| 146 |
f - Global files. |
| 147 |
ll - List of lists. |
| 148 |
ln - Line record. |
| 149 |
ls - List Package. |
| 150 |
lr - Lister package. |
| 151 |
ma - Macro. |
| 152 |
mc - Macro Call. |
| 153 |
mn - Macro Name. |
| 154 |
op - Options package. |
| 155 |
pr - Parser. |
| 156 |
ps - Position record. |
| 157 |
sc - Scrap record. |
| 158 |
sn - Section. |
| 159 |
tb - Table package. |
| 160 |
ty - Typesetter directive. |
| 161 |
wf - Write file package. |
| 162 |
wl - Write with EOL (misc.c). |
| 163 |
wr - Write (misc.c). |
| 164 |
</PRE> |
| 165 |
|
| 166 |
<P><B>Pointers:</B> Variables or types denoting |
| 167 |
pointers start with "<TT>p_</TT>". |
| 168 |
|
| 169 |
<P><B>Types:</B> Names denoting types end in |
| 170 |
"<TT>_t</TT>". Thus, a type for a pointer to a table would |
| 171 |
be named <SAMP>p_tb_t</SAMP>. |
| 172 |
|
| 173 |
<P><B>File names:</B> All FunnelWeb source |
| 174 |
files have file |
| 175 |
names that are from one to eight characters long and file |
| 176 |
extensions that are from one to three characters long. This |
| 177 |
ensures that the FunnelWeb source code can be portably moved |
| 178 |
to all kinds of machines, including MSDOS! |
| 179 |
|
| 180 |
|
| 181 |
<P> |
| 182 |
<TABLE WIDTH="100%"> |
| 183 |
<TR> |
| 184 |
<TD ALIGN="left" VALIGN="bottom"><A HREF="implement_self.html"><IMG SRC="binary/fw_left.gif" HEIGHT="32" WIDTH="32" BORDER="0" ALT="Prev"></A></TD> |
| 185 |
<TD ALIGN="center" VALIGN="bottom"><A HREF="implement.html"><IMG SRC="binary/fw_up.gif" HEIGHT="32" WIDTH="32" BORDER="0" ALT="Up"></A></TD> |
| 186 |
<TD ALIGN="right" VALIGN="bottom"><A HREF="implement_memory.html"><IMG SRC="binary/fw_right.gif" HEIGHT="32" WIDTH="32" BORDER="0" ALT="Next"></A></TD> |
| 187 |
</TR> |
| 188 |
</TABLE> |
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
<P> |
| 193 |
<HR> |
| 194 |
<FONT SIZE="2"> |
| 195 |
<A HREF="mailto:[email protected]">Webmaster</A> |
| 196 |
<A HREF="copyright.html">Copyright © Ross N. Williams 1992,1999. All rights reserved.</A><BR> |
| 197 |
</FONT> |
| 198 |
|
| 199 |
</FONT> |
| 200 |
</TD> |
| 201 |
</TR> |
| 202 |
</TABLE> |
| 203 |
|
| 204 |
|
| 205 |
</BODY> |
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
</HTML> |