Indent Style - BSD KNF Style

BSD KNF Style

Also known as Kernel Normal Form style, this is currently the form of most of the code used in the Berkeley Software Distribution operating systems. Although mostly intended for kernel code, it is widely used as well in userland code. It is essentially a thoroughly-documented variant of K&R style as used in the Bell Labs Version 6 & 7 UNIX source code.

The hard tabulator (ts in vi) is kept at 8 columns, while a soft tabulator is often defined as a helper as well (sw in vi), and set at 4.

The hard tabulators are used to indent code blocks, while a soft tabulator (4 spaces) of additional indent is used for all continuing lines that must be split over multiple lines.

Moreover, function calls do not use a space before the parenthesis, although C language native statements such as if, while, do, switch and return do (in the case where return is used with parens). Functions that declare no local variables in their top-level block should also leave an empty line after their opening block brace.

Here follow a few samples:

while (x == y) { something; somethingelse; } finalthing;

if (data != NULL && res > 0) { if (JS_DefineProperty(cx, o, "data", STRING_TO_JSVAL(JS_NewStringCopyN(cx, data, res)), NULL, NULL, JSPROP_ENUMERATE) != 0) { QUEUE_EXCEPTION("Internal error!"); goto err; } PQfreemem(data); } else { if (JS_DefineProperty(cx, o, "data", OBJECT_TO_JSVAL(NULL), NULL, NULL, JSPROP_ENUMERATE) != 0) { QUEUE_EXCEPTION("Internal error!"); goto err; } }

static JSBool pgresult_constructor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { QUEUE_EXCEPTION("PGresult class not user-instantiable"); return (JS_FALSE); }

Read more about this topic:  Indent Style

Famous quotes containing the word style:

    I concluded that I was skilled, however poorly, at only one thing: marriage. And so I set about the business of selling myself and two children to some unsuspecting man who might think me a desirable second-hand mate, a man of good means and disposition willing to support another man’s children in some semblance of the style to which they were accustomed. My heart was not in the chase, but I was tired and there was no alternative. I could not afford freedom.
    Barbara Howar (b. 1934)