commit: e1bd683cfacc2b059eacbf451014733a6c9586e2
parent c6a22ed0818d6093568b8700424f6de4d0688c41
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Fri, 23 Oct 2015 20:06:54 +0200
correct example indent and put my mods
Diffstat:
3 files changed, 37 insertions(+), 37 deletions(-)
diff --git a/coding style.shtml b/coding style.shtml
@@ -8,6 +8,7 @@
<!--#include file="/templates/en/nav.shtml" -->
<main>
<h1>Coding Style</h1>
+ <p>This is taken from © 2006-2015 <a href="//suckless.org">suckless.org</a> community, with few modifications because no coder have the same style.</p>
<p>Note that the following are guidelines and the most important aspect of style is consistency. Strive to keep your style consistent with the project on which you are working.</p>
<h2>Recommended Reading</h2>
<p>The following contain good information, some of which is repeated below, some of which is contradicted below.</p>
@@ -53,24 +54,24 @@
<h2>Blocks</h2>
<ul>
<li>All variable declarations at top of block</li>
- <li><code>{</code> on same line preceded by single space (except functions)</li>
+ <li><code>{</code> on same line preceded by single space</li>
<li><code>}</code> on own line unless continuing statement (<code>if else</code>, <code>do while</code>, …)</li>
<li>Use block for single statements iff<ul>
<li><p>Inner statement needs a block</p>
-<pre><code> for (;;) {
- if (foo) {
- bar;
- baz;
- }
- }
+<pre><code>for (;;) {
+ if (foo) {
+ bar;
+ baz;
+ }
+}
</code></pre></li>
<li><p>Another branch of same statement needs a block</p>
-<pre><code> if (foo) {
- bar;
- } else {
- baz;
- qux;
- }
+<pre><code>if (foo) {
+ bar;
+} else {
+ baz;
+ qux;
+}
</code></pre></li>
</ul></li>
</ul>
@@ -97,14 +98,12 @@
</ul>
<h2>Keywords</h2>
<ul>
- <li>Use a space after <code>if</code>, <code>for</code>, <code>while</code>, <code>switch</code> (they are not function calls)</li>
<li>Do not use a space after the opening <code>(</code> and before the closing <code>)</code></li>
<li>Always use <code>()</code> with <code>sizeof</code></li>
- <li>Do not use a space with <code>sizeof()</code> (it does act like a function call)</li>
</ul>
<h2>Switch</h2>
<ul>
- <li>Do not indent cases another level</li>
+ <li>indent cases another level</li>
<li>Comment cases that FALLTHROUGH</li>
</ul>
<h2>Headers</h2>
@@ -127,9 +126,9 @@
<li>Do not typedef builtin types</li>
<li>Capitalize the type name</li>
<li><p>Typedef the type name, if possible without first naming the struct</p>
-<pre><code> typedef struct {
- double x, y, z;
- } Point;
+<pre><code>typedef struct {
+ double x, y, z;
+} Point;
</code></pre></li>
</ul>
<h2>Line Length</h2>
@@ -143,20 +142,20 @@
<li>Do not test against <code>0</code> explicitly</li>
<li>Do not use <code>bool</code> types (stick to integer types)</li>
<li><p>Assign at declaration when possible</p>
-<pre><code> Type *p = malloc(sizeof(*p));
- if (!p)
- hcf();
+<pre><code>Type *p = malloc(sizeof(*p));
+if (!p)
+ hcf();
</code></pre></li>
<li><p>Otherwise use compound assignment and tests unless the line grows too long</p>
-<pre><code> if (!(p = malloc(sizeof(*p))))
- hcf();
+<pre><code>if (!(p = malloc(sizeof(*p))))
+ hcf();
</code></pre></li>
</ul>
<h2>Handling Errors</h2>
<ul>
<li><p>When functions <code>return -1</code> for error test against <code>0</code> not <code>-1</code></p>
-<pre><code> if (func() < 0)
- hcf();
+<pre><code>if (func() < 0)
+ hcf();
</code></pre></li>
<li>Use <code>goto</code> to unwind and cleanup when necessary instead of multiple nested levels</li>
<li><code>return</code> or <code>exit</code> early on failures instead of multiple nested levels</li>
@@ -166,18 +165,17 @@
<h2>Enums vs #define</h2>
<ul>
<li><p>Use enums for values that are grouped semantically and #define otherwise.</p>
-<pre><code> #define MAXSZ 4096
- #define MAGIC1 0xdeadbeef
+<pre><code>#define MAXSZ 4096
+#define MAGIC1 0xdeadbeef
- enum {
- DIRECTION_X,
- DIRECTION_Y,
- DIRECTION_Z
- };
+enum {
+ DIRECTION_X,
+ DIRECTION_Y,
+ DIRECTION_Z
+};
</code></pre></li>
</ul>
- <span class="right">© 2006-2015 suckless.org community | <a href="http://garbe.us/Contact">Impressum</a>
</main>
<!--#include file="/templates/en/footer.html" -->
</body>
-</html>
+</html>
+\ No newline at end of file
diff --git a/images/support_lqdn_728_en.gif b/images/support_lqdn_728_en.gif
Binary files differ.
diff --git a/templates/en/nav.shtml b/templates/en/nav.shtml
@@ -14,4 +14,6 @@
<li><a href="//gitlab.com/lanodan/blog/">Gitlab</a></li>
</ul>
</nav>
- <h1 style="display:block;background-color:#F27935;color:#FFF;padding: 0.5em;text-align:center;font-family:sans-serif;"><img style="border:0;height:2em;vertical-align:middle;" src="/images/oeil.png"> Tracking law <strong style="background-color:#FFF;color:#F27935;">NO!</strong> <a style="color:inherit;" href="//sous-surveillance.fr/">sous-surveillance.fr</a></h1>
-\ No newline at end of file
+ <header>
+ <img src="/images/support_lqdn_728_en.gif" title="Support La Quadrature Du Net" alt="Support La Quadrature Du Net"/>
+ </header>