Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABtNtWEHMLvUT=aUvbyvWU7gkgu5gaLBCymfDmwWj4H0phD6LQ@mail.gmail.com>
Date: Fri, 5 Jun 2015 16:31:39 +0800
From: Kai Zhao <loverszhao@...il.com>
To: john-dev@...ts.openwall.com
Subject: Re: Coding Style

> What is it exactly that running astyle on top of indent buys us?

There are 3 problems that indent can not solve while astyle can.

1. trailing whitespace
----------------------------

void function(void)
{
        /*
         * The line before this line has a blank
         */
}

2. while should follow close brace '}'
------------------------------------------------

void function(void)
{
        do
        {
                do_something();
                do_something();
        }
        while (--w32_cnt);
}

-->

void function(void)
{
        do
        {
                do_something();
                do_something();
        } while (--w32_cnt);
}

3. Unnecessary space before function pointer arguments
---------------------------------------------------------------------------

struct fmt_main *(*loader) (int fmt_version);

-->

struct fmt_main *(*loader)(int fmt_version);


> I am not using alignment in core, and I don't intend to.

I am confused since you and magnum have different opinion.
magnum thinks **indent with tab and align with spaces** and tab width
is 4 chars.
Is it ok that core and jumbo have different coding style ? If no, we would
better make it clear.

> What about the (questionable) construct like?

Case1
--------

tab-width = 4
$ indent -kr -i4 -ts4 -nlp -nbbo -ncs -l79 -lc79 -bad -il0 cracker.c

        pw = salt->list;
        do {
            if (crk_methods.cmp_all(pw->binary, match))
                for (index = 0; index < match; index++)
                    if (crk_methods.cmp_one(pw->binary, index))
                        if (crk_methods.cmp_exact(crk_methods.source(pw->
                                    source, pw->binary), index)) {
                            if (crk_process_guess(salt, pw, index))
                                return 1;
                            else {
                                if (!(crk_params.flags & FMT_NOT_EXACT))
                                    break;
                            }
                        }
        } while ((pw = pw->next));

Case2
--------

tab-width = 8
$ indent -kr -i4 -ts4 -nlp -nbbo -ncs -l79 -lc79 -bad -il0 cracker.c

                pw = salt->list;
                do {
                        if (crk_methods.cmp_all(pw->binary, match))
                                for (index = 0; index < match; index++)
                                        if (crk_methods.cmp_one(pw->binary,
index))
                                                if
(crk_methods.cmp_exact(crk_methods.source(pw->

source, pw->binary), index)) {
                                                        if
(crk_process_guess(salt, pw, index))
                                                                return 1;
                                                        else {
                                                                if
(!(crk_params.flags & FMT_NOT_EXACT))

break;
                                                        }
                                                }
                } while ((pw = pw->next));

Case3
--------

tab-width = 8
$ indent -kr -i8 -ts8 -nlp -nbbo -ncs -l79 -lc79 -bad -il0 cracker.c

                pw = salt->list;
                do {
                        if (crk_methods.cmp_all(pw->binary, match))
                                for (index = 0; index < match; index++)
                                        if (crk_methods.cmp_one(pw->binary,
                                                index))
                                                if (crk_methods.
                                                    cmp_exact(crk_methods.
                                                        source(pw->source,
                                                            pw->binary),
                                                        index)) {
                                                        if
(crk_process_guess
                                                            (salt, pw,
index))
                                                                return 1;
                                                        else {
                                                                if (!

(crk_params.

flags &

FMT_NOT_EXACT))

break;
                                                        }
                                                }
                } while ((pw = pw->next));

For case1, after indent, it looks ok.

For case2, the indent with tab-width = 4, so the column may exceed
80 if you use tab-width = 8.

For case3, the indent with tab-width = 8, it looks ugly. To avoid this, we
should refactor this part.

Thanks,

Kai

Content of type "text/html" skipped

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.