logo_kerberos.gif

Difference between revisions of "Coding style/Transition strategies"

From K5Wiki
Jump to: navigation, search
(Implementation of transition)
Line 5: Line 5:
 
Multiple phases. Consider batching changes.
 
Multiple phases. Consider batching changes.
   
* Tabs to spaces
 
  +
* Tabs to spaces (and related whitespace issues like end-of-line whitespace)
 
** Mark with emacs file variables
 
** Mark with emacs file variables
 
** Confirm that this worked by checking if "<code>diff -w</code>" shows no changes
 
** Confirm that this worked by checking if "<code>diff -w</code>" shows no changes

Revision as of 19:58, 22 June 2009

Parts of the existing source tree are not conforming to our coding style. These inconsistencies can create barriers to entry for new contributors. This page outlines some transition strategies.

Implementation of transition

Multiple phases. Consider batching changes.

  • Tabs to spaces (and related whitespace issues like end-of-line whitespace)
    • Mark with emacs file variables
    • Confirm that this worked by checking if "diff -w" shows no changes
  • Reindent
    • Mark with emacs file variables
    • As this may change linebreaks, requires a little more review

Exempt code

Sun-origin code:

  • src/lib/rpc
  • src/include/gssrpc

BSD-origin code:

  • src/appl/bsd
  • src/appl/telnet
  • src/appl/gssftp

Whitespace

To mark files as having all tabs expanded to space characters, place the following Emacs mode/local-variable line at the very top of the file:

/* -*- mode: c; indent-tabs-mode: nil -*- */

Indentation

To mark files as having indentation conforming to our coding style, add c-file-style: "krb5" to the local variable line:

/* -*- mode: c; c-file-style: "krb5"; indent-tabs-mode: nil -*- */

Remember to add the definition of the "krb5" c style to your .emacs file.

For BSD-derived code, use

/* -*- mode: c; c-file-style: "bsd"; indent-tabs-mode: t -*- */

If we get a style declaration for the "sun" C style, use that where appropriate as well (src/lib/rpc among others).

Vim?

Do we want to add file modelines for vim? Some versions of vim had vulnerabilities in handling of modelines.