   Copyright (C) 1996 Aladdin Enterprises.  All rights reserved.
  
  This file is part of Aladdin Ghostscript.
  
  Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  or distributor accepts any responsibility for the consequences of using it,
  or for whether it serves any particular purpose or works at all, unless he
  or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  License (the "License") for full details.
  
  Every copy of Aladdin Ghostscript must include a copy of the License,
  normally in a plain ASCII text file named PUBLIC.  The License grants you
  the right to copy, modify and redistribute Aladdin Ghostscript, but only
  under certain conditions described in the License.  Among other things, the
  License requires that the copyright notice and this notice be preserved on
  all copies.

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

This file, c-style.txt, describes Aladdin's C coding guidelines.

For an overview of Ghostscript and a list of the documentation files, see
README.

Generalities
============

All the rules below are meant to produce code that is easy to read.  If you
find a rule getting in your way or producing ugly-looking results once in a
while, it's OK to break it.

Indentation
-----------

Tab stops are set every 8 columns.

C code
======

Indentation
-----------

Put the first indentation point at the first tab stop.  Then proceed as
follows:

	{ ... in-line compound statement ...
	}
	... construct requiring subordinate code ...
	  ... subordinate simple statement ...
	... construct requiring subordinate code ...
	  { ... subordinate code ...
	  }

Spaces
------

Do put a space:
	- after every comma and semicolon, unless it ends a line;
	- around every binary operator, although you can omit the spaces
	around the innermost operator in a nested expression if you like;
	- on both sides of the the parentheses of an if, for, or while.

Don't put a space:
	- at the end of a line;
	- before a comma or semicolon;
	- after unary prefix operators;
	- before the parenthesis of a macro or procedure call.

Types
-----

Use 'private' instead of 'static' for constructs (procedures and variables)
declared at the outermost scope.  This allows making such constructs either
visible or invisible to profilers with a single changed #define.

Use const wherever possible and appropriate.

Avoid global variables (non-const data) like the plague.  Avoid global const
data, but don't knock yourself out over it.

If you find yourself wanting to use void *, try to find an alternative using
unions or (in the case of super- and subclasses) casts.

Other
-----

Format procedures as follows:

scope return_type
proc_name(type1 arg1, type2 arg2, type3 arg4, type4 verylongargument4,
  type5 argument5)
{	... body ...
}

Leave a blank line after the declarations of local variables in a procedure
or compound statement, unless there's only 1 variable and the scope is less
than 10 lines or so.

PostScript code
===============

Put indentation points every 3 spaces.

Format procedure definitions like this:

/procname		% <arg1> <arg2> procname <result1> <result2>
 { ...code...
 } bind def
