HACKING: Modernize a little bit

This commit is contained in:
Dirk-Jan C. Binnema 2021-03-17 18:34:24 +02:00
parent 750a9d1626
commit 8ec5ece4c2
1 changed files with 23 additions and 22 deletions

45
HACKING
View File

@ -16,20 +16,21 @@
attempts to follow the following rules: attempts to follow the following rules:
1. Basic code layout is like in the Linux kernel coding style. Keep the '{' 1. Basic code layout is like in the Linux kernel coding style. Keep the '{'
on the same line as the statement, except for functions. Tabs for on the same line as the statement, except for functions. We're slowly
indentation, space for alignment; use 8-char tabs. moving to use SPC for indentation: all new code should use that.
While TABs are techically better, it seems that using SPCs is harder to
get wrong.
2. Lines should not exceed 100 characters 2. Lines should not exceed 100 characters
3. Functions should not exceed 35 lines (with few exceptions). You can easily 3. Functions should be kept short.
check if any functions violate this rule with 'make line35', which lists
all functions with more than 35 non-comment lines.
4. Source files should not exceed 1000 lines 4. Source files should not exceed 1000 lines, with few exceptions.
5. Non-static C-functions have the prefix based on their module, e.g., 5. Non-static C-functions have the prefix based on their module, e.g.,
~mu-foo.h~ declares a function of 'mu_foo_bar (int a);', mu-foo.c implements ~mu-foo.h~ declares a function of 'mu_foo_bar (int a);', mu-foo.c implements
this. C++ functions using the Mu namespace this. C++ functions use the Mu namespace
6. Non-global functions *don't* have the module prefix, and are declared 6. Non-global functions *don't* have the module prefix, and are declared
static. static.
@ -49,10 +50,10 @@
In C code, the declaration does *not* initialize the variable. This will In C code, the declaration does *not* initialize the variable. This will
give the compiler a chance to warn us if the variable is not initialized give the compiler a chance to warn us if the variable is not initialized
in a certain code path. in a certain code path. Exception: autoptr & friends.
9. Returned strings of type char* must be freed by the caller; if they are 9. Returned strings of type ~char*~ must be freed by the caller; if they are
not to be freed, 'const char*' should be used instead not to be freed, ~const char*~ should be used instead
10. Functions calls have a space between function name and arguments, unless 10. Functions calls have a space between function name and arguments, unless
there are none, so: there are none, so:
@ -65,9 +66,8 @@
after a comma, a space should follow. after a comma, a space should follow.
11. C-functions that do not take arguments are explicitly declared as 11. C-functions that do not take arguments are explicitly declared as f(void)
f(void) and not f(). Reason: f() means that the arguments are and not f(). Reason: f() means that the arguments are /unspecified/ (in C)
/unspecified/ (in C)
12. C-code should not use ~//~ comments. 12. C-code should not use ~//~ comments.
@ -78,7 +78,8 @@
except when logging may not have been initialized. except when logging may not have been initialized.
The logging system redirects most logging to the log file (typically, The logging system redirects most logging to the log file (typically,
=~/.cache/mu/mu.log=). ~g_critical~ messages are written to stderr. =~/.cache/mu/mu.log, or to the systemd journal=). ~g_critical~ messages are
written to stderr.
- ~g_message~ is for non-error messages the user will see (unless running with - ~g_message~ is for non-error messages the user will see (unless running with
~--quiet~) ~--quiet~)
@ -99,16 +100,16 @@
You need to install a few dependencies; e.g. on Debian/Ubuntu: You need to install a few dependencies; e.g. on Debian/Ubuntu:
#+BEGIN_EXAMPLE #+BEGIN_EXAMPLE
sudo apt-get install \ sudo apt-get install \
automake \ automake \
autoconf-archive \ autoconf-archive \
autotools-dev \ autotools-dev \
libglib2.0-dev \ libglib2.0-dev \
libxapian-dev \ libxapian-dev \
libgmime-3.0-dev \ libgmime-3.0-dev \
m4 \ m4 \
make \ make \
libtool \ libtool \
pkg-config pkg-config
#+END_EXAMPLE #+END_EXAMPLE
Then, to compile straight from ~git~: Then, to compile straight from ~git~: