Blame HACKING

Packit 228f82
============
Packit 228f82
Coding Style
Packit 228f82
============
Packit 228f82
Packit 228f82
- Use explicit ``!= NULL``, ``!= 0``, etc. This makes code easier to read
Packit 228f82
  and remove warnings on some platform. Don't forget SPACES before and
Packit 228f82
  after the comparison operator.
Packit 228f82
Packit 228f82
  Examples:
Packit 228f82
    BAD:
Packit 228f82
            ``if (a)``
Packit 228f82
    BAD:
Packit 228f82
            ``if (a!=NULL)``
Packit 228f82
    GOOD:
Packit 228f82
            ``if (a != NULL)``
Packit 228f82
    GOOD:
Packit 228f82
            ``if (a != 0)``
Packit 228f82
Packit 228f82
- Put figure brackets ``{}`` even if you have only one operator
Packit 228f82
  in ``if``, ``for``, etc. This also makes code easier to read and 
Packit 228f82
  saves a lot of time when you need to quickly change something. 
Packit 228f82
Packit 228f82
  Examples:
Packit 228f82
    BAD:
Packit 228f82
      .. line-block::
Packit 228f82
Packit 228f82
         if (a != NULL)
Packit 228f82
           message(G_LOG_LEVEL_MESSAGE, "Ko");
Packit 228f82
    GOOD:
Packit 228f82
      .. line-block::
Packit 228f82
Packit 228f82
         if (a != NULL) {
Packit 228f82
           message(G_LOG_LEVEL_MESSAGE, "Ok");
Packit 228f82
         }
Packit 228f82
Packit 228f82
- Put SPACES before the opening round bracket and after the closing round
Packit 228f82
  bracket with ``if``, ``for``, ``switch``, ``while``, etc. One more time,
Packit 228f82
  it improves the readability of the code.
Packit 228f82
Packit 228f82
  Examples:
Packit 228f82
    BAD:
Packit 228f82
      .. line-block::
Packit 228f82
Packit 228f82
         if(a != NULL){
Packit 228f82
           message(G_LOG_LEVEL_MESSAGE, "Ko");
Packit 228f82
         }
Packit 228f82
    GOOD:
Packit 228f82
      .. line-block::
Packit 228f82
Packit 228f82
         if (a != NULL) {
Packit 228f82
           message(G_LOG_LEVEL_MESSAGE, "Ok");
Packit 228f82
         }
Packit 228f82
Packit 228f82
- Limit line length to at most 100 characters.
Packit 228f82
Packit 228f82
- Check for memory leaks.
Packit 228f82
  I recommend valgrind (http://valgrind.kde.org) utility with options:
Packit 228f82
    --leak-check=yes
Packit 228f82
    --show-reachable=yes
Packit 228f82
    --num-callers=32
Packit 228f82
    --suppressions=tests/valgrind/openssl.supp
Packit 228f82
Packit 228f82
Packit 228f82
Packit 228f82
GNU Emacs
Packit 228f82
=========
Packit 228f82
Packit 228f82
::
Packit 228f82
Packit 228f82
  (defun lasso-c-mode ()
Packit 228f82
    "C mode with adjusted defaults for use with Lasso."
Packit 228f82
    (interactive)
Packit 228f82
    (c-mode)
Packit 228f82
    (c-set-style "K&R")
Packit 228f82
    (setq tab-width 8)
Packit 228f82
    (setq indent-tabs-mode t)
Packit 228f82
    (setq c-basic-offset 8))
Packit 228f82
Packit 228f82
This will define the M-x lasso-c-mode command.  It can be switched on
Packit 228f82
automatically in a given directory::
Packit 228f82
Packit 228f82
  (setq auto-mode-alist (cons '("/usr/src/lasso.*/.*\\.[ch]$" .  lasso-c-mode)
Packit 228f82
	auto-mode-alist))
Packit 228f82