On Mon, 14 Mar 2016, Gisle Vanem wrote:

Regarding "No space before parentheses". That's okay.

[background]

We once had a mix of space and non-space before parentheses, and when I then counted and compared, we had more occurances of the non-space than with-space so we took the non-space route for consistency.

But IMHO this is *not* okay:
 return (env[0] != '\0')?strdup(env):NULL;

(from getenv.c etc).

IMHO a rule for that specifies "adding spaces for easier reading".
Hence:
return (env[0] != '\0') ? strdup(env) : NULL;

Yes! I would agree that your latter version is easier on the eye and thus a better way to express that code.

Maybe expressed like this:

  "Please use space on both sides of operators in C expressions"

Postfix ((), [], ->, ., ++, --) and Unary (+, - !, ~, & etc) operators excluded of course. Like:

    bla = func();
    who = name[0];
    age += 1;
    true = !false;
    size += -2 + 3;
    ptr->member = a++;
    struct.field = b--;
    ptr = &address;
    contents = *pointer;
    complement = ~bits;

--

 / daniel.haxx.se
-------------------------------------------------------------------
List admin: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:  https://curl.haxx.se/mail/etiquette.html

Reply via email to