On Thursday 24 February 2005 09:37, Nathan Folkman wrote:
> Exactly. Thinking of enumerating some higher level guidance:
>
> 1. Where ever possible use or wrap core Tcl APIs vs. creating your own
> implementation.
> 2. Tcl APIs should be implemented as Tcl Obj commands.
>
> ...etc...

So I have a few questions about the finer details. Reading the Tcl/Tk Manual,
I have been using these conventions:

1. no tabs, indents are 4 spaces.
2. continuation lines are indented 8 spaces:
3. continuations in if ( ) conditions begin with something that doesn't look
like a function call: &&, ||, etc.
4. continuations of function prototypes/defs are also indented 8 spaces, not
lined up with the first arg.
5. lines have no trailing whitespace.

There are a lot of differences still in config.c:
1. function prototypes of exported functions are missing.
2. functions are declared with the type on one line and the name on the
following:
char *
Ns_MyChar(...
{

}

Examples:

static int
Poly1305AESObjCmd(ClientData context, Tcl_Interp *interp, int objc,
        Tcl_Obj **objv);  /* 8 space continuation */

extern void
Ns_Poly1305Authenticate( /* Tcl Manual suggests this style */
        char          auth[16],
        char          kr[32],
        char          nonce[16],
        char         *message,
        unsigned int  messageLen); /* each arg on separate line */


static void                                                 /* good or bad */
ConfigSet(char *section, char *key, char *value)
{
    Ns_Set *set;

    if (section != NULL
            && key != NULL           /* indent 8 on continuation, start && */
            && ( (set = Ns_ConfigGetSection(section)) != NULL) ) {
        Ns_SetPut(set, key, value);       /* back to 4 indents */
        Ns_Log(Debug, "ConfigSet: Added %s = %s to %s", key, value, section);
    } else {
        Ns_Log(Debug, "ConfigSet: Unable to add key %s to section %s",
                key, section);
    }
    return;
}

Comment code examples:

The AOLserver style guide says to use ==== where the code actually uses -----

Below, Ns_ConfigGetSections:
 1. follows one blank line after --- line which extends to column 79
 2. is indented one space
 3. followed by space -- ' --'
 3. is followed by a blank line
Description:
 1. indented 5 spaces beyond the previous indent, so 6 spaces from the *
 2. continuations are lined up???
 3. followed by a blank line.
Overall:
 No trailing whitespace
 Should text end in a period, or no punctuation?

/*
 *----------------------------------------------------------------------
 *
 * Ns_ConfigGetSections --
 *
 *      Return a malloc'ed, NULL-terminated array of sets, each
 *      corresponding to a config section
 *
 * Results:
 *      An array of sets
 *
 * Side effects:
 *      The result is malloc'ed memory
 *
 *----------------------------------------------------------------------
 */

tom jackson


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to