]> granicus.if.org Git - curl/commitdiff
CODE_STYLE: Space around operators
authorDaniel Stenberg <daniel@haxx.se>
Mon, 14 Mar 2016 13:31:14 +0000 (14:31 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 14 Mar 2016 13:31:14 +0000 (14:31 +0100)
As just discussed on the mailing list, also document how we prefer
spacing in expressions.

docs/CODE_STYLE.md

index 0dbf87bae65d6f4ccaa54021ff59eb503a164c4e..8cfb26e6fd0bb488e080718878a96c588bcfdc24 100644 (file)
@@ -130,6 +130,25 @@ and NEVER:
     if(a) return TRUE;
     else if(b) return FALSE;
 
+## Space around operators
+
+Please use spaces on both sides of operators in C expressions.  Postfix `(),
+[], ->, ., ++, --` and Unary `+, - !, ~, &` operators excluded they should
+have no space.
+
+Examples:
+
+    bla = func();
+    who = name[0];
+    age += 1;
+    true = !false;
+    size += -2 + 3 * (a + b);
+    ptr->member = a++;
+    struct.field = b--;
+    ptr = &address;
+    contents = *pointer;
+    complement = ~bits;
+
 ## Platform dependent code
 
 Use `#ifdef HAVE_FEATURE` to do conditional code. We avoid checking for