summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-03-13 00:42:50 +0100
committerwm4 <wm4@nowhere>2014-03-30 17:42:40 +0200
commitb6ed94fa7cb03350e73509edd3debe41c2309c6d (patch)
tree062e87063298a148f4d0367c2266a3bd81cf124b
parenta4197035493fb0423eb938c42aaf5208db0931be (diff)
downloadmpv-b6ed94fa7cb03350e73509edd3debe41c2309c6d.tar.bz2
mpv-b6ed94fa7cb03350e73509edd3debe41c2309c6d.tar.xz
DOCS/coding-style: add an example and another rule
-rw-r--r--DOCS/coding-style.md25
1 files changed, 25 insertions, 0 deletions
diff --git a/DOCS/coding-style.md b/DOCS/coding-style.md
index 9c19cd9fc3..8174a92436 100644
--- a/DOCS/coding-style.md
+++ b/DOCS/coding-style.md
@@ -44,6 +44,31 @@ General formatting
```
- If the body of an if statement uses braces, the else branch should also
use braces (and reverse).
+
+ Example:
+
+ ```C
+ if (a) {
+ // do something
+ something();
+ something_else();
+ } else {
+ one_line();
+ }
+ ```
+- If an if condition spans multiple physical lines, then put the opening brace
+ for the if body on the next physical line. (Also, preferably always add a
+ brace, even if technically none is needed.)
+
+ Example:
+
+ ```C
+ if (very_long_condition_a &&
+ very_long_condition_b)
+ {
+ code();
+ }
+ ```
- Remove any trailing whitespace.
- If the file you're editing uses formatting different from from what is
described here, it's probably an old file from times when nobody followed a