Introduction
------------
This is part 1 of the style guide.  It concerns how the C/C++ syntax 
should be formated within a file.

Unified coding style is important because it eases software review 
and maintenance.  This file specifies guidelines which can be broken 
for specific cases, but should be adhered to as closely as possible.

Plastimatch can't be properly formatted automatically by GNU indent 
or astyle.  Uncrustify will do a decent job; an uncrustify configuration 
file is included in the distribution.

iles
-----
Source code files should use Unix-style end-of-line characters.
All source code should be written in 7-bit clean ASCII.

Third-party code
----------------
Third-party code should be placed in separate files, and should be 
clearly identified, so that no mistake in licensing occurs.

Indentation
-----------
Indentation should be 4 spaces.  Tabs are not allowed.
For Microsoft Visual Studio compilers, you should adjust your setting.

Line breaking
-------------
Code should be limited to 80 columns when possible.  Use typedefs to 
assist in this process.

Curly braces
------------
Use GNU curly brace style (curly on its own line) for function 
definitions, and K&R curly brace style (curly on same line as conditional)
everywhere else.

Always use curly braces for if/do/while/for statements, even if there 
is only one statement in the block.

For a simple else clause, cozy it up with the previous right curly.  
For testing multiple cases, move the else keyword to a new line.

Examples:

    int
    foo (int bar)
    {
        if (bar == 3) {
            return 1;
        } else {
            return 0;
        }
    }

    int
    foo (int bar)
    {
        if (bar == 3) {
            return 1;
        }
        else if (bar == 5) {
            return 2;
        }
	else {
            return 0;
	}
    }

Switch statement
----------------
Case labels are not indented in the switch statement.  A default label 
is required (even if there is no code).

    switch (x) {
    case a:
        code;
    case b:
        code;
    case c:
    default:
        code;
    }

Function definitions
--------------------
Declaritors and return values go on a separate line (GNU style):

    static int
    foo (int bar)
    {

Explicit "void" in the argument list is discouraged::

    void
    foo ()   // rather than foo (void)
    {

Horizontal whitespace
---------------------
Horizontal whitespace is used between operators and operands.  
Conditionals should be laid out like this:

    if (bar == 3 && baz > 4) {

Function calls like this:

    foo (a, b);

When there are no arguments, you may omit the space:

    foo();

When the return value is used with member reference, omitting space
is preferred::

    foo(bar,baz)->boo().fuz

Pointers and references
-----------------------
As per linux kernel style, put the '*' adjacent to the data name or 
function name and not adjacent to the type name.

    char *foo;
    char *bar (char *baz, char **boo);

The reason for this rule is it allows the declaration of multiple 
variables of the same type in a single statement.

    char *p, *q, *pv, *pq;

However, references go together with the type rather than the name.

    char& linux_banner = s1;
    char& bar (char& baz, char*& boo);

Vertical whitespace
-------------------
A single empty line is used between functions or between 
two groups of code.

Identifier naming
-----------------
Prefer English words to abbreviations.  Words are separated by 
underscores.  Use lowercase for function names, variable names, 
and structure names.  Use all upper case for constants.

    struct long_list {
        int list_length;
        void *list_items;
    }

    int
    my_function (struct long_list employee_list)
    {
        const int DESIRED_LENGTH = 3;
        employee_list->list_length = DESIRED_LENGTH;
    }

Names for typedefs and C++ classes should capitalize only the first letter.
Member names are lower case.

    class Volume_resizer {
    public:
        int foo;
	void bar (void);
    }

    void
    Volume_resizer::bar (void)
    {
        code;
    }
