| 70 | |
| 71 | }}} |
| 72 | |
| 73 | === Code blocks (if, for, case...)=== |
| 74 | |
| 75 | Always follow an 'if' keyword with a space but don't include additional |
| 76 | spaces following or preceding the parentheses in the conditional. |
| 77 | |
| 78 | This is right: |
| 79 | {{{ |
| 80 | if (i == 0) |
| 81 | }}} |
| 82 | This is wrong: |
| 83 | {{{ |
| 84 | if ( i == 0 ) |
| 85 | /* |
| 86 | if (0 == i) |
| 87 | }}} |
| 88 | |
| 89 | Always insert a space between the name and left parentheses when invoking functions. |
| 90 | |
| 91 | This is right: |
| 92 | {{{ |
| 93 | do_example (int param1, int *result1); |
| 94 | }}} |
| 95 | This is wrong: |
| 96 | {{{ |
| 97 | do_example(int param1, int *result1); |
| 98 | }}} |
| 99 | |
| 100 | |
| 101 | |
| 102 | Braces for code blocks used by '''for, if, switch, while, do..while''', etc. should begin on the next line after the statement keyword and end on a line of their own. |
| 103 | |
| 104 | Functions are different and the beginning left brace should be located in the first column on the next line. |
| 105 | |
| 106 | If the beginning statement has to be broken across lines due to length, the beginning brace should be on a line of its own. |
| 107 | |
| 108 | This is right: |
| 109 | {{{ |
| 110 | if (xterm_flag && xterm_title) |
| 111 | { |
| 112 | path = strip_home_and_password (current_panel->cwd); |
| 113 | ... |
| 114 | } |
| 115 | |
| 116 | for (j = 0; j < 10; j++) |
| 117 | { |
| 118 | for (i = 0; str_options[i].opt_name != NULL; i++) |
| 119 | g_free (*str_options[i].opt_addr); |
| 120 | } |
| 121 | |
| 122 | }}} |
| 123 | This is wrong: |
| 124 | {{{ |
| 125 | if (xterm_flag && xterm_title) { |
| 126 | path = strip_home_and_password (current_panel->cwd); |
| 127 | ... |
| 128 | } |
| 129 | |
| 130 | if (xterm_flag && xterm_title) |
| 131 | { |
| 132 | path = strip_home_and_password (current_panel->cwd); } |
| 133 | |
| 134 | for (k = 0; k < 10; k++) |
| 135 | for (j = 0; j < 10; j++) |
| 136 | for (i = 0; str_options[i].opt_name != NULL; i++) |
| 137 | g_free (*str_options[i].opt_addr); |
| 138 | |