Openwall GNU/*/Linux - a small security-enhanced Linux distro for servers
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Fri, 15 Jul 2011 19:23:38 +0400
From: Aleksey Cherepanov <aleksey.4erepanov@...il.com>
To: john-dev@...ts.openwall.com
Subject: Re: coding styles for c/c++? indenter? emacs settings?

Thanks alot!

> With nested loops fully sharing their body, I often only indent the body
> by one tab, like:

It was interesting for me when i looked through John's code. Now i think
it looks nice.

I tried to use indent with john-1.7.8 sources and look for
differences. I think it is possible to add -ncs key
(--no-space-after-casts) to indent command. For instance following
string will not be changed by indent:
 		value = (int)atoi16[ARCH_INDEX(ciphertext[index + 4])] << 4;

But indent does not do it really good:
-		if (mask == ~(ARCH_WORD)0) goto next_depth;
+		if (mask == ~(ARCH_WORD) 0)
+			goto next_depth;

In this example indent seems to not understand that '(ARCH_WORD)' is a
cast.

Also this example shows that short if statements are not splitted. I saw
such lines several times and i even found 'if (cond) stat; else stat;'
on one line ("grep if *.c | grep '; else'" in john's src directory). I
do not know how to tell indent to keep such lines.

By the way indent gives errors on rules.c:
$ indent rules.c
indent: rules.c:347: Error:Stmt nesting error.
indent: rules.c:354: Error:Stmt nesting error.
indent: rules.c:868: Error:Stmt nesting error.
indent: rules.c:973: Error:Unexpected end of file

Also i found Qt's coding style at
http://developer.qt.nokia.com/wiki/Qt_Coding_Style . Hence the question
what style should be used for code using Qt? For instance what style
should be used for Johnny development?

Regards,
Aleksey Cherepanov

Powered by blists - more mailing lists

Your e-mail address:

Powered by Openwall GNU/*/Linux - Powered by OpenVZ