[gnome-devel-docs/wip/swilmet/various-fixes: 5/7] programming-guidelines: fix code using the Linux Kernel style
- From: Sébastien Wilmet <swilmet src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-devel-docs/wip/swilmet/various-fixes: 5/7] programming-guidelines: fix code using the Linux Kernel style
- Date: Sat, 14 Feb 2015 12:34:22 +0000 (UTC)
commit 6811ce3c55742a20c04f1d4f655c0958146557ec
Author: Sébastien Wilmet <swilmet gnome org>
Date: Fri Feb 13 17:17:34 2015 +0100
programming-guidelines: fix code using the Linux Kernel style
Replace 8 spaces by tabs.
https://bugzilla.gnome.org/show_bug.cgi?id=744521
programming-guidelines/C/c-coding-style.page | 124 +++++++++++++-------------
1 files changed, 62 insertions(+), 62 deletions(-)
---
diff --git a/programming-guidelines/C/c-coding-style.page b/programming-guidelines/C/c-coding-style.page
index e3dac82..4533555 100644
--- a/programming-guidelines/C/c-coding-style.page
+++ b/programming-guidelines/C/c-coding-style.page
@@ -106,15 +106,15 @@
<code style="valid">
for (i = 0; i < num_elements; i++) {
- foo[i] = foo[i] + 42;
-
- if (foo[i] < 35) {
- printf ("Foo!");
- foo[i]--;
- } else {
- printf ("Bar!");
- foo[i]++;
- }
+ foo[i] = foo[i] + 42;
+
+ if (foo[i] < 35) {
+ printf ("Foo!");
+ foo[i]--;
+ } else {
+ printf ("Bar!");
+ foo[i]++;
+ }
}</code>
</item>
@@ -191,9 +191,9 @@ for (i = 0; i < num_elements; i++)
<code style="valid">
/* valid */
if (condition)
- single_statement ();
+ single_statement ();
else
- another_single_statement (arg1);</code>
+ another_single_statement (arg1);</code>
<p>
The “no block for single statements” rule has only four
@@ -211,12 +211,12 @@ else
<code style="valid">
/* valid Linux kernel style */
if (condition) {
- a_single_statement_with_many_arguments (some_lengthy_argument,
- another_lengthy_argument,
- and_another_one,
- plus_one);
+ a_single_statement_with_many_arguments (some_lengthy_argument,
+ another_lengthy_argument,
+ and_another_one,
+ plus_one);
} else
- another_single_statement (arg1, arg2);
+ another_single_statement (arg1, arg2);
/* valid GNU style */
if (condition)
@@ -241,7 +241,7 @@ if (condition1 ||
(condition2 && condition3) ||
condition4 ||
(condition5 && (condition6 || condition7))) {
- a_single_statement ();
+ a_single_statement ();
}
/* valid GNU style */
@@ -263,10 +263,10 @@ if (condition1 ||
<code style="valid">
/* valid Linux kernel style */
if (condition) {
- if (another_condition)
- single_statement ();
- else
- another_single_statement ();
+ if (another_condition)
+ single_statement ();
+ else
+ another_single_statement ();
}
/* valid GNU style */
@@ -281,10 +281,10 @@ if (condition)
<code style="invalid">
/* invalid */
if (condition)
- if (another_condition)
- single_statement ();
- else if (yet_another_condition)
- another_single_statement ();</code>
+ if (another_condition)
+ single_statement ();
+ else if (yet_another_condition)
+ another_single_statement ();</code>
</item>
<item>
@@ -329,12 +329,12 @@ statement_1 ();
statement_2 ();
{
- int var1 = 42;
- gboolean res = FALSE;
+ int var1 = 42;
+ gboolean res = FALSE;
- res = statement_3 (var1);
+ res = statement_3 (var1);
- retval = res ? -1 : 1;
+ retval = res ? -1 : 1;
}</code>
<p>
@@ -347,7 +347,7 @@ statement_2 ();
static void
my_function (int argument)
{
- do_my_things ();
+ do_my_things ();
}
/* valid GNU style*/
@@ -361,7 +361,7 @@ my_function (int argument)
/* invalid */
static void
my_function (int argument) {
- do_my_things ();
+ do_my_things ();
}
/* invalid */
@@ -384,12 +384,12 @@ my_function (int argument)
<code style="invalid">
/* invalid */
if (condition == TRUE)
- do_foo ();</code>
+ do_foo ();</code>
<code style="valid">
/* valid */
if (another_condition)
- do_bar ();</code>
+ do_bar ();</code>
<p>
Even if C handles <code>NULL</code> equality like a boolean, be
@@ -400,16 +400,16 @@ if (another_condition)
<code style="valid">
/* valid */
if (some_pointer == NULL)
- do_blah ();
+ do_blah ();
/* valid */
if (something != NULL)
- do_foo ();</code>
+ do_foo ();</code>
<code style="invalid">
/* invalid */
if (some_other_pointer)
- do_blurp ();</code>
+ do_blurp ();</code>
</section>
<section id="functions">
@@ -470,7 +470,7 @@ align_function_arguments (first_argument,
<code style="valid">
/* valid */
if (condition)
- do_my_things ();
+ do_my_things ();
/* valid */
switch (condition) {
@@ -479,11 +479,11 @@ switch (condition) {
<code style="invalid">
/* invalid */
if(condition)
- do_my_things();
+ do_my_things();
/* invalid */
if ( condition )
- do_my_things ( );</code>
+ do_my_things ( );</code>
<p>
When declaring a structure type use newlines to separate logical sections
@@ -493,19 +493,19 @@ if ( condition )
<code style="valid">
struct _GtkWrapBoxPrivate
{
- GtkOrientation orientation;
- GtkWrapAllocationMode mode;
+ GtkOrientation orientation;
+ GtkWrapAllocationMode mode;
- GtkWrapBoxSpreading horizontal_spreading;
- GtkWrapBoxSpreading vertical_spreading;
+ GtkWrapBoxSpreading horizontal_spreading;
+ GtkWrapBoxSpreading vertical_spreading;
- guint16 vertical_spacing;
- guint16 horizontal_spacing;
+ guint16 vertical_spacing;
+ guint16 horizontal_spacing;
- guint16 minimum_line_children;
- guint16 natural_line_children;
+ guint16 minimum_line_children;
+ guint16 natural_line_children;
- GList *children;
+ GList *children;
};</code>
<p>
@@ -555,12 +555,12 @@ if (condition) foo (); else bar ();</code>
/* valid Linux kernel style */
switch (condition) {
case FOO:
- do_foo ();
- break;
+ do_foo ();
+ break;
case BAR:
- do_bar ();
- break;
+ do_bar ();
+ break;
}
/* valid GNU style */
@@ -610,15 +610,15 @@ switch (condition)
<code style="valid">
switch (condition) {
case FOO:
- do_foo ();
- break;
+ do_foo ();
+ break;
case BAR:
- do_bar ();
- break;
+ do_bar ();
+ break;
default:
- do_default ();
+ do_default ();
}</code>
<p>
@@ -636,17 +636,17 @@ default:
<code style="valid">
switch (enumerated_condition) {
case HANDLED_1:
- do_foo ();
- break;
+ do_foo ();
+ break;
case HANDLED_2:
- do_bar ();
- break;
+ do_bar ();
+ break;
case IGNORED_1:
case IGNORED_2:
default:
- do_default ();
+ do_default ();
}</code>
<p>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]