[gnome-devel-docs/wip/swilmet/various-fixes: 6/7] programming-guidelines: fix GNU code example and re-order items
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs/wip/swilmet/various-fixes: 6/7] programming-guidelines: fix GNU code example and re-order items
- Date: Sat, 14 Feb 2015 12:34:27 +0000 (UTC)
commit dc9636b841267c6f4d1a6bd7dd495df0d5627083
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Feb 13 17:29:21 2015 +0100
programming-guidelines: fix GNU code example and re-order items
1. move the GNU-specific item to the top
2. fix GNU example in a later example
If the GNU-specific item is explained after (2), one can wonder why the
Linux and GNU styles are different for the same example.
https://bugzilla.gnome.org/show_bug.cgi?id=744521
programming-guidelines/C/c-coding-style.page | 62 +++++++++++++------------
1 files changed, 32 insertions(+), 30 deletions(-)
---
diff --git a/programming-guidelines/C/c-coding-style.page b/programming-guidelines/C/c-coding-style.page
index 4533555..2354cf2 100644
--- a/programming-guidelines/C/c-coding-style.page
+++ b/programming-guidelines/C/c-coding-style.page
@@ -201,6 +201,35 @@ else
</p>
<list type="ordered">
+ <item>
+ <p>
+ In GNU style, if either side of an if-else statement has
+ braces, both sides should, to match up indentation:
+ </p>
+
+<code style="valid">
+/* valid GNU style */
+if (condition)
+ {
+ foo ();
+ bar ();
+ }
+else
+ {
+ baz ();
+ }</code>
+
+<code style="invalid">
+/* invalid */
+if (condition)
+ {
+ foo ();
+ bar ();
+ }
+else
+ baz ();</code>
+ </item>
+
<item>
<p>
If the single statement covers multiple lines, e.g. for functions with
@@ -227,7 +256,9 @@ if (condition)
plus_one);
}
else
- another_single_statement (arg1, arg2);</code>
+ {
+ another_single_statement (arg1, arg2);
+ }</code>
</item>
<item>
@@ -286,35 +317,6 @@ if (condition)
else if (yet_another_condition)
another_single_statement ();</code>
</item>
-
- <item>
- <p>
- In GNU style, if either side of an if-else statement has
- braces, both sides should, to match up indentation:
- </p>
-
-<code style="valid">
-/* valid GNU style */
-if (condition)
- {
- foo ();
- bar ();
- }
-else
- {
- baz ();
- }</code>
-
-<code style="invalid">
-/* invalid */
-if (condition)
- {
- foo ();
- bar ();
- }
-else
- baz ();</code>
- </item>
</list>
<p>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]