With the body of functions, this is the way we aim to do it. We are not religious about it, but consistency helps. We use an indentation form that is known as the BSD c style. If you think your way is smarter, you may be right but this is the way we do it ;-). The format is also pretty close to the one you find in The C Programming Language by Kernighan and Ritchie.
if
,
while
, etc which affects the block
for (i=0; i<2; i++) { HTList *cur = conversions[i]; HTPresentation *pres; while ((pres =(HTPresentation *) HTList_nextObject(cur))) { if (pres->rep_out == WWW_PRESENT) { if (pres->quality != 1.0) { sprintf(line, "Accept: %s; q=%.3f%c%c", HTAtom_name(pres->rep), pres->quality, CR, LF); } else { sprintf(line, "Accept: %s%c%c", HTAtom_name(pres->rep), CR, LF); } HTChunkPuts(command, line); } } }
You can get your emacs to do automatic indentation according to those rules
by adding the following to your local .emacs
file:
;; C style indentation ;; ===================== (defun w3c-c-mode-common-hook () ;; use BSD for all C, C++, and Objective-C code (c-set-style "BSD") ;; other customizations can go here (setq c-tab-always-indent nil) ) (add-hook 'c-mode-common-hook 'w3c-c-mode-common-hook)
/* ** This is a comment that spans several lines. If you want to do this ** then please use the comment markers as indicated. Do not use ** C++ style comments - they are not portable */
Remember to use comments in the source code - it makes life easier for everybody