www.delorie.com/djgpp/doc/kb/kb_13.html   search  
DJGPP Knowledge Base

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

5.3.1 Source indentation

Most of the DJGPP sources are formatted in a standard way; please observe and preserve this formatting when writing new code.

The indentation style generally looks like this:

 
 if (foo)
 {
   bar(baz);
 }

That is, the braces are on a separate line and in the same column as the if (or for, or while) clause that opens the block.

Here's how to set up Emacs's C Mode for this indentation style:

 
(c-add-style
 "DJ"
 '((c-basic-offset . 2)
   (c-comment-only-line-offset . (0 . 0))
   (c-offsets-alist . ((substatement-open . 0)
		       (label . 0)
		       (statement-case-open . +)
		       (statement-cont . +)
		       (arglist-intro . c-lineup-arglist-intro-after-paren)
		       (arglist-close . c-lineup-arglist)
		       ))
   ))

(c-set-style "DJ")

And here's the list of options for the GNU indent program, to be put on your `.indent.pro' profile file, in case you need to reformat your sources to comply with the DJGPP style:

 
/* DJ */
-nbad -bap -nbc -bbo -bl -bli0 -brs -ncdb -nce -cp1 -cs -di2
-nfc1 -fca -hnl -i2 -ip2 -ci0 -lp -npcs -nprs -psl -nsc -nsob


  webmaster   donations   bookstore     delorie software   privacy  
  Copyright © 2004   by DJ Delorie     Updated Nov 2004  

Please take a moment to fill out this visitor survey
You can help support this site by visiting the advertisers that sponsor it! (only once each, though)