Update 'Coding Style'

Patrick Vogler 2023-06-22 14:15:07 +00:00
parent b58ac21058
commit 4a7c92aa40

@ -282,6 +282,28 @@ Do eliminate trailing whitespace on any line, preferably as a separate patch or
### Conditions
Boolean values should not be checked for equality to make the code more readable:
```c
if (error)
return 1;
if (!error)
return 0;
```
The check for 0 should refer to the specific way the 0 is used: `0` for a numeric value, `'\0'` for the end of a string, or `NULL` for a pointer. In this way, the variable type can be derived implicitly by reading the comparison. For the FALSE boolean we refer to the rule about boolean equations.
```c
if (buffer == NULL)
return NULL;
if (get_bit (stream) == 0)
node->value++;
if (bwc->info.file_ext [0] != '\0')
return 0;
```
### Functions
The following general rules should be followed when defining a function in BigWhoop:
* Function name must be lowercase, optionally separated with underscore _ character